xtask: preserve filenames during asset-policy checks #2581

Open
github-bot wants to merge 1 commit from github-bot/gh-2581 into main AGit
Owner

@⁠XeNS1 on GitHub · 2026-11-25 16:10 UTC · original
XeNS1:codex/xtask-policy-filenames-20261125 → main · +117 −13 · 3 files · 1 commits · open

Claimed as: XTASK-POLICY-FILENAME-FIDELITY
#1633

Problem and change

On POSIX, literal\name.rs is a legal filename. Asset-policy enumeration changed the backslash into /, so it inspected literal/name.rs instead. If that path was absent, the check skipped the contents; if it held clean text, it checked the wrong file. Non-UTF-8 filenames were similarly replaced with a different name by lossy decoding. The policy could report success while a synthetic NUL-bearing file went unchecked.

Keep Git's UTF-8 paths verbatim: Git already emits / directory separators. For source trees without Git, normalize only the native directory separator. Refuse non-UTF-8 filenames explicitly rather than substituting a name that can identify another file.

Add temporary-file regressions for Git worktree/untracked scans, staged content, source exports without .git, literal backslashes, invalid UTF-8 names and Unicode controls. The controls also verify that staged mode reads the index rather than unstaged worktree contents. Every binary test input is a generated single NUL byte in a temporary directory; no game files are used.

tempfile is an existing workspace dependency, added only as an xtask dev-dependency. No dependency versions change.

Validation

Linux x86-64, Rust/Cargo 1.100.0; 2 test/build workers:

  • cargo test -p xtask --locked --offline -j 2 -- --test-threads=2: 9 passed.
  • Negative control: retain the new tests but restore the original production implementation; 7 pass, the backslash and non-UTF-8 regressions both fail. Restore the fix: 9 pass.
  • cargo clippy -p xtask --all-targets --all-features --locked --offline -j 2 -- -D warnings: passed.
  • cargo fmt --package xtask -- --check: passed.
  • cargo run --quiet --locked --offline -p xtask -- policy: 184 files passed.
  • The corresponding policy --staged: exactly the three changed files passed.
  • git diff --check: passed.

The pinned Rust 1.98.1 and native Windows were not tested locally. POSIX-only filename cases are gated with cfg(unix); the ordinary Unicode/index regression also runs on Windows. The whole Windows runtime workspace and game were not run.

Related: #2246 changes the same policy file for decimal-array detection; #2166 adds CPU verification tooling. Their behavior is outside this change. Depends on: none.

GPUs tested: n/a, CPU-only filesystem/Git checks.

AI-assisted: OpenAI Codex.

**@⁠XeNS1** on GitHub · 2026-11-25 16:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/2581) `XeNS1:codex/xtask-policy-filenames-20261125` → `main` · +117 −13 · 3 files · 1 commits · open Claimed as: XTASK-POLICY-FILENAME-FIDELITY https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 ### Problem and change On POSIX, `literal\name.rs` is a legal filename. Asset-policy enumeration changed the backslash into `/`, so it inspected `literal/name.rs` instead. If that path was absent, the check skipped the contents; if it held clean text, it checked the wrong file. Non-UTF-8 filenames were similarly replaced with a different name by lossy decoding. The policy could report success while a synthetic NUL-bearing file went unchecked. Keep Git's UTF-8 paths verbatim: Git already emits `/` directory separators. For source trees without Git, normalize only the native directory separator. Refuse non-UTF-8 filenames explicitly rather than substituting a name that can identify another file. Add temporary-file regressions for Git worktree/untracked scans, staged content, source exports without `.git`, literal backslashes, invalid UTF-8 names and Unicode controls. The controls also verify that staged mode reads the index rather than unstaged worktree contents. Every binary test input is a generated single NUL byte in a temporary directory; no game files are used. `tempfile` is an existing workspace dependency, added only as an xtask dev-dependency. No dependency versions change. ### Validation Linux x86-64, Rust/Cargo 1.100.0; 2 test/build workers: - `cargo test -p xtask --locked --offline -j 2 -- --test-threads=2`: 9 passed. - Negative control: retain the new tests but restore the original production implementation; 7 pass, the backslash and non-UTF-8 regressions both fail. Restore the fix: 9 pass. - `cargo clippy -p xtask --all-targets --all-features --locked --offline -j 2 -- -D warnings`: passed. - `cargo fmt --package xtask -- --check`: passed. - `cargo run --quiet --locked --offline -p xtask -- policy`: 184 files passed. - The corresponding `policy --staged`: exactly the three changed files passed. - `git diff --check`: passed. The pinned Rust 1.98.1 and native Windows were not tested locally. POSIX-only filename cases are gated with `cfg(unix)`; the ordinary Unicode/index regression also runs on Windows. The whole Windows runtime workspace and game were not run. Related: #2246 changes the same policy file for decimal-array detection; #2166 adds CPU verification tooling. Their behavior is outside this change. Depends on: none. GPUs tested: n/a, CPU-only filesystem/Git checks. AI-assisted: OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:09:44 +00:00
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 16:33 UTC · original

oni-swr verification — head 2c13b1c48dea5db6bb12a364b39bce4ea9ac1b9e, origin/main 67e8ae1401df112248aed36d0024483181b718b7

