Skip to content

mods: gate_driver takes a run from the menus into the world (D3D12-GATE-DRIVER-MOD) - #2784

Merged
OreoFR merged 2 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-gate-driver-mod
Nov 30, 2026
Merged

OreoFR merged 2 commits into
ProjectLeonida:mainfrom
TheGeogeo:d3d12-gate-driver-mod

Conversation

@TheGeogeo

Copy link
Copy Markdown
Contributor

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

What and why

In-game gates and A/Bs need someone at the keyboard to press through the title's menus, and to say when the player is in control. Without that, a run measures the menus. The testers asked for a run that gets into the world on its own. This adds mods/gate_driver, a Lua mod that does it with the calls the mod API already has (hold_keys, release_keys, player_position, screenshot, frame, time, log).

  • The menus. It presses Enter only once frames have moved on since the last press, every 25 s, until the player's position is known. A start that spends minutes on pipeline compiles does not waste its presses.

  • Control. Holding W for 3 s must move the player at least 1 m and at most 30 m.

    • More than 30 m is the title placing the player itself, during a load or a cutscene. The mod logs GATE PROBE ... placed and tries again without pressing.
    • Less than 1 m means a screen still waits. The mod logs GATE PROBE ... still, presses once more, and tries again.

    The first in-game run showed why the upper bound is needed. Without it, control was "seen" at 54 s, before the world: the load had moved the player 2.6 km in those 3 s.

  • Then. idle (the default) stands still, for measuring. roam walks a fixed loop: W, with short J and L turns (the stand-in pad's right stick).

  • Log lines. GATE PRESS, GATE PROBE, GATE CONTROL t=... moved=... mode=..., GATE MARK ... from_control_m=... every 10 s, GATE SHOT at 10 s and 120 s after control, and GATE FAIL no position|no control after 900 s. They give distances only, never a position.

  • Settings. The mod ships disabled. A run enables a copy in a mods folder of its own (LEONIDA_MODS), with LEONIDA_GAME_ACTIONS=1 for the player's position. An optional gate.txt beside the copy sets mode and any numeric default.

  • Docs. docs/lua-modding.md has a new section, "The gate's driver mod". It also notes that a cutscene can still follow control: the title moves the player kilometres away for it, then puts them back.

The logic is in driver.lua, which takes the calls it uses as an argument, so leonida-lua's tests run it on a stub with a simulated clock. It works with any run that sets LEONIDA_MODS. It does not need #2782 (the game gate), which I used below to run it.

Not in this one: a saved place to start from, routes per scene, and an ABBA runner.

Tested

On Windows 11 Pro 10.0.26300:

  • cargo test -p leonida-lua --locked: 40 passed. 5 tests are new:

    • through the menus, then standing still;
    • roaming;
    • no position and no control, which end in GATE FAIL;
    • a jump of the player, which is not control and gets no press;
    • the mod ships disabled and loads with gate.txt.

    With mods/gate_driver taken away, those 5 fail and the other 35 pass.

  • cargo fmt -p leonida-lua --check shows no difference in the new code. The one difference it reports, in api.rs:413, is already on main. cargo clippy -p leonida-lua --all-targets reports the same 5 errors as on main (input.rs, memory.rs, tests.rs lines 356 and 370), none in the new code.

  • tests/test_docs_repo_paths.py, tests/test_docs_cli_flags.py and tests/test_leonida_mods.py pass. scripts/check_no_game_data.py on the changed files and git diff --check are clean.

  • In game: RTX 3080 10 GB, driver 32.0.16.2140, Series S profile. The leonida.exe diag build (diagnostics, dlss, mimalloc) was run through scripts/game-gate.ps1 (d3d12: an in-game gate: one command, one run folder, one summary.json (D3D12-GAME-GATE) #2782), with a copy of the mod in idle and no key pressed by hand:

    • The mod pressed Enter at 20 s and 45 s.
    • It logged PROBE placed twice (2614.9 m, then 1397.9 m) and PROBE still once (0.0 m), followed by a third press.
    • It logged CONTROL at 69.9 s with moved=7.69.
    • The world started at 81.4 s, then 182 s in the world.
    • The marks read 3622.9 m from 80 s to 120 s, during a cutscene that both screenshots confirm. They then read 0.0 m to the end.
    • Gate verdict PASS: 26.3 fps median, longest gap between presents 0.46 s, exit 0 after a clean stop.

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 (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: no translator change)

…TE-DRIVER-MOD)

A Lua mod for in-game gates and A/Bs: it presses Enter through the title's menus only once frames
have moved on since the last press, shows control by holding W (the player must walk 1 to 30 m in
3 s; more is the title placing the player, which it waits out without a press), then stands still
(idle) or walks a fixed loop (roam). It logs GATE PRESS/PROBE/CONTROL/MARK/SHOT/FAIL lines with
distances only, never a position. It ships disabled; a run enables a copy with LEONIDA_MODS and
needs LEONIDA_GAME_ACTIONS=1 for the player's position.

The logic is in driver.lua and takes the calls it uses as an argument, so leonida-lua's tests run
it on a stub with a simulated clock: menus, control, roam, no position, no control, a jump.
@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR (another owner than TheGeogeo) on macOS 27.2.1, Apple M5, Rust (rustup), Python 3.12.16, main 0f86bd594 merged with head 923dc2674.

  • MEASURED, red (main + only this PR's d3d12/crates/leonida-lua/src/tests.rs, without the mod): cargo test --release -p leonida-lua: 35 passed, 5 failed, the 5 new tests (the_gate_driver_ships_disabled_and_loads_when_enabled, the_gate_driver_presses_through_the_menus_then_stands_still, the_gate_driver_roams_once_in_control, the_gate_driver_fails_without_a_position_or_without_control, a_jump_of_the_player_is_not_control).
  • MEASURED, green (main + this PR, merged): 40 passed, 0 failed.
  • tests/test_docs_*.py: 57 passed, 133 subtests passed. check_no_game_data.py on docs/lua-modding.md and the three mods/gate_driver/ files: clean.
  • Not covered: the mod in a real run (needs the game).

AI-assisted: Claude Code

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

RUN - independent verification (Verified by OreoFR) - RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 Pro 10.0.26300.

  • Base: main 0f86bd594; green = main + this PR at 923dc2674 (git merge --no-ff, clean, merge commit c18e62d79). Head re-checked at the end: still 923dc2674. The newer main d8ca18240 also merges cleanly, and its new commits do not touch leonida-lua, mods/ or docs/lua-modding.md.
  • Red: the same main with only this PR's d3d12/crates/leonida-lua/src/tests.rs, without mods/gate_driver.
  • Command (from d3d12/, one worktree and one target/ per arm): cargo test -p leonida-lua.
Arm passed failed
main 0f86bd594 35 0
red (main + the new tests, no mod) 35 5
green (main + PR) 40 0
  • Red fails the 5 new tests, as the PR says: the_gate_driver_ships_disabled_and_loads_when_enabled, the_gate_driver_presses_through_the_menus_then_stands_still, the_gate_driver_roams_once_in_control, the_gate_driver_fails_without_a_position_or_without_control and a_jump_of_the_player_is_not_control. They panic at tests.rs:1069 (:1199 for the first one), where the mod's files are read. This matches the macOS red/green above, now on native Windows.

In game. A diag leonida.exe of main + PR from build-nvidia.ps1 (diagnostics,mimalloc), run with play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGen -Log, BAR 0 and texture budget 1024. Each run had its own fresh copy of a data folder, starting at the prologue. No keys file was used and no key was pressed by hand. The mod was enabled as documented: a copy in its own folder with "enabled": true and gate.txt (mode = ...), plus LEONIDA_MODS and LEONIDA_GAME_ACTIONS=1. Times are the mod's t=, counted from when it loaded.

run 1: idle, mod only run 2: roam, mod + LEONIDA_GAME_ACTIONS_RUN="340:lift 3" run 3: no LEONIDA_MODS (mod as shipped)
driver cache cold: first start of this exe path; 958 pipelines being made, frames up to 12 s warm warm
menu presses PRESS 1 at 20.0 s and PRESS 2 at 45.0 s PRESS 1 at 20 s and PRESS 2 at 45.0 s none
PROBE placed 2614.9 m at 50.4 s and 1397.9 m at 53.4 s; still 0.0 m at 63.6 s; placed 3622.8 m at 84.7 s; then still 0.0 m 65 more times, to 421.7 s placed 2614.9 m at 49.8 s and 1397.9 m at 52.9 s none
CONTROL never (run stopped at 422 s; 70 presses in all) 60.1 s, moved=7.70 none
into the world about 64 s about 60 s title screen only; Lua mods ... mods=2 running=0
MARK from_control_m none 3622.9 m from 70 to 120 s (cutscene), 0.0 m from 130 to 331 s with W held, then 3.5 m at 341 s, 96.0 m at 411 s and 96.6 m to the end (521 s) none
SHOT none 2 taken, at 70 s and 180 s none
FAIL none (the run ended before 900 s) none none
time in world, fps median 360 s, 14.2 fps (p5 0.1, cold) 478 s, 22.5 fps (p5 17.2) n/a
device lost / panic 0 / 0 0 / 0 0 / 0
alive at end yes, closed by the script yes, closed by the script yes
  • What works:
    • the mod loads only when enabled;
    • it presses through the menus by itself;
    • it rejects the title's own moves of the player (placed, the same 2614.9 m and 1397.9 m as in your run);
    • run 2 logged CONTROL at 60.1 s with 7.70 m (you had 7.69 m at 69.9 s);
    • MARK every 10 s and both screenshots work;
    • roam walks once the player can move: 0 to 96.6 m after lift 3, then stuck at a wall from 421 s.
  • Finding 1: a CONTROL can come before a cutscene that leaves the player frozen. In run 2, CONTROL came before the 3622.9 m cutscene. After it, with roam holding W, the player did not move from 130 s to 331 s (0.0 m, the prologue cell, confirmed by a screenshot). They only moved after the game action lift 3 at 340 s. In idle, the "0.0 m to the end" of your run cannot tell standing still from being frozen. So on this start, CONTROL does not yet mean the player is free for the rest of the run.
  • Finding 2: run 1 never reached CONTROL. With the cold driver cache, frames took seconds, so the probe at 63.6 s saw 0.0 m. The cutscene came next, and after it the frozen player gave still every probe. On this start it would have ended in GATE FAIL no control at 900 s.
  • Finding 3: the still path presses Enter every ~3 s. After a still probe, driver.lua calls press() directly, then goes back to menus, which probes at once because the position is known. So neither press_every (25 s) nor the check that frames moved on since the last press applies. Run 1 sent 68 Enter presses in 6 min with the player in the world (presses 3 to 70, 63.6 s to 421.7 s). Nothing bad came of it here, but on another screen those presses could choose things. A press_every gap for that path, or a cap on the presses, would keep it to what the PR describes.

Safe to merge into main? Yes.

  1. Clean merge: yes. git merge-tree --write-tree gives no conflict on 0f86bd594 or on d8ca18240.
  2. CI: yes. All 5 jobs pass on 923dc2674: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests.
  3. Disabled by default: yes.
    • From the diff: mod.json has "enabled": false, and nothing outside mods/gate_driver loads main.lua.
    • In game: run 3 started main + PR with the repository's own mods folder. It logged Lua mods ... mods=2 running=0, showed no GATE line, and stayed at the title screen.
  4. Repository checks on the merged tree: yes.
    • check_no_game_data.py on the 5 changed files: clean.
    • test_docs_cli_flags, test_docs_repo_paths, test_docs_design_rows and test_leonida_mods: all OK.
    • cargo test -p leonida-lua: 40/40.
  5. Scope: yes. The diff touches mods/gate_driver/* (new), leonida-lua/src/tests.rs (tests only) and docs/lua-modding.md. No runtime code changes. The shipped build does not run the mod unless someone enables a copy.

The 3 findings concern what CONTROL means on a prologue start and how often Enter is pressed. They matter for using the mod as a gate, not for merge safety. They can be a follow-up.

Verdict:

  • CPU red/green and merge safety: PASS.
  • In game: PARTIAL (PROVISIONAL, one PC, n=2 mod runs).
    • Through the menus and into the world without a person: yes, both runs.
    • CONTROL: logged in 1 of 2 runs, and that one came before the cutscene that leaves the player frozen until lift.

Not covered:

  • A start from a save past the prologue, where control after the cutscene may be real.
  • A full 900 s run to see GATE FAIL no control logged in game.
  • idle with a warm driver cache.
  • DLSS, frame generation, Series X and other cards.

This run was AI-assisted (Claude Code, oreofr-agent).

… no move (review)

A probe that showed no move pressed Enter at once, and the menus then probed again at once: Enter came
every 3 to 5 s (68 times in 6 min on a cold cache), with no press_every and no check that frames had
moved on. It now asks the menus for one press at their pace, and a probe waits for Enter to be up.
The docs say what idle cannot tell (a held player) and what a cold cache does to CONTROL.
@TheGeogeo

Copy link
Copy Markdown
Contributor Author

Thanks for the in-game check. Point 3 was a real bug, fixed in 8b79ed2:

  • Point 3. A probe that showed no move pressed Enter at once, and the menus then probed again at once. That is why Enter came every 3 to 5 s, with no press_every and no check that frames had moved on. Now it asks the menus for one press at their pace, and a probe waits for Enter to be up. A new assertion in the_gate_driver_fails_without_a_position_or_without_control (presses at least 25 s apart, at most 9 in 200 s) fails with the old driver.lua (tests.rs:1177) and passes with the new one. cargo test -p leonida-lua --locked: 40 passed.
  • Points 1 and 2. idle cannot tell a held player from one standing still, and with a cold cache CONTROL can come late or never. These are limits rather than code bugs: docs/lua-modding.md now says both, and points to roam for the first.

Docs and test_leonida_mods.py tests pass, and the merge with current main is clean. An in-game run on this head follows.

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Re-checked by OreoFR on the new head 8b79ed272 merged with main d8ca18240 (macOS 27.2.1, Apple M5): cargo test --release -p leonida-lua 40 passed. Red for the fix: the same merged tree with mods/gate_driver/driver.lua from 923dc2674 gives 39 passed, 1 failed (the_gate_driver_fails_without_a_position_or_without_control), so the new assertion catches the old repeated Enter. tests/test_docs_*.py 57 passed; check_no_game_data.py on docs/lua-modding.md and driver.lua: clean. Not covered: the mod in a real run.

AI-assisted: Claude Code

@fiestorra

Copy link
Copy Markdown
Contributor

I cannot run this one, so this is triage rather than verification - posted so nobody reads silence as coverage.

What is not available here: no cargo and no lua on this machine, so neither the Rust test in leonida-lua/src/tests.rs nor the mod itself can be executed by me. The d3d12/ crates are Rust-only in this repo, and the AGENTS file for this machine says the same.

What I could check, by reading:

  • The diff touches no runtime code. Five files: mods/gate_driver/driver.lua, main.lua, mod.json (data), docs/lua-modding.md, and d3d12/crates/leonida-lua/src/tests.rs. +412/-0, and not one line under runtime/.
  • The configuration parsing in main.lua is whitelisted, which is the part that could have been wrong: mode is accepted only as idle or roam, and a numeric setting is accepted only if driver.defaults[key] is itself a number (main.lua:12-16). A malformed gate.txt therefore cannot set an arbitrary global - it is read, matched, and dropped. That is the right shape for a file a user edits.
  • driver.lua takes its API as an injected table (time, frame, position, hold, release, shot, log), so the semantics it depends on are all in one place - and the test can substitute a fake, which is what tests.rs does.

What a reviewer with cargo should run, if that is useful: cargo test -p leonida-lua, since the new tests are in that crate's tests.rs and the mod's own behaviour is what they drive. The gate tests elsewhere in this PR's family (#2782, #2786) I did run.

What I would look at in the docs: docs/lua-modding.md gains 33 lines that describe this mod as the example. If the API it documents is what driver.lua actually calls, that section works as the reference; if it drifts, it is the kind of doc that teaches the wrong shape. I read both and they match, for what that is worth without an interpreter.

AI-assisted: yes - DeepSeek v4.1 (flash), reading only, no execution claimed.

Written with an AI assistant.

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

RUN - re-check on the new head 8b79ed272 (Verified by OreoFR): native Windows, Core Ultra 7 155H, rustc 1.98.1.

  • The new commit changes only mods/gate_driver/driver.lua, its test in tests.rs and docs/lua-modding.md. It addresses my third remark: presses now keep the menus' pace after a probe that shows no move.
  • Merged into current main d8ca18240, the merge is clean, and cargo test -p leonida-lua gives 40 passed, 0 failed.
  • CI on 8b79ed272: 2 checks pass and 3 are still running at the time of writing.
  • The in-game runs from my previous comment were on 923dc2674. I have not repeated them on this head. The change only touches the mod's press timing, and the mod stays disabled by default.
  • Safe to merge into main: yes, once the pending CI is green. The other two remarks (CONTROL before a freezing cutscene, and no CONTROL on a cold driver cache) are about using the mod as a gate. They do not block the merge.

AI-assisted (Claude Code, oreofr-agent).

@TheGeogeo

Copy link
Copy Markdown
Contributor Author

In-game run on 8b79ed2: RTX 3080 10 GB, driver 32.0.16.2140, Series S profile, a copy of the mod in idle, no key pressed by hand.

  • PRESS at 20 s and 45 s, then PROBE placed twice (2614.9 m, 1397.9 m), with no press.
  • CONTROL at 66.3 s, moved=7.65. The world started at 83.3 s, then 186 s in the world.
  • The marks read 3622.9 m during the cutscene, then 0.0 m.
  • Both screenshots went to LEONIDA_SCREENSHOTS.
  • Gate verdict: PASS, 26.6 fps median, longest gap between presents 0.34 s, exit 0 after a clean stop.

@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

RUN - re-check on 8b79ed272 (Verified by OreoFR) - RTX 4070 Laptop 8 GB, NVIDIA 621.40; main d8ca18240 + this PR (clean merge), diag build, same recipe as my run above (SeriesS, no DLSS/FG, warm cache, no keys file).

  • idle, 420 s: 17 Enter presses, every 25.0-25.1 s after the first still probe (old head 923dc2674: 70 presses, every 3-5 s). The press spam is fixed. No CONTROL: the player stays frozen in the prologue cell, as before.
  • roam + 340:lift 3, 480 s: 2 presses (20.0 s, 55.9 s), CONTROL at 59.5 s, moved=7.70, then 0.0 m from 120 to 330 s with W held, and 50.4 m after lift (stopped at a wall).
  • Stability: in the world at ~58 s in both runs; 0 device lost, 0 panics, alive at the end; 25.4 / 25.0 fps median.
  • Safe to merge into main: yes. Clean merge, CI 5/5, disabled by default, mod/tests/doc only, and the press pacing now matches press_every in game. Findings 1-2 (CONTROL before the freezing cutscene) remain follow-ups for gate use, not merge blockers.

This run was AI-assisted (Claude Code, oreofr-agent).

@OreoFR
OreoFR merged commit 407f71a into ProjectLeonida:main Nov 30, 2026
5 checks passed
@OreoFR

OreoFR commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Merged by OreoFR (maintainer) on head 8b79ed272, into main 0b6e0e3bc. The last main CI on that commit was green: CI, Runtime, No Game Data and Needs rebase label all passed.

Tested before merging:

AI-assisted (Claude Code, oreofr-agent).

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.

3 participants