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

Open
github-bot wants to merge 4 commits from github-bot/gh-589 into main AGit
Owner

@⁠oxybes on GitHub · 2026-12-04 08:48 UTC · original
oxybes:pr/profile-hardening → main · +1372 −158 · 10 files · 4 commits · draft

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.
**@⁠oxybes** on GitHub · 2026-12-04 08:48 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/589) `oxybes:pr/profile-hardening` → `main` · +1372 −158 · 10 files · 4 commits · draft 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.
Installing a title profile wrote its tables into the live folder before
profile.toml, and the launcher's BCPack fallback copy after it, so an
interrupted install could leave one download's profile beside another's
tables. The install now stages every file in `<folder>.new-<pid>` beside
the folder, renames the previous folder to `<folder>.old-<pid>`, renames
the new one into place and deletes the old one; a failure before the swap
removes the staging folder and leaves the previous install untouched.
The swap is two renames, not one: between them the folder is absent, and
a failed swap that cannot put the previous folder back leaves it beside
the target, where the next install removes it. `install_file_then` lets
the launcher write its `bcpack-tables.bin` into the same staged folder,
so it is swapped in with the rest.

Table files were read whole, before any validation, so a multi-GB
`bcpack*.bin` beside the executable or an oversized pipelines table was
allocated at start. Every table file must now be a plain file of at most
256 MiB (`victory_profile::MAX_TABLE_SIZE`), checked from its metadata;
hashing is streamed with `blake3::Hasher::update_reader`, and an install
copies instead of reading into memory, then hashes the copy so a file
replaced after validation is not installed. A BCPack table file must be
exactly `TABLES_SIZE` bytes (`Profile::table_exact`). One table candidate
that cannot be read (a folder, an over-cap file) no longer ends the
search: the reason is kept and said if nothing loads. `victory warm`
refuses a `VICTORY_PIPELINE_LIST` over `known::MAX_LIST` (256 MiB) and
`Seed::open` (now returning `io::Result`) refuses a list over it.

Tests: install over an existing install with a damaged table and with a
failing `fill`, a folder an earlier install left beside the target, an
over-cap table (optional left out, required refuses, status names the
reason), a wrong-size BCPack table file, a non-file candidate passed by,
and the happy path with `status` loading its tables. Caps and the swap
are documented in docs/title-profile-format.md.
A profile can name no shader for a role the engine asks for while the
title runs, and nothing said so: the feature was simply off (the
character lost its face for want of `face_shapes`). victory-profile now
keeps the list of those roles with what each costs
(`LOAD_BEARING_ROLES`, 14 roles; the translator's roles are switches by
design except `lds_unbounded`, `pass.*` feeds a census, and
`early_pipeline`/`cull_census` are read by nothing). `victory
title-profile install` prints one line per empty role and refuses the
install, leaving the installed folder untouched and exiting non-zero,
unless `--allow-empty-roles` is given. The launcher's `roles=<n>/<N>`
counts against that list rather than every role the engine knows, the
run line does the same, and a run names the empty ones at info once.

The installed profile is 13/14: it names no `lds_unbounded` shader, so a
fresh install of it now needs the flag or that role.

Parser hardening: `name_len` under 3 and the FNV-1a of the empty name are
refused (a length of 0 matched the CS_ prefix of every program);
VICTORY_PROFILE_ANY_EXE takes 0/off/false/no in any case; a [[place]]
offset is checked against the image's size where it is read
(`Profile::place_within`), so a garbled one is not read past it; and
BCPack's `Reader` takes bytes with `get(..)` and returns its `Error`
instead of panicking on a short table.

Public additions: `LOAD_BEARING_ROLES`, `empty_load_bearing`,
`named_load_bearing`, `Refused::EmptyRoles`, `Profile::place_within`,
`install_file_with`, `install_file_then_with`; `install_file` and
`install_file_then` keep their signatures and now refuse empty roles.

Tests: 35 in victory-profile (a name of length 0 or the empty name's
hash, ANY_EXE=off, a place past the image, the install refusal and the
flag), 47 in victory-formats (a short table is an error), 649 in
victory-gpu --lib, 6 in the app's title_profile (the run line counts
roles against the list). A real profile with face_shapes removed is
refused with exit 1 and its install untouched (same SHA-256, status
13/14); with the flag it installs into a scratch LOCALAPPDATA and loads
there at 12/14.
The roles the engine reads at run time are now two lists. REFUSE_EMPTY_ROLES (12 roles) stops an install without --allow-empty-roles; REPORT_ONLY_ROLES (lds_unbounded, probe_ray_activation) is named at install and at run with its cost and the install goes on. roles=<n>/<N> still counts both lists (14), and the role check now runs after table validation, so a broken table is refused as a broken table.

Every install refusal now exits 1 (a successful install and status stay 0). frame_rate::settings_snapshot checks the settings root, vtable slot, method and offset (sane ranges and checked adds) before using them as addresses, so a garbled profile cannot produce an arbitrary read or a wrapped offset.

Tests: the two role lists are asserted by literal name; a report-only-only profile installs without a flag; the bcpack short-read test drives Reader for u8/u16/u32/bytes instead of a size-checked truncation; and the settings place test lays out an object in memory and rejects each garbled field. Docs and commands usage match the split and the 14-role denominator.
A name_len of 3 is the CS_ prefix itself, whose FNV matches every compute program; require more than 3. Correct lds_unbounded and probe_ray_activation costs, guard the settings offset addition, and make the role-list test assert disjointness.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 08:52:23 +00:00
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/589/head:github-bot/gh-589'
git switch 'github-bot/gh-589'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-589'
git switch 'github-bot/gh-589'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-589'
git switch 'github-bot/gh-589'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-589'
git switch 'main'
git merge --squash 'github-bot/gh-589'
git switch 'main'
git merge --ff-only 'github-bot/gh-589'
git switch 'main'
git merge 'github-bot/gh-589'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.