refactor(research_budget): Phase B language-advantage pass — dichotomy wave (positional budget slots)

This commit is contained in:
Nick committed 2026-10-13 11:03:04 +01:00
1 parent 55a347dba7
commit 719954c4fc
1 file changed
+6 -3
+6 -3
View File
@@ -88,9 +88,12 @@ fn set_field(b: &mut Json, key: &str, val: Json) {
}
pub fn spend(budget: &Json, kind: &str, n: i64) -> Result<Json, String> {
let query = kind == "query";
let used_key = if query { "queries_used" } else { "tools_used" };
let cap_key = if query { "query_budget" } else { "tool_budget" };
// Phase B (language advantage): the two slot pairs are positional
// (query=0, tool=1) — one branchless index instead of string-key
// selection on every spend. Python's dict-key dispatch cannot do this.
let slot = usize::from(kind != "query");
let used_key = ["queries_used", "tools_used"][slot];
let cap_key = ["query_budget", "tool_budget"][slot];
let mut b = budget.clone();
if truthy(b.get("stopped")) {
let reason = get_str(&b, "stop_reason");