game-abba: pass the gate's memory stops to every gate run (D3D12-GAME-ABBA-MEMORY-STOP) #3305

Open
OtavMacedo wants to merge 3 commits from upstream-pr/3305 into main
OtavMacedo commented 2026-12-03 07:16:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OtavMacedo on 2026-12-03T07:16:17Z.


Claimed in the coordination issue as: D3D12-GAME-ABBA-MEMORY-STOP (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7370240477)

What and why

scripts/game-gate.ps1 has three memory stops (-StopPrivateMB, -StopCommitLeftMB, -StopOverBudgetSeconds, docs/game_gate.md), but scripts/game-abba.ps1 could not pass them on, so every ABBA gate run took the gate's defaults.

On a PC with 16 GB of memory the default private-bytes cap is min(0.9 x commit limit, 1.25 x RAM), which is 20,382 MB here. That is under what the title holds in the world, so the measured runs fail their gate by memory_stop and the runner never reaches a comparison. The numbers are in the finding in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7369342822). For example, a Series X run went over the cap 16.7 s into the world (20,769 MB private), with 4,956 MB still free to commit. MEASURED, n=1 for Series X at the default cap. The cap is there for a reason (two Windows crashes at about 100 GB private), so the fix is to let the caller set it, not to change the default.

The change:

  • game-abba.ps1 takes -StopPrivateMB, -StopCommitLeftMB and -StopOverBudgetSeconds. Only the ones given go to every gate run of both arms (warm-up, discarded, measured, retries). A stop left out keeps the gate's own default: an unbound [int] would be 0, which means "off" to the gate.
  • abba.json records them as given in memory_stops ({} when none is given). Each run's run.json already has the values the gate used.
  • -DryRun prints them on each gate command.
  • In two-build mode, a checkout whose gate lacks a stop that was given (gates before 2026-12-01, aa75f1319) is refused before any run. Without this, that arm's first run would fail after the other arm's warm-up, with an error that does not say why.
  • docs/measuring_fps.md section 3 and the script's header describe all of the above.

Tested

  • tests/test_game_abba.py: 27 tests pass on Windows 11 with PowerShell 7. The stand-in gate now accepts the three stops and logs which ones were bound. Four new tests:
    • the stops given reach every gate call of both arms, including a negative -StopCommitLeftMB, and are recorded;
    • one stop given alone goes alone;
    • with no stop given, none is bound and memory_stops is {};
    • a gate without a given stop is refused before any run, with nothing deleted;
    • plus a -DryRun test of the printed plan.
  • Red and green with python -I scripts/red_green.py d3d12-game-abba-memory-stop --no-cargo. Base origin/main d9b618f10. The 4 new tests are red, then green; 23 tests pass on both sides.
  • tests/test_docs_*.py: all pass. python -I scripts/check_no_game_data.py: passes.
  • In game: an ABBA (LEONIDA_WINDOWS_BAR_MB=3072 against 0, Series X -Resolution 1080 -NoFrameGen, 300 s in the world, 4 pairs) is running with the runner from the first commit and -StopPrivateMB 27000 -StopOverBudgetSeconds 0. Both warm-ups PASS, with the stops on the gate's command line. The data for #3035 will follow there once the comparison is done. On this PC the measured runs fail their gate without -StopPrivateMB.

The change was reviewed by a separate read-only Claude Opus 5.5 agent before this pull request. It found nothing blocking. Fixed from its review: the older-gate refusal, test-comment wording (a negative -StopOverBudgetSeconds means off, not the default), a -DryRun test, the memory_stops-as-given note, and line wrapping.

GPUs tested: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.24, Windows 11, 16 GB RAM (profile M). Runner change; no GPU code.

