Config: victory config exits nonzero on an asset policy violation #1828

Merged
Ingenioeren merged 1 commit from upstream-pr/1830 into main 2026-11-25 21:51:42 +00:00
Ingenioeren commented 2026-11-24 23:07:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Ingenioeren on 2026-11-24T23:07:07Z.


What

show_config in apps/victory/src/main.rs printed POLICY VIOLATION: … for each configured path inside the source tree but always returned Ok(()). I moved the policy loop into check_policy, which counts the violations and, after printing them all, returns Error: N configured path(s) violate the asset policy. Because of that error, victory config now exits with 1. What it prints on stdout doesn't change, and a clean configuration still exits 0.

Why

#831: a command whose description says "show the resolved configuration and check it" reported success even when the check failed. A script or CI step can't tell the two apart.

The issue thread has three fork branches for this, all from people who couldn't open PRs at the time (kyle7908, pushkarreddyy, Louisreed). This PR is written independently but has the same shape as kyle7908's, which winne42's comparison recommended: violations stay on stdout and only the exit status changes.

How tested

Windows 11, Rust 1.98.1:

  • cargo test --locked -p victory --bins: 3 passed. The new tests::config_check_fails_a_path_inside_the_repository failed before the fix (unwrap_err() on an Ok value) and passes after it. tests::config_check_passes_paths_outside_the_repository passes both before and after. The tests build Config with ..Default::default(), so new fields won't break them.
  • The binary, run from %TEMP% so that no victory.toml is read:
    • With VICTORY_CACHE_DIR inside the checkout, it prints the violation, then Error: 1 configured path(s) violate the asset policy, and exits 1.
    • With the default directories, it exits 0.
  • cargo clippy --locked -p victory --all-targets: no warnings.
  • cargo fmt --check -p victory: clean.
  • cargo run -p xtask -- policy --staged: 1 files ok.

Not tested: Linux/macOS. The change is platform-neutral.

Fixes #831

