MTGBench improvement loop

Overview · Experiment index

Iteration 4: Gate the diagnostic affordability proof probe

state confirm-pending — rejected by the gate on a fingerprint artifact; after the fp-probe-scope fix: -2.21% instructions at 4,000 actions, parity 7/7; awaiting workstation wall-clock, integration and patch record
switch PHASE_CONTRACT_PROOF_PROBE_LEGACY · branch loop/it4 · base 3f4ca44ee · candidate e77deab12 · took 3h 0m

Results

Verdict: GOOD: 2.19% fewer instructions, above the 1% bar. The final word is always the PC wall-clock.
Gate: 1,000 actions (screen) — -2.19% instructions, equal work: yes
Gate FAILED: the harness refused this A/B (exit 1); see the write-up below. These counts are not a valid measurement.
-1% retain-0.3% kill0-2.19%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,311,898,5194,0005,327,9752,6232,216
optimized20,844,575,9444,0005,211,1442,9782,833
Instruction counts are deterministic and machine-specific (aarch64 homelab). contract and apply ms are wall time under perf: indicative only, not a clean timing.
Verdict: GOOD: 2.09% fewer instructions, above the 1% bar. The final word is always the PC wall-clock.
After the fingerprint-scope fix: 1,000 actions, seed 91 — -2.09% instructions, same-arm spread 0.015%, equal work: yes-1% retain-0.3% kill0-2.09%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy22,417,136,92722,413,729,2504,0005,603,8582,9382,375
optimized21,945,787,26221,946,371,1484,0005,486,5202,8432,586
Instruction counts are deterministic and machine-specific (aarch64 homelab). contract and apply ms are wall time under perf: indicative only, not a clean timing.
Verdict: GOOD: 2.21% fewer instructions, above the 1% bar. The final word is always the PC wall-clock.
After the fingerprint-scope fix: 4,000 actions, seed 91 — -2.21% instructions, same-arm spread 0.019%, equal work: yes-1% retain-0.3% kill0-2.21%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy83,035,091,47483,048,682,81111,4187,272,89320,74911,720
optimized81,213,300,02681,197,667,76611,4187,112,05820,52612,270
Instruction counts are deterministic and machine-specific (aarch64 homelab). contract and apply ms are wall time under perf: indicative only, not a clean timing.
Workstation wall-clock (Windows PC, one binary, two arms, 4,000 actions, ABBA)it4 s91 -2.8%it4 s42 -1.8%it4 s91 -2.9%it4-merged s91 -2.7%it4-merged s42 -3.3%it4-merged s91 -1.5%it4-merged s42 -1.1%0 (grey band = same-arm noise)
WhenCommitSeedVerdictDetail
202609304bf20cf2491retained-candidate|-2.8%| exceeds 1.5x the 1.0% floor; all pairs and 100% of games agree in sign
202609304bf20cf2442retained-candidate|-1.8%| exceeds 1.5x the 0.2% floor; all pairs and 100% of games agree in sign
202609304bf20cf2491retained-candidate|-2.9%| exceeds 1.5x the 0.5% floor; all pairs and 100% of games agree in sign
2026093096ebc371391neutral|-2.7%| is within the 2.9% same-arm spread
2026093096ebc371342retained-candidate|-3.3%| exceeds 1.5x the 0.8% floor; all pairs and 100% of games agree in sign
2026093096ebc371391neutral|-1.5%| is within the 4.4% same-arm spread
2026093096ebc371342neutral|-1.1%| is within the 3.7% same-arm spread

Where the time went

planner: 9 minexecutor: 48 minreviewer: 0 mingate fmt: 0 mingate check: 24 mingate focused: 41 mingate build: 6 mingate ir1k: 0 minnot attributed: 48 min
planner 9mexecutor 48mreviewer 0mgate fmt 0mgate check 24mgate focused 41mgate build 6mgate ir1k 0mnot attributed 48m
executor: 5,891,684 in / 14,666 out tokensplanner: 1,929,469 in / 12,632 out tokensreviewer: 20,678 in / 561 out tokens

