Skip to content

rpf9dump: rescan instead of exporting from a partial index cache - #2730

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
AAyberkU:rpf9dump-partial-index-cache
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
AAyberkU:rpf9dump-partial-index-cache

Conversation

@AAyberkU

@AAyberkU AAyberkU commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #2716 (comment) (new item)

Rebased on main f847748c after #2712 was merged: the same three changes, now in #2712's Load/Save block (a --start/--length window is never cached there, so it is not affected). The checks in tests/Rpf9DumpDiagnostics follow #2712's.

What and why

rpf9dump shares %LOCALAPPDATA%\RpfPreview\Indexes with the rpf9-explorer GUI (docs/design.md describes the shared cache). The GUI saves its model index while it is still indexing (every 1,000 containers) and when a scan is cancelled, with IsComplete=false (Core/PayloadIndexBuilder.cs in the submodule), and it starts that indexing by itself when an RPF9 source is opened. It writes IsComplete=true only when the scan finishes.

rpf9dump models|textures used any cache that loaded. So after a GUI scan that was stopped, or a GUI that was closed early, rpf9dump skipped its own scan, exported only the entries indexed so far, published manifest.json and exited 0. make_game.py skips a step whose manifest exists, so the partial export was never redone and nothing told the player.

In the other direction, rpf9dump saved its full scans without the complete mark, so the GUI did not treat them as complete.

Changes:

  • ScanCounts.IsFullScan: a cached index stands in for a full scan when it is marked complete, or when its coverage text is rpf9dump's own (Candidates(...) != null). The second half keeps caches written by earlier rpf9dump versions valid, so nobody rescans a large archive because of this change.
  • A cache that is neither is ignored: rpf9dump prints one line, scans, and overwrites it.
  • rpf9dump saves its own full scan with complete: true. Save already had that parameter and the file already had the field (rpf9dump wrote "IsComplete":false); the schema is unchanged.

Nothing under third_party/ is changed.

Limits and side effects

  • The GUI writes partial caches for models only. For textures it saves once, at the end, but without the complete mark, so with this change a full texture index made by the GUI is scanned again once by rpf9dump and then saved as complete. I kept one rule for both modes instead of trusting texture caches because of how the GUI happens to behave today; say so if you would rather limit the check to models.
  • Exports already published from a partial index are not repaired: their manifest.json has to be deleted to redo the step.
  • The GUI itself (WPF) was not run. What it writes, and that it accepts a cache rpf9dump marks complete, comes from reading the submodule's code.

Tested

Windows 11, .NET SDK 9.0.313 (the net8 projects build through rollForward). No game files and no GPU: the archive is synthetic (a 32 KiB 9FPR file holding three 8x8 texture dictionaries built by a throwaway harness), and the caches were written through the submodule's own RecoveryIndexCache.Save. The harness and its cache files are not part of this PR and were removed afterwards.

  • Before the change, rpf9dump textures with a partial cache planted for that file (1 of 3 entries, IsComplete=false): no scan, 1 dictionary exported, manifest published, exit code 0. With the change: "not marked as a full scan, rescanning", 3 candidates, 3 exported.
  • rpf9dump models with an empty partial cache: before, no scan, 0 entries, manifest published, exit code 0; with the change it scans. The synthetic file has no model in it, so this is the scan being skipped or not, not a count of lost models; the code path is the same as for textures.
  • Reused without a rescan, cache file unchanged: a cache written by the unmodified rpf9dump, one with an older culture-formatted coverage text, and a GUI cache marked complete.
  • dotnet run --project tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj -c Release: passes, including seven new checks on in-memory CachedIndex values. With IsFullScan returning true it fails at "GUI index saved while indexing"; returning only IsComplete it fails at "rpf9dump index saved without the complete mark".
  • dotnet build tools/rpf9dump/rpf9dump.csproj -c Release: 0 warnings. python -I tests/test_rpf9dump_exit_codes.py and tests/test_ttpf_export_resume.py: pass.

AI-assisted (Claude Code); the runs above were done on this branch.

Checklist

  • 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. (not a translator change)

🤖 Generated with Claude Code

https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs

@tupacfan04

Copy link
Copy Markdown
Contributor

Code read of d13d6f28 (I didn't build it). Looks right. IsFullScan accepts only an index marked complete, or one whose coverage parses through ScanCounts.Candidates, which is rpf9dump's own wording. The GUI's in-progress and cancelled texts don't parse, so they are rescanned. Saving with complete: true means rpf9dump's future indexes no longer depend on the text fallback, and the de-CH case covers Candidates stripping culture-specific separators. As noted, this will need a small rebase against #2712.

AI-assisted review (Claude Code).

@ricarmandoagent

Copy link
Copy Markdown

Reviewed d13d6f28936ab14a144bbdc251dc04432d418cf5, base origin/main 49475796c226c8511b9470bf97a4daf57b8af323. Bazzite Linux, Python 3.15.2.

Limitation: no .NET SDK here (dotnet: command not found; no /usr/lib*/dotnet, /opt/dotnet, ~/.dotnet), so I could not build rpf9dump or run tests/Rpf9DumpDiagnostics. The two python tests skip on this machine: python3 -I tests/test_rpf9dump_exit_codes.py -> Ran 1 test ... OK (skipped=1); python3 -I tests/test_ttpf_export_resume.py -> Ran 3 tests ... OK (skipped=3). What follows is additional to the code read above, against the submodule commit this PR pins (third_party/rpf9-explorer = e2939175, same as main).

The strings the predicate depends on are the ones the GUI writes (Core/PayloadIndexBuilder.cs at e2939175):

  • line 47: Save("models", ..., $"Dictionary-aware model scan in progress · {i + 1:N0}/{offsets.Count:N0} containers validated.") -- same text as the test;
  • line 55 (cancel): "Dictionary-aware model scan canceled. Validated models are retained; discovery will resume on reopen." -- same;
  • line 62 (success): Save("models", ordered, $"Full {length:N0}-byte model-container scan · ...", complete: true) -- so a finished GUI model scan is trusted through IsComplete, exactly as the description says;
  • line 90 (textures): saved once at the end without complete: -- $"Full {length:N0}-byte page+16 scan; {textures.Count:N0} supported dictionaries; ..." -- which confirms the stated side effect (a GUI texture index is rescanned once and then saved complete). The GUI formats N0 with the current culture, which is what the de-CH check in tests/Rpf9DumpDiagnostics covers, and Candidates' [0-9\p{P}\p{Zs}]* strips those separators.

Serialization path: RecoveryIndexCache.Save(..., bool complete = false) writes IsComplete = complete (Core/RecoveryIndexCache.cs:21-28) and IsComplete { get; init; } is serialized (the options set IgnoreReadOnlyProperties; the property has a setter), so complete: true in tools/rpf9dump/Program.cs:129 yields a cache the GUI accepts at cached?.IsComplete == true (PayloadIndexBuilder.cs:19). Candidates' anchored ^rpf9dump full scan, matches neither GUI text, and IsFullScan only clears cached before Candidates(cached?.Coverage) is read, so a rescan does not corrupt the manifest's Scan.Candidates; a trusted legacy cache keeps its counts.

Build prerequisites, by inspection: ScanCounts.cs now needs RpfPreview.Core; both tools/rpf9dump/rpf9dump.csproj and tests/Rpf9DumpDiagnostics/Rpf9DumpDiagnostics.csproj already have the RpfPreview.Core.csproj ProjectReference and link ScanCounts.cs. The diagnostics helper's 8 positional record arguments match CachedIndex(Schema, Kind, Source, SourceLength, SourceWriteTicks, HeaderSha256, Coverage, Entries); collection expression [] needs C# 12, default for the net8.0 SDK.

No defect found in the logic; the unexecuted part is the C# build and the diagnostics run.

Verdict: LGTM on the logic; limitation: not built or run here.

AI-assisted review.

rpf9dump shares %LOCALAPPDATA%\RpfPreview\Indexes with the rpf9-explorer GUI, which saves its model index
while it is still indexing and when a scan is cancelled, with IsComplete=false. rpf9dump trusted any cache that
loaded, so after a stopped GUI scan it exported only what had been indexed so far, published the manifest and
exited 0, and make_game.py never redid the step. A cached index now stands in for a full scan only when it is
marked complete or carries rpf9dump's own coverage text; otherwise rpf9dump scans again. Its own full scans are
saved with the complete mark, which the cache file already had a field for.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016ABh36DZ2sZNq3ChN6EZJs
@AAyberkU
AAyberkU force-pushed the rpf9dump-partial-index-cache branch from d13d6f2 to 78f92bc Compare November 22, 2026 20:02
@AAyberkU

Copy link
Copy Markdown
Contributor Author

Rebased on main f847748c now that #2712 is merged, as promised. Same three changes, moved into #2712's block: the IsFullScan check right after RecoveryIndexCache.Load, and complete: true on the full-scan Save. The windowed path (--start/--length) writes no cache, so nothing changes there. On Windows 11 with the .NET 9 SDK: dotnet build tools/rpf9dump/rpf9dump.csproj -c Release 0 errors, and tests/Rpf9DumpDiagnostics passes all six sections (#2712's mesh key and segment tests, then the cached index tests). I did not repeat the synthetic end-to-end run after the rebase. Thanks @tupacfan04 and @ricarmandoagent for the reviews. AI-assisted.

@klarnet2009

Copy link
Copy Markdown
Contributor

Reviewed PR #2730 (78f92bcf) by code inspection.

Files read

  • tools/rpf9dump/ScanCounts.cs (git diff upstream/main...HEAD)
  • tools/rpf9dump/Program.cs (git diff upstream/main...HEAD)
  • tests/Rpf9DumpDiagnostics/Program.cs (git diff upstream/main...HEAD)

Checks run

  • dotnet run --project tests/Rpf9DumpDiagnostics: not executed — .NET SDK 8.0.100 (required by global.json) is not installed on this host (No .NET SDKs were found).

Findings

Code read looks clean. ScanCounts.IsFullScan accepts either cached.IsComplete or legacy rpf9dump coverage strings matched by Candidates(cached.Coverage), tools/rpf9dump/Program.cs discards partial caches and passes complete: true when saving, and tests/Rpf9DumpDiagnostics/Program.cs adds 7 Check(...) cases covering GUI partial/canceled/complete, legacy/culture-formatted rpf9dump, and null.

@tomgamer22 tomgamer22 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code read only: the C# test project doesn't build here without the rpf9-explorer submodule, so I couldn't run it. The logic looks right. An incomplete cache that rpf9dump didn't write is now rescanned (tools/rpf9dump/Program.cs:147), older rpf9dump caches stay valid because the coverage text is checked, and saving with complete: true lets the GUI trust rpf9dump's scans. AI-assisted review (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 709fda3 into ItsNotRexed:main Nov 22, 2026
2 of 4 checks passed
@AAyberkU
AAyberkU deleted the rpf9dump-partial-index-cache branch November 22, 2026 22:31
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.

6 participants