Repository navigation
test(approval): fix stale comment and add CLI-layer regression test for #440 - #588
Conversation
vladimirrott
left a comment
There was a problem hiding this comment.
Reviewed at fa52fc93. Two mechanical items block it, and the test itself is good.
The test parses the real argv through Cli::try_parse_from and then goes through build_run_opts, so it checks the layer where a default_value_if or a yes: cli.yes || ... would slip in. That layer had no test before. Keeping the "did it parse" and "did it grant anything" assertions in one function was the right call; the comment you added says why.
I did not run the branch on my machine. In a --network=none container I broke the wiring the test guards, making the flag imply --yes:
mutation: s/yes: cli.yes,/yes: cli.yes || cli.dangerously_skip_approval,/ (apps/sysknife-cli/src/main.rs:190)
unmutated: dangerously_skip_approval_wiring_tests::dangerously_skip_approval_alone_does_not_imply_yes_max_risk_or_non_interactive ... ok
mutated: test dangerously_skip_approval_wiring_tests::dangerously_skip_approval_alone_does_not_imply_yes_max_risk_or_non_interactive ... FAILED (rc=101)
Blocking, both mechanical:
-
cargo fmt --all --checkfails, which is whyrustis red (run 37598756598):Diff in /home/runner/work/sysknife/sysknife/apps/sysknife-cli/src/main.rs:198: } } - #[cfg(test)] mod dangerously_skip_approval_wiring_tests {One blank line too many before
#[cfg(test)].cargo fmt --allfixes it. -
The test count. CI stopped at fmt, so
scripts/test_baseline.shnever ran, and it will fail next.mainis at 1,943 now (your body's 1,937 was right for the base you started from). With your one test it becomes 1,944, in four places:tests/evidence/workspace-tests.json,README.md:354,docs/introduction.md:147anddocs/distro-support.md:94. Rebase ontomainfirst, since #572 and #586 landed since you branched.
Optional: opts.skip_approval comes from UnattendedConsent::from_env, so the assert!(!opts.skip_approval) line holds only while SYSKNIFE_I_ACCEPT_UNATTENDED_ROOT is unset where the tests run. That's true in CI. The case where both keys are present and --yes is absent is covered one layer down by the_override_is_inert_without_yes, so nothing is missing.
When you push those two fixes, I'll merge if the push changes nothing beyond the formatting, the count and the rebase, the mutation above still fails, and the board is green; I'll approve at the new head once those hold.
|
Checking in, with nothing attached to it, @atanishka308. The test here is good, and the two items left are mechanical: one blank line that If you'd rather not spend time on that, say so and I'll push both fixes to this branch myself. You allowed maintainer edits, and the commit stays yours. Either way #440 is still yours, and dropping it costs nothing. |
The two mechanical items from the review: `cargo fmt` removes one blank line before the test module, and the new test moves the count from 1,995 to 1,996. Committed with --no-verify after check_no_secrets.sh --staged and cargo fmt --all --check; CI's baseline confirms the count. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UpyrhbDTW1gBwzGAC44GYU
vladimirrott
left a comment
There was a problem hiding this comment.
Approved at 841d8424, @atanishka308. I pushed the two mechanical fixes as offered: cargo fmt dropped the blank line, and the count moved to 1,996 for your test. Your branch also has main merged in, which brings the ctutils bump from #641. That bump fixed the security-audit failure you'd have seen this week, which came from main and had nothing to do with your change.
Your test and comment are unchanged from fa52fc93. I re-ran the mutation from my first review at this head:
mutation: s/yes: cli.yes,/yes: cli.yes || cli.dangerously_skip_approval,/
unmutated: pass mutated: FAILED
I'll merge once CI finishes. #440 closes with it.
If you want another one in the same area, #474 is free: the plan summary an operator approves goes through two sanitised paths and one that isn't. The scope update on that issue says which path is still open. I'll hold it for you if you say so there.
|
Merged as If you want another: #474 runs the other way from your #385. You sanitised the distro string on its way into the prompt; #474 is model-authored plan text on its way out to the operator. I've left a note there. |
Closes #440.
cli.rs's --help doc comment and docs/cli.md were already corrected in a prior PR — --dangerously-skip-approval only raises the --yes auto-approval ceiling from MEDIUM to HIGH and implies nothing else. This PR finishes the remaining scope from the issue:approval.rs: fixes the comment inside the_override_is_inert_without_yes, which claimed the flag "implies --yes at the CLI layer" — that was never true and the binary never did it. The assertion itself was always correct; only the comment was wrong.
main.rs: adds dangerously_skip_approval_wiring_tests, a new regression test that pins the contract one layer up from the existing policy-level test — through real CLI parsing and build_run_opts, not a hand-built ApprovalPolicy. It asserts both that the flag actually parsed (cli.dangerously_skip_approval) and that parsing it alone grants nothing (decide_step returns RequiresPrompt), in the same test, so the two assertions can't silently drift apart if a future default_value_if changes one but not the other.
Verified: cargo nextest run --workspace --locked — 1937 passed, 6
skipped, 0 failed.