Mechanism. At ai_support/context.rs:45–52, AiDecisionContract::issue runs single_candidate_affordability_probe_with_gate before authoritative enumeration, even when affordability attribution is disabled. Run this probe only when attribution or the new legacy switch is enabled. Its result feeds diagnostic counters, never candidate selection.

Evidence. The xn5.75 final memo section records probe time by first exit gate. Summing those intervals gives 289.413 ms / 8,937 ms = 3.24% of contract+apply for seed 91 and 216.493 ms / 8,022 ms = 2.70% for seed 42. This bounds the actual removable computation, rather than the much larger pass-only contract family. Recorded reports: bench/reports/xn575-overlap-s91-20260925-145328-* and xn575-overlap-s42-20260925-145544-*.

Counter and kill threshold. Use the existing affordability proof-probe gate timers as the component bound. Drop below a 1.5% reduction in instructions/action at the final 4,000-action A/B. The 1,000-action run is an initial screen; fingerprint divergence kills the change immediately.

Invariant. The ordered candidate domain, authorized actor, action stream, auto-tap selection and final state remain identical. Preserve the existing probe when attribution is enabled; when it is skipped, do not report a successful proof. Add a permanent differential regression comparing complete contracts with the probe enabled and disabled across pass-only, playable-land, mana-source and non-priority fixtures, including same-revision state mutation.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol9m 54s01,929,469 / 12,632
executorcodex / gpt-6-luna48m 28s05,891,684 / 14,666
reviewercodex / gpt-6.1-sol0m 23s020,678 / 561

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
checkpass0
focusedpass0
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it4-build
ir1kFAIL1pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode ab -Instrument perf -Legacy PHASE_CONTRACT_PROOF_PROBE_LEGACY -Actions 1000 -Seed 91 -Workers 1 -Timeout 1800 -Repeats 2 -SkipBuild -Label it4-ir1k -IrThresholdPercent 1.0 -IrDeterminismPercent 0.05 -VerdictJson /data/mtgbench/loop/reports/it4/ir1k.verdict.json -PerfSudo

Write-up: 2026-09-29 - Loop iteration 4: Gate the diagnostic affordability proof probe (rejected)

Status: rejected (loop, instruction-count gate; wall-clock not yet confirmed)

Automated loop result on homelab (aarch64). Switch PHASE_CONTRACT_PROOF_PROBE_LEGACY, mechanism class compute. Mechanism: At ai_support/context.rs:45–52, AiDecisionContract::issue runs single_candidate_affordability_probe_with_gate before authoritative enumeration, even when affordability attribution is disabled. Run this probe only when attribution or the new legacy switch is enabled. Its result feeds diagnostic counters, never candidate selection. Invariant: The ordered candidate domain, authorized actor, action stream, auto-tap selection and final state remain identical. Preserve the existing probe when attribution is enabled; when it is skipped, do not report a successful proof. Add a permanent differential regression comparing complete contracts with the probe enabled and disabled across pass-only, playable-land, mana-source and non-priority fixtures, including same-revision state mutation.

gatepasseddetail
fmtyescargo fmt --all -- --check
checkyes
focusedyes
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kNOpwsh -NoProfile -File scripts/bench_phase.ps1 -Mode ab -Instrument perf -Legacy

Wall-clock confirmation on the workstation is required before this counts as a speedup; instruction count is a screen, not a time prediction.

Write-up: 2026-09-29 - Loop iteration 4 addendum: why the A/B was refused, and a direct instruction measurement (informational)

Status: rejected (as recorded by the gate; the harness refused the A/B as invalid). Follow-up needed: see Decision.

What the harness said. INVALID A/B: seat=2 differs in auto_tap_selection_hash; no measurement at ir1k (1,000 actions, seed 91), so no timing or instruction verdict was produced.

Why. The auto-tap selection hash is a rotate-and-xor over every auto-tap call in the process (casting_costs.rs:187, :241, :12318), including the simulated auto-taps the diagnostic affordability probe performs. Candidate PHASE_CONTRACT_PROOF_PROBE_LEGACY skips that probe when attribution is off, so the hash differs by construction whatever the game does. On the same seed-91 workload, at 4,000 actions, the two arms matched on action-stream hash, final-state hash, total actions and turns in all four seats; the auto-tap hash differed in seats 2 and 3 only (seats 0 and 1 matched, because the probe made no selections there).

