Skip to content

CLI: report incomplete shader directory scans - #517

Open
Dathinel wants to merge 3 commits into
Marvisak:mainfrom
Dathinel:fix/report-shader-traversal-errors
Open

Dathinel wants to merge 3 commits into
Marvisak:mainfrom
Dathinel:fix/report-shader-traversal-errors

Conversation

@Dathinel

Copy link
Copy Markdown
Contributor

Both shader-info and translate exit 0 when a scan root is missing. This makes an incomplete batch look like a successful scan of an empty directory.

Report each traversal error on stderr, keep scanning accessible inputs, and exit 1 after printing the partial summary. A readable empty directory still exits 0. Scripts that use the exit status can now detect partial results.

Reproduce with cargo run -p victory -- shader-info missing-dir or cargo run -p victory -- translate missing-dir, using a path that does not exist. On Windows 11 with Rust 1.98.1, both returned 0 on d2a4bae and 1 with this patch.

cargo test --locked -p victory --test shader_paths checks that both commands count a synthetic container between two missing roots and report both paths. The workspace suite passed (265 passed, 4 ignored).

#254 moves the traversal loop in translate; combining the changes requires resolving that hunk. #115 covers census.

Codex implemented and tested the change. Claude Code independently reviewed the final diff.

@mercuryVM mercuryVM 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.

Tested 5f21114 on Windows 11, RTX 5070, MSVC: the workspace passes (196 outside victory-shader), including tests/shader_paths.rs.

  • Safety screen: the Cargo.toml and Cargo.lock changes only add tempfile as a dev-dependency of apps/victory. It is already a workspace dependency used by other crates' tests, so the lockfile only gains the edge and no new package.
  • Reporting traversal errors, keeping the scan going, and then failing with "scan incomplete" after the summary is the right behaviour for batch scripts. Suppressing the "none found" hint when the emptiness came from errors avoids a misleading message.
  • scan_entries is shared by both commands. #115 does the same for census, with a depth-0 hard error instead. The two are slightly inconsistent (fail fast versus finish then fail), which is worth aligning eventually, but not in this PR.

No issues found.

AI-assisted (Claude Code).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…ry scans

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@catminou4 catminou4 mentioned this pull request Nov 24, 2026
3 tasks done

@catminou4 catminou4 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.

Triage: this and #534 attack the same problem (shader/translate scan input failures) with different designs. Comparison for whoever reviews:

  • #517 (this one): shared scan_entries helper counting walk errors, hard failure at the end (anyhow::ensure!(walk_errors == 0)), missing root surfaces as a traversal error, integration test drives the real victory binary (tests/shader_paths.rs, exit code 1, stderr names both bad inputs), and Cargo.lock is updated.
  • #534: per-file errors collected and printed but the command still exits 0; missing root is a hard anyhow::ensure!; unit tests in shader.rs/translate.rs; Cargo.lock NOT updated → breaks --locked builds (verified locally, see my review there).

Semantic difference that matters: #517 fails the entire scan if any traversal error occurs anywhere in the tree (one unreadable file in a big dump kills the run); #534 only fails on a missing root and merely reports per-file errors. For a diagnostic CLI over multi-GB title dumps I'd mildly prefer #534's distinction, but #517's integration test and lockfile are stronger as submitted.

