Repository navigation
Reserve Exit Status 64 for a Refused Argument in the host-setup/linux Scripts - #4381
Conversation
… Scripts Every argument refusal in the eight host-setup/linux scripts now exits 64 (EX_USAGE) through one die_usage function. An EXIT trap maps any other exit carrying 64 to 1, so a caller can tell a refusal from a run that started and failed. Each --help, the README, and CODESTYLE.md "Command-Line Arguments" state the contract. The four scripts holding a temporary directory also take the interrupt rule now that they are edited: INT and TERM traps stop the running child, name the signal, and re-raise it, and run() waits on its command in the background. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…l Tests apt-get, dpkg, and do-release-upgrade do not stop cleanly on SIGTERM, so run() runs them in the foreground again and the INT and TERM traps only name and re-raise the signal. A --repo path holding no host-tools.json is now a refused argument, install-agents.sh states 64 in its existing exit-status sentence, and the per-script refusal tables move into the one cross-script case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The unknown-option check for host-setup/linux joins the existing unknown-flag loop, the cross-script table drops rows the per-script modules already assert, the script set comes from git ls-files, and the trap comments cite the launcher case of "Interrupts in Shell". Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 24 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
|
A recorded local strict-review pass covers head |
…mment The help-states-64 check moves into the existing sandboxed --help loop, the duplicate unknown-tool row goes, and the trap comment no longer claims the trap runs where sudo's use_pty keeps Ctrl-C from the shell. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🔵 Needs a closer look
Because the change affects signal propagation and reserved exit-status handling across all Linux host launchers, deployed sudo/PTY behavior still requires maintainer confirmation beyond the direct process-group signaling tests.
No open issues 🎉
What changed in this PR
This PR reserves exit status 64 for refused command-line arguments in every host-setup/linux script, prevents unrelated failures from leaking status 64, and documents the contract for callers.
Changes:
- Adds argument-refusal handling, status remapping, and signal cleanup to the Linux host scripts.
- Updates help text, host-setup documentation, and shared shell and Python coding guidance.
- Expands tests for refusal statuses, reserved-status behavior, help text, and interrupt cleanup.
| File | Description |
|---|---|
| tests/test_restore_secrets.py | Pins argument refusals to status 64 while preserving root-account refusal as status 1. |
| tests/test_install_tools.py | Updates the JSON argument-refusal expectation to status 64. |
| tests/test_install_agents.py | Updates agent installation and argument-refusal expectations to status 64. |
| tests/test_cli_usage.py | Adds cross-script coverage for exit statuses, help text, status remapping, and interrupt cleanup. |
| host-setup/linux/upgrade-host.sh | Adds status-64 argument refusal handling, help text, and signal traps. |
| host-setup/linux/setup-github.sh | Adds status-64 argument refusal handling, help text, and signal traps. |
| host-setup/linux/restore-secrets.sh | Adds status-64 handling for invalid bucket and option arguments while retaining the root refusal status. |
| host-setup/linux/README.md | Documents the Linux host-setup script exit-status contract. |
| host-setup/linux/install-tools.sh | Adds status-64 argument validation, help text, and signal cleanup. |
| host-setup/linux/install-skills.sh | Adds status-64 handling for unknown options and documents the contract in help. |
| host-setup/linux/install-safety-kit.sh | Adds status-64 handling for unknown options and documents the contract in help. |
| host-setup/linux/install-global-rules.sh | Adds status-64 handling for unknown options and documents the contract in help. |
| host-setup/linux/install-agents.sh | Adds status-64 argument validation, help text, and signal cleanup. |
| CODESTYLE.md | Defines the reserved argument-refusal status and related shell-script requirements. |
| .github/skills/shell-codestyle/SKILL.md | Carries the updated shell command-line status guidance. |
| .github/skills/python-codestyle/SKILL.md | Carries the updated shared command-line status guidance for Python. |
| .claude-plugin/fleet-skills/skills/shell-codestyle/SKILL.md | Updates the generated Claude shell coding guidance. |
| .claude-plugin/fleet-skills/skills/python-codestyle/SKILL.md | Updates the generated Claude Python coding guidance. |
| .claude-plugin/fleet-skills/.source-digests/shell-codestyle | Updates the source digest for the generated shell coding guidance. |
| .claude-plugin/fleet-skills/.source-digests/python-codestyle | Updates the source digest for the generated Python coding guidance. |
| .agents/skills/shell-codestyle/SKILL.md | Updates the authored shell coding guidance with the command-line contract. |
| .agents/skills/python-codestyle/SKILL.md | Updates the authored Python coding guidance with the command-line contract. |
Review effort: Lite
restore-secrets.sh passes its buckets to secrets_sync.py, whose own refusal of one exits 1, so the README and the CODESTYLE.md bullet now say 64 covers the script's own refusals. The install-agents.sh interrupt comment names what that script actually runs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4381 +/- ##
===========================================
- Coverage 81.60% 79.35% -2.26%
===========================================
Files 26 45 +19
Lines 9070 16046 +6976
===========================================
+ Hits 7402 12734 +5332
- Misses 1668 3312 +1644
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Each step runs under timeout, which gives it a process group of its own, so the comment now says the trap runs once that step returns or times out rather than citing the launcher case. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |
Its steps differ in what a Ctrl-C reaches, a download directly and an updater under timeout, so the comment keeps only what the trap does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Bound the Signal Test An empty --repo value is now a refused argument rather than silently dropping the repository's tools. The CODESTYLE.md bullet allows an exec target whose 64 also means a refused argument. The interrupt test uses the shared group helpers, so a failed case kills what it started. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the Signal Test Fails An empty --name, --email, or --shared-checkout value is now a refused argument, as an empty --repo is, rather than silently falling back. The interrupt test reports which script never started its child, with its stderr. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |
|
@coderabbitai review |
|
/review |
Action not completed
|
…, Shared Run Deadline, and Second-Shell Paste-Safe (#4388) Promotes the ten pull requests that landed on develop since the last promotion: backlog burndown round 5, plus #4374 and #4376. - #4374: Quote the last paste-safe placeholders and run the check in the local block (the #1615 remainder). - #4376: Declare host-secrets for HomeAutomation-Config in the registry. - #4378: GOVERNANCE.md "Verification Discipline" requires the whole test suite before every push. The Husky hook bullet says it passes the staged paths to the prose gate. The `pr-review-conduct` Merge Gate names the rate-limit `success` check trap, the only part of #1298 kept per the maintainer's 2026-11-23 answer. - #4379: `validate-task.yml` fails a promotion when main's first-parent chain since the previous promotion holds a single-parent commit, an accidental squash into main. The conflicted-promotion cut and the squash recovery are documented in `branching-and-release-model`, and `drive-pr` points at them. - #4380: `canonical_review.py record` binds each unit's pass to the reviewer's written report rather than a typed `--findings` count. - #4381: Every argument refusal in the `host-setup/linux` scripts exits 64 through `die_usage`, and an EXIT trap maps a stray 64 to 1. The contract is stated in CODESTYLE.md "Command-Line Arguments". - #4382: The prose gate's `paste-safe` rule reads the string handed to `su`/`runuser -c`, a POSIX shell's `-c`, and `ssh`. This edits `host-setup/agent-safety/README.md` (two example loops only), which the maintainer approved and merged on 2026-11-24. - #4384: `upstream-contribution-workflow` says what a refused lease push on the dirty branch means. `audit-a-repo` carries the convention-layout note on its `--checkout` path. - #4385: Every timed captured run in the review and install tooling goes through one shared `scripts/run_deadline.py`, so a captured timeout holds its deadline on Windows. - #4386: The canonical `.editorconfig` sets every IDE code-style rule to `warning`, per the maintainer's strictest-defaults answer, and the `dotnet-codestyle` skill now agrees with the rules it enforces. ## Owed by the maintainer before rollout - A fleet resync is owed, because carried text changed: GOVERNANCE.md, CODESTYLE.md, `.editorconfig`, the reusable `validate-task.yml`, and several skills. - Every carrying C# repository has to fix its code at its next `.editorconfig` resync (#4386). The rules likely to fire most are IDE0058, IDE0046, IDE0210, IDE0290 and IDE0047/IDE0048. - HomeAutomation-Config#1466 can adopt the exit-64 contract once this is released. - #4379 keeps the `048a442f` floor your decision named, but the walk always stops at a later promotion merge, so the floor is never reached. Whether to drop it is your call. Fixes #1615 Fixes #2280 Fixes #3820 Fixes #1298 Fixes #2510 Fixes #4373 Fixes #3804 Fixes #3605 Fixes #4375 Fixes #4345 Fixes #3854 Fixes #1842 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Every
host-setup/linuxscript now exits 64 (EX_USAGEfromsysexits.h) for an argument it refuses itself, and for no other failure. A caller wrapping a script can therefore tell "the arguments were refused, nothing changed" from "the run started and failed" by the status alone. The maintainer chose 64 over 2 on the issue.die_usage, which prints theERROR:line, marks the refusal, and exits 64. Every argument refusal goes through it:upgrade-host.sh: an unknown option, and more than one action.install-tools.sh: an unknown option,--repowith no or an empty path, or with a path holding nohost-tools.json, more than one action,--jsonbeside another action,--sudo-timestampwith a tool, and an unknown tool name.install-agents.sh: an unknown option, more than one action,--jsonbeside another action,--allbeside another action,--allwith a tool name, an unknown tool name, and--installwith neither.setup-github.sh: an unknown option,--name,--email, or--shared-checkoutwith no or an empty value, and more than one action.install-skills.sh,install-global-rules.sh,install-safety-kit.sh: an unknown option.restore-secrets.sh: an unknown option,--bucketwith no value or a bad name, and no bucket at all.EXITtrap turns any other exit carrying 64 into 1, since underset -ea failed command's own status becomes the script's. The trap callsexitonly on that remap, so a signal death and every other status pass through unchanged.install-global-rules.sh,install-safety-kit.sh, andrestore-secrets.shhave the same shape asinstall-skills.sh, which the issue lists, and the proposal covers everyhost-setup/linuxscript. Each of the four ends byexec-ing a program, which replaces the trap. None of those programs exits 64. They arescripts/skills_install.py,global_rules.py, the kit'sinstall.shand theinstall.pyit execs, andscripts/secrets_sync.py. CODESTYLE.md now says a script relying on the contract execs only such a program.--helpsaysExit status 64 means an argument was refused, so nothing was changed. No other failure exits 64.install-agents.shputs 64 into the exit-status sentence its help already carried instead. The same contract is stated inhost-setup/linux/README.mdand in a new CODESTYLE.md "Command-Line Arguments" bullet. That bullet reaches theshell-codestyleandpython-codestyleinclude regions throughbuild_dist.py.upgrade-host.sh,install-tools.sh,install-agents.sh, andsetup-github.shtake CODESTYLE.md "Interrupts in Shell". TheEXITtrap is set before newINTandTERMtraps, which print one line naming the signal and re-raise it. Every command stays in the foreground, as that section requires of a launcher that does not stop its tool cleanly on SIGTERM. apt-get, dpkg,do-release-upgrade, and the agent updaters are such launchers. So Ctrl-C reaches the running command as before, and apt still finishes the dpkg call it is in before it stops. The trap runs once the command returns.Tests
tests/test_cli_usage.pyholds the contract for every trackedhost-setup/linux/*.sh, read fromgit ls-files. Its existing unknown-flag check now asserts 64 for those scripts. A new case checks that each--helpnames the status. It also checks that each refusal no other module covers exits 64 with its message and no effect. And it checks thatdie_usageexits 64 under the script's own traps, while another command exiting 64 underset -eleaves as 1 and another status passes through unchanged. A second case signals the process group of each of the four temporary-directory scripts with SIGINT and with SIGTERM while a foreground command runs. It asserts death by the signal, the line naming it, the directory removed, and the command gone. Theinstall-skills.shandinstall-safety-kit.shcases live here.test_install_tools.py,test_install_agents.py, andtest_restore_secrets.pynow pin 64, and each of those refusals is asserted there alone.test_restore_secrets.pyalso pins the root refusal at 1, since it refuses the account rather than an argument.Local review findings fixed after the opening push
Every finding a push listed as open is fixed in a later commit. The duplicate unknown-tool row is gone. The help check now sits in the sandboxed
--helploop. The interrupt comment no longer claims the trap runs where sudo'suse_ptykeeps a Ctrl-C from the script's own shell. A later pass also found thatrestore-secrets.shforwards its buckets tosecrets_sync.py, whose own refusal of twohost-buckets exits 1. So the README and the CODESTYLE.md bullet now say 64 covers a script's own refusals, and a forwarded argument the program refuses keeps that program's status. The bullet also allows anexectarget whose own 64 means a refused argument. An empty--repo,--name,--email, or--shared-checkoutvalue is refused rather than silently read as absent. The interrupt test usestest_pre_commit_hook's group helpers, so a failed case kills what it started.Local review findings declined
tests/test_cli_usage.pysourced_copyduplicates the strip-main "$@"helpers in five other test modules (consolidation). Declined as out of scope here. The other five are each bound to one script, and this is the one that takes a path. A shared test module would be a new file outside this change's file claim.on_exitremap in the four scripts that end byexec-ing a program guards nothing those scripts run today (over-hardening). Declined because the issue's agreed proposal reserves the status with that trap in everyhost-setup/linuxscript. The trap keeps the contract whole against a later edit that adds a command able to exit 64.Closes on promotion: #3605
ptr727/HomeAutomation-Config#1466 waits on this contract.
🤖 Generated with Claude Code