Skip to content

d3d12: an in-game gate: one command, one run folder, one summary.json (D3D12-GAME-GATE) - #2782

Merged
MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-game-gate
Nov 30, 2026
Merged

MoonEyes merged 4 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-game-gate

Conversation

@TheGeogeo

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: D3D12-GAME-GATE (#2570 (comment))

What and why

In-game gates and A/Bs were run by hand on five machines (MoonEyes, OreoFR, enlighted, DadaCap, mine), each with its own launcher wrapper and log parsers. Runs were lost to agent consoles and to key files read while written. The precompile lines were never kept. Verdicts were written in free text.

This adds one command and one result format. The format was circulated on the bridge as a draft first, and the testers' answers are folded in.

  • scripts/game-gate.ps1 run|start|stop runs leonida.exe through this checkout's scripts/play-d3d12.ps1, so a run is what players run, and writes one folder per run under -RunRoot:
    • run.json, launch.ps1, the -DryRun settings, and the F1 settings file when there is one;
    • launcher.txt, the precompile lines;
    • leonida.log, the runtime's log with one line per present;
    • events.jsonl, what the gate did and saw;
    • data\, a copy of the tester's data template, so their own saves are never touched;
    • summary.json.
  • It refuses to run in three cases:
    • a run root inside a checkout;
    • a run already going;
    • a missing exe, which the play script would build inside the timed run.
  • It stops the game with WM_SYSCOMMAND/SC_CLOSE once -WorldSeconds (300) were spent in the world, on a STOP file (stop), or after -MaxMinutes. That is the runtime's own end: the title is suspended and the pipeline cache saved. A plain WM_CLOSE does not end the title. It kills the game only 60 s later.
  • It keeps the game's real exit code: 0x887A0005 means the device was lost.
  • start runs the same thing detached, created through CIM, so the end of an agent's or a console's job does not end the run. A supervisor.log keeps its output.
  • tools/game_gate.py (standard library) turns the folder into summary.json (leonida-gate-summary/1, described in docs/game_gate.md). It has:
    • build, card, driver, settings (from the run's settings line, d3d12: a run logs the LEONIDA_ settings it starts with (D3D12-RUN-SETTINGS-LINE) #2775, so no paths), precompile counts;
    • the time to the world: two frame lines with 500 draws or more; cutscenes count;
    • when the pipeline cache went warm: 60 s with nothing being made and no wait run out;
    • fps from the presents: median, p5, frame p95, the end median, the first second under 2 frames, the longest gap with no frame;
    • crashes by kind: device lost (also an out-of-memory command list that did not close), panic, or fault by module kind, never names or addresses;
    • exit, stop and the verdict.
  • PASS needs all of these:
    • 300 s in the world;
    • no device loss, panic, or fault before the stop;
    • no gap over 10 s without a presented frame, so a run frozen on pipeline compiles does not pass (DadaCap's case);
    • the game alive at the stop.
  • ERROR covers a STOP file before the time, menus only at the time limit, and a relaunch.

Not in this one: a Lua driver for the menus, an ABBA runner, a time series, VRAM peaks, a "memory rising" warning, and the Vulkan runtime.

Tested

On Windows 11 Pro 10.0.26300:

  • tests/test_game_gate.py, 20 tests, all passing:

    • the parser on synthetic run folders, which the tests write in the runtime's formats with no game data: PASS, device loss by exit code and by report, out-of-memory list close, panic with the title alive, menus only, STOP before the time, too little world time, frozen on compiles, dying before the stop, warm cache with dropped draws, percentiles, frame-line fallback, ANSI colour, title watchdog, settings and precompile lines, no path in the summary;
    • a contract test: every runtime string the parser reads is still in the source;
    • a script check: no variable reuses a parameter's name in another case. That PowerShell trap turned the game process into a string here during validation.

    They run in the standard-library CI loop.

  • test_docs_design_rows.py, test_ci_registration.py, check_no_game_data.py and git diff --check are clean.

  • In game, RTX 3080 10 GB, driver 32.0.16.2140, Series S profile, main 8f41d7d:

    • R0, the first start after the translator change. Precompile: 74 s translating, 3,049 pipelines warmed in 334 s. The world came at 504 s. Verdict FAIL present_gap (11.4 s without a frame during the compile storm), as intended for a cold run. This run found the variable trap, which is now fixed and tested.
    • R1, warm, detached start, 300 s target: world at 85 s, 304 s in the world. Stopped with SC_CLOSE: exit 0 in 6 s, cache saved, title suspended. 26.9 fps median, p5 22.9, longest gap 0.39 s, no crash. PASS.
    • R2, warm, stopped with stop 35 s into the world: ERROR stopped_early, with a clean stop (exit 0, cache saved).

GPUs tested: NVIDIA GeForce RTX 3080 10 GB, driver 32.0.16.2140, Windows 11 Pro 10.0.26300.

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly.
  • 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. The data template and the run folders stay outside the checkout. The summary holds numbers and switch names only.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator change.)

… (D3D12-GAME-GATE)

Testers ran in-game gates and A/Bs by hand on five machines, each with
their own launcher wrapper and log parsers, and lost runs to consoles and
key files. scripts/game-gate.ps1 runs leonida.exe through the checkout's
play-d3d12.ps1 and writes one folder per run: run.json, launch.ps1, the
-DryRun settings, the F1 settings file, the launcher's output (the
precompile lines nobody kept), the runtime's log, events.jsonl and a copy
of the tester's data template (their own saves are never touched). It
stops the game with WM_SYSCOMMAND/SC_CLOSE (the runtime's own end: suspend,
pipeline cache saved) once -WorldSeconds were spent in the world, on a
STOP file or after -MaxMinutes, and kills it only 60 s later; it keeps the
game's exit code. `start` runs the same detached (created through CIM, so
an agent's or console's end does not end it); `stop` asks a run to end.

