WIP: feat(sandbox)!: the builder is the game: only entrypoint, sandbox and broker #2898

Closed
HumanBean wants to merge 29 commits from bitg/builder-is-the-game into mod-api
Owner

Title: feat(builder)!: the builder is the game: the game process runs, draws and plays sound; everything else that touches the player's PC is the builder's

Summary

The game process now does three things: it runs the game, draws and plays sound. Everything else that touches the player's PC is the builder's: the player's files, the environment, restarts, crash records, logs and bug reports, mod watching, the control bridge and the Steam Deck's sensors. The sandbox then says the same thing on both systems and every kernel: system files read-only, the program's own files, the GPU and sound devices, the display and sound servers' sockets, and the few folders the system's libraries open themselves. No sandbox rule names a folder of the player's. Plan: builder-is-the-game-plan.md (team notes), one commit per step, so the history reads step by step.

  1. Restart is the builder's only. A channel op restart {build} replaces restart_to_apply; the window's close and the bridge's relaunch ask once, then exit. Gone: relaunch() on both systems (execve, CreateProcessW, the kept environment), host/hos_relaunch.h, the C channel client (bc_open ... bc_restart_to_apply). host/hos_relaunch.c is host/hos_close.c. A restart drops Safe start and --set.
  2. The builder hands the game a finished environment (build_core::game_env): the real environment, then HOS_ENV_FILE's file, else the profile's longshot_env.txt, else the game folder's, checked against gpu/vk/switches.def (parsed in build-core's build.rs: an unknown name warns, a removed one says its row, a bad value is left out). The game reads no file of switches (load_longshot_env, host/env_own.h gone); the builder's four other readers of the file are one. The file is the builder's too: its lines answer the builder's own switches (build_driver::env). Windows compares names case-blind; LD_* and LONGSHOT_GAME_MODULE are refused from any file.
  3. The game never listens on the control bridge. The builder listens and hands each client's connection over (already built); the game's Linux socket and Windows pipe listeners, their DACL and LONGSHOT_CONTROL_BY_BUILDER go.
    3b. One command set for the bridge: the builder's Longshot.exe mod (21 commands, one list, COMMANDS in modtool); scripts/longshot_ctl.py keeps the run harness and forwards every bridge command to it; longshot_bridge.Bridge is the raw client. mod shot stages in the game's temp/ (a confined game cannot write the socket's folder: a bug).
  4. Mod watching: the game asks the system for no change notices (inotify and ReadDirectoryChangesW out of host/mod_watch.c, 747 lines to 123): the builder tells it, or it walks.
  5. Crash records made by the builder from a small block the game fills (build_core::crash_block): Linux, the handler stops itself, the builder reads the stopped child (/proc/<pid>/maps, process_vm_readv; a bounded stack copy in the block where Yama forbids the read) and resumes it; Windows, the builder walks the stack through its process handle (StackWalk64) and writes the minidump. host/hos_crash_record.c 929 lines to about 170; LONGSHOT_CRASH_BY_BUILDER, LONGSHOT_CRASH_DUMP, LONGSHOT_LOG_PATH gone; seccomp refuses process_vm_readv/writev.
  6. One log redactor, in the builder's tee, on every start of the game; bug reports assembled by the builder (a bug_report op; MKWVK_API_VERSION 82). Gone: host/log_redact.{c,h}, longshot_redact.h, build_driver::redact, most of vk_bug_report.cpp. Logs are read without following links. Also fix(dev): dev.py vk named the renderer by the host, not the target.
  7. One file rulebook (files_rules), deciding on an ask that names no system, with a Windows front (today's code) and a POSIX one. No behaviour change.
  8. Linux's files slot: build_core::files_linux serves the player's files beneath held folder descriptors (openat2 RESOLVE_BENEATH); host/hos_file_linux.c wraps the game's file calls at both links (--wrap, which covers Rust's std in the same link) and asks the builder only when the kernel refuses.
  9. The flip: the player's folders are the builder's roots on both systems and the fence keeps only what the system's libraries open. A .hosnew stand-in beside each file written in place replaces hos_atomic_file.h's write-in-place fallback. One list of roots for both systems. Review fixes here: <game>/user was served as a written root, which let the game write the launcher's files (older than this stack); the builder's shader cache was a root on neither system.
  10. The Steam Deck's sensors are read by the builder (build_core::deck_imu) and reach the game in the pads' snapshot: the game opens no hidraw node, and the last device rule for one goes.
  11. One start message: hello's reply carries what the builder decided (the settings file, the user folder, the confinement's notes); the game works none of it out again (host/options_path.c to about 40 lines; five LONGSHOT_SANDBOX_* variables gone). A hello without it ends the start.
  12. Docs: sandbox.md around the end state (one table of roots, what the fence still grants, the kernel table cut), build.md's slots and ops, control-bridge.md, switches.md, tools.md. Proposed text for the Modding API Spec's 12.2.1 and 12.7 is in the first comment.

After review (the user's answers): the builder serves the pads to every game it starts, confined or not, so the Steam Deck's own sensors work with HOS_SANDBOX=0 too (the game's own SDL reads controllers only when the builder serves none); longshot-builder game runs keep a crash record like play's (no window: a line on stderr naming it; none under --wait-for-debugger); the Switch 2 Pro Controller over USB and its NFC reader (Windows) moved into the builder's pads, so they work whatever the confinement. Its NFC commands are answered off the pads' thread (frame type 15, read-only reader commands only), so a tag scan never stalls the pads; the driver starts only when the builder's SDL can give its virtual pad.

Read first: builder/crates/build-core/src/game_env.rs, files_rules.rs, files_linux.rs, sandbox_linux.rs (rules, served_roots), crash_block.rs, host/hos_file_linux.c, game/crates/modtool/src/cmd/live.rs.

Testing

Tested: Linux (CachyOS, kernel 7.3, Landlock ABI 9 in use, RTX 3090, NVIDIA driver), the stack's tip, built through the job queue (pack and runtime on the shared base):

  • A smoke run through longshot_ctl.py (Skip title on, the kokiri-start save): the game confined by the builder (sandbox: files and folders confined by the builder (Landlock ABI 9)), reached play, the Insert menu opened (the system/menu page), then relaunch: restart: the builder starts the game again, back in play (frame 527). files: 198 served by the builder, 7 refused (the first frame in play); after the restart 129 and 6.
  • The timed A/B below: four confined runs in Hyrule Field, both sides reaching play.
  • The follow-ups (the pads for every start, a game run's crash record, the Switch 2 Pro driver in the builder) each had a cold review, fixed; then one batched queue job on their top: the full suite 805 passed (the two failures it found, the Wine file check's link and a formatting slip, fixed and rerun: pass), the host's C for Linux and Windows, the game's pack, clippy for Windows on build-core and longshot-game (in the helpers' jobs).
  • Checks: the full game-free suite (tests/run_all.py, through the queue) passes at the tip, as it does on mod-api@origin; on the way, test_program_hooks, test_lifter, test_fs_save_commit and test_display_startup_failure were brought up to date with the change. The host's C compiles for Linux (clang) and Windows (llvm-mingw), every file (only host/dav1d_av1.c and host/nn_video.c fail on Windows here, for the dav1d and FFmpeg headers this PC lacks, as on mod-api); the renderer compiles and links for Windows (RX_TARGET=windows dev.py vk); clippy -D warnings on the touched crates on Linux and Windows (gnullvm); tests/test_builder_files_wine.py under Wine (27 checks); the builder's Windows tests of the control pipe and the file service under Wine. Each step had its own cold review, and the whole stack one; their findings are fixed in the commits (two security ones: <game>/user served as a written root let the game write the launcher's files, older than this PR; a hostile crash block could make the builder panic).

Still to test:

  • Windows 11, any GPU: a confined play: Restart now from the Insert menu with and without a code mod change, a Bug report from the menu, HOS_CRASH_TEST (a record, the crash window, a minidump with HOS_CRASH_MINIDUMP), saves, settings, a screenshot, the shader store and NFC folder as roots, the .hosnew rename of the settings file, a second start compiling nothing, Longshot.exe mod status/shot through the pipe, expecting each to work as on main (@Beanstalk Windows NVIDIA and AMD: "confined play: restart, bug report, crash test, saves, settings, screenshot, second start")
  • Steam Deck (SteamOS): gyro aiming with no pad with sensors, expecting the Deck's own sensors to steer as on main (@Beanstalk Steam Deck, or by hand)
  • Steam Deck, HOS_SANDBOX=0: the same gyro aiming, expecting the Deck's sensors through the builder too (@Beanstalk Steam Deck, or by hand)
  • Windows, a Switch 2 Pro Controller over USB: its buttons, sticks and rumble in play, and Scan tag on controller with an amiibo, confined and with HOS_SANDBOX=0, expecting them as on main (by hand: the farm has none)
  • Windows, HOS_SANDBOX=0: controllers through the builder's pads pipe, expecting them as confined (@Beanstalk Windows)
  • Windows and Linux: longshot-builder game with HOS_CRASH_TEST, expecting a record in the game folder's bug-reports/pending/ and a stderr line naming it (by hand)
  • Linux, a kernel with Landlock ABI 1-3 (Debian 12, Ubuntu 22.04): a confined play saves and settings, expecting them kept (by hand)
  • Linux, a player with an older build's user/ in the game folder: a start moves it to ~/.local/share/longshot once (or keeps it while it cannot), the saves there (by hand)
  • Linux: what the 7 opens refused before the first frame in play are (the counter does not name them; the game plays as on main), by hand with a log of the refusals
  • The lab PC (HDD) and a heavy mod profile: start to play, mod-api against this PR (by hand)

Measurements

Verdict: no change in play; a confined start reaches play about 1 s later (one warm sample a side), with about 110 files opened through the builder before the first frame in play and a handful more in play.

Setup: Linux (CachyOS, kernel 7.3), RTX 3090, NVIDIA driver; Hyrule Field (child), the A/B's pinned options (cap off, Render resolution 67 %), 1080p, no upscaler; dev.py ab with each side's own runtime (--a-runtime), two interleaved 60 s runs each, timing mode; the start-up marks are the log's start: timeline line, the files counter the log's files: lines.

Before: mod-api @ 12f42db5 After: this PR @ 97a436e8 (the game as at the tip b78ca2bc, which adds only longshot_ctl.py)
fps (run 1 / run 2) 81.6 / 81.2 82.2 / 81.7
median frame time 12.27 / 12.34 ms 12.23 / 12.31 ms
p99 frame time 14.96 / 14.93 ms 14.81 / 14.74 ms
1 % low 66.8 / 67.0 fps 67.5 / 67.8 fps
start to play (play=) 30.7 s (cold, first) / 8.3 s 9.2 / 9.7 s
files through the builder, first frame in play / later (none: Landlock grants) 109 / 114, 113 / 118
A1: 4897 frames in 60 s, 81.6 fps, median 12.27 ms, p99 14.96 ms, 1% low 66.8 fps
B1: 4930 frames in 60 s, 82.2 fps, median 12.23 ms, p99 14.81 ms, 1% low 67.5 fps
A2: 4869 frames in 60 s, 81.2 fps, median 12.34 ms, p99 14.93 ms, 1% low 67.0 fps
B2: 4901 frames in 60 s, 81.7 fps, median 12.31 ms, p99 14.74 ms, 1% low 67.8 fps
B1: files: 109 served by the builder, 7 refused (the first frame in play)

Not measured yet: the lab PC (HDD) and Windows (its file service was already in use; steps 5, 6 and 9 change it), and the heaviest mod profile's start.

Risks

  • Every file of the player's the game opens, makes, renames or removes now goes through the builder (Linux newly; Windows already). A library that opens a player's file itself, not through the game's file calls, is refused: the list of what the fence still grants is in sandbox.md. The served-files counter (files: N served by the builder) says how many in the log.
  • Breaking for tools: restart_to_apply is restart; mod stop is mod quit, mod restart --manifest is mod relaunch, mod wait takes <EVENT> --frames/--state; the channel is version 2. The mod API is unshipped; nothing in LongshotLauncher calls a renamed command.
  • Every game the builder starts reads its controllers through the builder (confined or not); a builder that finds no SDL3 says so, and the game then reads them itself.
  • After updating: nothing for saves or settings; longshot_env.txt lines the builder leaves out are named in the log.
  • MKWVK_API_VERSION goes to 82 here (step 6's builder_bug_report in MkwVkHost), as it does in #2877, #2880 and #2882: whichever merges later takes the next number.
  • A revert of the PR is enough to go back.

Checklist

Ready for review

  • One topic, on current mod-api; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • MKWVK_API_VERSION bumped (MkwVkHost or MkwVkRenderer in gpu/vk/vk_api.h changed).
  • Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc

Title: feat(builder)!: the builder is the game: the game process runs, draws and plays sound; everything else that touches the player's PC is the builder's ## Summary The game process now does three things: it runs the game, draws and plays sound. Everything else that touches the player's PC is the builder's: the player's files, the environment, restarts, crash records, logs and bug reports, mod watching, the control bridge and the Steam Deck's sensors. The sandbox then says the same thing on both systems and every kernel: system files read-only, the program's own files, the GPU and sound devices, the display and sound servers' sockets, and the few folders the system's libraries open themselves. No sandbox rule names a folder of the player's. Plan: `builder-is-the-game-plan.md` (team notes), one commit per step, so the history reads step by step. 1. **Restart is the builder's only.** A channel op `restart {build}` replaces `restart_to_apply`; the window's close and the bridge's `relaunch` ask once, then exit. Gone: `relaunch()` on both systems (`execve`, `CreateProcessW`, the kept environment), `host/hos_relaunch.h`, the C channel client (`bc_open` ... `bc_restart_to_apply`). `host/hos_relaunch.c` is `host/hos_close.c`. A restart drops Safe start and `--set`. 2. **The builder hands the game a finished environment** (`build_core::game_env`): the real environment, then `HOS_ENV_FILE`'s file, else the profile's `longshot_env.txt`, else the game folder's, checked against `gpu/vk/switches.def` (parsed in build-core's `build.rs`: an unknown name warns, a removed one says its row, a bad value is left out). The game reads no file of switches (`load_longshot_env`, `host/env_own.h` gone); the builder's four other readers of the file are one. The file is the builder's too: its lines answer the builder's own switches (`build_driver::env`). Windows compares names case-blind; `LD_*` and `LONGSHOT_GAME_MODULE` are refused from any file. 3. **The game never listens on the control bridge.** The builder listens and hands each client's connection over (already built); the game's Linux socket and Windows pipe listeners, their DACL and `LONGSHOT_CONTROL_BY_BUILDER` go. 3b. **One command set for the bridge**: the builder's `Longshot.exe mod` (21 commands, one list, `COMMANDS` in `modtool`); `scripts/longshot_ctl.py` keeps the run harness and forwards every bridge command to it; `longshot_bridge.Bridge` is the raw client. `mod shot` stages in the game's `temp/` (a confined game cannot write the socket's folder: a bug). 4. **Mod watching**: the game asks the system for no change notices (inotify and `ReadDirectoryChangesW` out of `host/mod_watch.c`, 747 lines to 123): the builder tells it, or it walks. 5. **Crash records made by the builder** from a small block the game fills (`build_core::crash_block`): Linux, the handler stops itself, the builder reads the stopped child (`/proc/<pid>/maps`, `process_vm_readv`; a bounded stack copy in the block where Yama forbids the read) and resumes it; Windows, the builder walks the stack through its process handle (StackWalk64) and writes the minidump. `host/hos_crash_record.c` 929 lines to about 170; `LONGSHOT_CRASH_BY_BUILDER`, `LONGSHOT_CRASH_DUMP`, `LONGSHOT_LOG_PATH` gone; seccomp refuses `process_vm_readv`/`writev`. 6. **One log redactor, in the builder's tee**, on every start of the game; bug reports assembled by the builder (a `bug_report` op; `MKWVK_API_VERSION` 82). Gone: `host/log_redact.{c,h}`, `longshot_redact.h`, `build_driver::redact`, most of `vk_bug_report.cpp`. Logs are read without following links. Also `fix(dev)`: `dev.py vk` named the renderer by the host, not the target. 7. **One file rulebook** (`files_rules`), deciding on an ask that names no system, with a Windows front (today's code) and a POSIX one. No behaviour change. 8. **Linux's files slot**: `build_core::files_linux` serves the player's files beneath held folder descriptors (`openat2` `RESOLVE_BENEATH`); `host/hos_file_linux.c` wraps the game's file calls at both links (`--wrap`, which covers Rust's std in the same link) and asks the builder only when the kernel refuses. 9. **The flip**: the player's folders are the builder's roots on both systems and the fence keeps only what the system's libraries open. A `.hosnew` stand-in beside each file written in place replaces `hos_atomic_file.h`'s write-in-place fallback. One list of roots for both systems. Review fixes here: `<game>/user` was served as a written root, which let the game write the launcher's files (older than this stack); the builder's shader cache was a root on neither system. 10. **The Steam Deck's sensors** are read by the builder (`build_core::deck_imu`) and reach the game in the pads' snapshot: the game opens no `hidraw` node, and the last device rule for one goes. 11. **One start message**: hello's reply carries what the builder decided (the settings file, the user folder, the confinement's notes); the game works none of it out again (`host/options_path.c` to about 40 lines; five `LONGSHOT_SANDBOX_*` variables gone). A hello without it ends the start. 12. **Docs**: `sandbox.md` around the end state (one table of roots, what the fence still grants, the kernel table cut), `build.md`'s slots and ops, `control-bridge.md`, `switches.md`, `tools.md`. Proposed text for the Modding API Spec's 12.2.1 and 12.7 is in the first comment. **After review** (the user's answers): the builder serves the pads to every game it starts, confined or not, so the Steam Deck's own sensors work with `HOS_SANDBOX=0` too (the game's own SDL reads controllers only when the builder serves none); `longshot-builder game` runs keep a crash record like play's (no window: a line on stderr naming it; none under `--wait-for-debugger`); the Switch 2 Pro Controller over USB and its NFC reader (Windows) moved into the builder's pads, so they work whatever the confinement. Its NFC commands are answered off the pads' thread (frame type 15, read-only reader commands only), so a tag scan never stalls the pads; the driver starts only when the builder's SDL can give its virtual pad. Read first: `builder/crates/build-core/src/game_env.rs`, `files_rules.rs`, `files_linux.rs`, `sandbox_linux.rs` (`rules`, `served_roots`), `crash_block.rs`, `host/hos_file_linux.c`, `game/crates/modtool/src/cmd/live.rs`. ## Testing **Tested:** Linux (CachyOS, kernel 7.3, Landlock ABI 9 in use, RTX 3090, NVIDIA driver), the stack's tip, built through the job queue (pack and runtime on the shared base): - A smoke run through `longshot_ctl.py` (Skip title on, the kokiri-start save): the game confined by the builder (`sandbox: files and folders confined by the builder (Landlock ABI 9)`), reached play, the Insert menu opened (the `system/menu` page), then `relaunch`: `restart: the builder starts the game again`, back in play (frame 527). `files: 198 served by the builder, 7 refused (the first frame in play)`; after the restart 129 and 6. - The timed A/B below: four confined runs in Hyrule Field, both sides reaching play. - The follow-ups (the pads for every start, a game run's crash record, the Switch 2 Pro driver in the builder) each had a cold review, fixed; then one batched queue job on their top: the full suite 805 passed (the two failures it found, the Wine file check's link and a formatting slip, fixed and rerun: pass), the host's C for Linux and Windows, the game's pack, clippy for Windows on build-core and longshot-game (in the helpers' jobs). - Checks: the full game-free suite (`tests/run_all.py`, through the queue) passes at the tip, as it does on mod-api@origin; on the way, `test_program_hooks`, `test_lifter`, `test_fs_save_commit` and `test_display_startup_failure` were brought up to date with the change. The host's C compiles for Linux (clang) and Windows (llvm-mingw), every file (only `host/dav1d_av1.c` and `host/nn_video.c` fail on Windows here, for the dav1d and FFmpeg headers this PC lacks, as on mod-api); the renderer compiles and links for Windows (`RX_TARGET=windows dev.py vk`); clippy `-D warnings` on the touched crates on Linux and Windows (gnullvm); `tests/test_builder_files_wine.py` under Wine (27 checks); the builder's Windows tests of the control pipe and the file service under Wine. Each step had its own cold review, and the whole stack one; their findings are fixed in the commits (two security ones: `<game>/user` served as a written root let the game write the launcher's files, older than this PR; a hostile crash block could make the builder panic). **Still to test:** - Windows 11, any GPU: a confined play: Restart now from the Insert menu with and without a code mod change, a Bug report from the menu, `HOS_CRASH_TEST` (a record, the crash window, a minidump with `HOS_CRASH_MINIDUMP`), saves, settings, a screenshot, the shader store and NFC folder as roots, the `.hosnew` rename of the settings file, a second start compiling nothing, `Longshot.exe mod status`/`shot` through the pipe, expecting each to work as on main (@Beanstalk Windows NVIDIA and AMD: "confined play: restart, bug report, crash test, saves, settings, screenshot, second start") - Steam Deck (SteamOS): gyro aiming with no pad with sensors, expecting the Deck's own sensors to steer as on main (@Beanstalk Steam Deck, or by hand) - Steam Deck, `HOS_SANDBOX=0`: the same gyro aiming, expecting the Deck's sensors through the builder too (@Beanstalk Steam Deck, or by hand) - Windows, a Switch 2 Pro Controller over USB: its buttons, sticks and rumble in play, and Scan tag on controller with an amiibo, confined and with `HOS_SANDBOX=0`, expecting them as on main (by hand: the farm has none) - Windows, `HOS_SANDBOX=0`: controllers through the builder's pads pipe, expecting them as confined (@Beanstalk Windows) - Windows and Linux: `longshot-builder game` with `HOS_CRASH_TEST`, expecting a record in the game folder's `bug-reports/pending/` and a stderr line naming it (by hand) - Linux, a kernel with Landlock ABI 1-3 (Debian 12, Ubuntu 22.04): a confined play saves and settings, expecting them kept (by hand) - Linux, a player with an older build's `user/` in the game folder: a start moves it to `~/.local/share/longshot` once (or keeps it while it cannot), the saves there (by hand) - Linux: what the 7 opens refused before the first frame in play are (the counter does not name them; the game plays as on main), by hand with a log of the refusals - The lab PC (HDD) and a heavy mod profile: start to play, mod-api against this PR (by hand) ## Measurements **Verdict:** no change in play; a confined start reaches play about 1 s later (one warm sample a side), with about 110 files opened through the builder before the first frame in play and a handful more in play. Setup: Linux (CachyOS, kernel 7.3), RTX 3090, NVIDIA driver; Hyrule Field (child), the A/B's pinned options (cap off, Render resolution 67 %), 1080p, no upscaler; `dev.py ab` with each side's own runtime (`--a-runtime`), two interleaved 60 s runs each, timing mode; the start-up marks are the log's `start: timeline` line, the files counter the log's `files:` lines. | | Before: mod-api @ 12f42db5 | After: this PR @ 97a436e8 (the game as at the tip b78ca2bc, which adds only `longshot_ctl.py`) | |---|---|---| | fps (run 1 / run 2) | 81.6 / 81.2 | 82.2 / 81.7 | | median frame time | 12.27 / 12.34 ms | 12.23 / 12.31 ms | | p99 frame time | 14.96 / 14.93 ms | 14.81 / 14.74 ms | | 1 % low | 66.8 / 67.0 fps | 67.5 / 67.8 fps | | start to play (`play=`) | 30.7 s (cold, first) / 8.3 s | 9.2 / 9.7 s | | files through the builder, first frame in play / later | (none: Landlock grants) | 109 / 114, 113 / 118 | ``` A1: 4897 frames in 60 s, 81.6 fps, median 12.27 ms, p99 14.96 ms, 1% low 66.8 fps B1: 4930 frames in 60 s, 82.2 fps, median 12.23 ms, p99 14.81 ms, 1% low 67.5 fps A2: 4869 frames in 60 s, 81.2 fps, median 12.34 ms, p99 14.93 ms, 1% low 67.0 fps B2: 4901 frames in 60 s, 81.7 fps, median 12.31 ms, p99 14.74 ms, 1% low 67.8 fps B1: files: 109 served by the builder, 7 refused (the first frame in play) ``` Not measured yet: the lab PC (HDD) and Windows (its file service was already in use; steps 5, 6 and 9 change it), and the heaviest mod profile's start. ## Risks - Every file of the player's the game opens, makes, renames or removes now goes through the builder (Linux newly; Windows already). A library that opens a player's file itself, not through the game's file calls, is refused: the list of what the fence still grants is in `sandbox.md`. The served-files counter (`files: N served by the builder`) says how many in the log. - Breaking for tools: `restart_to_apply` is `restart`; `mod stop` is `mod quit`, `mod restart --manifest` is `mod relaunch`, `mod wait` takes `<EVENT> --frames/--state`; the channel is version 2. The mod API is unshipped; nothing in LongshotLauncher calls a renamed command. - Every game the builder starts reads its controllers through the builder (confined or not); a builder that finds no SDL3 says so, and the game then reads them itself. - After updating: nothing for saves or settings; `longshot_env.txt` lines the builder leaves out are named in the log. - `MKWVK_API_VERSION` goes to 82 here (step 6's `builder_bug_report` in `MkwVkHost`), as it does in #2877, #2880 and #2882: whichever merges later takes the next number. - A revert of the PR is enough to go back. ## Checklist ### Ready for review - [x] One topic, on current `mod-api`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] `MKWVK_API_VERSION` bumped (`MkwVkHost` or `MkwVkRenderer` in `gpu/vk/vk_api.h` changed). - [x] Host code builds on Windows (llvm-mingw) and Linux, with UTF-8 paths. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
The Insert menu's Restart now and the control bridge's relaunch ask the builder over the game's channel
(restart, args.build) and exit; play starts the game again through the fast check, built first when asked
(at most 3 builds in a row), and longshot-builder game starts it again as it is (a build asked is answered
build: false). restart_to_apply goes.

Removed: relaunch() on both systems (execve of /proc/self/exe, CreateProcessW with the kept environment
and standard handles), host/hos_relaunch.h, hos_relaunch_keep_env, the confined-restart special case, the
C channel client (bc_open, bc_send, bc_request, bc_read_message, bc_close, bc_restart_to_apply,
bc_has_channel and the C copy of the frame format), host_sys::builder::{restart_to_apply, has_channel,
sandboxed}, hos_romfs_nup_passed, sbxw_handle_text, HOS_RESTART_OF (now GONE), and longshot_bridge.py's
relaunch following (follow_relaunch, Adopted, relaunched_game): the run's process is the builder, the same
before and after. host/hos_relaunch.c is host/hos_close.c.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
build_core::game_env resolves the game's environment at every start (play, longshot-builder game, the shader
preparation), before its channel is made: the real environment first, then HOS_ENV_FILE's file (any name but
the sandbox's own), else the profile's longshot_env.txt, else the game folder's (config/ first), a player's
file giving the game's switches alone and no path (and HOS_CONTROL as a bare name); HOS_START_SLOT from the
profile's profile.json alone. Each line is checked against gpu/vk/switches.def (include_str! and a small
SW/GONE parser): an unknown or removed name is said and set, a value that is not the row's number is said
and left out; never fatal. HOS_SANDBOX from a file still never takes effect.

Removed: load_longshot_env, env_line_allowed, env_sandbox_own, removed_switch_notes, profile_start_slot and
its note in host/hos_main.c; host/env_own.h and env_own::c_header; longshot_profile_start_slot and the lp_*
JSON reader, longshot_profile_file, LONGSHOT_PROFILE_FILE(_MAX); control::env_file_lines and path_for's file
half; sandbox_linux's env_file_of and env_file_overlay; gather.rs's overlay; env_line::taken_from_file;
shaders.rs's own file parser; the pads' own reading of SDL_* lines. Fence: HOS_ENV_FILE's read grant (Linux)
and ACL (Windows). tests/test_env_file.py goes: its cases are game_env's tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
The game's own listeners go from host/control.c: the Linux socket (its folder check, bind, chmod, accept,
SO_PEERCRED) and the Windows named pipe (its DACL, the AppContainer SID, HOS_CONTROL_PEER_SID's check), and
LONGSHOT_CONTROL_BY_BUILDER with them: the bridge only serves the clients build_core::control hands over.
tests/control_test.c drives clients handed by a stand-in builder; the endpoint's security checks move to
build_core::control's tests (the folder others can write, a live socket, the pipe's first instance and DACL,
more refused SIDs), and tests/test_control_pipe_security.py, which read the deleted C, goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
The bridge's commands are the builder's `mod` alone (game/crates/modtool cmd/live.rs, its one COMMANDS list for
`mod help`, and a test holding control-bridge.md and tools.md to it). It gains what longshot_ctl.py had of its own:
release, relaunch (waits for the game started again; restart --manifest goes), age, option, saves, slots, watch,
mem, and press/stick/sequence/shot/wait/teleport options with the bridge's names; stop becomes quit. Its shot now
stages the picture in the game's temp/ as a confined game needs (it asked for the socket's folder, which the game
can no longer write).

longshot_ctl.py keeps the run harness (launch, runs, show, finish, stop, log, saves --repo) and hands every other
command to the builder as it is; --json prints the builder's result, the exit codes stay. longshot_bridge.Bridge is
the raw client: the sequence-units conversion and relaunch() go (the bridge converts units itself).
tests/test_longshot_ctl_finite.py, which checked the deleted argument parsing, goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
inotify and ReadDirectoryChangesW go from host/mod_watch.c, with mod_watch_open/_wait/_wake/_stats/_close,
mod_watch_hidden and the unused mod_watch_thread(_stack); mod_watch_hash and mod_watch_file_sig stay for the
walks. host_sys::watch loses ModWatch and Stats (Notice stays, the builder's events' type), and api::watch's
Source::System goes: its notices are the builder's (Fed), else (HOS_MODS_WATCH=poll, or no builder that
watches) a walk every 2 s. HOS_MODS_WATCH's row and the modders' docs say so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
At its start the builder hands the game a crash block (LONGSHOT_CRASH_BLOCK: Linux a memory
file, Windows a mapping and two events, build_core::crash_block). A crashing game writes
numbers only into it (plus, on Linux, a bounded copy of its stacks for where Yama refuses
the builder's read) and waits: Linux SIGSTOP, read by the builder's wait with
process_vm_readv, then SIGCONT; Windows the events, the stack walked by dbghelp and the
minidump taken by the builder. crash::record writes the crash and unclean records; the
running/ markers, the game's formatter, recovery, pruning, dump worker and privacy header
go, as do LONGSHOT_CRASH_BY_BUILDER, LONGSHOT_CRASH_DUMP and LONGSHOT_LOG_PATH. The game's
seccomp filter now refuses process_vm_readv.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
The game logs raw: every start of the game (play, --prepare-shaders, longshot-builder
game, with a log file or without) goes through build_core::game_log::StderrTee, which
redacts each line (crash::redact, now with the home folder's own and short names); a
line cut across two writes is held for its end, a very long one keeps an overlap. The
next-start redaction pass goes on both sides, and the builder opens the game's logs
without following a link. host/log_redact.{c,h}, gpu/vk/compat/longshot_redact.h and
build_driver::redact (with its example and test) go. The new channel op bug_report takes
what only the game knows (version, GPU line, settings changed) and the picture as a file
of its own; the builder writes bug-reports/<date>_<time>/ (build_driver::bug_report: this
PC, the place from the log, the switches from the resolved environment, both logs) and
opens it. The game no longer writes bug-reports/ on either system.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
A Windows renderer cross-built on Linux (RX_TARGET=windows) is longshot_vk.dll: dev.py vk
looked for longshot_vk.so and failed after a good build, and skipped the DLL's export
check. The export check finds llvm-objdump in a Linux build of LONGSHOT_MINGW too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
files_rules decides on an OS-neutral ask (an op, what an open wants: read,
write, create, new, truncate, delete; the paths in a front's form): the roots
(generic over the path form), the longest-root match, what each op may do in
a read root, a write root and a file written in place, the rate and the
results. files_rules::windows is today's form and checks (norm, device_name,
under with ASCII folding, access_map, the share, attribute and flag checks,
final_form, final_ok) and reads CreateFileW's args as wants;
files_rules::posix (for Linux's files slot, not served yet) takes an absolute
path as bytes, open's flags and mode. Access moves from sandbox_windows to
files_rules; the ACE's mask stays there. The wire is unchanged: the head's
four u32 are the system's own args. Each rule is tested once in both forms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
build_core::files_linux serves a third SOCK_SEQPACKET connection (LONGSHOT_FILES_FD): each root's folder held,
openat2 beneath it (RESOLVE_BENEATH | RESOLVE_NO_MAGICLINKS), make, remove and rename on the parent's one name, the
descriptor beside the reply. host/hos_file_linux.c, wrapped by lld's --wrap at the executable's and the renderer's
links, calls the real function first and asks only on EACCES; Rust's std::fs is reached the same way.
With LONGSHOT_SANDBOX_FILES=served the player's folders leave the Landlock rules for the builder's roots; without it
nothing changes. The game logs what was served at the load, in play and 60 s after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Linux: the files slot is the only way (LONGSHOT_SANDBOX_FILES goes); sandbox_linux::rules names none of the player's
folders, served_roots holds them; the rules keep the system, the program folder, devices and sockets, the drivers'
caches, TMPDIR, Steam's files, DLSS's runtime. Windows: the shader store and the NFC tags move from ACLs to roots, and
SDL_GAMECONTROLLERCONFIG_FILE's grant goes on both (the builder reads the pads). A file written in place's stand-in
(<file>.hosnew) is its root's, so hos_atomic_file.h loses its write-in-place fallback. GAME_SUBDIRS and USER_SUBDIRS
are one list in files_rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
build_core::deck_imu ports host/deck_imu.c's reader (the Deck's state report on its hidraw node, the IMU setting turned
on where it could be read first and put back where still ours), behind a Hid trait so it runs on a canned report
stream. The pads' request (version 2) says whether the game wants it, and each snapshot ends with its reading;
pad_sdl.c takes it through game_builder_deck_imu. The fence's last hidraw rule goes: the dev nodes are NVIDIA's and
udmabuf. Removes host/deck_imu.c and .h and their two tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
The answer to the game's hello carries build_core::channel::Start: the settings file
(build_core::settings_folder, its folder made, its moves and carry done), and the sandbox's
part, filled before the start: the confined game's user folder, notes and needs (Windows),
the Landlock ABI and the private folders' status (Linux). The game takes them through
game_builder_said: host/options_path.c chooses, moves and copies nothing; sandbox_linux.c
and sandbox_windows.c and user_dir_early read hello, not the environment.

Removed: LONGSHOT_SANDBOX_NOTE, _USER, _NEEDS, _BY_BUILDER, _PRIVATE (env_own::OWN, their
switch rows now GONE), options_path.c's moves and carry, longshot_profile.h's settings
helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
sandbox.md: one Files section, one roots' table for both systems (files_rules'
GAME_SUBDIRS, USER_SUBDIRS, DIAGNOSTICS, the stand-in; Linux's mouse_sens.txt and
diagnostic folders, Windows' language.txt), one list of what the fence still grants
(the system libraries' files: lib_read, lib_write, program_files; Windows' ACLs),
the kernel table cut to what still differs (ABI 3's truncate served, 4, 5, 6, 9),
What keeps an ACL in three lines. Gone: the Windows roots' second list (with a
user\ it no longer serves), a profile.json and Linux language.txt written in place,
the in-process net engine "with no builder", host/sandbox_plan.h as holding the rules,
"Linux's service is not built yet".

build.md: the slots in a table (channel, main, pads, files, per system), the channel's
ops in a table as build_driver::channel and game_ops have them.

Also: the user page's files line, net.md's "every game with a script mod", and the
running game's commands (mod stop is now mod quit; test_doc_commands follows live.rs).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
LONGSHOT_SHADER_CACHE (<the builder's cache>/shaders/<stamp>/<driver>), which play sets and gpu/vk/vk_paths.h takes
when it is there, was a root on neither system: a confined game's shader and pipeline caches were refused there. It
is a written root now on both, guarded as the shader store. The diagnostic switches' folders and the user folder's
single files are one list in files_rules (SWITCH_DIRS, SWITCH_FILES, SHADER_CACHE, USER_FILES) taken by both: Windows
gains the switches' folders and mouse_sens.txt, and loses language.txt, which the game reads and never writes (as
Linux). Stale comments fixed; sandbox.md's Files table one list for both systems.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
On Linux the move of an older build's user/ into ~/.local/share/longshot was the game's own, after the builder had
confined it: the new place's top is only listed and the game folder only read, so the move was refused and the game
kept <game>/user while the builder served the new place: its saves could not be written. The builder now chooses as
Windows' gather does (sandbox_linux user_early: a cut move finished or undone, the old place kept while it holds saves
or a save's journal not finished) and says it in hello's user; the confined game takes it, and its own move runs only
unconfined (HOS_SANDBOX=0). Stale comments in host/hos_main.c and host/net_engine.h fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Step 12's review: the builder makes, removes, renames and truncates too; every slot but the channel opens with a
greeting; hello's v and stamp are the request's own keys; the Linux grants listed as rules() and lib_read have them;
the modding docs name every running-game command.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Step 11's review: a refused hello, or one with no start object, ends the start (channel version 2), never a game on
defaults; the sandbox's plans take the settings file from the Start instead of choosing and carrying it again
(settings_folder::game_of, one way to the game folder on both systems); a settings path that is no UTF-8 goes as its
bytes; settings_write compares with the file hello said; a value that does not fit is said. The kill-step scaffolding
of tests/test_options_path.py went with what it tested; carry lets a failed write go (no file: defaults), and the
fallback that kept the game folder's settings for a profile that cannot be written went.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
- The user folder and the save folder are the builder's choice on every start, confined or not
  (build_core::user_folder, crate::channel::Start's user, saves and saves_refused, paths as path_json): an older
  build's user/ moved by the builder, the game's journaled move ported (copies under .moving-<name>, the names,
  the renames, the commit, the old entries deleted; a cut start settled). host/hos_main.c's move and nn_fs.c's
  own choice go; the game takes hello's words. Both sandboxes' plans serve that choice.
- Windows: one read-and-run ACE per program file (the exe and its DLLs) in place of the whole game folder; a
  refused one ends the start.
- A game started outside the builder in an AppContainer no longer runs.
- AF_NETLINK only for a game the builder did not confine (it reads its own pads); a confined one opens no
  controller, and Mesa's udev monitor serves display events the renderer never registers.
- No written settings folder without a profile on either system: every confined start has one.
- host/sandbox_win_plan.h's test-only helpers gone; path_norm's cases in its Rust test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
- The main pipe goes: its greeting said only what hello and each connection's own greeting
  say. LONGSHOT_BUILDER_PIPES is <pads>,<files>; game_builder_connect and pads' SERVES go; the
  confined game asks game_builder_started.
- longshot-builder game redacts its stderr before the channel (game_env's notes name paths).
- crash: the game folder's settings file is settings/settings.toml (config/ organized), as the
  builder chooses it.
- switches.def: LONGSHOT_FILES_FD, LONGSHOT_NUP_HANDLE and LONGSHOT_BUILDER_PIPES rows; GONE rows
  for LONGSHOT_CRASH_BY_BUILDER, LONGSHOT_CRASH_DUMP, LONGSHOT_LOG_PATH.
- docs: a restart applies the headset row, HOS_CONTROL_PEER_SID is the builder's own, the
  settings file's name, crash-window's step 3, the bridge's shot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
run-vk.ps1 started longshot-game.exe itself, which the game now refuses (the builder is the only entrypoint);
longshot_ctl.py launch is the run harness on both systems. saves.md, build.md and sandbox.md follow
build_core::user_folder and the start's saves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
fix(build): the Rust store carries the switch table; the lift's key knows launcher-profile; two tests' stand-ins
All checks were successful
PR description / Title and description (pull_request_target) Successful in 14s
b78ca2bcc2
- build-core's build script reads gpu/vk/switches.def: the Rust store copies it (and keys on it), so the game's Rust
  builds from the store's copy again (a test in rust_store's). A release's tree carries all of gpu/ already.
- lift's key_crates: launcher-profile, build-core's, is not in the lifted code (NOT_IN_KEY).
- tests/test_fs_save_commit.py: game_builder_said's stand-in plays the builder's hello (the save folder or its
  refusal); the folder's own checks are build_core::user_folder's tests.
- tests/display_startup_failure_test.cpp: user_dir_early takes no arguments.
- files_linux's connection test: its end is an end of file or, a send having crossed the close, a reset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Member

Possibly related, for context:

  • PR #2822 feat(game)!: the game side and the whole mod API in Rust, with system mods and the sandbox on by default — Parent stack already implements builder-started sandbox and broker; overlapping architecture work
  • PR #2894 WIP: refactor(settings): environment switches set settings, one system (stacked on #2882) — Environment-switch handling overlaps and explicitly depends on this stack's behavior
  • PR #2726 fix(sandbox): Windows: a sandboxed start with a profile reaches play, its saves and the test mode's results written — Open Windows sandbox/profile and broker-file fixes touching flows this changes
Possibly related, for context: - PR #2822 feat(game)!: the game side and the whole mod API in Rust, with system mods and the sandbox on by default — Parent stack already implements builder-started sandbox and broker; overlapping architecture work - PR #2894 WIP: refactor(settings): environment switches set settings, one system (stacked on #2882) — Environment-switch handling overlaps and explicitly depends on this stack's behavior - PR #2726 fix(sandbox): Windows: a sandboxed start with a profile reaches play, its saves and the test mode's results written — Open Windows sandbox/profile and broker-file fixes touching flows this changes
Author
Owner

Windows host compile (llvm-mingw, with tools.lock's FFmpeg 9.0.2 headers): every host unit compiles at this head; box ticked.

Windows host compile (llvm-mingw, with tools.lock's FFmpeg 9.0.2 headers): every host unit compiles at this head; box ticked.
Every start the builder makes but the shader preparation now gets the pads slot, confined or not (HOS_SANDBOX=0, a
kernel without Landlock, a confinement that failed): Linux's LONGSHOT_PADS_FD made apart from the confinement
(sandbox_linux::pads_slot), Windows' pipes for an unconfined start (sandbox_windows::pipes_unconfined, the files' slot
serving no root). The game's pads are the builder's whenever its slot is there and the builder serves them
(game_builder_pads_remote no longer asks whether it is confined), so its own SDL opens no controller and none is read
twice; Steam's ignore list is the builder's SDL's, as for a confined game. The unconfined run's "no Deck gyro" line
goes; the Switch 2 USB driver, whose virtual pad is the game's own SDL's, is off whenever the builder reads the pads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
longshot-builder game (dev.py, the bridge's runs, the checks) now hands the game the crash
block and writes the run's record after it as play does (the game folder's
bug-reports/pending/, no log), with no window and nothing sent: a line on stderr names
the record. A crash ends the restart loop, its record written first. Under
--wait-for-debugger the game gets no block: the debugger owns its stops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
- Linux's pads greeting says pads only with the builder's SDL3 there (Devices::available), as Windows' does: an
  unconfined game whose builder has none reads its own.
- A pads slot dropped ends its own run alone (a generation): a restart's slot made meanwhile stays.
- Unconfined Windows: the pads' pipe alone (the game's has_files reads the files' entry); the inheritable window noted.
- The NFC reader's scan says unavailable whenever the builder serves the pads (host/nn_nfp.c, nfc.md); the Switch 2
  driver's gating is left for the user's call.
- host_sys::builder::confined and its declarations gone (dead).
- Test runs start no SDL3 in the builder (sandbox_linux::serve_no_pads); the tests that make pads slots one at a time.
- "confined" wording that no longer holds: switches.def, pads.rs, deck_imu.rs, sandbox_windows.rs, channel.rs, build.md,
  game.h, pad_sdl.c, hos_sdl.c, sandbox.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
game_cmd's start is game_start (the block, the run, the record), which the test drives,
with --wait-for-debugger giving no block and no record. A crash block that cannot be made
and a record that could not be written are said on stderr; a bare program name is found
through PATH before its game folder is taken. Docs name the organized layout's
diagnostics/bug-reports/pending/ too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
host/pad_switch2.c moves into the builder as build_core::switch2 (Windows): the
controller's vendor interface over WinUSB (start-up commands, calibration),
its reports over HID, a virtual gamepad with an accelerometer and a gyroscope
in the builder's SDL3, so it is one of the builder's pads (list, snapshot,
rumble and sensors through the pads' commands). The rumble keeps its stuck-
controller fallback to the controller's own samples, and HOS_SWITCH2 and
HOS_SWITCH2_RUMBLE_TEST stay switches, read by the builder from the game's.

The game's NFC reader (host/nn_nfp.c) asks the controller's reader commands
over the pads slot (game_builder_switch2, frame type 15); the builder lets
through the reader's read-only subcommands alone. host/pad_sdl.c loses its
Switch 2 path, and the game links no longer winusb or hid.

The protocol is tested on canned bytes through a fake pipe (commands, the
calibration, a report stream made the pad's state, rumble reports and the
fallback, the reader's commands let through), the request on both sides.
Not run on hardware: Windows, a Switch 2 Pro over USB and an amiibo.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Review of the Switch 2 move:
- A reader command no longer holds the pads back: the builder answers type 15 at
  once and works the controller's reply out on a thread of the connection's
  (switch2::Asker); the game sends the command, then asks for its answer every
  2 ms, the pads' lock taken only for each message (switch2_command). Tested:
  a two-second answer does not delay a pads exchange.
- game_builder_switch2 says no controller (-2) without the builder's pads, and a
  connection that could not be made is not tried again for a second.
- The driver starts only with an SDL3 that has the gamepads' and the virtual
  joysticks' calls, takes the controller only once SDL's gamepads are started,
  and lets it go when its virtual pad is not taken.
- The reader's allowlist: 0x03, 0x04, 0x05, 0x06 and 0x15 alone (no 0x0c), the
  header's other bytes as nn_nfp.c sends them.
- HOS_SWITCH2 and HOS_SWITCH2_RUMBLE_TEST read by crate::switch, the one parser.
- Docs: nfc.md, sandbox.md (type 15), build.md, frame.rs.
- Nits: the stuck rumble silences a buzz before a click as the C did; the
  generation bumped before the controller is published; one event a thread;
  control::pad_switches; a source check of hos_nfc_scan's gate.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
fix(build): the game's Windows link and the file service's Wine check name WinUSB and HID again
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
beanstalk/approval can't be tested as asked: see the farm's comment
17a3fa3b61
build_core, which the game links, carries the builder's Switch 2 Pro driver: its objects name WinUSB's and HID's calls,
so the game's Windows link and tests/test_builder_files_wine.py's child take -lwinusb and -lhid (and -lsetupapi).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
Author
Owner

Pushed 17a3fa3b (was b78ca2bc), 7 commits on top: the builder serves pads (and the Deck's sensors) to unconfined games too; longshot-builder game runs keep a crash record; the Windows Switch 2 Pro USB driver and its NFC reader moved into the builder; review fixes. Full suite passes (bitg-f4 + bitg-f5).

Pushed 17a3fa3b (was b78ca2bc), 7 commits on top: the builder serves pads (and the Deck's sensors) to unconfined games too; longshot-builder game runs keep a crash record; the Windows Switch 2 Pro USB driver and its NFC reader moved into the builder; review fixes. Full suite passes (bitg-f4 + bitg-f5).
Author
Owner

@Beanstalk please test this PR's head (17a3fa3b) against its base, mod-api:

  1. Windows NVIDIA and Windows AMD, a normal (confined) play: the game starts through the builder, reaches play, saves, changes a setting, takes a screenshot, restarts with and without a rebuild, and starts a second time. Also a run with HOS_CRASH_TEST set: a crash record and minidump are written.
  2. Windows, with HOS_SANDBOX=0: controllers still work (they now come through the builder's pads pipe).
  3. Steam Deck, confined and with HOS_SANDBOX=0: gyro aiming works in both.
@Beanstalk please test this PR's head (17a3fa3b) against its base, mod-api: 1. **Windows NVIDIA and Windows AMD, a normal (confined) play:** the game starts through the builder, reaches play, saves, changes a setting, takes a screenshot, restarts with and without a rebuild, and starts a second time. Also a run with `HOS_CRASH_TEST` set: a crash record and minidump are written. 2. **Windows, with `HOS_SANDBOX=0`:** controllers still work (they now come through the builder's pads pipe). 3. **Steam Deck, confined and with `HOS_SANDBOX=0`:** gyro aiming works in both.
Member

Beanstalk test farm

Commit 96d5bc7 · approved by nobody yet · dashboard

A member of BigBeans can review this commit and comment @Beanstalk to test it.

<!-- beanstalk:sticky --> ### Beanstalk test farm Commit `96d5bc7` · approved by nobody yet · [dashboard](https://beanstalk.magicbean.dev/prs/2898) A member of `BigBeans` can review this commit and comment `@Beanstalk` to test it.
HumanBean force-pushed bitg/builder-is-the-game from 17a3fa3b61
Some checks failed
PR description / Title and description (pull_request_target) Successful in 7s
beanstalk/approval can't be tested as asked: see the farm's comment
to 96d5bc78fc
Some checks are pending
PR description / Title and description (pull_request_target) Successful in 7s
beanstalk/approval not approved yet
2026-11-30 17:12:49 +00:00
Compare
Author
Owner

Rebased onto mod-api 75bcd270 (#2881), no conflicts: was 17a3fa3b, now 96d5bc78. Host compiles on Linux and Windows (llvm-mingw with tools.lock's FFmpeg/dav1d headers), dev.py pack passes, run_all 806 passed / 1 failed: test_lifter's game-sites stress test (retire::tests::many_site_readers...), which this PR doesn't touch and which passed on a rerun before; test_builder_files_wine 27/27.

Rebased onto mod-api 75bcd270 (#2881), no conflicts: was 17a3fa3b, now 96d5bc78. Host compiles on Linux and Windows (llvm-mingw with tools.lock's FFmpeg/dav1d headers), dev.py pack passes, run_all 806 passed / 1 failed: test_lifter's game-sites stress test (retire::tests::many_site_readers...), which this PR doesn't touch and which passed on a rerun before; test_builder_files_wine 27/27.
Author
Owner

Landed on mod-api as 716735d8 (one commit), after its review fixes and one batched build + game run of all six cleanup areas together. mod-api work now goes straight onto the branch once self-reviewed.

Landed on mod-api as 716735d8 (one commit), after its review fixes and one batched build + game run of all six cleanup areas together. mod-api work now goes straight onto the branch once self-reviewed.
HumanBean closed this pull request 2026-11-30 22:34:19 +00:00
Some checks are pending
PR description / Title and description (pull_request_target) Successful in 7s
beanstalk/approval not approved yet

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!2898
No description provided.