MTGBench improvement loop

Overview · Experiment index

Iteration 11: Prefilter protection grants before attachment recipient checks

state confirm-pending — gate ir4k: marginal instruction reduction (compute); the workstation wall-clock decides
switch PHASE_ATTACHMENT_PROTECTION_PREFILTER_LEGACY · branch loop/it11 · base 4ec0b9ef1 · candidate 6049eb7ba · took 5h 30m

Results

Verdict: TOO SMALL: only 0.06% fewer instructions, under the 0.3% floor. The final word is always the PC wall-clock.
Gate: 1,000 actions (screen) — -0.06% instructions, same-arm spread 0.015%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.06%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy22,098,281,08922,096,681,9094,0005,524,3703,8903,743
optimized22,086,215,44122,082,813,5104,0005,521,1292,9633,051
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: MARGINAL: 0.71% fewer instructions, between 0.3% and 1%. It is sent to the PC wall-clock check instead of being kept outright. The final word is always the PC wall-clock.
Gate: 4,000 actions (verdict) — -0.71% instructions, same-arm spread 0.030%, equal work: yes, fingerprints match: yes-1% retain-0.3% kill0-0.71%
ArmRun 1 instructionsRun 2ActionsInstr / actioncontract msapply ms
legacy81,023,655,69481,047,622,44011,4187,097,18318,63912,781
optimized80,449,690,50180,473,471,51511,4187,046,90719,03812,209
Instruction counts are deterministic and machine-specific (aarch64 homelab). contract and apply ms are wall time under perf: indicative only, not a clean timing.
Gate: parity (7 seeds, decks rotate per seed)
coverage: 253 distinct cards cast, 35 action kinds, 41 decision kinds, 59 event kinds, max battlefield 35, max stack 5
coverage: 143 of 257 engine counters were nonzero somewhere (unioned over 7 seeds; decks rotate per seed)
parity: 1 matched, 6 matched with an engine rejection in both arms, 0 diverged, 0 arm failures; summary /data/mtgbench/edh-play/bench/reports/it11-parity-20261001-154048-parity.json
9 games ended early on an engine rejection (counted over both arms). A rejection that happens identically in both arms is a match, but those games never reach their late game, so late-game behaviour of those decks is not exercised.

Where the time went

planner: 12 minexecutor: 67 minreviewer: 0 mingate fmt: 0 mingate build: 11 mingate ir1k: 1 mingate ir4k: 3 mingate check: 29 mingate focused: 59 mingate parity: 5 minnot attributed: 138 min
planner 12mexecutor 67mreviewer 0mgate fmt 0mgate build 11mgate ir1k 1mgate ir4k 3mgate check 29mgate focused 59mgate parity 5mnot attributed 138m
executor: 8,203,082 in / 15,884 out tokensplanner: 3,212,974 in / 13,021 out tokensreviewer: 21,136 in / 757 out tokens

Mechanism. In game/effects/attach.rs:1549, protection_blocks_attachment computes definition indices, clones affected filters and evaluates recipient filters before discovering whether a static or transient effect contains AddKeyword { Protection(..) }. Check that modification shape first and skip effects with no protection grant. Keep the existing functioning-ability iterator and all protection matching, exemption and fallback logic.

Evidence. xn5.67, docs/stage0-decision-memo.md:L4904, identifies attachment_illegality_projected as an allocation owner in the saved profile. The fingerprint-valid xn5.65 reports provide a tighter family bound: sba_family_unattached_equipment_ns totals 172.016 ms / 8,255 ms contract+apply = 2.08% on seed 91, and 32.897 ms / 7,442 ms = 0.44% on seed 42. Reports: bench/reports/xn565-final-s91-20260923-135943-optimized.json and xn565-final-s42-20260923-140228-optimized.json. These historical family bounds include work the prefilter cannot remove; the protection-filter subset is unmeasured.

Counter and kill threshold. Existing sba_family_unattached_equipment_ns and xn5.67 attachment profile attribution. Expected instruction reduction per action: approximately 0.5–1.0% on seed 91, with a smaller 0.1–0.3% expectation on seed 42. These are hypotheses, not measured savings; this candidate may be marginal or dropped by the loop.

Invariant. Effects without an AddKeyword Protection modification cannot change any_matching_grant or produce a protection rejection in this function. Preserve traversal order for contributing effects, chosen-quality resolution, grant-start exemptions and the host-keyword fallback. Add a permanent differential regression comparing rejection reasons and settled attachment state across unrelated grants, printed protection, static/transient protection, chosen qualities and exempt attachments.

Agent steps

RoleHarness / modelTimeExitTokens in / outNote
plannercodex / gpt-6.1-sol12m 24s03,212,974 / 13,021
executorcodex / gpt-6-luna1h 7m08,203,082 / 15,884
reviewercodex / gpt-6.1-sol0m 54s021,136 / 757

Gates

GateResultExitDetail
fmtpass0cargo fmt --all -- --check
buildpass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fast-inc -Label it11-build
ir1kpass0Ir -0.06% within +/-1%, same-arm spread 0.0167% | optimized 22,083,851,710 vs legacy 22,096,692,353 instructions; fingerprints match: True
ir4kFAIL0Ir -0.72% within +/-1%, same-arm spread 0.0319% | optimized 80,460,559,004 vs legacy 81,040,259,087 instructions; fingerprints match: True
checkpass0
focusedpass0
paritypass0pwsh -NoProfile -File scripts/bench_phase.ps1 -Mode parity -Seeds 1,2,3,5,7,11,13 -Actions 1000 -CargoProfile bench-fast-inc -Label it11-parity

Write-up: 2026-10-01 - Loop iteration 11: Prefilter protection grants before attachment recipient checks (confirm-pending)

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

Automated loop result on homelab (aarch64). Switch PHASE_ATTACHMENT_PROTECTION_PREFILTER_LEGACY, mechanism class compute. Mechanism: In game/effects/attach.rs:1549, protection_blocks_attachment computes definition indices, clones affected filters and evaluates recipient filters before discovering whether a static or transient effect contains AddKeyword { Protection(..) }. Check that modification shape first and skip effects with no protection grant. Keep the existing functioning-ability iterator and all protection matching, exemption and fallback logic. Invariant: Effects without an AddKeyword Protection modification cannot change any_matching_grant or produce a protection rejection in this function. Preserve traversal order for contributing effects, chosen-quality resolution, grant-start exemptions and the host-keyword fallback. Add a permanent differential regression comparing rejection reasons and settled attachment state across unrelated grants, printed protection, static/transient protection, chosen qualities and exempt attachments.

gatepasseddetail
fmtyescargo fmt --all -- --check
buildyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode build -CargoProfile bench-fa
ir1kyesIr -0.06% within +/-1%, same-arm spread 0.0167%
ir4kmarginal: workstation checkIr -0.72% within +/-1%, same-arm spread 0.0319%
checkyes
focusedyes
parityyespwsh -NoProfile -File scripts/bench_phase.ps1 -Mode parity -Seeds 1,2,3,5,7,11,1

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:17 · read-only · refreshes every 30 s