Title profile: refuse empty roles the engine reads, cap table reads, install whole #589

Open
oxybes wants to merge 4 commits from upstream-pr/589 into main
oxybes commented 2026-12-04 08:48:35 +00:00 (Migrated from github.com)

Imported from readmet3xt-lab/foxhound. Originally posted by oxybes on 2026-12-04T08:48:35Z.


Three problems a title profile can hand a run silently. Each is fixed here with a test; no behaviour changes for a profile that names every role it needs.

1. An empty role is silent

A profile that names no shader for a role the engine reads at run time (bake, bake_geometry, face_shapes, interface_composite, scene_input, leave_out, rt_resolve, ambient.*, water.leave_out) simply makes plays() return false everywhere. Nothing is logged, and roles=<n> counts declared entries, not the ones that matter.

We lost a character's blend-shape pass for a whole scene this way: roles=13/22 was printed, the pipeline was never waited for at its first use, the once-only dispatch was dropped and the face stayed missing for the session. It took reading the pipeline logs to find it.

victory title-profile install now prints one line per empty load-bearing role, with what it costs, and refuses unless --allow-empty-roles is passed. lds_unbounded and probe_ray_activation are reported but never refuse: their absence keeps the conservative behaviour (shared-memory bounds checks; the activation pass running), and the first one's program hashes are private to a profile we do not have.

The status/run line reports roles=<n>/<N> with N from the same list, and a run names the empty ones once at info. tables=, file= and the field order are unchanged, so the launcher and scripts keep parsing it.

2. Install is not atomic

Table files were written into the live install folder before profile.toml, so an interrupted install (a full disk, a locked file, a refused table) left the previous profile next to replaced table bytes; the next start refused a table and the feature it needed was off.

Install now validates everything, stages into <target>.new-<pid> on the same volume, re-hashes each staged table (the hash used to be taken before the copy, so a file swapped in between would install unchecked), then swaps by rename: <target> -> <target>.old-<pid>, staged -> <target>, delete the old. A failure before the swap removes the staged folder and leaves the previous install whole; a failed final rename puts the old folder back (tried twice, error names both paths). <name>.new-<pid> and <name>.old-<pid> are excluded from the profile search, and leftovers of other pids are removed at the next install.

3. Table reads have no cap

A multi-gigabyte bcpack*.bin beside the executable, or an oversized pipelines table, was read whole at start or during warm, twice.

Table lookups now check metadata first (a plain file, at most 256 MiB; the bcpack table exactly TABLES_SIZE), hash with a streamed reader, and name the reason when a candidate is passed over. VICTORY_PIPELINE_LIST and Seed::open check a list against the same cap.

Also in this PR

  • name_len of 3 is refused. Three bytes is exactly the CS_ prefix and the role search hashes name_len bytes from that position, so name_len = 3 with the FNV of CS_ (0b424019aa0d5a04) matched every compute program. The empty name's FNV stays refused.
  • VICTORY_PROFILE_ANY_EXE accepts 0, off, false, no in any case, not just the literal 0.
  • [[place]] offsets are bounds-checked with checked_add against the image, and the settings places (root, slot, method, offset) are validated before pointer arithmetic, so a garbled profile cannot read out of bounds even in a diagnostics build.
  • The bcpack table reader returns its Error instead of panicking on a short file.

Testing

  • cargo test -p victory-profile: 37 tests, including the role lists asserted by literal name and for disjointness, a report-only role installing, an empty load-bearing role refusing, a failed fill leaving the previous install whole, and over-cap and wrong-size tables refused before they are read.
  • cargo test -p victory-gpu --lib: 649 (the pipelines list cap).
  • cargo test -p victory-formats: 47 (a short table is an error, not a panic).
  • cargo test -p victory-loader frame_rate::: a garbled settings place is not read.
  • A real install/status cycle, then a copy of the profile with face_shapes removed: refuses, exit 1, and the installed profile is byte-identical afterwards.

Compatibility

  • title-profile install now exits 1 on a refusal; it used to return 0 for most of them, which made "installed" and "refused" indistinguishable to a script.
  • Report::missing_tables gains the file and a reason (tables=missing:pipelines(over-cap)); the field still starts with tables=.
  • Seed::open returns io::Result; its only caller in the tree is warm.
  • No format change: a profile that names all the roles installs exactly as before.
