Skip to content

Report model decode failure reasons in rpf9dump - #30

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
cxchhh:codex/rpf9dump-model-diagnostics
Nov 21, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
cxchhh:codex/rpf9dump-model-diagnostics

Conversation

@cxchhh

@cxchhh cxchhh commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Classify rejected model decodes using the existing resource extent probe.
  • Print up to three examples per failure category and add aggregate counts to the model manifest.
  • Exercise the classifier with generated resource headers, including a truncated prefix and a malformed page table.

Validation

  • dotnet build tools/rpf9dump/rpf9dump.csproj -c Release
  • dotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release

Both passed on Windows with .NET SDK 8.0.428 and the pinned rpf9-explorer revision. This is CPU-only validation. AI-assisted.

@cxchhh

cxchhh commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

@ItsNotRexed, I opened a companion PR in the decoder submodule, breadbbbb/rpf9-explorer#3. It reads parent indices and inverse bind matrices from an external drawable and resolves mesh bone palettes by hash. The tests use a generated three-joint fixture.

This diagnostics PR can be reviewed independently. Once the decoder PR is merged, Leonida can pick up the skeleton API by updating its rpf9-explorer submodule pin.

@Kam471

Kam471 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Useful diagnostic, and the generated-header tests are a good idea. One measured caveat from a run over the actual archives: this classifier only sees entries that reach RageModelDecoder.Decode. Most of the missing models never get that far.

Measured on the 1.0.2.1 package (same submodule revision 48557ea):

Archive Candidates Recovered Hidden rejects
data.rpf 2,313 1,350 963
levels.rpf sample 0-8 GiB 28,748 26,184 2,564
levels.rpf sample 4-4.5 GiB 4,010 3,821 189

The data.rpf hidden 963 split into: 388 where a trailing system block prevents the graphics block from being followed, 259 graphics-trailing-byte rejects, 231 drawable-bounds rejects (these do reach Decode), 67 "block found but no split decoded", 18 "no adjacent block". Only the 231 bounds rejects are visible to Decode; the rest are discarded in Rpf9ModelRecovery before list is built.

Two consequences:

  1. ModelDecodeFailures will be empty in the common case even when 40% of candidates are missing. The manifest still reports fail=0.
  2. The 231 bounds rejects will all appear as decode-rejected ("size and metadata checks passed"), because Explain does not model the drawable-bounds check at RageModelDecoder.cs:377.

Suggestion: also write the scan-level Candidates and Recovered counts (or HiddenRejects = Candidates - Recovered) into the manifest, so a reader can see the shortfall even when no Decode call fails. On the cache path the counts are only in the saved description string today; a sidecar would be cleaner. If you want a category for the bounds case, it needs the submodule to expose the reason, or a re-probe with the same containment check; otherwise decode-rejected is honest but not specific.

For reference, truncating both spans to RequiredSystemBytes/RequiredGraphicsBytes and relaxing the drawable-bounds envelope recovers 2,313/2,313 in data.rpf and 4,010/4,010 in the 4-4.5 GiB levels.rpf window; I am documenting that as a separate docs-only PR, not asking you to fold it in here.

@ItsNotRexed
ItsNotRexed merged commit aa3fe04 into ItsNotRexed:main Nov 21, 2026
cxchhh added a commit to cxchhh/Leonida that referenced this pull request Nov 21, 2026
Candidates that RecoverAtOffsets rejects never reach the per-item loop,
so ModelDecodeFailures stays empty even when many candidates are missing
(data.rpf at 48557ea: 963 of 2,313). Write Scan { Candidates, Recovered,
NotRecovered } into the manifest and print the shortfall.

On a cached run the candidate count comes from the index cache's coverage
text, which rpf9dump now writes with invariant digits; older caches with
grouped digits still parse. The count is null when a cache was written by
another tool.

Suggested by Kam471 in the review of ItsNotRexed#30.
@cxchhh

cxchhh commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the measurements. I added your suggestion in 4f8aaa2.

The manifest now has a Scan object with Candidates, Recovered and NotRecovered. rpf9dump also prints the shortfall, so a run that rejects candidates before decoding no longer reports only fail=0. On a cached run, the candidate count is read from the coverage text that rpf9dump writes into the index cache. That text now uses invariant digits. Older caches with grouped digits (2,313) still parse. The count is null when the cache came from another tool.

I checked this on data.rpf at 48557ea, reading from an existing cache: Candidates 2313, Recovered 1350, NotRecovered 963. Those match your numbers. The diagnostics test now also covers the coverage round-trip for invariant, comma-grouped, space-grouped and foreign text.

You're right that decode-rejected stays generic for the bounds case. PR #1 removes that check, so I left the category as it is.

Tested on Linux x64 with .NET SDK 8.0.428 (CPU only; no GPU involved). AI-assisted.

@cxchhh

cxchhh commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Correction to my comment above: I pushed 4f8aaa2 after this PR had already been merged at 58cb83d, so the scan counts did not land. They are resubmitted on current main as #853, which also handles the per-child dictionary entries of the 917e9b9 pin.

ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
Candidates that RecoverAtOffsets rejects never reach the per-item loop,
so ModelDecodeFailures stays empty even when candidates are missing.
Write Scan { Candidates, Recovered, NotRecovered, Entries } into the
manifest and print the shortfall. Recovered counts resources (distinct
candidate offsets): since the 917e9b9 pin a drawable dictionary yields
one entry per child, so Entries can exceed Candidates.

On a cached run the candidate count comes from the index cache's coverage
text, which rpf9dump now writes with invariant digits; older caches with
grouped digits still parse. The count is null when another tool wrote the
cache.

Suggested by Kam471 in the review of #30; that follow-up commit was pushed
after #30 had been merged, so it is resubmitted here on current main.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants