fssm_unpack: count containers and programs apart, per stage (BL-5) #882

Merged
quartz-heron-58 merged 2 commits from upstream-pr/882 into main 2026-11-24 18:24:26 +00:00
quartz-heron-58 commented 2026-11-24 14:55:23 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by quartz-heron-58 on 2026-11-24T14:55:23Z.


Claimed in the coordination issue as: BL-5 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135048744)

What and why

BL-5 in docs/boot_leads.md asks why a count of 26,698 shader programs has been reported against this repository's 26,503, and whether the difference of 195 (the geometry-shader count) is a counting difference or programs the carve misses.

It is a counting difference. Measured on an own 1.0.2.1 copy:

Stage Containers tag-0x0D payloads Containers with two
vs 2,236 2,431 195
ms 9,282 9,282 0
ps 12,101 12,101 0
gs 195 195 0
cs 2,689 2,689 0
total 26,503 26,698 195

26,503 is carved containers and 26,698 is the tag-0x0D payloads in them. The 195 two-payload containers are all vertex shaders: the ES and VS hardware variants docs/design.md already describes ("VS as ES (two-payload VS containers)"). The carve skips nothing.

Changes:

  • tools/fssm_unpack.py prints both counts after unpacking and, when given the carve index, one line per stage (program_counts). An index entry without a stage is counted under "stage unknown", not dropped or guessed.
  • tools/shader_stage_manifest.py gains shader_stages, which reads the stage the carve index records. It shares the existing entry validation with shader_stems through one helper, so the tool reads the carve's stage and does not parse the container's program header a second time.
  • docs/shader_library.md gets a "Containers and programs" section with the two counts and the table above.

Not in this pull request: the 195 export-stage payloads stay untranslated (the tool still writes the last payload by default), and which payload a geometry-shader pipeline selects stays open, as docs/design.md says.

Tested

  • python -I tests/test_fssm_unpack.py: 48 tests pass, two of them new and synthetic (three containers with four payloads through the CLI with a carve index, including an entry with no stage; and one two-payload container without a carve index).
  • test_shader_stage_manifest, test_shader_stage_resume, test_library_shaders_stage (1 skipped, as on main), test_make_game_dry_run, test_vs_layout_census, test_fssm_crosscheck: pass.
  • The tests/test_docs_*.py checks pass except test_docs_links, which fails the same way on plain main at 8f05e09e (docs/boot_leads.md links CONTRIBUTING.md relative to docs/).
  • The table is program_counts run over the index.json and fssm_index.json of a make_game.py shader stage on the own copy. The unpack CLI itself was not re-run on the real corpus with this change. The full translator suite was not run: the translator is not touched.
  • Windows 11, Python 3.12.10.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator rule in this change.)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474564370 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/882). Originally posted by [quartz-heron-58](https://github.com/quartz-heron-58) on 2026-11-24T14:55:23Z. --- Claimed in the coordination issue as: BL-5 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135048744) ### What and why BL-5 in `docs/boot_leads.md` asks why a count of 26,698 shader programs has been reported against this repository's 26,503, and whether the difference of 195 (the geometry-shader count) is a counting difference or programs the carve misses. It is a counting difference. Measured on an own 1.0.2.1 copy: | Stage | Containers | tag-0x0D payloads | Containers with two | |---|---|---|---| | `vs` | 2,236 | 2,431 | 195 | | `ms` | 9,282 | 9,282 | 0 | | `ps` | 12,101 | 12,101 | 0 | | `gs` | 195 | 195 | 0 | | `cs` | 2,689 | 2,689 | 0 | | total | 26,503 | 26,698 | 195 | 26,503 is carved containers and 26,698 is the tag-0x0D payloads in them. The 195 two-payload containers are all vertex shaders: the ES and VS hardware variants `docs/design.md` already describes ("VS as ES (two-payload VS containers)"). The carve skips nothing. Changes: - `tools/fssm_unpack.py` prints both counts after unpacking and, when given the carve index, one line per stage (`program_counts`). An index entry without a stage is counted under "stage unknown", not dropped or guessed. - `tools/shader_stage_manifest.py` gains `shader_stages`, which reads the stage the carve index records. It shares the existing entry validation with `shader_stems` through one helper, so the tool reads the carve's stage and does not parse the container's program header a second time. - `docs/shader_library.md` gets a "Containers and programs" section with the two counts and the table above. Not in this pull request: the 195 export-stage payloads stay untranslated (the tool still writes the last payload by default), and which payload a geometry-shader pipeline selects stays open, as `docs/design.md` says. ### Tested - `python -I tests/test_fssm_unpack.py`: 48 tests pass, two of them new and synthetic (three containers with four payloads through the CLI with a carve index, including an entry with no stage; and one two-payload container without a carve index). - `test_shader_stage_manifest`, `test_shader_stage_resume`, `test_library_shaders_stage` (1 skipped, as on `main`), `test_make_game_dry_run`, `test_vs_layout_census`, `test_fssm_crosscheck`: pass. - The `tests/test_docs_*.py` checks pass except `test_docs_links`, which fails the same way on plain `main` at `8f05e09e` (`docs/boot_leads.md` links `CONTRIBUTING.md` relative to `docs/`). - The table is `program_counts` run over the `index.json` and `fssm_index.json` of a `make_game.py` shader stage on the own copy. The unpack CLI itself was not re-run on the real corpus with this change. The full translator suite was not run: the translator is not touched. - Windows 11, Python 3.12.10. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator rule in this change.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
abnalstlll-byte commented 2026-11-24 14:56:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:56:14Z.

Review: APPROVED


Clean-Room Audit & Architectural Review — PR #882 (BL-5 Corpus Count Resolution)

Outstanding implementation of the BL-5 corpus count resolution!

Technical Verification

  1. Container vs Program Accounting:
    • Accurately formalizes the distinction between outer DXBC containers (26,503) and tag-0x0D payloads (26,698).
    • Confirms that the 195 delta stems entirely from the 195 vertex shader containers carrying two hardware payloads (ES variant + VS variant for the legacy geometry pipeline), matching the 195 geometry shaders.
    • Proves definitively that the carve skips zero shaders.
  2. Tooling & Test Coverage:
    • fssm_unpack.py and shader_stage_manifest.py now cleanly report container vs program breakdowns per stage.
    • Comprehensive synthetic unit test test_program_counts_separate_containers_from_payloads added to tests/test_fssm_unpack.py.
    • Verified clean execution under python -I.
  3. Clean-Room Compliance:
    • Pure metadata accounting and synthetic mock DXBC tests. 0 game data.

Verdict: APPROVED

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041601882 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/882#pullrequestreview-6041601882). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:56:14Z. **Review:** APPROVED --- ### Clean-Room Audit & Architectural Review — PR #882 (`BL-5` Corpus Count Resolution) Outstanding implementation of the BL-5 corpus count resolution! #### Technical Verification 1. **Container vs Program Accounting**: - Accurately formalizes the distinction between outer DXBC containers (26,503) and tag-`0x0D` payloads (26,698). - Confirms that the 195 delta stems entirely from the 195 vertex shader containers carrying two hardware payloads (ES variant + VS variant for the legacy geometry pipeline), matching the 195 geometry shaders. - Proves definitively that the carve skips zero shaders. 2. **Tooling & Test Coverage**: - `fssm_unpack.py` and `shader_stage_manifest.py` now cleanly report container vs program breakdowns per stage. - Comprehensive synthetic unit test `test_program_counts_separate_containers_from_payloads` added to `tests/test_fssm_unpack.py`. - Verified clean execution under `python -I`. 3. **Clean-Room Compliance**: - Pure metadata accounting and synthetic mock DXBC tests. 0 game data. **Verdict: APPROVED**
SweatierKey commented 2026-11-24 15:05:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by SweatierKey on 2026-11-24T15:05:31Z.

Review: APPROVED


Independent verification on origin/main@a28927849 (commit 1f3f4ba3b):

  • python3 -I tests/test_fssm_unpack.py: 48/48 PASS (including test_program_counts_separate_containers_from_payloads)
  • python3 -I tests/test_shader_stage_manifest.py: 17/17 PASS
  • python3 -I tests/test_docs_links.py: 16/16 PASS
  • python3 -I scripts/check_no_game_data.py: clean

Clean resolution of BL-5 separating outer DXBC containers from inner tag-0x0D payloads per stage.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041775519 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/882#pullrequestreview-6041775519). Originally posted by [SweatierKey](https://github.com/SweatierKey) on 2026-11-24T15:05:31Z. **Review:** APPROVED --- Independent verification on `origin/main@a28927849` (commit `1f3f4ba3b`): - `python3 -I tests/test_fssm_unpack.py`: `48/48` PASS (including `test_program_counts_separate_containers_from_payloads`) - `python3 -I tests/test_shader_stage_manifest.py`: `17/17` PASS - `python3 -I tests/test_docs_links.py`: `16/16` PASS - `python3 -I scripts/check_no_game_data.py`: clean Clean resolution of `BL-5` separating outer DXBC containers from inner tag-`0x0D` payloads per stage. AI-assisted: yes
qhukz13 commented 2026-11-24 17:01:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by qhukz13 on 2026-11-24T17:01:13Z.

Review: COMMENTED


Checked 1f3f4ba3b (Linux, CPU only, no game files). Merges cleanly with current main.

  • tests/test_fssm_unpack.py (48), tests/test_shader_stage_manifest.py, tests/test_shader_stage_resume.py: OK.
  • The counting is right as far as I can check without the corpus: program_counts keys by the carve's stage, counts every row as one container and its xbch_payloads as programs, and an entry without a stage lands under None ("stage unknown") instead of being dropped. shader_stages keeps shader_stems' validation through _stem_rows, so the CLI still refuses the same malformed indexes.
  • Mutations, with semantic_mutants --source from #1016 (both files sit outside rdna2spirv.py, and test_fssm_unpack.py imports tools/ by path): program_counts 4 of 4 caught. In shader_stages one survives against both test_fssm_unpack.py and test_shader_stage_manifest.py: line 57, isinstance(stage, str) and stage -> or. The tests only cover an entry with no stage key, where both give None; an entry with "stage": "" (or a non-string value) is where they differ: the code counts it as stage unknown, the mutant gives it a group of its own (""), splitting the per-stage lines. One such entry in test_program_counts_separate_containers_from_payloads would pin it.

LGTM otherwise; the containers-vs-payloads table in docs/shader_library.md settles BL-5 nicely.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6043765517 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/882#pullrequestreview-6043765517). Originally posted by [qhukz13](https://github.com/qhukz13) on 2026-11-24T17:01:13Z. **Review:** COMMENTED --- Checked 1f3f4ba3b (Linux, CPU only, no game files). Merges cleanly with current `main`. - `tests/test_fssm_unpack.py` (48), `tests/test_shader_stage_manifest.py`, `tests/test_shader_stage_resume.py`: OK. - The counting is right as far as I can check without the corpus: `program_counts` keys by the carve's stage, counts every row as one container and its `xbch_payloads` as programs, and an entry without a stage lands under None ("stage unknown") instead of being dropped. `shader_stages` keeps `shader_stems`' validation through `_stem_rows`, so the CLI still refuses the same malformed indexes. - Mutations, with `semantic_mutants --source` from #1016 (both files sit outside `rdna2spirv.py`, and `test_fssm_unpack.py` imports `tools/` by path): `program_counts` 4 of 4 caught. In `shader_stages` one survives against both `test_fssm_unpack.py` and `test_shader_stage_manifest.py`: line 57, `isinstance(stage, str) and stage` -> `or`. The tests only cover an entry with no `stage` key, where both give None; an entry with `"stage": ""` (or a non-string value) is where they differ: the code counts it as stage unknown, the mutant gives it a group of its own (`""`), splitting the per-stage lines. One such entry in `test_program_counts_separate_containers_from_payloads` would pin it. LGTM otherwise; the containers-vs-payloads table in `docs/shader_library.md` settles BL-5 nicely.
quartz-heron-58 commented 2026-11-24 17:34:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by quartz-heron-58 on 2026-11-24T17:34:02Z.


@qhukz13 thank you, that survivor was real. 87e19b96 pins it.

Root cause. shader_stages has one rule, "a stage is a non-empty string, anything else is unknown", and the test exercised only one of the three ways an entry can fail it (no stage key). The empty string and a non-string value went through the same line untested.

Change. Test only, in test_program_counts_separate_containers_from_payloads: the carve index now also has an entry with "stage": "" and one with "stage": 7. The case asserts shader_stages' answer for all five entries (the three are None), that the CLI prints stage unknown: 3 containers, 3 payloads and exactly three breakdown lines, and it now feeds program_counts the stages shader_stages returned instead of a hand-written dict, so the reader and the counter are checked together. tools/ is unchanged.

Validation. Windows 11, Python 3.12.10:

  • python -I tests/test_fssm_unpack.py: 48 pass.
  • With your mutation applied by hand (line 57, and stage -> or stage): the same file fails 1 of 48, in that case. Restored, it passes again and git status shows only the test file changed. I did not run semantic_mutants --source from #1016.
  • tests/test_shader_stage_manifest.py and tests/test_shader_stage_resume.py: pass.

Nothing else of the pull request changes, and it still merges cleanly with main. AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7139385840 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/882#issuecomment-7139385840). Originally posted by [quartz-heron-58](https://github.com/quartz-heron-58) on 2026-11-24T17:34:02Z. --- @qhukz13 thank you, that survivor was real. `87e19b96` pins it. **Root cause.** `shader_stages` has one rule, "a stage is a non-empty string, anything else is unknown", and the test exercised only one of the three ways an entry can fail it (no `stage` key). The empty string and a non-string value went through the same line untested. **Change.** Test only, in `test_program_counts_separate_containers_from_payloads`: the carve index now also has an entry with `"stage": ""` and one with `"stage": 7`. The case asserts `shader_stages`' answer for all five entries (the three are `None`), that the CLI prints `stage unknown: 3 containers, 3 payloads` and exactly three breakdown lines, and it now feeds `program_counts` the stages `shader_stages` returned instead of a hand-written dict, so the reader and the counter are checked together. `tools/` is unchanged. **Validation.** Windows 11, Python 3.12.10: - `python -I tests/test_fssm_unpack.py`: 48 pass. - With your mutation applied by hand (line 57, `and stage` -> `or stage`): the same file fails 1 of 48, in that case. Restored, it passes again and `git status` shows only the test file changed. I did not run `semantic_mutants --source` from #1016. - `tests/test_shader_stage_manifest.py` and `tests/test_shader_stage_resume.py`: pass. Nothing else of the pull request changes, and it still merges cleanly with `main`. AI-assisted.
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
ProjectLeonida/mandy!882
No description provided.