<!-- greyfinch-sync:readmet3xt-lab/foxhound:issue:5643332479 --> Imported from [readmet3xt-lab/foxhound](https://github.com/readmet3xt-lab/foxhound/pull/589). Originally posted by [oxybes](https://github.com/oxybes) on 2026-12-04T08:48:35Z. --- Three problems a title profile can hand a run silently. Each is fixed here with a test; no behaviour changes for a profile that names every role it needs. ## 1. An empty role is silent A profile that names no shader for a role the engine reads at run time (`bake`, `bake_geometry`, `face_shapes`, `interface_composite`, `scene_input`, `leave_out`, `rt_resolve`, `ambient.*`, `water.leave_out`) simply makes `plays()` return false everywhere. Nothing is logged, and `roles=<n>` counts declared entries, not the ones that matter. We lost a character's blend-shape pass for a whole scene this way: `roles=13/22` was printed, the pipeline was never waited for at its first use, the once-only dispatch was dropped and the face stayed missing for the session. It took reading the pipeline logs to find it. `victory title-profile install` now prints one line per empty load-bearing role, with what it costs, and refuses unless `--allow-empty-roles` is passed. `lds_unbounded` and `probe_ray_activation` are reported but never refuse: their absence keeps the conservative behaviour (shared-memory bounds checks; the activation pass running), and the first one's program hashes are private to a profile we do not have. The status/run line reports `roles=<n>/<N>` with `N` from the same list, and a run names the empty ones once at `info`. `tables=`, `file=` and the field order are unchanged, so the launcher and scripts keep parsing it. ## 2. Install is not atomic Table files were written into the live install folder before `profile.toml`, so an interrupted install (a full disk, a locked file, a refused table) left the previous profile next to replaced table bytes; the next start refused a table and the feature it needed was off. Install now validates everything, stages into `<target>.new-<pid>` on the same volume, re-hashes each staged table (the hash used to be taken before the copy, so a file swapped in between would install unchecked), then swaps by rename: `<target>` -> `<target>.old-<pid>`, staged -> `<target>`, delete the old. A failure before the swap removes the staged folder and leaves the previous install whole; a failed final rename puts the old folder back (tried twice, error names both paths). `<name>.new-<pid>` and `<name>.old-<pid>` are excluded from the profile search, and leftovers of other pids are removed at the next install. ## 3. Table reads have no cap A multi-gigabyte `bcpack*.bin` beside the executable, or an oversized `pipelines` table, was read whole at start or during warm, twice. Table lookups now check metadata first (a plain file, at most 256 MiB; the bcpack table exactly `TABLES_SIZE`), hash with a streamed reader, and name the reason when a candidate is passed over. `VICTORY_PIPELINE_LIST` and `Seed::open` check a list against the same cap. ## Also in this PR - `name_len` of 3 is refused. Three bytes is exactly the `CS_` prefix and the role search hashes `name_len` bytes from that position, so `name_len = 3` with the FNV of `CS_` (`0b424019aa0d5a04`) matched every compute program. The empty name's FNV stays refused. - `VICTORY_PROFILE_ANY_EXE` accepts `0`, `off`, `false`, `no` in any case, not just the literal `0`. - `[[place]]` offsets are bounds-checked with `checked_add` against the image, and the settings places (`root`, `slot`, `method`, `offset`) are validated before pointer arithmetic, so a garbled profile cannot read out of bounds even in a diagnostics build. - The bcpack table reader returns its `Error` instead of panicking on a short file. ## Testing - `cargo test -p victory-profile`: 37 tests, including the role lists asserted by literal name and for disjointness, a report-only role installing, an empty load-bearing role refusing, a failed `fill` leaving the previous install whole, and over-cap and wrong-size tables refused before they are read. - `cargo test -p victory-gpu --lib`: 649 (the pipelines list cap). - `cargo test -p victory-formats`: 47 (a short table is an error, not a panic). - `cargo test -p victory-loader frame_rate::`: a garbled settings place is not read. - A real install/status cycle, then a copy of the profile with `face_shapes` removed: refuses, exit 1, and the installed profile is byte-identical afterwards. ## Compatibility - `title-profile install` now exits 1 on a refusal; it used to return 0 for most of them, which made "installed" and "refused" indistinguishable to a script. - `Report::missing_tables` gains the file and a reason (`tables=missing:pipelines(over-cap)`); the field still starts with `tables=`. - `Seed::open` returns `io::Result`; its only caller in the tree is `warm`. - No format change: a profile that names all the roles installs exactly as before.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/589:upstream-pr/589'
git switch 'upstream-pr/589'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/589'
git switch 'upstream-pr/589'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/589'
git switch 'upstream-pr/589'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/589'
git switch 'main'
git merge --squash 'upstream-pr/589'
git switch 'main'
git merge --ff-only 'upstream-pr/589'
git switch 'main'
git merge 'upstream-pr/589'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
readmet3xt-lab/foxhound!589
No description provided.