graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs
Python
fix(escalation): a learned decline names the learned policy
justrach4a02763d1739
diff --git a/evals/harness_behavior.jsonl b/evals/harness_behavior.jsonlindex 98069d33..62364c1d 100644--- a/evals/harness_behavior.jsonl+++ b/evals/harness_behavior.jsonl@@ -31,7 +31,7 @@{"id": "synthesize-slot-not-anchor-checked", "why": "report_anchors.isReportSlot: only find/verify/sweep/review carry the report contract. A synthesize phase citing a phantom path must NOT be anchor-checked - no brief note, no rejection - while the sweep phase before it is, and the sweep's partial warning rides {{prev}} into the synthesize brief. Green-expected lock on the slot boundary.", "args": [], "env": {"GRAFF_NO_CODEDB_GUARD": "1"}, "prompt": "investigate the retry queue and summarize how jobs re-enter it", "script": [{"tool": "write_file", "arguments": {"path": "queue.py", "content": "RETRIES = 3\n"}}, {"tool": "workflow", "arguments": {"phases": [{"title": "sweep the queue sources", "tasks": [{"description": "scout", "prompt": "read the queue sources and report how jobs re-enter"}]}, {"title": "synthesize the answer", "tasks": [{"description": "writer", "prompt": "write the final answer from the sweep results"}]}]}}, {"text": "Jobs re-enter through queue.py; a dead-letter path may exist in ghost.py."}, {"text": "SYNTH-SENTINEL-9e1f: the answer cites phantom.zig as the sole source."}, {"text": "the queue answer is ready"}], "timeout_s": 90, "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"request_contains": {"index": 2, "text": "Anchor every finding to real code"}}, {"request_contains": {"index": 3, "text": "[anchor warning: "}}, {"request_contains": {"index": 3, "text": "e.g. ghost.py"}}, {"request_lacks": {"index": 3, "text": "Anchor every finding to real code"}}, {"request_contains": {"index": -1, "text": "SYNTH-SENTINEL-9e1f"}}, {"request_contains": {"index": -1, "text": "phantom.zig"}}, {"request_lacks": {"index": -1, "text": "report anchors unresolved"}}, {"request_contains": {"index": -1, "text": "phase 2/2 synthesize the answer: 1/1 ok, 0 retried"}}, {"final_text_contains": "the queue answer is ready"}]}{"id": "orch-audit-decision-row-lands-review-cell", "why": "#290/#372 loop input: every admission must file a kind:\"orch\" decision row in .graff/trajectories/<run>.jsonl, and an audit-worded ask must land in the REVIEW cell (shapes.classOf checks isAuditClass first) with the rung and source the gate chose - miscelled or unwritten rows silently poison every future fold. Green-expected: regression lock.", "args": ["--max-model-calls", "8"], "env": {"GRAFF_FLEET": "on"}, "prompt": "run an audit of the error handling in server.py", "script": [{"tool": "workflow", "arguments": {"phases": [{"title": "find problems", "tasks": [{"description": "find", "prompt": "read server.py and list the problems"}]}, {"title": "verify each finding", "tasks": [{"description": "verify", "prompt": "verify the problems in server.py"}]}]}}, {"tool": "bash", "arguments": {"command": "grep -h '\"kind\":\"orch\"' .graff/trajectories/*.jsonl | grep '\"task_class\":\"review\"' | grep '\"source\":\"bootstrap\"' | grep -q '\"arm\":\"R0\"' && echo orch-row-recorded"}}, {"text": "declined by the ladder; the decision row is on disk"}], "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"request_contains": {"index": 1, "text": "(escalation R0):"}}, {"event": {"type": "tool_result", "name": "bash", "text": "orch-row-recorded\n"}}, {"final_text_contains": "the decision row is on disk"}]}{"id": "orch-explicit-shape-stamps-explicit-source", "why": "#290 write side: when the USER names the orchestration ('use the workflow tool'), the decision row must say source:\"explicit\" and hold rung R2 - explicit rows are the ones foldArms must later skip, so stamping them bootstrap would let user intent vote on policy. The unaffordable pool (cap 8) keeps the explicit R2 on the solo advisory instead of spawning. Green-expected: regression lock.", "args": ["--max-model-calls", "8"], "env": {"GRAFF_FLEET": "on"}, "prompt": "use the workflow tool to fix the crash in engine.py", "script": [{"tool": "workflow", "arguments": {"phases": [{"title": "find the defect", "tasks": [{"description": "find", "prompt": "read engine.py and locate the crash"}]}, {"title": "implement the fix", "tasks": [{"description": "fix", "prompt": "fix the crash in engine.py"}]}]}}, {"tool": "bash", "arguments": {"command": "grep -h '\"kind\":\"orch\"' .graff/trajectories/*.jsonl | grep '\"task_class\":\"bugfix\"' | grep '\"source\":\"explicit\"' | grep -q '\"arm\":\"R2\"' && echo explicit-row-stamped"}}, {"text": "the user-named shape was recorded as explicit"}], "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"request_contains": {"index": 1, "text": "(escalation R0):"}}, {"event": {"type": "tool_result", "name": "bash", "text": "explicit-row-stamped\n"}}, {"final_text_contains": "recorded as explicit"}]}-{"id": "orch-folded-tradedown-declines-the-fleet", "why": "The learned override, end to end: >=min_arm_obs seeded orch_outcome rows where R0 beats R2 for (bugfix, unlimited, lmstudio) must trade a ladder-R2 ask (3 files, widest 2, affordable) down to a learned R0 decline, and the decision row must say source:\"learned\" arm:\"R0\". RED-expected today: needs the workspace_seed runner extension - the archive folds ONCE at startup (bench_priors.loadInto), before any scripted step runs, so without pre-launch seeding the ladder proceeds R2 and every assert fails (verified).", "args": [], "env": {"GRAFF_FLEET": "on"}, "workspace_seed": {".graff/trajectories/seed.jsonl": "{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 6, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 7, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 8, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 0.1, \"calls_used\": 30, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 0.1, \"calls_used\": 28, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 0.1, \"calls_used\": 31, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n"}, "timeout_s": 120, "prompt": "fix the failing checks in parser.py, lexer.py and tokens.py", "script": [{"tool": "workflow", "arguments": {"phases": [{"title": "find the defects", "tasks": [{"description": "find parser", "prompt": "read parser.py and locate the failing check"}, {"description": "find lexer", "prompt": "read lexer.py and locate the failing check"}]}, {"title": "implement the fixes", "tasks": [{"description": "fix", "prompt": "fix the failing checks in tokens.py"}]}]}}, {"tool": "bash", "arguments": {"command": "grep -h '\"kind\":\"orch\"' .graff/trajectories/*.jsonl | grep '\"task_class\":\"bugfix\"' | grep '\"source\":\"learned\"' | grep -q '\"arm\":\"R0\"' && echo learned-tradedown-row"}}, {"text": "the learned cell traded the fleet down to solo"}], "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"request_contains": {"index": 1, "text": "(escalation R0):"}}, {"event": {"type": "tool_result", "name": "bash", "text": "learned-tradedown-row\n"}}, {"final_text_contains": "traded the fleet down to solo"}]}+{"id": "orch-folded-tradedown-declines-the-fleet", "why": "The learned override, end to end: >=min_arm_obs seeded orch_outcome rows where R0 beats R2 for (bugfix, unlimited, lmstudio) must trade a ladder-R2 ask (3 files, widest 2, affordable) down to a learned R0 decline, and the decision row must say source:\"learned\" arm:\"R0\". RED-expected today: needs the workspace_seed runner extension - the archive folds ONCE at startup (bench_priors.loadInto), before any scripted step runs, so without pre-launch seeding the ladder proceeds R2 and every assert fails (verified). The decline advisory must NAME the learned policy - the generic R0 scope-arithmetic text is a lie about why the fleet was traded down.", "args": [], "env": {"GRAFF_FLEET": "on"}, "workspace_seed": {".graff/trajectories/seed.jsonl": "{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 6, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 7, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 8, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 0.1, \"calls_used\": 30, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 0.1, \"calls_used\": 28, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 0.1, \"calls_used\": 31, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n"}, "timeout_s": 120, "prompt": "fix the failing checks in parser.py, lexer.py and tokens.py", "script": [{"tool": "workflow", "arguments": {"phases": [{"title": "find the defects", "tasks": [{"description": "find parser", "prompt": "read parser.py and locate the failing check"}, {"description": "find lexer", "prompt": "read lexer.py and locate the failing check"}]}, {"title": "implement the fixes", "tasks": [{"description": "fix", "prompt": "fix the failing checks in tokens.py"}]}]}}, {"tool": "bash", "arguments": {"command": "grep -h '\"kind\":\"orch\"' .graff/trajectories/*.jsonl | grep '\"task_class\":\"bugfix\"' | grep '\"source\":\"learned\"' | grep -q '\"arm\":\"R0\"' && echo learned-tradedown-row"}}, {"text": "the learned cell traded the fleet down to solo"}], "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"request_contains": {"index": 1, "text": "(escalation R0, learned):"}}, {"event": {"type": "tool_result", "name": "bash", "text": "learned-tradedown-row\n"}}, {"final_text_contains": "traded the fleet down to solo"}]}{"id": "orch-two-obs-cell-stays-bootstrap", "why": "min_arm_obs: a candidate arm with min_arm_obs-1 (=2) observations must NOT override - the base R0 arm is folded (n=3) but the winning R2 arm is one row short, so the decision stays source:\"bootstrap\" R0. Adding one more R2 row flips it to a learned R2 fleet (verified), so this is exactly the threshold. A scripted seed-presence probe keeps this case loudly RED until the workspace_seed runner extension exists - without it an empty archive declines identically and the case would otherwise pass while guarding nothing; once the seed lands it locks the n-gate.", "args": [], "env": {"GRAFF_FLEET": "on"}, "workspace_seed": {".graff/trajectories/seed.jsonl": "{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 0.5, \"calls_used\": 6, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 0.5, \"calls_used\": 7, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 0.5, \"calls_used\": 8, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 12, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 13, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n"}, "timeout_s": 90, "prompt": "fix the regression in mathutil.py", "script": [{"tool": "workflow", "arguments": {"phases": [{"title": "find the defect", "tasks": [{"description": "find", "prompt": "read mathutil.py and locate the regression"}]}, {"title": "implement the fix", "tasks": [{"description": "fix", "prompt": "fix the regression in mathutil.py"}]}]}}, {"tool": "bash", "arguments": {"command": "test -s .graff/trajectories/seed.jsonl && echo seed-present"}}, {"tool": "bash", "arguments": {"command": "grep -h '\"kind\":\"orch\"' .graff/trajectories/*.jsonl | grep '\"task_class\":\"bugfix\"' | grep '\"source\":\"bootstrap\"' | grep -q '\"arm\":\"R0\"' && echo sparse-cell-stayed-bootstrap"}}, {"text": "two observations are not evidence; the hand ladder decided"}], "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"request_contains": {"index": 1, "text": "(escalation R0):"}}, {"event": {"type": "tool_result", "name": "bash", "text": "seed-present\n"}}, {"event": {"type": "tool_result", "name": "bash", "text": "sparse-cell-stayed-bootstrap\n"}}, {"final_text_contains": "the hand ladder decided"}]}{"id": "orch-explicit-and-foreign-stratum-never-fold", "why": "#290 fold side, both firewalls at once: seeded R2 rows that would win the cell outright are marked source:\"explicit\" (user intent) or carry stratum gpt-5.6-sol (different model), so neither may fold into the (bugfix, unlimited, lmstudio) ask - the decision must stay bootstrap R0. Relabeling the explicit rows bootstrap flips it to a learned R2 fleet (verified), so each firewall is individually load-bearing. A scripted seed-presence probe keeps this case loudly RED until the workspace_seed runner extension exists - without it an empty archive declines identically and the case would otherwise pass while guarding nothing; once the seed lands it locks both firewalls.", "args": [], "env": {"GRAFF_FLEET": "on"}, "workspace_seed": {".graff/trajectories/seed.jsonl": "{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 0.0, \"calls_used\": 6, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 0.0, \"calls_used\": 7, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R0\", \"source\": \"bootstrap\", \"score\": 0.0, \"calls_used\": 8, \"exhausted\": false, \"landed\": false, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"explicit\", \"score\": 1.0, \"calls_used\": 12, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"explicit\", \"score\": 1.0, \"calls_used\": 13, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"lmstudio\", \"arm\": \"R2\", \"source\": \"explicit\", \"score\": 1.0, \"calls_used\": 14, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"gpt-5.6-sol\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 12, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"gpt-5.6-sol\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 13, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n{\"kind\": \"orch_outcome\", \"task_class\": \"bugfix\", \"budget_band\": \"unlimited\", \"stratum\": \"gpt-5.6-sol\", \"arm\": \"R2\", \"source\": \"bootstrap\", \"score\": 1.0, \"calls_used\": 14, \"exhausted\": false, \"landed\": true, \"variant_free\": true}\n"}, "timeout_s": 90, "prompt": "fix the crash in payments.py", "script": [{"tool": "workflow", "arguments": {"phases": [{"title": "find the defect", "tasks": [{"description": "find", "prompt": "read payments.py and locate the crash"}]}, {"title": "implement the fix", "tasks": [{"description": "fix", "prompt": "fix the crash in payments.py"}]}]}}, {"tool": "bash", "arguments": {"command": "test -s .graff/trajectories/seed.jsonl && echo seed-present"}}, {"tool": "bash", "arguments": {"command": "grep -h '\"kind\":\"orch\"' .graff/trajectories/*.jsonl | grep '\"task_class\":\"bugfix\"' | grep '\"source\":\"bootstrap\"' | grep -q '\"arm\":\"R0\"' && echo firewalled-rows-did-not-fold"}}, {"text": "user intent and foreign strata stayed out of the cell"}], "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"request_contains": {"index": 1, "text": "(escalation R0):"}}, {"event": {"type": "tool_result", "name": "bash", "text": "seed-present\n"}}, {"event": {"type": "tool_result", "name": "bash", "text": "firewalled-rows-did-not-fold\n"}}, {"final_text_contains": "stayed out of the cell"}]}{"id": "citation-free-report-not-rejected", "why": "The false-positive axis of anchorCheck: a report-slot worker that honestly cites nothing must pass in one call - no anchor rejection, no burnt phase retry. The scan once counted the harness's own appended inspect link (.graff/subagents/<id>.md) as a fabricated citation, auto-rejecting every citation-free report; this locks the fix (report_anchors.scan skips .graff/ paths).", "args": [], "prompt": "investigate whether any throttle wiring exists in this project", "script": [{"tool": "workflow", "arguments": {"phases": [{"title": "sweep the project for throttle wiring", "tasks": [{"description": "scout", "prompt": "search for throttle wiring and report what exists"}]}]}}, {"text": "No throttle wiring exists anywhere in this project; there is nothing to cite."}, {"text": "confirmed: no throttle wiring exists"}], "timeout_s": 90, "assert": [{"event": {"type": "tool_result", "name": "workflow", "is_error": false}}, {"events_at_most": {"match": {"type": "agent_usage"}, "count": 1}}, {"request_lacks": {"index": 2, "text": "Anchor every finding to real code"}}, {"request_contains": {"index": -1, "text": "1/1 ok, 0 retried"}}, {"final_text_contains": "confirmed: no throttle wiring exists"}]}diff --git a/src/escalation.zig b/src/escalation.zigindex 961a0ed4..e475e33e 100644--- a/src/escalation.zig+++ b/src/escalation.zig@@ -240,12 +240,9 @@ pub fn ladderRung(o: Observables) Rung {if (o.prior_failure and !o.audit and o.prior_failure_count == 1 ando.files < fleet_scope_min and o.verifier != .none) return .R0d;if ((o.audit or o.prior_failure) and fleet_affordable) return .R3;- // An open-ended question is the one case where delegation pays for itself- // at width ONE: the scout burns its own context on the search and hands- // back a summary, which is the whole benefit. Wider adds cost, not value —- // measured, in the study's research run: three sweepers over three small- // files scored identically to one, at 4x the calls, on briefs that- // measured 1.00 similar to each other.+ // An open-ended question is the one case where delegation pays at width+ // ONE: the scout burns its own context and hands back a summary. Wider+ // adds cost, not value (measured: three sweepers scored equal to one, 4x).if (o.shape == .research and !o.audit) return .R1;if (o.files >= fleet_scope_min and o.widest >= 2 and fleet_affordable) return .R2;return .R0;@@ -295,15 +292,19 @@ pub fn verdictFor(rung: Rung, o: Observables, phases: []const Value) Verdict {.R2, .R3 => {if (l.fits(o.remaining, o.plan_estimate)) return .proceed;const w = downsizeWidth(phases, o.cap, o.remaining);- // Nothing fits, not even one worker per phase, so a fleet here- // would be a fan-out that cannot finish. Solo is not a demotion,- // it is the only rung with a budget.+ // Nothing fits, not even one worker per phase: solo is the only rung with a budget.if (w == 0) return .{ .solo = solo_advice };return .{ .downsize = w };},}}+/// A learned decline names its real reason, not unconsulted scope arithmetic.+fn learnedVerdict(rung: Rung, o: Observables, phases: []const Value) Verdict {+ if (rung == .R0) return .{ .solo = orch.learned_solo_advice };+ return verdictFor(rung, o, phases);+}+// ── session state: prior failure, explicit choice, exploration ─────────────/// How many times this session already declined (or scouted) an ask of each@@ -462,7 +463,7 @@ pub fn decide(o: Observables, phases: []const Value, explicit: bool, arms: []con}const reserve = pb.landingReserve(o.cap);if (orch.override(arms, key, ladder, o.remaining, reserve)) |learned| {- return .{ .rung = learned, .source = .learned, .verdict = verdictFor(learned, o, phases) };+ return .{ .rung = learned, .source = .learned, .verdict = learnedVerdict(learned, o, phases) };}if (ladder == .R0 and shouldExplore(o)) {return .{ .rung = .R1, .source = .explore, .verdict = verdictFor(.R1, o, phases) };@@ -489,14 +490,12 @@ pub fn admit(c: Ctx, phases: []const Value, shape: route_policy.Shape) Decision.budget_band = orch.BudgetBand.of(o.remaining),.stratum = route_policy.stratumOf(c.stratum),};- // The learned lookup is keyed with the REAL stratum; `decide` takes the- // arms slice so the pure path can be driven with fixtures.+ // Keyed with the REAL stratum; arms passed so tests can drive the pure path.var d = decide(o, phases, userChoseShape(raw), armsFor(key), key);- // Nothing learned for this cell? Fall back to the compiled bootstrap- // prior, which is the study's own measurements as n=2 pseudo-rows.+ // No learned cell: fall back to the compiled bootstrap prior (study rows, n=2).if (d.source == .bootstrap and !userChoseShape(raw)) {if (orch.learnedRung(key, d.rung, o.remaining, pb.landingReserve(o.cap))) |learned| {- d = .{ .rung = learned, .source = .learned, .verdict = verdictFor(learned, o, phases) };+ d = .{ .rung = learned, .source = .learned, .verdict = learnedVerdict(learned, o, phases) };}}// R0d's advisory carries the observed failure evidence, composed herediff --git a/src/escalation_tests.zig b/src/escalation_tests.zigindex 3d77d78f..3ab9e5da 100644--- a/src/escalation_tests.zig+++ b/src/escalation_tests.zig@@ -213,6 +213,8 @@ test "decide: a learned cell overrides the hand ladder and says so" {// Trading DOWN needs only "not worse", and this is much better.try std.testing.expectEqual(Rung.R0, d.rung);try std.testing.expectEqual(orch.Source.learned, d.source);+ // The advisory names the learned policy, not the ladder's scope arithmetic.+ try std.testing.expect(std.mem.indexOf(u8, d.verdict.solo, "(escalation R0, learned):") != null);}fn armWith(key: orch.Key, arm: Rung, n: u32, score: f64, calls: u32) orch.ArmObs {diff --git a/src/orchestration_policy.zig b/src/orchestration_policy.zigindex 3f5d0050..2efb9b84 100644--- a/src/orchestration_policy.zig+++ b/src/orchestration_policy.zig@@ -413,6 +413,16 @@ pub fn override(arms: []const ArmObs, key: Key, ladder: Rung, remaining: u64, la/// Production entry point: the session's folded arms, falling back to the/// compiled prior when the local archive has never seen this cell.+/// The solo advisory for a LEARNED R0: escalation's solo_advice contract,+/// but naming the real reason — recorded outcomes for this cell traded the+/// fleet down — instead of scope arithmetic the decision never consulted.+pub const learned_solo_advice =+ "workflow declined (escalation R0, learned): recorded outcomes for this task class and " +++ "budget band score solo work above a fleet here, so the learned policy traded the " +++ "orchestration down. Do it yourself — read the files, make the edits, verify — and " +++ "re-invoke the workflow tool only if verification fails, which is the signal that " +++ "earns a fleet.";+pub fn learnedRung(key: Key, ladder: Rung, remaining: u64, landing_reserve: u64) ?Rung {if (override(g_arms, key, ladder, remaining, landing_reserve)) |r| return r;var buf: [8]ArmObs = undefined;