tools/game_gate.py (standard library) reads the folder into
summary.json (leonida-gate-summary/1): build, card, settings (the run's
settings line, no paths), precompile counts, time to the world (two frame
lines with 500 draws or more, cutscenes included), when the pipeline
cache went warm (60 s with nothing being made), fps from the presents
(median, p5, frame p95, end median, the first second under 2 frames, the
longest gap with no frame), crashes by kind (device lost, panic, fault by
module kind), exit, stop and a verdict: PASS needs 300 s in the world,
no device loss, panic or fault, no gap over 10 s, alive at the stop. The
testers' answers to a draft on the bridge are folded in. Its tests use
synthetic logs and check that the runtime still writes what it reads.
@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12.16, main 51dbc5b58 merged with head b535fb0dc.

  • MEASURED, green: tests/test_game_gate.py 20 passed; python -I tests/test_game_gate.py OK. Red (main + only the test): 1 error at import, as expected for a new tool.
  • python -I scripts/check_no_game_data.py on tools/game_gate.py, tests/test_game_gate.py, docs/game_gate.md: clean.
  • MEASURED, one docs test fails with this PR (passes on main: tests/test_docs_*.py 57 passed there): tests/test_docs_cli_flags.py::DocsCliFlags::test_fenced_commands_use_the_flags_of_their_tool, ('docs/game_gate.md:19', 'scripts/game-gate.ps1', '-NoFrameGen'). Line 19 shows -PlayArgs '-SeriesS -NoFrameGen': those are the game's flags inside a string, but the checker reads -NoFrameGen as a flag of game-gate.ps1, which has no such parameter. The check job should hit the same failure. Possible fixes: show the game flags outside the fenced command (in the prose or a separate block), or a placeholder such as -PlayArgs '<game flags>'.
  • Not covered: scripts/game-gate.ps1 itself (needs PowerShell and the game).

AI-assisted: Claude Code

…wn (review)

test_docs_cli_flags read the -SeriesS -NoFrameGen inside -PlayArgs '...'
in the fenced command as flags of game-gate.ps1. The block now shows a
placeholder, and the text gives the example.
@TheGeogeo

Copy link
Copy Markdown
Contributor Author

Thanks, OreoFR. Confirmed and fixed in the new head of this pull request.

tests/test_docs_cli_flags.py read the -SeriesS -NoFrameGen inside -PlayArgs '...' in the fenced command of docs/game_gate.md as flags of game-gate.ps1. The block now shows -PlayArgs '<play-d3d12.ps1 switches>', and the text gives -SeriesS -NoFrameGen as the example.

