windows-boot: state-relative input presses (BOOT-INPUT-STATE-RELATIVE) #1917

Closed
leonida/mandy
BubsMcgee wants to merge 0 commits from boot-input-state into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

BubsMcgee commented 2026-11-25 15:47:20 +00:00

Claimed in the coordination issue as: BOOT-INPUT-STATE-RELATIVE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7166666931). No dependencies; this is the harness side and reads keys through the keyboard pad (GetAsyncKeyState), so #1790's focus mode is orthogonal.

Fixes: #1900

What and why

-InputScript was absolute-time only (a@45,a@60,...). The title reaches the same states at different times from run to run, so the same script lands presses in different game states; in A/B runs an A at 75/90 s can advance in one build and back out to the menu (session d -> 0) in another, changing presents, PSO counts and the path being compared.

This adds button@game=<hex>+<delay> / button@session=<hex>+<delay>: the harness watches the existing LEONIDA_PEEK values (0x7446510 game, low dword of 0x98f828c session) and injects the key once that state has been seen for the delay. Absolute entries still go to the runtime unchanged.

Files

  • tools/boot_input_script.py: parse and due matcher (stdlib only).
  • scripts/windows-boot/boot.ps1: split the script, watch the log, inject through the keyboard pad (SendInput, LEONIDA_KEYBOARD_PAD=always; no focus needed), and read the log in the digest with a share that tolerates the redirect handle.
  • scripts/windows-boot/README.md and --help: the new form and an example.
  • tests/test_boot_input_script.py: synthetic parse/due cases.

Tested

  • python -I tests/test_boot_input_script.py: 12/12.
  • python -I scripts/check_no_game_data.py on the changed files: OK.
  • -DryRun with a@session=3+5,a@session=d+5: absolute='' state=2.
  • 200 s boot on RTX 3080 Ti / Windows 11 / NVIDIA 616.64 with a@session=3+5,a@session=d+5: the harness injected a at session=3 (55.8 s) and session=d (70.9 s); the keyboard pad logged press a@54.9/69.0/69.9; -DigestOnly reads states session=3 @55 s, session=d @70 s, and the known world-start device loss (lib_cs_03426...).

AI-assisted.

Claimed in the coordination issue as: BOOT-INPUT-STATE-RELATIVE (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7166666931). No dependencies; this is the harness side and reads keys through the keyboard pad (`GetAsyncKeyState`), so #1790's focus mode is orthogonal. Fixes: #1900 ### What and why `-InputScript` was absolute-time only (`a@45,a@60,...`). The title reaches the same states at different times from run to run, so the same script lands presses in different game states; in A/B runs an A at 75/90 s can advance in one build and back out to the menu (`session d -> 0`) in another, changing presents, PSO counts and the path being compared. This adds `button@game=<hex>+<delay>` / `button@session=<hex>+<delay>`: the harness watches the existing `LEONIDA_PEEK` values (`0x7446510` game, low dword of `0x98f828c` session) and injects the key once that state has been seen for the delay. Absolute entries still go to the runtime unchanged. ### Files - `tools/boot_input_script.py`: parse and due matcher (stdlib only). - `scripts/windows-boot/boot.ps1`: split the script, watch the log, inject through the keyboard pad (`SendInput`, `LEONIDA_KEYBOARD_PAD=always`; no focus needed), and read the log in the digest with a share that tolerates the redirect handle. - `scripts/windows-boot/README.md` and `--help`: the new form and an example. - `tests/test_boot_input_script.py`: synthetic parse/due cases. ### Tested - `python -I tests/test_boot_input_script.py`: 12/12. - `python -I scripts/check_no_game_data.py` on the changed files: OK. - `-DryRun` with `a@session=3+5,a@session=d+5`: `absolute='' state=2`. - 200 s boot on RTX 3080 Ti / Windows 11 / NVIDIA 616.64 with `a@session=3+5,a@session=d+5`: the harness injected `a` at session=3 (55.8 s) and session=d (70.9 s); the keyboard pad logged `press a@54.9/69.0/69.9`; `-DigestOnly` reads states `session=3 @55 s`, `session=d @70 s`, and the known world-start device loss (`lib_cs_03426...`). AI-assisted.
lixonik reviewed 2026-11-25 19:28:00 +00:00
lixonik left a comment
No description provided.
Independent Windows check at `34da84a13`: the 12 Python tests pass. Synthetic state transitions and two PowerShell 5.1 dry runs reproduce the timing and plan-file issues below. No game process was launched and no system input was sent. AI-assisted. **`scripts/windows-boot/boot.ps1` line 438:** > [P2] Start the delay when the observed value changes > > The timer is set on the first report for the field and is never reset if its value changes. With a synthetic first report of session `0` at t=0 and the first `d` at t=10, the watcher code supplies `seen-session=0` and `button@session=d+5` is due immediately. It should first be eligible at t=15. Track the current value and its entry time for both fields, and add a transition case to the tests. **`scripts/windows-boot/boot.ps1` line 235:** > [P2] Keep the input plan local to the run > > This path is keyed only by `-Name` and is written before the `-DryRun` exit and before the run lock. Two dry runs using different output directories and the same name created and then replaced the same temporary plan. The second run can also replace a live run's plan, since the watcher opens it on each poll. Keep the plan in memory or use a unique per-run file written after validation and dry-run handling. **`scripts/windows-boot/boot.ps1` line 407:** > [P2] Keep unattended input out of the system keyboard stream > > `SendInput` enters the system keyboard stream. `LEONIDA_KEYBOARD_PAD=always` lets the game observe it in the background, and the foreground app can still receive the synthesized Enter, Backspace or Escape. This makes unattended runs affect other apps. Route scripted presses through the runtime's virtual pad. [Win32 SendInput docs](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendinput).
MoonEyes commented 2026-11-28 02:49:22 +00:00