AI assistance: prepared with Claude Code, reviewed by Ingenioeren.

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6593227637 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1830). Originally posted by [Ingenioeren](https://github.com/Ingenioeren) on 2026-11-24T23:07:07Z. --- ## What `show_config` in `apps/victory/src/main.rs` printed `POLICY VIOLATION: …` for each configured path inside the source tree but always returned `Ok(())`. I moved the policy loop into `check_policy`, which counts the violations and, after printing them all, returns `Error: N configured path(s) violate the asset policy`. Because of that error, `victory config` now exits with 1. What it prints on stdout doesn't change, and a clean configuration still exits 0. ## Why #831: a command whose description says "show the resolved configuration and check it" reported success even when the check failed. A script or CI step can't tell the two apart. The issue thread has three fork branches for this, all from people who couldn't open PRs at the time (kyle7908, pushkarreddyy, Louisreed). This PR is written independently but has the same shape as kyle7908's, which winne42's comparison recommended: violations stay on stdout and only the exit status changes. ## How tested Windows 11, Rust 1.98.1: - `cargo test --locked -p victory --bins`: 3 passed. The new `tests::config_check_fails_a_path_inside_the_repository` failed before the fix (`unwrap_err()` on an `Ok` value) and passes after it. `tests::config_check_passes_paths_outside_the_repository` passes both before and after. The tests build `Config` with `..Default::default()`, so new fields won't break them. - The binary, run from `%TEMP%` so that no `victory.toml` is read: - With `VICTORY_CACHE_DIR` inside the checkout, it prints the violation, then `Error: 1 configured path(s) violate the asset policy`, and exits 1. - With the default directories, it exits 0. - `cargo clippy --locked -p victory --all-targets`: no warnings. - `cargo fmt --check -p victory`: clean. - `cargo run -p xtask -- policy --staged`: `1 files ok`. **Not tested:** Linux/macOS. The change is platform-neutral. Fixes #831 AI assistance: prepared with Claude Code, reviewed by Ingenioeren. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
catminou4 commented 2026-11-25 00:06:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:47:47Z.

Review: COMMENTED


Static review only: apps/Windows-only — nothing compiles on macOS; source review of the diff.

victory config exits nonzero on an unknown key: CLI validation fix. apps-side; small.

<!-- greyfinch-sync:Marvisak/VIctory:review:6049283643 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1830#pullrequestreview-6049283643). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:47:47Z. **Review:** COMMENTED --- Static review only: apps/Windows-only — nothing compiles on macOS; source review of the diff. victory config exits nonzero on an unknown key: CLI validation fix. apps-side; small.
Marvisak commented 2026-11-25 07:03:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:32:22Z.


Automated triage for the maintainers.

Merge candidate. The head has not changed since the previous review (f148f00). check_policy in apps/victory/src/main.rs counts the victory_core::ensure_outside_repo refusals for the configured paths and returns an error, so victory config now exits nonzero on an asset-policy violation. Before this change it printed the message and still exited 0. The two unit tests check one path inside the checkout and one outside it, and Config derives Default, so the struct-update syntax in them compiles.

On the later discussion: the end-to-end exit-code table on Windows (0 on main and 1 with the patch for paths inside the checkout, 0 for paths outside) confirms the intended behaviour. Keeping kyle7908's CLI integration tests for a separate follow-up PR is fine. Nothing here changes the verdict. CI: no check runs on the head commit.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154894711 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7154894711). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:32:22Z. --- <!-- victory-triage v1 head=f148f005111fc55b2c0de2c631b3e4ead2a2c2e1 verdict=merge-candidate at=2026-11-25T11:21:28Z --> Automated triage for the maintainers. **Merge candidate.** The head has not changed since the previous review (`f148f00`). `check_policy` in `apps/victory/src/main.rs` counts the `victory_core::ensure_outside_repo` refusals for the configured paths and returns an error, so `victory config` now exits nonzero on an asset-policy violation. Before this change it printed the message and still exited 0. The two unit tests check one path inside the checkout and one outside it, and `Config` derives `Default`, so the struct-update syntax in them compiles. On the later discussion: the end-to-end exit-code table on Windows (0 on main and 1 with the patch for paths inside the checkout, 0 for paths outside) confirms the intended behaviour. Keeping kyle7908's CLI integration tests for a separate follow-up PR is fine. Nothing here changes the verdict. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
Ingenioeren commented 2026-11-25 07:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Ingenioeren on 2026-11-25T06:37:13Z.


I verified the CLI exit status end to end on Windows 11 with this patch applied cleanly to current main at 940d32f. Both builds used cargo build --locked --offline -p victory. Each invocation of victory config read a temporary TOML file via VICTORY_CONFIG.

Build and inputs Exit code Policy messages
Unmodified main, two paths inside the checkout 0 2
Main with f148f00, same two paths 1 2
Main with f148f00, all paths outside the checkout 0 0

The patched failure names both violations and reports the count on stderr. The input paths were synthetic. No game files or game process were involved.

AI-assisted verification.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154981036 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7154981036). Originally posted by [Ingenioeren](https://github.com/Ingenioeren) on 2026-11-25T06:37:13Z. --- I verified the CLI exit status end to end on Windows 11 with this patch applied cleanly to current `main` at `940d32f`. Both builds used `cargo build --locked --offline -p victory`. Each invocation of `victory config` read a temporary TOML file via `VICTORY_CONFIG`. | Build and inputs | Exit code | Policy messages | | --- | ---: | ---: | | Unmodified main, two paths inside the checkout | 0 | 2 | | Main with `f148f00`, same two paths | 1 | 2 | | Main with `f148f00`, all paths outside the checkout | 0 | 0 | The patched failure names both violations and reports the count on stderr. The input paths were synthetic. No game files or game process were involved. _AI-assisted verification._
kyle7908 commented 2026-11-25 10:07:51 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kyle7908 on 2026-11-25T09:54:16Z.


Hi @Ingenioeren,

I've reviewed PR #1830 against my earlier implementation for #831 (kyle7908/VIctory@a91e4db).

Your implementation looks solid, and I'm happy to support #1830 as the upstream fix rather than open a duplicate PR.

I also carried out an independent comparison using upstream 940d32f. Both implementations produced the expected results across 19 synthetic configuration scenarios in an isolated Linux Rust harness. This wasn't a full Windows CLI run, but my existing fork has separately passed its Windows CI suite (344 passed, 0 failed, 6 ignored).

One potentially useful addition is the two CLI integration tests from my implementation. Unlike the helper-level tests currently in #1830, they exercise configuration loading, command dispatch, actual process exit status and multiple policy violations. They also pass against #1830's implementation in the isolated harness.

I'd be happy to contribute those tests and the accompanying README clarification, while retaining your production implementation and giving appropriate attribution.

Would you prefer to incorporate those additions into #1830, or would a small follow-up PR be more useful?

Thanks for your work on this!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158956714 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7158956714). Originally posted by [kyle7908](https://github.com/kyle7908) on 2026-11-25T09:54:16Z. --- Hi @Ingenioeren, I've reviewed PR #1830 against my earlier implementation for #831 (kyle7908/VIctory@a91e4db). Your implementation looks solid, and I'm happy to support #1830 as the upstream fix rather than open a duplicate PR. I also carried out an independent comparison using upstream 940d32f. Both implementations produced the expected results across 19 synthetic configuration scenarios in an isolated Linux Rust harness. This wasn't a full Windows CLI run, but my existing fork has separately passed its Windows CI suite (344 passed, 0 failed, 6 ignored). One potentially useful addition is the two CLI integration tests from my implementation. Unlike the helper-level tests currently in #1830, they exercise configuration loading, command dispatch, actual process exit status and multiple policy violations. They also pass against #1830's implementation in the isolated harness. I'd be happy to contribute those tests and the accompanying README clarification, while retaining your production implementation and giving appropriate attribution. Would you prefer to incorporate those additions into #1830, or would a small follow-up PR be more useful? Thanks for your work on this!
Ingenioeren commented 2026-11-25 10:07:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Ingenioeren on 2026-11-25T10:00:54Z.


Thanks for comparing them, @kyle7908. I'd rather keep this PR small so it's easy to review. Your CLI integration tests would be a good follow-up PR once this lands: they test the real exit status and the multiple-violation case, and the helper tests here don't cover either. Since they're your tests, please open that PR yourself so the credit stays with you.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159107019 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7159107019). Originally posted by [Ingenioeren](https://github.com/Ingenioeren) on 2026-11-25T10:00:54Z. --- Thanks for comparing them, @kyle7908. I'd rather keep this PR small so it's easy to review. Your CLI integration tests would be a good follow-up PR once this lands: they test the real exit status and the multiple-violation case, and the helper tests here don't cover either. Since they're your tests, please open that PR yourself so the credit stays with you.
kyle7908 commented 2026-11-25 10:07:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kyle7908 on 2026-11-25T10:07:15Z.


Thanks @Ingenioeren, really appreciate that!

I'll prepare the CLI integration tests locally and wait until #1830 lands before opening a focused follow-up PR against upstream main.

I'll make sure the tests cover the actual process exit status, single and multiple policy violations, and preservation of the existing diagnostics, without changing your production implementation.

Thanks again for the collaboration!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7159252443 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7159252443). Originally posted by [kyle7908](https://github.com/kyle7908) on 2026-11-25T10:07:15Z. --- Thanks @Ingenioeren, really appreciate that! I'll prepare the CLI integration tests locally and wait until #1830 lands before opening a focused follow-up PR against upstream main. I'll make sure the tests cover the actual process exit status, single and multiple policy violations, and preservation of the existing diagnostics, without changing your production implementation. Thanks again for the collaboration!
upstream-sync closed this pull request 2026-11-25 22:03:11 +00:00
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!1828
No description provided.