Direct measurement, NOT a valid A/B. This bypasses the harness's fingerprint validation and is recorded as information only. perf stat -e instructions:u, seed 91, 4,000 actions/seat, one binary built from the candidate commit ee5c738 (branch loop/it4), switch off vs on (PHASE_CONTRACT_PROOF_PROBE_LEGACY=1 is the legacy arm): 80,126,551,639 optimized vs 81,949,983,199 legacy, -2.23%. One pair, no repeats; counts on this host repeat to about 0.02%. The planner's expectation from the xn5.75 timings was 2.7-3.2% of contract+apply time.

Decision needed (not taken by the loop). AGENTS.md rule 3 says a fingerprint difference voids the delta, and this candidate cannot satisfy it as the fingerprint is defined. Options: (a) make the selection hash skip calls made under a diagnostic-probe scope, so probe removal can be validated while any change to a decision-path selection is still caught (an engine measurement-instrumentation change, needs a Phase commit and patch record); (b) document an exemption for probe-removal candidates that requires equal action stream and final state plus a 7-seed parity sweep. The loop keeps rejecting this class until one is chosen.

Write-up: 2026-09-29 - Loop iteration 4 follow-up: fingerprint scope for the diagnostic probe, and the gated probe validated

Status: unknown (validated on the homelab instruction-count screen: retained-ir; workstation wall-clock, the full integration target and the patch record are still pending)

Resolves the decision recorded in the addendum above by taking option (a). Two Phase commits on the homelab branch fp-probe-scope (base 3f4ca44):

1. 862d07f perf(bench): keep diagnostic-probe auto-tap selections out of the selection fingerprint. AutoTapSelectionDiagnosticScope in casting_costs.rs; one helper, record_auto_tap_selection, now serves the three recording sites (planner, empty selection, replay). Selections made inside the scope still count in calls and selected_sources but do not enter selection_hash or the replay trace. The affordability probe call in ai_support/context.rs runs inside the scope. Two regression tests (diagnostic_scope_tests): counted-but-not-hashed, and nesting plus the replay trace. cargo check --lib passes; the new tests have NOT been compiled or run yet (the homelab test compile was not repeated for this commit). 2. 4bf20cf perf: Gate the diagnostic affordability proof probe (loop iteration 4), the candidate, cherry-picked onto (1). The probe runs only when affordability attribution or PHASE_CONTRACT_PROOF_PROBE_LEGACY is on. The candidate's own focused gate (11 resolved-command tests, 135 stack tests among others) passed on the original loop branch, before commit (1).

Validation (host: homelab aarch64, one bench-fast-inc binary, -Instrument perf, seed 91, -Repeats 2, exact command in /data/mtgbench/fp_run.sh):

runinstructions optimized vs legacysame-arm spreadfingerprints
1,000 actions21,946,079,205 vs 22,415,433,088 = -2.09%0.0152%all three match
4,000 actions81,205,483,896 vs 83,041,887,142 = -2.21%0.0193%all three match
parity, 7 seeds (1,2,3,5,7,11,13), 1,000 actions, bench-fast-inc7 matched, 0 diverged, 0 arm failures

Before commit (1) the same A/B was refused: INVALID A/B: seat=2 differs in auto_tap_selection_hash, with the action stream and final state equal in every seat (see the addendum). A first parity attempt exited 1 because the script used the default server-release profile, which was not built; that was a script error, not a divergence, and the rerun above is the result.

Not done, required before this counts as a retained speedup: the full cargo test -p phase-engine --test integration run (the loop ran only --lib filters), cargo check of the test targets on the merged pair, the workstation wall-clock ABBA at 4,000 actions on seeds 91 and 42, and scripts/write_phase_patch.ps1 after the Phase commits land in the workstation checkout. Instruction count under-reports savings from allocation and copy changes but this is a compute change, so a wall-clock effect near -2% is the expectation, not a claim.

generated 2026-11-28 18:17:06 · read-only · refreshes every 30 s