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

Manually merged
github merged 1 commit from gh-pr/1830/head into gh-pr/1830/base 2026-11-26 04:46:00 +00:00
Owner

@⁠Ingenioeren on GitHub · 2026-11-24 23:07 UTC · original
Ingenioeren:fix/831-config-policy-exit → main · +45 −0 · 1 files · 1 commits · merged 2026-11-25 21:51 UTC

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

**@⁠Ingenioeren** on GitHub · 2026-11-24 23:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1830) `Ingenioeren:fix/831-config-policy-exit` → `main` · +45 −0 · 1 files · 1 commits · merged 2026-11-25 21:51 UTC ## 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)
`show_config` printed `POLICY VIOLATION` for each configured path inside
the source tree but always returned `Ok`, so a script could not tell a
clean configuration from a refused one. It now counts the violations and
fails after printing them; the stdout output is unchanged.

Fixes #831

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:45:59 +00:00
github manually merged commit f148f00511 into gh-pr/1830/base 2026-11-26 04:46:00 +00:00
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 06:32 UTC · original · edited 2026-11-25 11:21 UTC

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

**@⁠Marvisak** on GitHub · 2026-11-25 06:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7154894711) · edited 2026-11-25 11:21 UTC <!-- 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)_
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 06:37 UTC · original

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.

**@⁠Ingenioeren** on GitHub · 2026-11-25 06:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7154981036) 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._
Author
Owner

@⁠kyle7908 on GitHub · 2026-11-25 09:54 UTC · original

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!

**@⁠kyle7908** on GitHub · 2026-11-25 09:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7158956714) 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!
Author
Owner

@⁠Ingenioeren on GitHub · 2026-11-25 10:00 UTC · original

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.

**@⁠Ingenioeren** on GitHub · 2026-11-25 10:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7159107019) 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.
Author
Owner

@⁠kyle7908 on GitHub · 2026-11-25 10:07 UTC · original

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!

**@⁠kyle7908** on GitHub · 2026-11-25 10:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1830#issuecomment-7159252443) 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!
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!1830
No description provided.