refactor(dev)!: dev.py builds runtimes with the builder's dev runtime; smoke, disk and tools commands #2869

Merged
HumanBean merged 5 commits from HumanBean/Longshot:cleanup/area9-dev-tooling into mod-api 2026-11-30 19:24:57 +00:00
Owner

Summary

The development builds had two incremental build systems. The Rust builder is incremental by content: its object
store, the lifts by key, the game's Rust by key, and a shared shader cache. Over it, scripts/devtools/packs.py
(1,328 lines) and build.py kept a second one: a base, packs made of the files that differ from it, and runtimes
assembled from both. To do that, the Python guessed at the builder's insides:

  • the link lists, the sources that carry the version, and which paths reach a link;
  • kProgramCacheFormat, read with a regex;
  • the renderer's cache file names, kept as a copied list.

shadercache.py was a second shared shader cache, with a key of its own. On mod-api nearly every change reaches the
game's Rust, so a pack was the whole module anyway.

This replaces both with one builder command and keeps only the policy in Python.

  • longshot-builder dev runtime <dir> (new, build-driver/src/dev_runtime.rs) has four modes:

    • With --game (a build): it is dev build. Every file whose bytes are the base's (--base) is a hard link of
      the base's file. The install still stages each file and renames it in, so nothing ever writes through a link.
    • Without --game (a copy): a copy of the base. The builder's files are linked, the rest cloned, and the play
      state is left out. It is refreshed in place, and the runtime's settings and env file are kept.
    • --prepare-only: the shaders prepared, only when the caches it has are not known to be this translator's,
      program-cache format's and shader list's.
    • --give-back: what a run added to the runtime's caches goes into the base and the PC's shared cache.
  • The caches:

    • Seeded as copy-on-write clones from the base and from the builder's own shared shader cache
      (<cache>/shaders/<translator>f<format>/<drivers>/).
    • Shared by name from an allowlist, checked against the renderer's source by a test, never its per-folder fault list
      or play markers.
    • Recorded per folder (cache/longshot_runtime_caches.txt).
    • Published back only when a preparation got to its end, never shrinking a file, under the renderer's locks.
  • The build writes program_cache_format= into longshot_version.txt.

  • longshot-builder info lists a new capability, dev_runtime.

  • dev.py:

    • rt: this checkout over the nearest base, in its own warm work folder. Two queue jobs under the base's lock: the
      build (build mode), then --prepare-only (shared mode, the GPU).
    • pack is gone, folded into rt.
    • rt --empty is a copy of the base.
    • ab keeps a runtime that is current.
    • check's builds and its cache harvest use the same steps.
  • dev.py packs base|pack|rt|warm keep the Test Farm's command lines and files:

    • base.json (commit, game_source, upscalers);
    • pack.json (generated, deleted);
    • dev_packs.busy, and the work folders' build_times.json.

    A pack is now a game folder of its own over the base. packs base still refuses a tree with uncommitted sources.

  • dev.py builder -- ARGS replaces packs run; mise run build and build-dev run it. packs head, which
    nothing ran, is gone.

  • New dev.py smoke: one headless queue run of a runtime. It plays from a save, presents 900 frames, opens the
    Insert menu, takes a screenshot and checks the log, then says PASS or FAIL. Every agent here kept its own script for
    this.

  • New dev.py disk [--prune]: what the development data uses on the disk, and what is safe to remove: never a
    store, never a runtime a process uses. It replaces dev.py bases --prune.

  • New dev.py tools, which mise run tools now runs: tools.lock's build tools installed once in the PC's shared
    tools-store, with the checkout's tools/ a link to them. Before, every checkout unpacked its own.

  • Removed: shadercache.py and its test, and about 700 lines of packs.py. packs.py went from 1,328 lines to 629.

Read first:

  • builder/crates/build-driver/src/dev_runtime.rs;
  • folder::install's base argument;
  • scripts/devtools/packs.py;
  • build.py's cmd_rt;
  • docs/dev/reference/build.md, "A runtime for development".

Testing