test_docs_cli_flags.py, test_game_gate.py (20) and test_docs_design_rows.py pass. Only docs/game_gate.md changed.

TheGeogeo added a commit to TheGeogeo/leonida that referenced this pull request Nov 30, 2026
test_docs_repo_paths failed: docs/measuring_fps.md named scripts/game-gate.ps1, which only ProjectLeonida#2782 adds.
Name the game gate's run folders instead, here and in the tool's docstring.
@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Re-checked by OreoFR on the new head 22e096e47 merged with main 0f86bd594 (macOS 27.2.1, Apple M5, Python 3.12.16): tests/test_game_gate.py 20 passed; tests/test_docs_*.py 57 passed, 134 subtests passed (the test_docs_cli_flags failure is gone); check_no_game_data.py on the three changed files: clean. scripts/game-gate.ps1 itself is not covered here (needs PowerShell and the game).

AI-assisted: Claude Code

tests/test_tool_stdout_encoding.py (on main since this branch started) wants every tool's __main__
block to do it: under -I a redirected stdout is strict in the console's code page.
@TheGeogeo

Copy link
Copy Markdown
Contributor Author

CI check and linux-python-and-viewer failed on tests/test_tool_stdout_encoding.py: tools/game_gate.py's __main__ block did not set errors="replace" on stdout (that test came to main after this branch). Fixed in be96bda with the same guard as tools/d3d12_run_fps.py. On Windows: test_tool_stdout_encoding.py OK, test_game_gate.py 20 OK, merge with current main clean.

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Re-checked by OreoFR on the new head be96bdade merged with main d8ca18240 (macOS 27.2.1, Apple M5, Python 3.12.16): tests/test_game_gate.py 20 passed; tests/test_tool_stdout_encoding.py 4 passed (the new stdout guard); tests/test_docs_*.py 57 passed.

AI-assisted: Claude Code

@fiestorra

Copy link
Copy Markdown
Contributor

Verified on Windows, and one thing the suite cannot currently tell apart: replacing statistics.median() with max() in parse_frames leaves all 20 tests passing.

What was run, at d60df1525 cherry-picked onto main d8ca18240 in a clean worktree, Python 3.13.14:

python -m pytest tests/test_game_gate.py -q      20 passed in 2.24s

Control, compile level: with tools/game_gate.py removed the suite does not collect (ImportError on the test module), so the tests are bound to the tool.

Control, behaviour level, and this is the finding:

out["median"] = round(1000.0 / max(counted), 2)     # was statistics.median(counted)
out["median"] = round(max(rates), 2)                # was statistics.median(rates)
python -m pytest tests/test_game_gate.py -q      20 passed in 2.08s

Why it passes: every case writes frames at one constant rate, so for each fixture median == max == mean. assertEqual(s["fps"]["median"], 50.0) is satisfied by any of the three, and median (L291, L311) is therefore not tested as a median.

The smallest change that closes it: one case with a varying rate - say alternating 40 and 60 fps, or an even number of 40s and 60s - asserting median == 50 while the maximum is 60. That single case makes the mutation above fail, and it is the case a real run produces anyway, since a title does not hold one frame rate.

The other numbers I checked are not affected - world_at_s == 70.0, fps.source == "presents", the exit code, cache_saved and crash.kind all moved when I mutated what feeds them, so the gap is specific to the rate statistics.

Two things I could not test here: the game-gate.ps1 launcher (it drives a real run folder and this is not the machine for it) and anything that needs game data - both are outside the no-game-data boundary this suite is built for.

AI-assisted: yes - DeepSeek v4.1 (flash). The mutation is the point of the comment, not a verdict on the PR: the tool and its 20 passing tests are a solid addition.

Written with an AI assistant.

@enlight3d

Copy link
Copy Markdown
Contributor