Not verifiable on macOS (app crate doesn't build here); both diffs read correctly statically.

@geiyiliyabumo

Copy link
Copy Markdown
Contributor

Independent review on Windows 11 x64 / MSVC (merged PR head 5f21114 into current main; reviewed the full origin/main..HEAD diff, clean auto-merge on translate.rs).

Verified:

  • cargo run --locked -p xtask -- policy -> "asset policy: 155 files ok" (rule Possible Fixes #1 clean: the new fixture is a tempfile tempdir + a synthetic DXBC header built in code, no game data)
  • cargo clippy --workspace --all-targets --locked -- -D warnings -> clean
  • cargo test -p victory --locked -> 2/2 pass, incl. new shader_commands_report_missing_roots_and_scan_the_rest

Looks correct and well scoped. scan_entries now counts (and prints) every WalkDir error; both shader-info and translate emit a non-zero exit via anyhow::ensure! when any traversal error occurred, while still printing the partial results first (best-effort output + honest exit code). Suppressing the "(none found...)" hint on an incomplete scan avoids reporting a failed scan as empty. The new test is hermetic/synthetic - it clears VICTORY_PAIRS so no GPU/D3D12 is needed - and checks exit 1, both missing roots, the exact count (2), and that the valid file is still scanned.

Non-blocking observations:

  • Only WalkDir traversal errors are counted. Per-file std::fs::read(...) and entry.metadata() failures are still silently skipped, so an exit 0 can in principle still mask individual unreadable files. If exhaustive completeness is the goal, those could feed the same counter.
  • census.rs:35-37 still uses filter_map(Result::ok) and silently drops the same walkdir errors. Out of scope for a shader-scan PR, but consider aligning it for consistency.
  • Behavior change worth noting to callers: both commands now exit 1 on any traversal error (previously 0). Deliberate and desirable.
  • Minor: no positive assertion that a fully-clean scan still returns 0 (guards against the new ensure! firing on a good run).

No blocking issues - nice, focused fix.

AI-assisted; synthetic tests only, no game files.

@Dathinel

Copy link
Copy Markdown
Contributor Author

Thanks @geiyiliyabumo. Added the clean-directory case in bab15db. Both shader-info . and translate . must exit 0 and count the one synthetic container in the directory. The mixed-input case still requires exit 1 and checks that both missing paths are reported.

To reproduce, run cargo test --locked -p victory --test shader_paths. On Windows/MSVC, forcing either command to return 1 on a clean scan failed the new assertion. With the patch integrated locally against ffe310e, the workspace suite passed (343 passed, 6 ignored), as did both Clippy configurations from CI.

For the overlap discussion, #115 covers census. At 29046af, #534 also includes the lockfile change and tests empty directories. The test here exercises the CLI on a populated directory.

AI-assisted. All fixtures for this test are synthetic.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 25, 2026
Where a fork-only change duplicates upstream's own version of a feature,
upstream's is kept and the fork's dropped:
- victory-shader is upstream's crate with the fork-only merges replayed
  onto it oldest first; those that do not apply onto upstream are dropped
  (37 of 63: among them Marvisak#704/raw views, gather4_l, the lane-mask and Marvisak#308
  ports, Marvisak#947, Marvisak#1022, Marvisak#1112, Marvisak#1090, Marvisak#1182). Marvisak#284 (legacy fused madds) and
  Marvisak#98 (permlane16 in whole-wave sections) are dropped too: the first
  disagrees with upstream's hardware-checked model, the second refused 46
  programs upstream translates.
- translate: upstream's --cache replaces Marvisak#254's write-cache and work queue;
  Marvisak#378, Marvisak#517, Marvisak#673 and the victory.toml console are re-applied.
- victory-gpu: upstream's stride table, page table and heap views replace
  the fork's Marvisak#704/stride-table wiring; fork-only fixes re-applied on top.

Package (shaders.rpf, translate --validate --list, counts): vertex/pixel
emitted 12559 -> 14295 of 14337, compute 2359 -> 2628 validated, mesh
2730 -> 2811 validated. Tests: the failures left (rect fourth corner,
two stride tests, row order, gather4 at a level, memory table, dynamic
heap slots) fail on upstream main as well on this host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: Cargo.lock, apps/victory/src/shader.rs, apps/victory/src/translate.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

@Dathinel

Copy link
Copy Markdown
Contributor Author

Resolved the conflicts in 0749a8e by integrating main@4118f33. The shader pack listing and translation progress from main are preserved.

On Windows/MSVC, cargo test --locked -p victory --test shader_paths failed on unmodified main with the added test (a partial scan exited 0) and passed after the fix. Both Clippy configurations passed. The PR CI run and the main CI run fail the same two shader tests: gathers_at_a_level_match_the_hardware and permutes_read_the_lane_named_and_zero_from_lanes_left_out.

AI-assisted; the scan regression uses a synthetic fixture.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants