tooling: validate relocated resource roots against their schemas #316

Manually merged
github merged 2 commits from gh-pr/316/head into gh-pr/316/base 2026-11-26 21:42:29 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 21:51 UTC · original
Vonsek:codex/resource-root-schema → main · +169 −0 · 6 files · 2 commits · merged 2026-11-22 02:36 UTC

Change

The same little-endian PRD0 v0x7a header marker occurs in archived resources from different subsystems. This command identifies the numeric root type and its verified byte size within one explicitly sized zlib member. It checks the root's one-based index, both relocated directory spans, the root span and its independent schema row. The CLI reports only the hash and byte count.

The new experiment describes the observed profile. #186 checks matching sizes in the section-based script tree walker. That walker uses separately serialized instance/schema sections and a five-array 80-byte root. This reader uses relocated virtual addresses and the directory of the supplied member. It shares the existing bounded zlib reader.

Verification

Commit 03d3211930cb5d2d3322c776bb4e9c93d463801e, base b53bfb0b6489398aba7a81f3761e2d56aaa00ccf, Windows x64, Python 3.12.

  • python -B tests/resource_root_check.py RootChecks.test_member_cli: before the reader existed the normal command returned exit 2 and the test failed. On this commit the fixture reports the expected root hash and byte size.
  • In a fresh worktree, python -m venv out/pe-env, out/pe-env/Scripts/python.exe -m pip install -r requirements-dev.txt, . ./tools/dev.ps1 and cmake --preset dev succeeded. ctest --preset dev --no-tests=error -R '^(resource_relocated_root|resource_range_controls|script_state_literals|docs_links)$' --output-on-failure passed all four tests.
  • git diff --check HEAD^ HEAD passed.

Evidence and follow-up

The original MIT-licensed fixture stores two distinct types in opposite schema/block orders. Selecting indices 1 and 2 reports different roots. Controls reject mismatched sizes, an ambiguous root schema, metadata aliasing, out-of-member pointers, incorrect stored length, and an over-budget member before a read.

For local verification, three nonoverlapping 8 MiB windows per archive (start, middle and end) were searched at 16-byte alignment. The survey allowed up to 512 KiB of stored bytes and 2 MiB of decoded bytes per candidate and required checksum-verified EOF. Of 616 marked animation-archive members, 556 contained the full required extents and shared a 352-byte root type. Two controls from the same package yielded 189 of 211 navigation members with a different 304-byte root, and 43 of 63 pack members with a third, 192-byte root. These observations establish directory and schema relationships for the measured profile. Animation class names, clip counts and playback were not established. All local assets stayed out of the repository.

The reader was independently implemented from the measured header fields and the public metadata row layouts and one-based root lookup. CodeWalker documents an older header version. The version-specific reference checks the marker and pointer offsets. Neither source was copied.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

This contribution was AI-assisted.

