graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(routing): the #291 ladder descent is not a human pin (#471)
Rach Pradhanccd5df857552
diff --git a/scripts/eval/tier1-manifest.json b/scripts/eval/tier1-manifest.jsonindex 63b6992f..9536f508 100644--- a/scripts/eval/tier1-manifest.json+++ b/scripts/eval/tier1-manifest.json@@ -14,7 +14,7 @@"src/main.zig","src/repl.zig"],- "test_count_baseline": 1151,+ "test_count_baseline": 1152,"test_count_slack": 25,"required_invariants": [{diff --git a/src/vision_ask.zig b/src/vision_ask.zigindex 81c849aa..6dc1ed29 100644--- a/src/vision_ask.zig+++ b/src/vision_ask.zig@@ -270,7 +270,17 @@ pub fn blockedByCost(base: Provider) []const u8 {/// The whole spawn-time decision: run the #292/#372 chain unchanged, then ask/// the vision question of its answer.pub fn forSpawn(base: Provider, obj: std.json.ObjectMap, session_pinned: bool, cell: route_policy.Cell, prompt: []const u8) Ask {- var ask: Ask = .{ .pin = subagent_pin.forSpawnIn(base, obj, !session_pinned, cell) };+ // #471: `session_pinned` is true for the automatic #291 ladder descent as+ // well as for a real --subagent-model, and sub-first tier routing was+ // reading it as "the human chose these workers, do not override". On any+ // root whose provider HAS a ladder that made the descent — which is most+ // of them — an explicit tier ask could therefore never reach a flat-rate+ // plan, and paid-for seats sat idle while metered rungs did the work.+ // The vision path a few lines down already draws this distinction+ // (userChose + g_default_from_ladder); this is the same rule, applied to+ // the same bit, one decision earlier.+ const user_pinned = session_pinned and !selection.g_default_from_ladder;+ var ask: Ask = .{ .pin = subagent_pin.forSpawnIn(base, obj, !user_pinned, cell) };ask.source = if (ask.pin.provider != null) ask.pin.source else route_trace.sessionSource(session_pinned);ask.path = imagePathIn(prompt) orelse return ask;const current = ask.pin.provider orelse base;diff --git a/src/vision_ask_tests.zig b/src/vision_ask_tests.zigindex e01c646d..f973a0b3 100644--- a/src/vision_ask_tests.zig+++ b/src/vision_ask_tests.zig@@ -380,3 +380,44 @@ test "#380 does not disturb #292: the pin chain's own outcomes still arrive" {const typo = va.forSpawn(codex(), obj(a, "{\"tier\":\"cheap\"}"), false, .{}, "read a.png");try std.testing.expectEqual(pin_mod.Outcome.unknown_tier, typo.pin.outcome);}++test "#471 the #291 ladder descent is not a human pin, so a tier ask still reaches a plan" {+ // The bug this guards, found by running the harness for real rather than+ // by unit test: resolveSubagentProvider returns a NON-null worker provider+ // for the automatic #291 ladder descent, so `session_pinned` was true in+ // every ordinary session on a provider that has a ladder. forSpawn read+ // that as "the human chose these workers" and skipped sub-first routing+ // entirely — a logged-in flat-rate plan sat idle while a metered rung did+ // the work. Every prior test passed sub_ok straight into subagent_pin and+ // so never exercised this computation at all.+ var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);+ defer arena_state.deinit();+ const a = arena_state.allocator();+ const saved_keys = bench.g_keys;+ const saved_ladder = selection.g_default_from_ladder;+ defer {+ bench.g_keys = saved_keys;+ selection.g_default_from_ladder = saved_ladder;+ }+ var keys: provider_mod.Keys = undefined;+ withKeys(&keys, &.{"codex"});++ // Seated by the automatic ladder: an explicit tier:"small" crosses to the+ // codex plan, because nothing here was a human decision.+ selection.g_default_from_ladder = true;+ const auto = va.forSpawn(deepseek(), obj(a, "{\"tier\":\"small\"}"), true, .{}, "extract the imports");+ try std.testing.expectEqual(pin_mod.Outcome.sub_routed, auto.pin.outcome);+ try std.testing.expectEqualStrings("codex", auto.pin.provider.?.id);+ try std.testing.expectEqualStrings("gpt-5.6-luna", auto.pin.provider.?.model);++ // A real --subagent-model session is still untouchable: the user picked+ // the workers, and no auto-route may override that.+ selection.g_default_from_ladder = false;+ const pinned = va.forSpawn(deepseek(), obj(a, "{\"tier\":\"small\"}"), true, .{}, "extract the imports");+ try std.testing.expect(pinned.pin.outcome != .sub_routed);++ // And an unpinned session behaves as it always did.+ selection.g_default_from_ladder = false;+ const free = va.forSpawn(deepseek(), obj(a, "{\"tier\":\"small\"}"), false, .{}, "extract the imports");+ try std.testing.expectEqual(pin_mod.Outcome.sub_routed, free.pin.outcome);+}