Environment: Windows 11 Pro (26200), rustc 1.98.1, CPU only (no GPU involved, no game files). Merge check: git merge-tree --write-tree origin/main <head> is clean.

Commands / results

  • cargo test --locked -p xtask: 7 passed, 0 failed, 0 ignored (incl. ordinary_unicode_paths_are_checked_in_both_modes and repository_passes_policy).
  • Windows limitation: literal_backslashes_do_not_hide_file_contents and non_utf8_names_are_refused_instead_of_substituted are #[cfg(unix)], so they were compiled out, not run here, and NTFS cannot create such filenames anyway. Those two paths are therefore unverified by me and need a Linux/macOS run (CI).

Review: the git branch now uses the NUL-separated names as-is (git already emits /) and fails loudly on non-UTF-8 instead of from_utf8_lossy + \ replacement; the walkdir branch errors on a non-UTF-8 relative path and only normalizes MAIN_SEPARATOR (so on POSIX a literal \ stays in the name). tempfile is a dev-dependency only; Cargo.lock change matches. Behaviour on Windows is unchanged for ordinary names. I found no defects.

Overlap: none; no other open PR touches xtask.

AI disclosure: this review and verification were done by Claude Code (Claude Sonnet 5.5), not a human reviewer. Comment-only; no code changed.

**@⁠oni-swr** on GitHub · 2026-11-25 16:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2581#issuecomment-7168181217) **oni-swr verification** — head `2c13b1c48dea5db6bb12a364b39bce4ea9ac1b9e`, `origin/main` `67e8ae1401df112248aed36d0024483181b718b7` **Environment:** Windows 11 Pro (26200), rustc 1.98.1, CPU only (no GPU involved, no game files). Merge check: `git merge-tree --write-tree origin/main <head>` is clean. **Commands / results** - `cargo test --locked -p xtask`: 7 passed, 0 failed, 0 ignored (incl. `ordinary_unicode_paths_are_checked_in_both_modes` and `repository_passes_policy`). - Windows limitation: `literal_backslashes_do_not_hide_file_contents` and `non_utf8_names_are_refused_instead_of_substituted` are `#[cfg(unix)]`, so they were **compiled out, not run** here, and NTFS cannot create such filenames anyway. Those two paths are therefore unverified by me and need a Linux/macOS run (CI). **Review:** the git branch now uses the NUL-separated names as-is (git already emits `/`) and fails loudly on non-UTF-8 instead of `from_utf8_lossy` + `\` replacement; the walkdir branch errors on a non-UTF-8 relative path and only normalizes `MAIN_SEPARATOR` (so on POSIX a literal `\` stays in the name). `tempfile` is a dev-dependency only; `Cargo.lock` change matches. Behaviour on Windows is unchanged for ordinary names. I found no defects. **Overlap:** none; no other open PR touches `xtask`. AI disclosure: this review and verification were done by Claude Code (Claude Sonnet 5.5), not a human reviewer. Comment-only; no code changed.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 22:19 UTC · original

Automated triage for the maintainers.

Needs the maintainer's decision. The change tightens xtask/src/policy.rs and does not loosen it. list_files keeps git's NUL-separated names verbatim instead of turning \ into / and decoding lossily, the walkdir fallback normalises only MAIN_SEPARATOR, and non-UTF-8 names now fail the check instead of being replaced by another name. By my reading this is correct, and the tests generate their inputs (single NUL bytes) in temp dirs. It merges cleanly and CI (check) passes, but the two cfg(unix) tests do not run on the Windows CI.

It adds tempfile as a dev-dependency of xtask (xtask/Cargo.toml, Cargo.lock), and its tests spawn git processes. Dependency changes and process spawning are left to the maintainer, so this cannot be marked a merge candidate by triage. Nothing is needed from the author unless the maintainer asks.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 22:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2581#issuecomment-7176212098) <!-- victory-triage v1 head=2c13b1c48dea5db6bb12a364b39bce4ea9ac1b9e verdict=needs-work at=2026-11-25T22:18:54Z --> Automated triage for the maintainers. **Needs the maintainer's decision.** The change tightens `xtask/src/policy.rs` and does not loosen it. `list_files` keeps git's NUL-separated names verbatim instead of turning `\` into `/` and decoding lossily, the walkdir fallback normalises only `MAIN_SEPARATOR`, and non-UTF-8 names now fail the check instead of being replaced by another name. By my reading this is correct, and the tests generate their inputs (single NUL bytes) in temp dirs. It merges cleanly and CI (`check`) passes, but the two `cfg(unix)` tests do not run on the Windows CI. It adds `tempfile` as a dev-dependency of `xtask` (`xtask/Cargo.toml`, `Cargo.lock`), and its tests spawn `git` processes. Dependency changes and process spawning are left to the maintainer, so this cannot be marked a merge candidate by triage. Nothing is needed from the author unless the maintainer asks. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2581/head:github-bot/gh-2581'
git switch 'github-bot/gh-2581'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2581'
git switch 'github-bot/gh-2581'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2581'
git switch 'github-bot/gh-2581'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2581'
git switch 'main'
git merge --squash 'github-bot/gh-2581'
git switch 'main'
git merge --ff-only 'github-bot/gh-2581'
git switch 'main'
git merge 'github-bot/gh-2581'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2581
No description provided.