AI-assisted: yes, Claude Code (Claude Opus 5.5); reviewer: separate read-only Claude Opus 5.5 agent

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5621838657 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3305). Originally posted by [OtavMacedo](https://github.com/OtavMacedo) on 2026-12-03T07:16:17Z. --- Claimed in the coordination issue as: D3D12-GAME-ABBA-MEMORY-STOP (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7370240477) ### What and why `scripts/game-gate.ps1` has three memory stops (`-StopPrivateMB`, `-StopCommitLeftMB`, `-StopOverBudgetSeconds`, docs/game_gate.md), but `scripts/game-abba.ps1` could not pass them on, so every ABBA gate run took the gate's defaults. On a PC with 16 GB of memory the default private-bytes cap is `min(0.9 x commit limit, 1.25 x RAM)`, which is 20,382 MB here. That is under what the title holds in the world, so the measured runs fail their gate by `memory_stop` and the runner never reaches a comparison. The numbers are in the finding in #2570 (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7369342822). For example, a Series X run went over the cap 16.7 s into the world (20,769 MB private), with 4,956 MB still free to commit. MEASURED, n=1 for Series X at the default cap. The cap is there for a reason (two Windows crashes at about 100 GB private), so the fix is to let the caller set it, not to change the default. The change: - `game-abba.ps1` takes `-StopPrivateMB`, `-StopCommitLeftMB` and `-StopOverBudgetSeconds`. Only the ones given go to every gate run of both arms (warm-up, discarded, measured, retries). A stop left out keeps the gate's own default: an unbound `[int]` would be 0, which means "off" to the gate. - `abba.json` records them as given in `memory_stops` (`{}` when none is given). Each run's `run.json` already has the values the gate used. - `-DryRun` prints them on each gate command. - In two-build mode, a checkout whose gate lacks a stop that was given (gates before 2026-12-01, aa75f1319) is refused before any run. Without this, that arm's first run would fail after the other arm's warm-up, with an error that does not say why. - `docs/measuring_fps.md` section 3 and the script's header describe all of the above. ### Tested - `tests/test_game_abba.py`: 27 tests pass on Windows 11 with PowerShell 7. The stand-in gate now accepts the three stops and logs which ones were bound. Four new tests: - the stops given reach every gate call of both arms, including a negative `-StopCommitLeftMB`, and are recorded; - one stop given alone goes alone; - with no stop given, none is bound and `memory_stops` is `{}`; - a gate without a given stop is refused before any run, with nothing deleted; - plus a `-DryRun` test of the printed plan. - Red and green with `python -I scripts/red_green.py d3d12-game-abba-memory-stop --no-cargo`. Base origin/main `d9b618f10`. The 4 new tests are red, then green; 23 tests pass on both sides. - `tests/test_docs_*.py`: all pass. `python -I scripts/check_no_game_data.py`: passes. - In game: an ABBA (`LEONIDA_WINDOWS_BAR_MB=3072` against `0`, Series X `-Resolution 1080 -NoFrameGen`, 300 s in the world, 4 pairs) is running with the runner from the first commit and `-StopPrivateMB 27000 -StopOverBudgetSeconds 0`. Both warm-ups PASS, with the stops on the gate's command line. The data for #3035 will follow there once the comparison is done. On this PC the measured runs fail their gate without `-StopPrivateMB`. The change was reviewed by a separate read-only Claude Opus 5.5 agent before this pull request. It found nothing blocking. Fixed from its review: the older-gate refusal, test-comment wording (a negative `-StopOverBudgetSeconds` means off, not the default), a `-DryRun` test, the `memory_stops`-as-given note, and line wrapping. GPUs tested: NVIDIA GeForce RTX 3070 8 GB desktop, driver 621.24, Windows 11, 16 GB RAM (profile M). Runner change; no GPU code. AI-assisted: yes, Claude Code (Claude Opus 5.5); reviewer: separate read-only Claude Opus 5.5 agent ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-12-03 07:18:33 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T07:18:33Z.

Review: CHANGES_REQUESTED


[P2] Check the gate's declared parameters before clearing earlier results. At f1829698, scripts/game-abba.ps1:164–166 searches the entire script for $StopOverBudgetSeconds. A comment or local variable can match even when the gate has no such parameter.

I reproduced this with the PR's synthetic gate fixture on d9b618f1 plus f1829698. Arm B's gate lacked -StopOverBudgetSeconds and mentioned $StopOverBudgetSeconds once in a comment. I seeded a successful previous comparison, then reran in two-build mode with -StopOverBudgetSeconds 0. The preflight let the run through, the runner removed the previous comparison, arm A completed one warm-up, and arm B's binder then rejected the option.

Reading Parser.ParseFile(...).ParamBlock.Parameters in the same preflight rejected the same fixture before either arm started and preserved the previous comparison byte-for-byte. The three existing forwarding, omission and missing-parameter tests also passed when I ran the synthetic fixture under Linux PowerShell 7.7.0. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6165265873 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3305#pullrequestreview-6165265873). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T07:18:33Z. **Review:** CHANGES_REQUESTED --- **[P2] Check the gate's declared parameters before clearing earlier results.** At `f1829698`, `scripts/game-abba.ps1:164–166` searches the entire script for `$StopOverBudgetSeconds`. A comment or local variable can match even when the gate has no such parameter. I reproduced this with the PR's synthetic gate fixture on `d9b618f1` plus `f1829698`. Arm B's gate lacked `-StopOverBudgetSeconds` and mentioned `$StopOverBudgetSeconds` once in a comment. I seeded a successful previous comparison, then reran in two-build mode with `-StopOverBudgetSeconds 0`. The preflight let the run through, the runner removed the previous comparison, arm A completed one warm-up, and arm B's binder then rejected the option. Reading `Parser.ParseFile(...).ParamBlock.Parameters` in the same preflight rejected the same fixture before either arm started and preserved the previous comparison byte-for-byte. The three existing forwarding, omission and missing-parameter tests also passed when I ran the synthetic fixture under Linux PowerShell 7.7.0. AI-assisted with OpenAI Codex.
fiestorra commented 2026-12-03 07:26:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T07:26:12Z.


VERIFY-3305 — 27 tests en verde (97 s), y el cambio es de la herramienta que mide A/B

scripts/game-abba.ps1    +23/−…     pasa los topes de memoria del portón a cada corrida
tests/test_game_abba.py  +67/−…     27 passed   (97 s)
docs/measuring_fps.md    +26/−…     documenta lo que cambia

Y el título es preciso: «pass the gate's memory stops to every gate run» — el gate es el A/B que compara main con una rama, y sus topes de memoria (los LEONIDA_* que limitan cuánta memoria puede usar el título) no se estaban pasando a todas las corridas.

Por qué eso invalida una medida, y no es un detalle: si la corrida A va con un tope y la B sin él, la diferencia de fps entre las dos puede ser el tope y no el cambio. Es el mismo error que un control mal puesto, en una herramienta cuyo único propósito es comparar.

Y docs/measuring_fps.md cambia con él, que es la señal de que el procedimiento documentado también cambia — bien: una herramienta de medida que cambia sin que cambie su documentación deja dos procedimientos en el repositorio.

Lo que verifiqué: los 27 tests del fichero, en su árbol.
Lo que no: una corrida A/B de verdad — necesita el juego, dos compilaciones y una hora; lo que el test cubre es que los parámetros llegan a las dos corridas, que es exactamente la mitad que se puede probar sin jugar.

Y una nota sobre el tiempo: 97 segundos para 27 tests — arranca procesos, como test_docs_cli_flags (34 s para 4) y test_red_green (86 s para 42). Los tres son de las herramientas, no del juego, y son los más lentos por test del repositorio: merece la pena saberlo antes de meterlos en un bucle de CI.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7370994784 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3305#issuecomment-7370994784). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T07:26:12Z. --- ## VERIFY-3305 — 27 tests en verde (97 s), y el cambio es de la herramienta que mide A/B ``` scripts/game-abba.ps1 +23/−… pasa los topes de memoria del portón a cada corrida tests/test_game_abba.py +67/−… 27 passed (97 s) docs/measuring_fps.md +26/−… documenta lo que cambia ``` **Y el título es preciso**: **«pass the gate's memory stops to every gate run»** — **el *gate* es el A/B que compara `main` con una rama, y sus topes de memoria (**los `LEONIDA_*` que limitan cuánta memoria puede usar el título**) no se estaban pasando a todas las corridas.** **Por qué eso invalida una medida, y no es un detalle**: **si la corrida A va con un tope y la B sin él, la diferencia de fps entre las dos puede ser el tope y no el cambio.** **Es el mismo error que un control mal puesto, en una herramienta cuyo único propósito es comparar.** **Y `docs/measuring_fps.md` cambia con él**, **que es la señal de que el procedimiento documentado también cambia** — **bien: una herramienta de medida que cambia sin que cambie su documentación deja dos procedimientos en el repositorio.** **Lo que verifiqué**: **los 27 tests del fichero, en su árbol.** **Lo que no**: **una corrida A/B de verdad** — **necesita el juego, dos compilaciones y una hora; lo que el test cubre es que los parámetros llegan a las dos corridas, que es exactamente la mitad que se puede probar sin jugar.** **Y una nota sobre el tiempo**: **97 segundos para 27 tests** — **arranca procesos, como `test_docs_cli_flags` (34 s para 4) y `test_red_green` (86 s para 42).** **Los tres son de las herramientas, no del juego, y son los más lentos por test del repositorio: merece la pena saberlo antes de meterlos en un bucle de CI.**
lixonik commented 2026-12-03 07:40:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-03T07:40:57Z.


Windows native check (partial -- PowerShell 7 / pwsh tests skipped) on head f1829698c (merged cleanly via git merge --no-ff onto main d9b618f10).

Checks (Windows 10 x64, Python 3.12, Windows PowerShell 5.1)

  • python -I scripts/check_no_game_data.py -> PASS
  • python -I tests/test_game_abba.py -v -> Ran 4 tests in 0.003s / OK (skipped=23) (the 23 PowerShell subtests skipped on this host, so the red control did not exercise the changed PowerShell paths; reporting transparently rather than claiming a red -> green pass).

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7371297021 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3305#issuecomment-7371297021). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-03T07:40:57Z. --- **Windows native check (partial -- PowerShell 7 / `pwsh` tests skipped)** on head `f1829698c` (merged cleanly via `git merge --no-ff` onto `main` `d9b618f10`). ### Checks (Windows 10 x64, Python 3.12, Windows PowerShell 5.1) - `python -I scripts/check_no_game_data.py` -> **PASS** - `python -I tests/test_game_abba.py -v` -> **`Ran 4 tests in 0.003s` / `OK (skipped=23)`** (the 23 PowerShell subtests skipped on this host, so the `red` control did not exercise the changed PowerShell paths; reporting transparently rather than claiming a `red -> green` pass). AI-assisted: yes (Antigravity -- Gemini 4 Neon).
OtavMacedo commented 2026-12-03 08:20:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OtavMacedo on 2026-12-03T08:20:13Z.


@merzleckeier thanks, you're right. Fixed in 7a36c1a87: the preflight now reads the gate's declared parameters with [System.Management.Automation.Language.Parser]::ParseFile(...).ParamBlock.Parameters, as you did, instead of searching the text.

The test's gate now lacks -StopOverBudgetSeconds, but names $StopOverBudgetSeconds in a comment and assigns it as a variable. It must be refused before any run, with runs and the earlier comparison.json unchanged byte for byte.

Red and green on this machine:

  • Previous head f1829698c: that test fails. The runner let it through, and the warm-up's gate refused the parameter (the gate did not start 01-warm-up-A).
  • This head: it passes.
  • Full file: 27 tests pass with PowerShell 7 on Windows 11 (95 s).
  • check_no_game_data.py passes.

On what the gate is (re the VERIFY note): scripts/game-gate.ps1 is one supervised game run with a PASS/FAIL verdict, not an A/B of main against a branch. Its memory stops are its own parameters (-StopPrivateMB, -StopCommitLeftMB, -StopOverBudgetSeconds), not LEONIDA_* settings. Before this PR both arms took the same defaults, so the arms did not differ. The problem was that on a 16 GB PC every measured run failed its gate on those defaults.

In-game use: the ABBA on #3035 (LEONIDA_WINDOWS_BAR_MB 3072 against 0) ran end to end with this runner (first-commit version) and -StopPrivateMB 27000 -StopOverBudgetSeconds 0: 12 gate runs, 1 left out and retried, verdict reached. Numbers on #3035.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7372132388 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3305#issuecomment-7372132388). Originally posted by [OtavMacedo](https://github.com/OtavMacedo) on 2026-12-03T08:20:13Z. --- @merzleckeier thanks, you're right. Fixed in `7a36c1a87`: the preflight now reads the gate's declared parameters with `[System.Management.Automation.Language.Parser]::ParseFile(...).ParamBlock.Parameters`, as you did, instead of searching the text. The test's gate now lacks `-StopOverBudgetSeconds`, but names `$StopOverBudgetSeconds` in a comment and assigns it as a variable. It must be refused before any run, with `runs` and the earlier `comparison.json` unchanged byte for byte. Red and green on this machine: - **Previous head `f1829698c`:** that test fails. The runner let it through, and the warm-up's gate refused the parameter (`the gate did not start 01-warm-up-A`). - **This head:** it passes. - **Full file:** 27 tests pass with PowerShell 7 on Windows 11 (95 s). - `check_no_game_data.py` passes. On what the gate is (re the VERIFY note): `scripts/game-gate.ps1` is one supervised game run with a PASS/FAIL verdict, not an A/B of `main` against a branch. Its memory stops are its own parameters (`-StopPrivateMB`, `-StopCommitLeftMB`, `-StopOverBudgetSeconds`), not `LEONIDA_*` settings. Before this PR both arms took the same defaults, so the arms did not differ. The problem was that on a 16 GB PC every measured run failed its gate on those defaults. In-game use: the ABBA on #3035 (`LEONIDA_WINDOWS_BAR_MB` 3072 against 0) ran end to end with this runner (first-commit version) and `-StopPrivateMB 27000 -StopOverBudgetSeconds 0`: 12 gate runs, 1 left out and retried, verdict reached. Numbers on #3035. AI-assisted (Claude Code, Claude Opus 5.5).
merzleckeier commented 2026-12-03 08:31:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T08:31:36Z.

Review: APPROVED


The preflight issue from my earlier review is resolved in 7a36c1a8, tested on main d9b618f1. I ran five focused cases with synthetic gates and PowerShell 7.7.0 on Linux, enabling those cases in a local test copy. All five passed, including explicit zero and negative stop values, omitted stops, and the dry-run plan.

In the two-checkout control, only B lacked the parameter and its name appeared in a comment. With the new head, the script identified B before either gate ran and preserved the existing comparison byte for byte. Restoring only the previous f1829698 runner let A warm up, removed the previous comparison, and then failed when B rejected the argument. The one-checkout regression also went red on that older runner.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6166150051 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3305#pullrequestreview-6166150051). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T08:31:36Z. **Review:** APPROVED --- The preflight issue from my earlier review is resolved in `7a36c1a8`, tested on `main` `d9b618f1`. I ran five focused cases with synthetic gates and PowerShell 7.7.0 on Linux, enabling those cases in a local test copy. All five passed, including explicit zero and negative stop values, omitted stops, and the dry-run plan. In the two-checkout control, only B lacked the parameter and its name appeared in a comment. With the new head, the script identified B before either gate ran and preserved the existing comparison byte for byte. Restoring only the previous `f1829698` runner let A warm up, removed the previous comparison, and then failed when B rejected the argument. The one-checkout regression also went red on that older runner. AI-assisted with OpenAI Codex.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3305:upstream-pr/3305'
git switch 'upstream-pr/3305'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3305'
git switch 'upstream-pr/3305'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3305'
git switch 'upstream-pr/3305'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3305'
git switch 'main'
git merge --squash 'upstream-pr/3305'
git switch 'main'
git merge --ff-only 'upstream-pr/3305'
git switch 'main'
git merge 'upstream-pr/3305'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!3305
No description provided.