Tested: Linux (CachyOS), RTX 3090.

  • One build job:

    • this branch's builder compiled;
    • tests/run_all.py;
    • the old flow (mod-api's dev.py pack --own-work + rt) against the new (dev.py rt): a first build, a small C
      change (host/hos_main.c) and a small Rust change (game/crates/longshot-game/src/cheats.rs), over the shared
      base 462919343e, with the same builder program.

    In the new flow, 46 of the runtime's 54 files were hard links of the base's. A C change then put 2 files in and kept
    52, and a Rust change put 1 file in.

  • Then one shared job:

    • dev runtime --prepare-only prepared the new runtime in 97 s and published 7 cache files into the shared cache;
    • dev.py smoke on it: PASS. In play from kokiri-start, 900 frames, the Insert menu opened with its page, no
      FATAL line.
  • Checks:

    • cargo test -p build-driver -p longshot-builder passes (queue);
    • clippy -D warnings is clean;
    • cargo fmt -p is clean for both crates.
  • tests/run_all.py:

    • 734 passed, 2 failed, 114 skipped.
    • test_lifter.py fails on cargo fmt --all --check of game/crates/api/src/services/mod.rs and
      game/crates/game-core/src/nav.rs. Those are mod-api's own (#2745), not touched here, and they fail on mod-api too.
    • test_dev_packs.py failed because the job's LONGSHOT_BUILD leaked into one test. That is fixed here, and the
      test passes with LONGSHOT_BUILD set.
  • The light checks: test_dev_packs, build, ab, check, disk, smoke, game_tests, update, migrate, mise_build,
    job_queue, doc_commands and doc_anchors pass; pre-commit is clean on every changed file.

  • The review's fixes (2d99edab..2006d19c), one build job: cargo fmt --check and clippy -D warnings of
    build-core and build-driver clean; cargo test of dev_runtime 11 passed (new: a unit taken whole and never to shrink
    a cache, a give-back skipping a unit a running game holds); test_dev_smoke, test_dev_disk, test_dev_packs,
    test_doc_anchors and test_doc_commands pass.

  • No host, renderer or other C/C++ file changed, so no llvm-mingw compile was needed.

Still to test:

  • Test Farm (it runs main's packs.py): a run on this branch once it has a base. Expecting packs base, pack pr
    and rt to work as before, with base.json and pack.json read as before (@Beanstalk after the Farm's changes
    in Risks).
  • Windows (dev.py rt, rt --empty): expecting the hard links, the CoW-or-copy clones and dev.py tools'
    junction to work (by hand).
  • This PC (dev.py disk): a real dry run over the development folder. Expecting a listing with sizes and nothing
    removed (by hand).
  • Any GPU (dev.py packs warm and dev.py check): expecting --give-back to copy grown caches back (by hand).

Measurements

Verdict: the tools' own cost per change went from minutes to seconds. A runtime takes no disk beyond its own
files, and the old flow's 1.5 GB per checkout is gone.

Setup:

  • this PC; one queue build job;
  • the same builder program on both sides, LONGSHOT_NO_PREPARE=1;
  • each side run in its own new checkout over the same base;
  • each step's wall time, from its log's timestamps;
  • disk as btrfs exclusive bytes (btrfs filesystem du).
Before: mod-api @ cb37f5ab (dev.py pack --own-work + rt) After: this PR @ dbc97d8b (dev.py rt)
First build in a new checkout 211 s for the pack (the change over the base), plus rt 27 s
Small C change 118 s (pack 32 s, then rt about 86 s) 8 s
Small Rust change 94 s (pack 40 s, then rt about 54 s) 9 s
Disk of the change's own folders 1,534 MB (pack-work.d 1,378, rt 156, the pack 0) 1,151 MB (the work folder; the runtime 0)

Caveat: the new side ran second. It took the objects and the game's Rust for the very same edits from the shared
store, which the old side had just compiled; the old pack's compile was its "done in" (0 to 1 min). So the
like-for-like number is the tooling's cost outside the compile: old rt about 54 to 86 s plus pack overhead, against new
about 8 s in all. A second run with distinct edits per side was not made, to keep to one queue job.

Switches: no new switch. LONGSHOT_JOBS (the builder's compilers at once) is not changed here and ships at its
default, unset: one compiler per CPU thread but one, so the PC stays usable while it builds (the launcher's Automatic
does the same). LONGSHOT_BUILD (a ready-made longshot-builder for dev.py, already on mod-api) is a development
tool's variable, unset by default: each step uses the tree's own builder. Neither is read by the renderer or the host,
so neither has a gpu/vk/switches.def row.

The review's fixes (2d99edab..2006d19c) change no timing: give-back and publish choose and lock differently, smoke and disk
judge differently. Nothing there to measure.

Risks

  • The Test Farm, which must change three things:
    1. It starts <runtime>/longshot directly. On mod-api the game is longshot-game, and only the builder starts it.
    2. Main's packs.py will need each side's builder to have dev runtime. A PR builder from before it exits 2 with
      "older than this dev.py". Check for dev_runtime in longshot-builder info's capabilities.builder, and use an
      older tree's packs.py for such a builder.
    3. A pack is now a whole game folder, packs/<name>/game, whose unchanged files are hard links of the base's; there
      are no loose files over the base any more. pack.json's generated and deleted are always empty.
  • Existing runtimes and bases on this PC keep working (copy and build mode accept folders the old Python made).
    But they hold no program_cache_format= line and no caches note, so:
    • each runtime prepares once, incrementally over its caches, after this lands;
    • an old base gives its runtimes no caches until it is built again with this builder.
  • Removed commands: dev.py pack, packs run (now dev.py builder), packs head and bases --prune (now
    dev.py disk --prune). Scripts calling them get an argparse error.
  • dev.py ab's "current" check does not notice a change to tools.lock or the build tools alone.
  • Players: the only player-visible change is the build's new program_cache_format= line in
    longshot_version.txt. A revert is enough.

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). Run as tests/run_all.py; its one
    failure, test_lifter's cargo fmt --all --check of game/crates/api/src/services/mod.rs and
    game/crates/game-core/src/nav.rs, is mod-api's own (#2745) and fails there too, as Testing says.
  • Measured against main, or Measurements says why there is nothing to measure (against mod-api, this PR's
    base).
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A check under tests/ that reads changed source is updated, not weakened.
  • Docs updated.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

🤖 Generated with Claude Code

https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc

## Summary The development builds had two incremental build systems. The Rust builder is incremental by content: its object store, the lifts by key, the game's Rust by key, and a shared shader cache. Over it, `scripts/devtools/packs.py` (1,328 lines) and `build.py` kept a second one: a base, packs made of the files that differ from it, and runtimes assembled from both. To do that, the Python guessed at the builder's insides: - the link lists, the sources that carry the version, and which paths reach a link; - `kProgramCacheFormat`, read with a regex; - the renderer's cache file names, kept as a copied list. `shadercache.py` was a second shared shader cache, with a key of its own. On mod-api nearly every change reaches the game's Rust, so a pack was the whole module anyway. This replaces both with one builder command and keeps only the policy in Python. - **`longshot-builder dev runtime <dir>`** (new, `build-driver/src/dev_runtime.rs`) has four modes: - **With `--game` (a build):** it is `dev build`. Every file whose bytes are the base's (`--base`) is a hard link of the base's file. The install still stages each file and renames it in, so nothing ever writes through a link. - **Without `--game` (a copy):** a copy of the base. The builder's files are linked, the rest cloned, and the play state is left out. It is refreshed in place, and the runtime's settings and env file are kept. - **`--prepare-only`:** the shaders prepared, only when the caches it has are not known to be this translator's, program-cache format's and shader list's. - **`--give-back`:** what a run added to the runtime's caches goes into the base and the PC's shared cache. - **The caches:** - Seeded as copy-on-write clones from the base and from the builder's own shared shader cache (`<cache>/shaders/<translator>f<format>/<drivers>/`). - Shared by name from an allowlist, checked against the renderer's source by a test, never its per-folder fault list or play markers. - Recorded per folder (`cache/longshot_runtime_caches.txt`). - Published back only when a preparation got to its end, never shrinking a file, under the renderer's locks. - **The build** writes `program_cache_format=` into `longshot_version.txt`. - **`longshot-builder info`** lists a new capability, `dev_runtime`. - **`dev.py`:** - `rt`: this checkout over the nearest base, in its own warm work folder. Two queue jobs under the base's lock: the build (`build` mode), then `--prepare-only` (`shared` mode, the GPU). - `pack` is gone, folded into `rt`. - `rt --empty` is a copy of the base. - `ab` keeps a runtime that is current. - `check`'s builds and its cache harvest use the same steps. - **`dev.py packs base|pack|rt|warm`** keep the Test Farm's command lines and files: - `base.json` (`commit`, `game_source`, `upscalers`); - `pack.json` (`generated`, `deleted`); - `dev_packs.busy`, and the work folders' `build_times.json`. A pack is now a game folder of its own over the base. `packs base` still refuses a tree with uncommitted sources. - **`dev.py builder -- ARGS`** replaces `packs run`; `mise run build` and `build-dev` run it. `packs head`, which nothing ran, is gone. - **New `dev.py smoke`:** one headless queue run of a runtime. It plays from a save, presents 900 frames, opens the Insert menu, takes a screenshot and checks the log, then says PASS or FAIL. Every agent here kept its own script for this. - **New `dev.py disk [--prune]`:** what the development data uses on the disk, and what is safe to remove: never a store, never a runtime a process uses. It replaces `dev.py bases --prune`. - **New `dev.py tools`**, which `mise run tools` now runs: tools.lock's build tools installed once in the PC's shared tools-store, with the checkout's `tools/` a link to them. Before, every checkout unpacked its own. - **Removed:** `shadercache.py` and its test, and about 700 lines of packs.py. packs.py went from 1,328 lines to 629. Read first: - `builder/crates/build-driver/src/dev_runtime.rs`; - `folder::install`'s `base` argument; - `scripts/devtools/packs.py`; - `build.py`'s `cmd_rt`; - docs/dev/reference/build.md, "A runtime for development". ## Testing **Tested:** Linux (CachyOS), RTX 3090. - **One build job:** - this branch's builder compiled; - `tests/run_all.py`; - the old flow (mod-api's `dev.py pack --own-work` + `rt`) against the new (`dev.py rt`): a first build, a small C change (`host/hos_main.c`) and a small Rust change (`game/crates/longshot-game/src/cheats.rs`), over the shared base 462919343ec9, with the same builder program. In the new flow, 46 of the runtime's 54 files were hard links of the base's. A C change then put 2 files in and kept 52, and a Rust change put 1 file in. - **Then one shared job:** - `dev runtime --prepare-only` prepared the new runtime in 97 s and published 7 cache files into the shared cache; - `dev.py smoke` on it: **PASS**. In play from kokiri-start, 900 frames, the Insert menu opened with its page, no FATAL line. - **Checks:** - `cargo test -p build-driver -p longshot-builder` passes (queue); - clippy `-D warnings` is clean; - `cargo fmt -p` is clean for both crates. - **`tests/run_all.py`:** - 734 passed, 2 failed, 114 skipped. - `test_lifter.py` fails on `cargo fmt --all --check` of `game/crates/api/src/services/mod.rs` and `game/crates/game-core/src/nav.rs`. Those are mod-api's own (#2745), not touched here, and they fail on mod-api too. - `test_dev_packs.py` failed because the job's `LONGSHOT_BUILD` leaked into one test. That is fixed here, and the test passes with `LONGSHOT_BUILD` set. - **The light checks:** test_dev_packs, build, ab, check, disk, smoke, game_tests, update, migrate, mise_build, job_queue, doc_commands and doc_anchors pass; pre-commit is clean on every changed file. - **The review's fixes (2d99edab..2006d19c)**, one build job: `cargo fmt --check` and clippy `-D warnings` of build-core and build-driver clean; `cargo test` of `dev_runtime` 11 passed (new: a unit taken whole and never to shrink a cache, a give-back skipping a unit a running game holds); test_dev_smoke, test_dev_disk, test_dev_packs, test_doc_anchors and test_doc_commands pass. - No host, renderer or other C/C++ file changed, so no llvm-mingw compile was needed. **Still to test:** - **Test Farm** (it runs main's `packs.py`): a run on this branch once it has a base. Expecting `packs base`, `pack pr` and `rt` to work as before, with `base.json` and `pack.json` read as before (`@Beanstalk` after the Farm's changes in Risks). - **Windows** (`dev.py rt`, `rt --empty`): expecting the hard links, the CoW-or-copy clones and `dev.py tools`' junction to work (by hand). - **This PC** (`dev.py disk`): a real dry run over the development folder. Expecting a listing with sizes and nothing removed (by hand). - **Any GPU** (`dev.py packs warm` and `dev.py check`): expecting `--give-back` to copy grown caches back (by hand). ## Measurements **Verdict:** the tools' own cost per change went from minutes to seconds. A runtime takes no disk beyond its own files, and the old flow's 1.5 GB per checkout is gone. Setup: - this PC; one queue build job; - the same builder program on both sides, `LONGSHOT_NO_PREPARE=1`; - each side run in its own new checkout over the same base; - each step's wall time, from its log's timestamps; - disk as btrfs exclusive bytes (`btrfs filesystem du`). | | Before: mod-api @ cb37f5ab (`dev.py pack --own-work` + `rt`) | After: this PR @ dbc97d8b (`dev.py rt`) | |---|---|---| | First build in a new checkout | 211 s for the pack (the change over the base), plus rt | 27 s | | Small C change | 118 s (pack 32 s, then rt about 86 s) | 8 s | | Small Rust change | 94 s (pack 40 s, then rt about 54 s) | 9 s | | Disk of the change's own folders | 1,534 MB (pack-work.d 1,378, rt 156, the pack 0) | 1,151 MB (the work folder; the runtime 0) | **Caveat:** the new side ran second. It took the objects and the game's Rust for the very same edits from the shared store, which the old side had just compiled; the old pack's compile was its "done in" (0 to 1 min). So the like-for-like number is the tooling's cost outside the compile: old rt about 54 to 86 s plus pack overhead, against new about 8 s in all. A second run with distinct edits per side was not made, to keep to one queue job. **Switches:** no new switch. `LONGSHOT_JOBS` (the builder's compilers at once) is not changed here and ships at its default, unset: one compiler per CPU thread but one, so the PC stays usable while it builds (the launcher's Automatic does the same). `LONGSHOT_BUILD` (a ready-made `longshot-builder` for dev.py, already on mod-api) is a development tool's variable, unset by default: each step uses the tree's own builder. Neither is read by the renderer or the host, so neither has a `gpu/vk/switches.def` row. **The review's fixes (2d99edab..2006d19c)** change no timing: give-back and publish choose and lock differently, smoke and disk judge differently. Nothing there to measure. ## Risks - **The Test Farm, which must change three things:** 1. It starts `<runtime>/longshot` directly. On mod-api the game is `longshot-game`, and only the builder starts it. 2. Main's `packs.py` will need each side's builder to have `dev runtime`. A PR builder from before it exits 2 with "older than this dev.py". Check for `dev_runtime` in `longshot-builder info`'s `capabilities.builder`, and use an older tree's `packs.py` for such a builder. 3. A pack is now a whole game folder, `packs/<name>/game`, whose unchanged files are hard links of the base's; there are no loose files over the base any more. `pack.json`'s `generated` and `deleted` are always empty. - **Existing runtimes and bases on this PC keep working** (copy and build mode accept folders the old Python made). But they hold no `program_cache_format=` line and no caches note, so: - each runtime prepares once, incrementally over its caches, after this lands; - an old base gives its runtimes no caches until it is built again with this builder. - **Removed commands:** `dev.py pack`, `packs run` (now `dev.py builder`), `packs head` and `bases --prune` (now `dev.py disk --prune`). Scripts calling them get an argparse error. - **`dev.py ab`'s "current" check** does not notice a change to `tools.lock` or the build tools alone. - **Players:** the only player-visible change is the build's new `program_cache_format=` line in `longshot_version.txt`. A revert is enough. ## 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). Run as `tests/run_all.py`; its one failure, `test_lifter`'s `cargo fmt --all --check` of `game/crates/api/src/services/mod.rs` and `game/crates/game-core/src/nav.rs`, is mod-api's own (#2745) and fails there too, as Testing says. - [x] Measured against `main`, or Measurements says why there is nothing to measure (against `mod-api`, this PR's base). - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] Docs updated. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
`longshot-builder dev runtime <dir>` makes the game folder a developer runs, over a base game folder:

- with `--game` it is `dev build`'s build, every file whose bytes are the base's (its install note's SHA-256, its stat
  still the note's) a hard link of the base's file instead of a copy; the install still stages `.new` and renames, so
  a later build never writes through a link;
- before the build its `cache/` gets copy-on-write clones of the base's caches (same translator) and of the builder's
  own shared shader cache (`<cache>/shaders/<translator stamp>/<drivers>/`), another translator's dropped first; it
  prepares only when those are not known to be this translator's or the shader list is not the base's, and publishes what a
  preparation made back into the shared cache;
- without `--game` it is a copy of the base: the builder's files linked, the rest cloned, the play state left out,
  refreshed in place on the next run;
- `--give-back` puts what a run grew in the runtime's caches back into the base's and the shared cache, refused across
  translators or program cache formats;
- `--prepare-only` prepares a runtime's shaders when its caches don't stand for it, nothing built: a GPU job of its own.

A cache file is one of the renderer's shareable caches by name (an allowlist, checked against the renderer's source):
never its per-folder fault list or play markers. The build now writes `program_cache_format=` in longshot_version.txt,
so a format bump drops caches as a translator change does. `longshot-builder info` lists `dev_runtime`.

This is what `dev.py rt` and `dev.py packs` now run instead of their own copy of the build's knowledge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
refactor(dev)!: dev.py builds runtimes with the builder; packs keep only the Test Farm's policy
Some checks failed
PR description / Title and description (pull_request_target) Failing after 7s
dbc97d8b20
`scripts/devtools/packs.py` and `build.py` kept a second incremental build over the builder's, guessing at its
insides (link lists, the stamped sources, which paths reach a link, kProgramCacheFormat by regex, the renderer's cache
names), and `shadercache.py` a second shared shader cache. Both go: every step is one `longshot-builder dev runtime`.

- `dev.py rt` builds this checkout over the nearest base, in its own warm work folder, as a build job, then prepares
  as a shared (GPU) job only when it must, both under the base's lock; `dev.py pack` is gone. `rt --empty` is a copy of
  the base. `dev.py ab` keeps a runtime that is current.
- `dev.py packs base|pack|rt|warm` stay for the Test Farm with the same command lines, `base.json`, `pack.json`
  (`generated`, `deleted`), `dev_packs.busy` and work folders; a pack is now a game folder of its own over the base.
  `packs base` still refuses a tree with uncommitted sources.
- `dev.py builder -- ARGS` (was `packs run`; `mise run build` and `build-dev`); `packs head`, which nothing ran, is gone.
- `dev.py smoke`: does a runtime start and play, in one headless queue run, PASS or FAIL.
- `dev.py disk [--prune]`: what the development data uses on the disk, and what is safe to remove (never a store,
  never a runtime a process uses); it replaces `dev.py bases --prune`.
- `dev.py tools` (`mise run tools`): tools.lock's build tools installed once in the PC's shared tools-store, the
  checkout's `tools/` a link to it.
- `dev.py check`'s builds and harvest use the same builder steps (`--give-back`): no cache names in Python.
- Docs: developing.md's base and runtime part, a smoke run, disk; setup.md, build.md, releases.md, AGENTS.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner
@review
BeanBot left a comment

Recommendation: Request changes. Cache give-back can replace a more complete cache with a smaller one or copy a cache while the game is writing it. The new smoke command can also report PASS without completing its frame wait, and disk pruning can remove an older base still in use.

The change consolidates development runtime builds and shader-cache handling in the builder and adds smoke, disk and shared-tools commands. It reduces duplicated build policy, but introduces cache consistency and cleanup risks that need correction before merge.

Blocking (2): must change before merging.

  1. L3 scripts/devtools/disk.py:272: An older base is marked removable unconditionally, without checking its busy marker, age or runtime references. (more on the line) Do: Apply the same busy, usage and runtime-reference protections to older bases, and do not automatically remove a base still usable by an older checkout.
  2. L5 builder/crates/build-driver/src/dev_runtime.rs:286: This adds unsafe system-call code outside the locations allowed by the repository's builder rules. (more on the line) Do: Move the system call behind a safe interface in an allowed build-core system module, or change the repository rule through the appropriate decision.

Should fix (3): not blocking, but worth doing before merging.

  • L1 builder/crates/build-driver/src/dev_runtime.rs:468: Give-back replaces a base cache whenever the sizes differ, including when the runtime's file is smaller and older. (more on the line) Do: Keep the base file when the candidate is smaller, and transfer related cache files consistently.
  • L2 builder/crates/build-driver/src/dev_runtime.rs:470: Give-back copies renderer caches without taking the renderer's locks; the builder's game-folder lock does not protect files held by a running game. (more on the line) Do: Take the renderer's program-cache lock for the data and index as a unit, and skip or retry while the game holds it. Apply the same paired locking to publication.
  • L4 scripts/devtools/smoke.py:98: The result of the requested frame wait is ignored, so a timeout does not fail the smoke run. (more on the line) Do: Record and require a successful frame-wait reply in the verdict; likewise fail when the requested screenshot cannot be taken.

Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)

  • L6: The claimed incremental-build speedup needs a comparison that does not warm one side with the other side's compiled edits. When: The reported new builds reused the old builds' objects and Rust output, so their wall times cannot establish the gain for an equivalent fresh edit. Do: Run at least two interleaved comparisons per side with distinct equivalent edits, the same starting cache state and hardware, and report build times and disk use.
  • L7: The Windows runtime and shared-tools paths have not been exercised. When: Windows uses hard links, copy fallback and junctions through different platform APIs from the tested Linux path. Do: Run rt, rt --empty and tools on Windows, including a refresh of an existing runtime, and report the result.
  • L8: The Test Farm integration has not been run with the new whole-folder pack format and builder capability. When: The Farm consumes pack metadata and starts runtimes through its own code, which must change alongside this pull request. Do: Run a Farm base, pack and runtime with the companion changes and record the result and merge order.

@fix can do L1, L2, L3, L4 and L5.

Questions (1) (not confirmed from the code; they don't hold the recommendation)

  • Does disk pruning run on systems with restricted access to other users' /proc entries? open_paths silently skips unreadable descriptors, which could make an active folder appear unused.

Checks: Failing on this head, which is behind its base, where it passes: PR description / Title and description (pull_request_target). @rebase (or @fix) brings it up to date and runs it again; not held against it.

More: does it help, other systems, switches, what was read

Does it help: Unproven. The reported single-run comparison shows 118 s versus 8 s for a C edit and 94 s versus 9 s for a Rust edit, but the new side ran second and reused objects compiled by the old side. Repeated, interleaved runs with distinct equivalent edits are needed to establish the gain.

Other systems: The Linux RTX 3090 build and smoke run provide evidence for one runtime path. Windows runtime copying and tools junctions, Test Farm compatibility, and cache give-back after gameplay remain untested. The cache code also runs during parallel check launches and must coordinate with a running renderer.

Switches: No game switch added, changed or removed. The new command options control development tooling.

Reviewed: dbc97d8b20 against cb37f5ab8a: Read the repository instructions, contribution rules, standards and PR template; reviewed the commit log, runtime and folder changes, and relevant build, packs, disk, smoke, check and bridge paths. Skimmed the remaining diffs and tests; did not read every changed code file in full or every documentation and test file.; nothing run (a code review).

Checked and fine:

  • Both commits record AI assistance in their trailers.
  • No changed host or renderer interface requires an API version bump.
  • The reported Linux smoke run reached play and opened the menu.

Testing: No commands from the pull request were run, as requested. The review uses the author's reported checks and Linux run as evidence.

Overlaps and merge order: The description identifies required Test Farm companion changes; their pull request and merge order were not available in the supplied context.


Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** Cache give-back can replace a more complete cache with a smaller one or copy a cache while the game is writing it. The new smoke command can also report PASS without completing its frame wait, and disk pruning can remove an older base still in use. The change consolidates development runtime builds and shader-cache handling in the builder and adds smoke, disk and shared-tools commands. It reduces duplicated build policy, but introduces cache consistency and cleanup risks that need correction before merge. **Blocking (2)**: must change before merging. 1. **L3** `scripts/devtools/disk.py:272`: An older base is marked removable unconditionally, without checking its busy marker, age or runtime references. (more on the line) **Do:** Apply the same busy, usage and runtime-reference protections to older bases, and do not automatically remove a base still usable by an older checkout. 2. **L5** `builder/crates/build-driver/src/dev_runtime.rs:286`: This adds unsafe system-call code outside the locations allowed by the repository's builder rules. (more on the line) **Do:** Move the system call behind a safe interface in an allowed build-core system module, or change the repository rule through the appropriate decision. **Should fix (3)**: not blocking, but worth doing before merging. - **L1** `builder/crates/build-driver/src/dev_runtime.rs:468`: Give-back replaces a base cache whenever the sizes differ, including when the runtime's file is smaller and older. (more on the line) **Do:** Keep the base file when the candidate is smaller, and transfer related cache files consistently. - **L2** `builder/crates/build-driver/src/dev_runtime.rs:470`: Give-back copies renderer caches without taking the renderer's locks; the builder's game-folder lock does not protect files held by a running game. (more on the line) **Do:** Take the renderer's program-cache lock for the data and index as a unit, and skip or retry while the game holds it. Apply the same paired locking to publication. - **L4** `scripts/devtools/smoke.py:98`: The result of the requested frame wait is ignored, so a timeout does not fail the smoke run. (more on the line) **Do:** Record and require a successful frame-wait reply in the verdict; likewise fail when the requested screenshot cannot be taken. **Testing before merging (3)** (runs on the systems it can change; it doesn't hold the recommendation) - **L6**: The claimed incremental-build speedup needs a comparison that does not warm one side with the other side's compiled edits. *When:* The reported new builds reused the old builds' objects and Rust output, so their wall times cannot establish the gain for an equivalent fresh edit. **Do:** Run at least two interleaved comparisons per side with distinct equivalent edits, the same starting cache state and hardware, and report build times and disk use. - **L7**: The Windows runtime and shared-tools paths have not been exercised. *When:* Windows uses hard links, copy fallback and junctions through different platform APIs from the tested Linux path. **Do:** Run rt, rt --empty and tools on Windows, including a refresh of an existing runtime, and report the result. - **L8**: The Test Farm integration has not been run with the new whole-folder pack format and builder capability. *When:* The Farm consumes pack metadata and starts runtimes through its own code, which must change alongside this pull request. **Do:** Run a Farm base, pack and runtime with the companion changes and record the result and merge order. `@fix` can do L1, L2, L3, L4 and L5. **Questions (1)** (not confirmed from the code; they don't hold the recommendation) - Does disk pruning run on systems with restricted access to other users' /proc entries? open_paths silently skips unreadable descriptors, which could make an active folder appear unused. **Checks:** Failing on this head, which is behind its base, where it passes: `PR description / Title and description (pull_request_target)`. `@rebase` (or `@fix`) brings it up to date and runs it again; not held against it. <details> <summary>More: does it help, other systems, switches, what was read</summary> **Does it help:** Unproven. The reported single-run comparison shows 118 s versus 8 s for a C edit and 94 s versus 9 s for a Rust edit, but the new side ran second and reused objects compiled by the old side. Repeated, interleaved runs with distinct equivalent edits are needed to establish the gain. **Other systems:** The Linux RTX 3090 build and smoke run provide evidence for one runtime path. Windows runtime copying and tools junctions, Test Farm compatibility, and cache give-back after gameplay remain untested. The cache code also runs during parallel check launches and must coordinate with a running renderer. **Switches:** No game switch added, changed or removed. The new command options control development tooling. **Reviewed:** dbc97d8b202b against cb37f5ab8a63: Read the repository instructions, contribution rules, standards and PR template; reviewed the commit log, runtime and folder changes, and relevant build, packs, disk, smoke, check and bridge paths. Skimmed the remaining diffs and tests; did not read every changed code file in full or every documentation and test file.; nothing run (a code review). **Checked and fine:** - Both commits record AI assistance in their trailers. - No changed host or renderer interface requires an API version bump. - The reported Linux smoke run reached play and opened the menu. **Testing:** No commands from the pull request were run, as requested. The review uses the author's reported checks and Linux run as evidence. **Overlaps and merge order:** The description identifies required Test Farm companion changes; their pull request and merge order were not available in the supplied context. </details> --- <sub>Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.</sub>
@ -0,0 +283,4 @@
fn reflink(from: &File, to: &File) -> bool {
use std::os::fd::AsRawFd;
// SAFETY: both are open files of this process; FICLONE reads the source's descriptor and nothing else.
unsafe { libc::ioctl(to.as_raw_fd(), libc::FICLONE, from.as_raw_fd()) == 0 }
Member

L5 (blocking): This adds unsafe system-call code outside the locations allowed by the repository's builder rules.

When: The Linux reflink path permits unsafe code in build-driver, although the standards restrict such code to the named system-call modules.

Do: Move the system call behind a safe interface in an allowed build-core system module, or change the repository rule through the appropriate decision.

**L5** (blocking): This adds unsafe system-call code outside the locations allowed by the repository's builder rules. *When:* The Linux reflink path permits unsafe code in build-driver, although the standards restrict such code to the named system-call modules. **Do:** Move the system call behind a safe interface in an allowed build-core system module, or change the repository rule through the appropriate decision.
@ -0,0 +465,4 @@
let theirs = cache_files(&to);
let mut given = Vec::new();
for (name, (size, time)) in cache_files(&from) {
let newer = theirs.get(&name).is_none_or(|&(s, t)| s != size || time > t);
Member

L1 (should fix): Give-back replaces a base cache whenever the sizes differ, including when the runtime's file is smaller and older.

When: Two check launches start from the same cache. After the first gives back a larger cache, the second gives back its smaller cache: the size inequality replaces the larger file and loses the first launch's cached work.

Do: Keep the base file when the candidate is smaller, and transfer related cache files consistently.

**L1** (should fix): Give-back replaces a base cache whenever the sizes differ, including when the runtime's file is smaller and older. *When:* Two check launches start from the same cache. After the first gives back a larger cache, the second gives back its smaller cache: the size inequality replaces the larger file and loses the first launch's cached work. **Do:** Keep the base file when the candidate is smaller, and transfer related cache files consistently.
@ -0,0 +467,4 @@
for (name, (size, time)) in cache_files(&from) {
let newer = theirs.get(&name).is_none_or(|&(s, t)| s != size || time > t);
if newer {
clone_file(&from.join(&name), &to.join(&name)).at(to.join(&name))?;
Member

L2 (should fix): Give-back copies renderer caches without taking the renderer's locks; the builder's game-folder lock does not protect files held by a running game.

When: The check warm-up calls harvest while its first game is still running. Give-back can clone its program data or index while the renderer appends to them, leaving the build with an inconsistent cache for later launches.

Do: Take the renderer's program-cache lock for the data and index as a unit, and skip or retry while the game holds it. Apply the same paired locking to publication.

**L2** (should fix): Give-back copies renderer caches without taking the renderer's locks; the builder's game-folder lock does not protect files held by a running game. *When:* The check warm-up calls harvest while its first game is still running. Give-back can clone its program data or index while the renderer appends to them, leaving the build with an inconsistent cache for later launches. **Do:** Take the renderer's program-cache lock for the data and index as a unit, and skip or retry while the game holds it. Apply the same paired locking to publication.
@ -0,0 +269,4 @@
out.append((e, "nothing this dev.py reads, and unused for %s: %s" % (ago, e["what"])))
elif e["kind"] == "base":
b = e["base"]
if "game_source" not in b:
Member

L3 (blocking): An older base is marked removable unconditionally, without checking its busy marker, age or runtime references.

When: An older checkout is building or using a base whose base.json lacks game_source. A disk prune from this checkout selects that base and can delete it despite the older tools still using it.

Do: Apply the same busy, usage and runtime-reference protections to older bases, and do not automatically remove a base still usable by an older checkout.

**L3** (blocking): An older base is marked removable unconditionally, without checking its busy marker, age or runtime references. *When:* An older checkout is building or using a base whose base.json lacks game_source. A disk prune from this checkout selects that base and can delete it despite the older tools still using it. **Do:** Apply the same busy, usage and runtime-reference protections to older bases, and do not automatically remove a base still usable by an older checkout.
@ -0,0 +95,4 @@
return None
in_play = ask("wait", timeout=plan["timeout"], event="in_play") is not None
if in_play:
ask("wait", timeout=plan["frames"] / 10, event="present", frames=plan["frames"])
Member

L4 (should fix): The result of the requested frame wait is ignored, so a timeout does not fail the smoke run.

When: The game reaches play but does not present the requested 900 frames within the wait. If its subsequent status still says play and the menu opens, the command reports PASS despite not completing the advertised check.

Do: Record and require a successful frame-wait reply in the verdict; likewise fail when the requested screenshot cannot be taken.

**L4** (should fix): The result of the requested frame wait is ignored, so a timeout does not fail the smoke run. *When:* The game reaches play but does not present the requested 900 frames within the wait. If its subsequent status still says play and the menu opens, the command reports PASS despite not completing the advertised check. **Do:** Record and require a successful frame-wait reply in the verdict; likewise fail when the requested screenshot cannot be taken.
Review of #2869:
- dev runtime --give-back and publish compare a cache unit (an index with its
  data) and take it whole only when no file of it would shrink, under the
  renderer's lock of the unit (<data>.lock) on both sides; a held unit is
  skipped and said. Before, give-back replaced a file of any other size and
  publish locked an index under a lock file the renderer never makes.
- reflink (FICLONE) moved into build-core's sys.rs, the builder's place for
  system calls.
- dev.py smoke fails when the frame wait or the screenshot does not answer.
- dev.py disk removes an older dev.py's base only by a base's rules (unused
  for the days, not busy, named by no runtime) and when no process has it open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(builder): reflink reached through fsx (sys stays private)
Some checks failed
PR description / Title and description (pull_request_target) Failing after 6s
2006d19c39
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

Thanks. Fixed in 2d99edab..2006d19c: give-back and publish now take a cache unit (an index with its data) whole, never to shrink a file, under the renderer's <data>.lock on both sides, skipping what a running game holds (L1, L2); the FICLONE call moved into build-core's sys.rs, reached through fsx::reflink (L5); dev.py smoke fails when the frame wait or the screenshot does not answer (L4); dev.py disk removes an older dev.py's base only by a base's rules and when no process has it open (L3).
L6 (an interleaved re-measure) and L7 (Windows) stay in Still to test: the Measurements caveat says why the gain is read as the tooling's cost outside the compile.

Thanks. Fixed in 2d99edab..2006d19c: give-back and publish now take a cache unit (an index with its data) whole, never to shrink a file, under the renderer's `<data>.lock` on both sides, skipping what a running game holds (L1, L2); the FICLONE call moved into build-core's `sys.rs`, reached through `fsx::reflink` (L5); `dev.py smoke` fails when the frame wait or the screenshot does not answer (L4); `dev.py disk` removes an older dev.py's base only by a base's rules and when no process has it open (L3). L6 (an interleaved re-measure) and L7 (Windows) stay in Still to test: the Measurements caveat says why the gain is read as the tooling's cost outside the compile.
HumanBean merged commit 203c476072 into mod-api 2026-11-30 19:24:57 +00:00
HumanBean deleted branch cleanup/area9-dev-tooling 2026-11-30 19:25:01 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 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!2869
No description provided.