Hi @BubsMcgee, thanks for this pull request. It currently conflicts with main (conflicting file(s): scripts/windows-boot/boot.ps1), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

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

Hi @BubsMcgee, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `scripts/windows-boot/boot.ps1`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 reviewed 2026-12-01 11:48:34 +00:00
aslan2142 left a comment
No description provided.
This PR cannot merge in its current state: - **Merge conflict** with `main` in `scripts/windows-boot/boot.ps1`. - **No CI run** on current head `34da84a`. - **Unaddressed PowerShell 5.1 timing/plan-file issues** reproduced in the review above. - **Competing variant with `#2749`** for `BOOT-INPUT-STATE-RELATIVE` / `#1900` (harness-side here vs runtime `GameInput` in `#2749`) — both cannot land unchanged. Please rebase onto current `main`, address the PowerShell 5.1 findings, coordinate the variant decision with `#2749`, and obtain a green CI run. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 11:49:20 +00:00

Closing this PR in favor of #2749 for BOOT-INPUT-STATE-RELATIVE (#1900).

Side-by-side comparison:

  • Clean-room compliance: #1917 hardcodes title-specific RVAs (0x7446510 and 0x98f828c) in scripts/windows-boot/README.md and scripts/windows-boot/boot.ps1. main has since removed hardcoded game RVAs in favor of locally supplied LEONIDA_GAME_STATE_RVA / LEONIDA_SESSION_STATE_RVA.
  • Architecture & reliability: #1917 conflicts with main, has no CI status, and injects OS-wide SendInput keys from PowerShell (with timing and plan-file bugs reproduced in @lixonik's review). #2749 implements state-relative scripted presses (button@game=<hex>+seconds[:hold] / button@session=<hex>+seconds[:hold]) natively inside the GameInput shim using the locally supplied RVA environment variables, works with both SDL3 and no-SDL paths, supports :hold, is MERGEABLE/CLEAN, and has all CI checks green (verified under ASan).

Thanks @BubsMcgee for the initial design and specification of the @game= / @session= syntax.

(AI-assisted review.)

Closing this PR in favor of **#2749** for `BOOT-INPUT-STATE-RELATIVE` (`#1900`). **Side-by-side comparison:** - **Clean-room compliance:** `#1917` hardcodes title-specific RVAs (`0x7446510` and `0x98f828c`) in `scripts/windows-boot/README.md` and `scripts/windows-boot/boot.ps1`. `main` has since removed hardcoded game RVAs in favor of locally supplied `LEONIDA_GAME_STATE_RVA` / `LEONIDA_SESSION_STATE_RVA`. - **Architecture & reliability:** `#1917` conflicts with `main`, has no CI status, and injects OS-wide `SendInput` keys from PowerShell (with timing and plan-file bugs reproduced in `@lixonik`'s review). `#2749` implements state-relative scripted presses (`button@game=<hex>+seconds[:hold]` / `button@session=<hex>+seconds[:hold]`) natively inside the `GameInput` shim using the locally supplied RVA environment variables, works with both SDL3 and no-SDL paths, supports `:hold`, is `MERGEABLE/CLEAN`, and has all CI checks green (verified under ASan). Thanks `@BubsMcgee` for the initial design and specification of the `@game=` / `@session=` syntax. *(AI-assisted review.)*
Sign in to join this conversation.
No description provided.