MTGBench improvement loop

Overview · Experiment index

Iteration 17: Validate mana selections against only their named source

state rejected — failed gate ir1k
switch PHASE_MANA_SELECTION_LOCAL_LEGACY · branch loop/it17 · base 4ec0b9ef1 · candidate 28439dd71 · took 1h 21m

Results

Verdict: TOO SMALL: only 0.18% fewer instructions, under the 0.3% floor. The final word is always the PC wall-clock.
Gate: 1,000 actions (screen) — -0.18% instructions, equal work: yes
Gate FAILED: INVALID A/B: seat=$($game.candidate_seat) differs …. These counts are not a valid measurement.
-1% retain-0.3% kill0-0.18%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy21,797,282,2304,0005,449,3212,4632,374
optimized21,758,747,6854,0005,439,6872,3112,317
Instruction counts are deterministic and machine-specific (aarch64 homelab). contract and apply ms are wall time under perf: indicative only, not a clean timing.

Where the time went

planner: 12 minexecutor: 57 minreviewer: 1 mingate fmt: 0 mingate build: 9 mingate ir1k: 0 min
planner 12mexecutor 57mreviewer 1mgate fmt 0mgate build 9mgate ir1k 0m
executor: 14,118,105 in / 24,553 out tokensplanner: 4,203,288 in / 15,061 out tokensreviewer: 22,062 in / 1,201 out tokens

Mechanism. At mana_sources.rs:840, preflight_tap_land_action builds every battlefield mana action before counting matches for one submitted selection. At :609, live_mana_source_option_for_selection similarly enumerates every source, then enumerates the selected source again. Replace these whole-battlefield membership scans with source-local enumeration using the existing option producers and exact semantic-selection comparisons.

Evidence. The xn5.59 memo section at L4524 attributes 200.2 ms across 582 TapLandForMana raw validations in the two 4,000-action workloads. This bounds that action's entire validation family, not just preflight. Source inspection confirms redundant enumeration, but its exclusive share is unmeasured. The historical timings predate subsequent optimizations and are opportunity bounds.

Counter and kill threshold. Existing xn5.59 raw-validation row TapLandForMana: 582 calls, 200.2 ms. Expected 4,000-action instruction reduction: 0.4–0.9% per action, a hypothesis likely to enter the marginal tier. No separate measurement prerequisite.

Invariant. Preserve acceptance, error variants, ambiguity detection, and validation-before-mutation. A selection includes source identity, so another permanent cannot match it. Preserve battlefield membership and duplicate-source multiplicity explicitly; retain the existing option producers, controller checks, incarnation comparison, and deferred-color canonicalization.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol12m 3s04,203,288 / 15,061
executorcodex / gpt-6-luna57m 35s014,118,105 / 24,553
reviewercodex / gpt-6.1-sol1m 3s022,062 / 1,201

Gates

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

Write-up: 2026-10-02 - Loop iteration 17: Validate mana selections against only their named source (rejected)

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

Automated loop result on homelab (aarch64). Switch PHASE_MANA_SELECTION_LOCAL_LEGACY, mechanism class compute. Mechanism: At mana_sources.rs:840, preflight_tap_land_action builds every battlefield mana action before counting matches for one submitted selection. At :609, live_mana_source_option_for_selection similarly enumerates every source, then enumerates the selected source again. Replace these whole-battlefield membership scans with source-local enumeration using the existing option producers and exact semantic-selection comparisons. Invariant: Preserve acceptance, error variants, ambiguity detection, and validation-before-mutation. A selection includes source identity, so another permanent cannot match it. Preserve battlefield membership and duplicate-source multiplicity explicitly; retain the existing option producers, controller checks, incarnation comparison, and deferred-color canonicalization.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kNOINVALID A/B: seat=$($game.candidate_seat) differs …

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

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