RUN (independent run on Windows, #2782 head be96bda, tested as it is; it merges cleanly into main d8ca182 per git merge-tree --write-tree. CI on be96bda: change-scope, check, linux-gpu-tools, linux-python-and-viewer, no-game-data, semantic-tests and windows pass; wine skipped. Since b535fb0, the first head I tested, only docs/game_gate.md (one line) and the stdout guard in tools/game_gate.py's __main__ block (4 lines) changed; scripts/game-gate.ps1 is identical.)

Commands, from the repository root, python -I (Python 3.13.12), at low priority:

  • python -I -m unittest discover -s tests -p test_game_gate.py on be96bda: 20 tests OK (the synthetic logs, plus the contract test that the runtime still writes the lines the parser reads).
  • python -I -m unittest discover -s tests -p test_tool_stdout_encoding.py on be96bda: 4 tests OK.
  • Red, import: on main with only the PR's test file added, the module does not import (ImportError, no game_gate).
  • Red, behavioural, one mutant per PASS/FAIL rule, with the tests kept (on b535fb0; the gap mutant again on be96bda). Each one fails tests:
    • present gap checked against 1000 x GAP_FAIL_S: test_a_run_frozen_on_a_compile_fails_though_alive fails;
    • world time never short (world_s < 0): test_too_little_world_time_at_the_time_limit_fails and test_a_stop_file_before_the_world_time_is_an_error fail;
    • device loss not a failure: test_a_lost_device_fails_by_its_exit_code_and_its_report and test_an_out_of_memory_list_close_counts_as_a_lost_device fail;
    • panic not a failure: test_a_panic_fails_even_with_the_title_alive fails;
    • exit before the stop not a failure: test_dying_before_the_stop_fails fails.
  • scripts/game-gate.ps1 parses with no error in Windows PowerShell 5.1 and in PowerShell 7 ([System.Management.Automation.Language.Parser]::ParseFile).
  • Neighbours, since docs/README.md changes: test_i18n_index.py 9 OK and test_docs_design_rows.py 5 OK.

In-game run on the RTX 3090: #2613's gate (head c6a8f71) run with scripts/game-gate.ps1 -WorldSeconds 600 -MaxMinutes 20, -SeriesS -NoDlss -NoFrameGen, Enter through a keys file until the world. The tool gave PASS, no device loss, no crash, exit 0x0 'clean', stopped by the window close (no kill, cache saved), save copied into the run folder. Against my own sampler on the same run: seconds in the world 607.9 vs 608; device loss, crash and exit code agree; fps median 11.2 (tool, presents after world+60 s) vs 10.1 (runtime fps lines from the world on), consistent given the different bases. (That run used 22e096e; game-gate.ps1 is the same there, and game_gate.py differs only by the 4-line stdout guard.)

Review notes (not blocking):

  1. run.json said dirty: false while two untracked files had been copied into the worktree. The script uses git status --porcelain --untracked-files=no (game-gate.ps1 line 122), so untracked files are left out on purpose or by accident. Worth a word in docs/game_gate.md, or a separate field.
  2. world_at_s counts from the start of the run, precompile included: 347 s in that run, about 276 s of it precompile. So it is not the game's own time to the world. Worth documenting, or a second field from the game's start.
  3. under_2_at_s came out at 356 s, 9 s after arrival, on a loading dip. The scan starts at the second the world is reached (fps_block, from int(world)), not at warm_at_s or at world+60 s like the median. Counting it from warm_at_s would say more. The longest present gap is also measured from the world on, so a long load hitch right after arrival can fail a run on present_gap.
  4. No VRAM figures and no REAPING lines in the summary, as we said before.

Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.

…d (review)

run.json's dirty leaves untracked files out; a new untracked count says how many there are. The first
second under 2 frames counted from the world's first second, so the arrival's streaming dip was the
run's; it now counts from 60 s in the world, like the median. The longest gap with no frame stays
from the world on: a freeze on pipeline compiles comes right after arrival. The docs say both, and
that world_at_s counts from the gate's start, the precompile included.
@TheGeogeo

Copy link
Copy Markdown
Contributor Author

Thanks for the run and the mutants. The four notes, in 46ea666:

  1. Untracked files. dirty stays "a tracked file changed". run.json and the summary now carry untracked, the number of files git does not track. docs/game_gate.md says both.
  2. world_at_s. It counts from the gate's start, like every time in the summary, so the precompile is in it. The docs say so now, and give the precompile's own seconds (precompile.shaders_s, precompile.made_s). I did not add a derived field: the two bases are already there.
  3. under_2_at_s. It now counts from 60 s in the world, the base the median already uses, so an arrival dip is no longer the run's. New test test_a_dip_on_arrival_is_not_the_first_second_under_2: it fails with the previous game_gate.py (it found 70 s) and passes now (300 s).
    The longest gap between presents stays measured from the world on, on purpose. A freeze on pipeline compiles comes right after arrival (DadaCap's case), and 10 s with no frame is what a player sees. The docs give that reason.
  4. VRAM and REAPING. These stay out of this PR, as agreed.

On Windows: test_game_gate.py 21 OK (with the previous game_gate.py, the two changed tests fail). The docs tests and test_tool_stdout_encoding.py pass. check_no_game_data.py is clean, the script parses in PowerShell 7, and the merge with current main is clean.

@MoonEyes

Copy link
Copy Markdown
Collaborator

Verified by MoonEyes (another person than the author) on head 46ea66693 merged with main d8ca18240: Windows 11, Python 3.14. tests/test_game_gate.py OK. Docs and test_tool_stdout_encoding OK. Red: the test does not import without the new tool. No game run from me (#2782 was run by enlight3d on an RTX 3090).

AI-assisted (Claude Code).

@ecox982745

Copy link
Copy Markdown
Contributor

Native Windows CLI handoff check with the merged A/B comparator from #2783. Tested 46ea66693 merged onto a596adfac (tree b7cc594c8). I generated synthetic gate logs with menu and world presents, real timestamp parsing, and a known 5 ms B improvement plus 0.5 ms of drift per run. The Windows paths contained spaces, an apostrophe, and an ampersand.

game_gate.py summary wrote all ten summaries. d3d12_ab_compare.py abba consumed them directly. It used the four balanced pairs, excluded the pair containing the device-loss fixture, and reported B faster, −4.999 ms, with a 95% interval of −5.913 to −4.085 ms. The discarded run was labeled gate FAIL. All 21 game-gate tests and 13 comparator tests also passed.

Synthetic logs only. This verifies the handoff and comparison arithmetic. AI-assisted with OpenAI Codex (GPT-6.2 Sol).

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Re-checked by OreoFR on the new head 46ea66693 merged with main a596adfac (macOS 27.2.1, Apple M5, Python 3.12.16): tests/test_game_gate.py 21 passed; tests/test_tool_stdout_encoding.py 4 passed; tests/test_docs_*.py 57 passed.

AI-assisted: Claude Code

@MoonEyes

Copy link
Copy Markdown
Collaborator

Merging. Head 46ea66693 merges cleanly with main a596adfac and does not force a rebase of #2566. CI is green on this head. Checked on it by OreoFR (macOS), ecox982745 and me (Windows); the notes of enlight3d's RTX 3090 run are addressed in this head. Tooling, tests and docs only. Merged by MoonEyes.

AI-assisted (Claude Code).

@MoonEyes
MoonEyes merged commit 0b6e0e3 into ProjectLeonida:main Nov 30, 2026
8 checks passed
@enlight3d

Copy link
Copy Markdown
Contributor

Follow-up on #2782 head 46ea666, after my RUN on be96bda. It merges cleanly into main 407f71a. CI on 46ea666: all checks pass (wine skipped).

The delta be96bda..46ea666 is one commit, and only the review points:

  • run.json gets an untracked count (git status --porcelain --untracked-files=normal, the ?? lines) beside dirty, and summary.json carries it.
  • under_2_at_s is now scanned from 60 s in the world, like the median (second = int(begin) instead of int(world)), with a new test.
  • docs/game_gate.md documents world_at_s and the rest.
  • The longest present gap is still measured from the arrival, on purpose. Nothing else changes.

Commands, from the repository root, python -I (Python 3.13.12), at low priority:

  • python -I -m unittest discover -s tests -p test_game_gate.py on 46ea666: 21 tests OK.
  • Red, by assertion: with be96bda's tools/game_gate.py and the new tests, 2 tests fail. test_a_dip_on_arrival_is_not_the_first_second_under_2 gets 70.0 for 300.0: the old scan stops on the arrival dip. test_a_clean_run_in_the_world_passes fails with KeyError: 'untracked'. With 46ea666's tool, both pass.
  • python -I -m unittest discover -s tests -p test_tool_stdout_encoding.py: 4 tests OK.
  • scripts/game-gate.ps1 parses with no error in Windows PowerShell 5.1 and in PowerShell 7.

Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants