Skip to content

make_game: hash untracked rpf9-explorer files into the decoder digest - #6073

Open
fishingpvalues wants to merge 2 commits into
ItsNotRexed:mainfrom
fishingpvalues:fix/decoder-digest-untracked
Open

fishingpvalues wants to merge 2 commits into
ItsNotRexed:mainfrom
fishingpvalues:fix/decoder-digest-untracked

Conversation

@fishingpvalues

@fishingpvalues fishingpvalues commented Nov 23, 2026 •

Copy link
Copy Markdown

Claimed in #5781 (claim).
Depends on: #6058 (this branch builds on it; the digest test uses that PR's Git fixture isolation).

What changed and why

compute_decoder_digest() decides whether the assets stage re-exports: it hashed the third_party/rpf9-explorer submodule's HEAD and its git diff HEAD, then the tools/rpf9dump sources. A decoder source file the submodule does not track at all — added but not git added — is in neither: git diff HEAD never shows untracked files, so decoder.sha256 stayed the same and assets() kept an export the new file would change. The comment there called this a shortcut; this closes it.

  • make_game.py compute_decoder_digest(): after the tracked diff, hash the paths and exact bytes of every untracked file (git ls-files --others --exclude-standard -z) and of the ignored files a build would still compile (git ls-files --others --ignored --exclude-standard -z, filtered to .cs, .csproj, .props, .targets, .resx and .json outside bin/ and obj/). That is @DoubleD17's review: the SDK compiles Core/**/*.cs even when the file is ignored through .gitignore, .git/info/exclude or core.excludesFile, while bin/ and obj/ are build output that must not churn the digest. Unreadable entries are hashed as a marker, not raised.
  • tests/test_make_game_assets_decoder.py: test_the_digest_follows_an_untracked_file_in_the_submodule adds NewDecoder.cs without adding it to the index; test_the_digest_follows_an_ignored_compiled_source adds an ignored LocalDecoder.cs and Strings.resx through .git/info/exclude, then ignored bin/Generated.cs and obj/notes.json. Both fail on the base and pass here; the ignored-output case must leave the digest unchanged. The fixtures' repeated isolation is one isolated_git_env() helper (from tests: keep fixture commits out of the contributor's global Git hooks #6058's change, moved rather than copied).

Tests run

macOS 27.2 (26B123), Python 3.12.8, CPU only, no game files, no GPU:

  • python -I tests/test_make_game_assets_decoder.py — OK, 8 tests (6 with tests: keep fixture commits out of the contributor's global Git hooks #6058 alone)
  • python -m pytest tests -q -k "make_game or decoder" — 428 passed, 4 skipped
  • the real submodule at e2939175, with Core/LocalDecoder.cs ignored through its info/exclude: the digest changes; with bin/Generated.cs added it does not
  • python -m compileall -q make_game.py tests/test_make_game_assets_decoder.py — clean
  • Windows: not run here. Rebased onto tests: keep fixture commits out of the contributor's global Git hooks #6058 1d86ef7d7: its synthetic global config writes hooksPath through git config --file and reads it back, so Git does the escaping itself (a hand-written C:\... was the error both Windows testers saw) and the test fails if the value does not round-trip. The Windows check of the hook fixture should be repeated here.

AI-assisted.

@Atomic258

Copy link
Copy Markdown

Tested on Windows Server 2022, CPython 3.13.12: partial

  • python -I tests/test_make_game_assets_decoder.py -> FAILED (errors=1): test_the_fixture_commit_ignores_a_global_git_hook - its inner git -C <fixture> subprocess exits non-zero on this box (Windows git global config, likely hooks/safe.directory handling in the sandbox env), not a logic failure in the change itself
  • Everything else in the suite OK

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@DoubleD17 DoubleD17 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

An ignored C# source can change the build without changing the digest

At bc3593b1f0dc9367c49e0add259ea4498a4f3fcb, the new git ls-files --others --exclude-standard -z also honours core.excludesFile and .git/info/exclude. The pinned Core/RpfPreview.Core.csproj uses the .NET SDK's default Compile glob. A developer can put Core/LocalDecoder.cs in a local ignore rule and still compile it. In that case, adding or editing the file changes the decoder while the submodule HEAD, tracked diff and new enumeration remain identical, so decoder.sha256 can still reuse a stale export.

I built a minimal synthetic .NET 8 project twice on Windows with SDK 8.0.428. After adding Core/LocalDecoder.cs matched by a fixture core.excludesFile, the compiled program detected the new type, while the exact ls-files command returned zero paths in both runs. I inspected the pinned project and the PR diff statically. Could the digest include ignored compile inputs while still excluding build outputs such as bin/ and obj/?

No game files. AI-assisted.

@Jadiac5

Jadiac5 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested bc3593b on Windows 11, Git 2.52.0.windows.1, Python 3.12 (CPU only): concern, from the stacked #6058, not from this PR's own change

  • python -I tests\test_make_game_assets_decoder.py -v: 6 pass, 1 ERROR. The new test_the_digest_follows_an_untracked_file_in_the_submodule passes. The error is test_the_fixture_commit_ignores_a_global_git_hook (comes from tests: keep fixture commits out of the contributor's global Git hooks #6058, which this branch contains): its git -C <control> init -q exits 128 because the test writes hooksPath = C:\...\hooks into the config file with a raw Windows path. Git reads the backslashes as escapes: fatal: bad config line 2 in file ...gitconfig. A / path or an escaped one would fix it (tests/test_make_game_assets_decoder.py:153-156 in this head).
  • Other tests: test_llvm_source_version.py 6 OK, test_make_game_submodule.py 3 OK, test_ci_registration.py 14 OK.
  • Negative control: this head's test file with main's make_game.py: the untracked-file test FAILS (digest unchanged), plus the same hook error.
  • Hand-made submodule (synthetic repo, compute_decoder_digest() with ROOT patched): ignored bin/ file keeps the digest; an untracked file in a nested folder, an edit to its bytes, a rename with the same bytes, a non-ASCII name, a CRLF-only difference and a file over 1 MiB each change it; a nested git repo (listed as a folder) does not raise.
  • Not done: macOS result of the author not repeated; a real submodule.

AI-assisted (Claude Code).

@fishingpvalues
fishingpvalues force-pushed the fix/decoder-digest-untracked branch from bc3593b to 5303d56 Compare November 23, 2026 13:52
@fishingpvalues

Copy link
Copy Markdown
Author

Thanks @Atomic258 and @Jadiac5: rebased onto #6058 at 50df3217, which fixes the Windows error you both hit — the synthetic hooksPath was written as a raw C:\... path and Git parsed the backslashes as escapes (bad config line 2). It is now quoted with forward slashes; please re-check.

@DoubleD17's point is implemented: the digest now also hashes ignored compiled inputs — .cs, .csproj, .json outside bin/ and obj/ from git ls-files --others --ignored --exclude-standard — so an ignored Core/LocalDecoder.cs (local exclude or core.excludesFile) changes decoder.sha256, while ignored bin//obj/ build output does not. The new test_the_digest_follows_an_ignored_compiled_source covers .git/info/exclude plus ignored bin/Generated.cs and obj/notes.json (it fails on the base digest code); I also checked the pinned submodule at e2939175 the same way.

macOS 27.2, Python 3.12.8: python -I tests/test_make_game_assets_decoder.py 8/8, pytest -k "make_game or decoder" 428 passed / 4 skipped.

test_the_digest_follows_an_uncommitted_submodule_edit committed "-m x" in a temporary Git repository. A
contributor whose global config sets core.hooksPath (a Conventional Commits commit-msg hook, e.g. a lint
setup) had that hook reject the message, so the file failed on their machine while CI stayed green.
Commit e1cc07c fixed the same problem in tests/test_make_game_submodule.py; this applies the same
isolation to the two fixtures that still lacked it.

The new test poisons the global config with a rejecting commit-msg hook, checks the control commit is
rejected, and runs the fixture test in a subprocess under that config. It fails on main and passes with the
fix.
@fishingpvalues
fishingpvalues force-pushed the fix/decoder-digest-untracked branch from 5303d56 to 08965cb Compare November 23, 2026 13:55
@fishingpvalues

Copy link
Copy Markdown
Author

Head is now 08965cb74. The #6058 base was rebased to 1d86ef7d7, where the synthetic hooksPath is written through git config --file and read back (Git escapes it; a hand-written C:\... was your error), so the Windows error @Atomic258 and @Jadiac5 saw should be gone. The digest tests are unchanged from above (python -I tests/test_make_game_assets_decoder.py 8/8 on macOS). A Windows re-check of the hook fixture is still the missing confirmation.

@fishingpvalues
fishingpvalues force-pushed the fix/decoder-digest-untracked branch 2 times, most recently from 5a4a01b to 4295086 Compare November 23, 2026 13:56
…decoder digest

compute_decoder_digest() hashed the submodule's HEAD and `git diff HEAD`, so a decoder source file the
submodule does not track at all (added but not `git add`ed) left decoder.sha256 unchanged and the assets
stage kept an export the new file would change. The same holds for a compiled input the .NET SDK builds
but git ignores (Core/LocalDecoder.cs, a .resx, an imported .props), which a reviewer of this change
showed with a synthetic .NET project.

Both are hashed now: every untracked file, and of the ignored ones the compiled or imported inputs (.cs,
.csproj, .props, .targets, .resx, .json) outside bin/ and obj/, so a build inside the submodule cannot
churn the digest. The tests cover an untracked file, an ignored source and resource, and ignored bin/ and
obj/ output.
@fishingpvalues
fishingpvalues force-pushed the fix/decoder-digest-untracked branch from 4295086 to 9337339 Compare November 23, 2026 13:56
@fishingpvalues

Copy link
Copy Markdown
Author

One follow-up on @DoubleD17's point: the ignored set is now .cs, .csproj, .props, .targets, .resx and .json (an ignored Strings.resx changes the digest; the test covers it), everything outside bin/obj. Head 9337339a4; macOS 8/8.

@fishingpvalues

Copy link
Copy Markdown
Author

Windows confirmation for the stacked base: @nullmarsh tested #6058 at 1d86ef7d on Windows 11 (Git 2.55.0.windows.2) — test_make_game_assets_decoder.py 6/6 with the hook test running, so the git config --file path is good there. This head 9337339a4 adds only the ignored-input filter (.props/.targets/.resx) and its test on top; the fixture changes are the ones just verified. @Atomic258 @Jadiac5 if you can, re-run at this head.

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.

5 participants