**@⁠Vonsek** on GitHub · 2026-11-21 21:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/316) `Vonsek:codex/resource-root-schema` → `main` · +169 −0 · 6 files · 2 commits · merged 2026-11-22 02:36 UTC ## Change The same little-endian PRD0 v0x7a header marker occurs in archived resources from different subsystems. This command identifies the numeric root type and its verified byte size within one explicitly sized zlib member. It checks the root's one-based index, both relocated directory spans, the root span and its independent schema row. The CLI reports only the hash and byte count. The [new experiment](https://github.com/Vonsek/Xbox2Windows/blob/03d3211930cb5d2d3322c776bb4e9c93d463801e/docs/experiments.md#relocated-resource-root) describes the observed profile. #186 checks matching sizes in the section-based script tree walker. That walker uses separately serialized instance/schema sections and a five-array 80-byte root. This reader uses relocated virtual addresses and the directory of the supplied member. It shares the existing bounded zlib reader. ## Verification Commit `03d3211930cb5d2d3322c776bb4e9c93d463801e`, base `b53bfb0b6489398aba7a81f3761e2d56aaa00ccf`, Windows x64, Python 3.12. - `python -B tests/resource_root_check.py RootChecks.test_member_cli`: before the reader existed the normal command returned exit 2 and the test failed. On this commit the fixture reports the expected root hash and byte size. - In a fresh worktree, `python -m venv out/pe-env`, `out/pe-env/Scripts/python.exe -m pip install -r requirements-dev.txt`, `. ./tools/dev.ps1` and `cmake --preset dev` succeeded. `ctest --preset dev --no-tests=error -R '^(resource_relocated_root|resource_range_controls|script_state_literals|docs_links)$' --output-on-failure` passed all four tests. - `git diff --check HEAD^ HEAD` passed. ## Evidence and follow-up The original MIT-licensed fixture stores two distinct types in opposite schema/block orders. Selecting indices 1 and 2 reports different roots. Controls reject mismatched sizes, an ambiguous root schema, metadata aliasing, out-of-member pointers, incorrect stored length, and an over-budget member before a read. For local verification, three nonoverlapping 8 MiB windows per archive (start, middle and end) were searched at 16-byte alignment. The survey allowed up to 512 KiB of stored bytes and 2 MiB of decoded bytes per candidate and required checksum-verified EOF. Of 616 marked animation-archive members, 556 contained the full required extents and shared a 352-byte root type. Two controls from the same package yielded 189 of 211 navigation members with a different 304-byte root, and 43 of 63 pack members with a third, 192-byte root. These observations establish directory and schema relationships for the measured profile. Animation class names, clip counts and playback were not established. All local assets stayed out of the repository. The reader was independently implemented from the measured header fields and the public [metadata row layouts and one-based root lookup](https://github.com/dexyfex/CodeWalker/blob/485d56bec00262ed7fa472261cce7bbc6202b96e/CodeWalker.Core/GameFiles/MetaTypes/Meta.cs#L208-L264). CodeWalker documents an older header version. The [version-specific reference](https://github.com/rpatty-dev/PercyStar/blob/1b710c5349ef1911d94092f19173e9813dfb300c/src/anim.rs#L180-L219) checks the marker and pointer offsets. Neither source was copied. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. This contribution was AI-assisted.
The same resource marker occurs in archives with different root types. Resolve the selected instance by its one-based index and verify its type, size and bounds against the independent schema directory.
Keep the expanded texture experiment and its test selector alongside the metadata experiment.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:42:27 +00:00
github manually merged commit 61ae89e953 into gh-pr/316/base 2026-11-26 21:42:29 +00:00
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 21:51 UTC · original · edited 2026-11-21 22:07 UTC

Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T22:07:09.817692Z 61ae89e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review" or "@⁠codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 21:51 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069771652) · edited 2026-11-21 22:07 UTC <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"61ae89e953b965b1758944a4af0c48d14b4b7173","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-21T22:07:09.817692Z">2026-11-21T22:07:09.817692Z</relative-time> | `61ae89e` | Manual request | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review" or "@⁠codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-21 21:58 UTC · original

At 03d3211 the merge conflicts are in README.md. Retain the schema-validation documentation alongside #298's descriptor lookup.

**@⁠R0Y00** on GitHub · 2026-11-21 21:58 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069855578) At `03d3211` the merge conflicts are in `README.md`. Retain the schema-validation documentation alongside #298's descriptor lookup.
Author
Owner

@⁠Vonsek on GitHub · 2026-11-21 22:04 UTC · original

The README at 61ae89e keeps the relocated-root schema experiment and the texture descriptor-key lookup from #298, including its resource_range_controls selector. The four selected CTest cases passed locally, and all three CI jobs passed on this commit.

@⁠codex review

**@⁠Vonsek** on GitHub · 2026-11-21 22:04 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069922426) The README at `61ae89e` keeps the relocated-root schema experiment and the texture descriptor-key lookup from #298, including its `resource_range_controls` selector. The four selected CTest cases passed locally, and all three [CI jobs](https://github.com/R0Y00/Xbox2Windows/actions/runs/44954474272) passed on this commit. @⁠codex review
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 22:07 UTC · original

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 61ae89e953

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@⁠codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 22:07 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/316#issuecomment-7069951889) <!-- codex-review-receipt:v1 --> Codex Review: Didn't find any major issues. More of your lovely PRs please. **Reviewed commit:** `61ae89e953` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@⁠codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.