Skip to content

Reserve Exit Status 64 for a Refused Argument in the host-setup/linux Scripts - #4381

Merged
ptr727 merged 9 commits into
developfrom
burndown/host-setup-usage-exit
Nov 24, 2026
Merged

ptr727 merged 9 commits into
developfrom
burndown/host-setup-usage-exit

Conversation

@ptr727

@ptr727 ptr727 commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

Every host-setup/linux script now exits 64 (EX_USAGE from sysexits.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.

  • One refusal path. Each script gains die_usage, which prints the ERROR: 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, --repo with no or an empty path, or with a path holding no host-tools.json, more than one action, --json beside another action, --sudo-timestamp with a tool, and an unknown tool name.
    • install-agents.sh: an unknown option, more than one action, --json beside another action, --all beside another action, --all with a tool name, an unknown tool name, and --install with neither.
    • setup-github.sh: an unknown option, --name, --email, or --shared-checkout with 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, --bucket with no value or a bad name, and no bucket at all.
  • The status is reserved as well as assigned. An EXIT trap turns any other exit carrying 64 into 1, since under set -e a failed command's own status becomes the script's. The trap calls exit only on that remap, so a signal death and every other status pass through unchanged.
  • The three scripts the issue predates are in scope. install-global-rules.sh, install-safety-kit.sh, and restore-secrets.sh have the same shape as install-skills.sh, which the issue lists, and the proposal covers every host-setup/linux script. Each of the four ends by exec-ing a program, which replaces the trap. None of those programs exits 64. They are scripts/skills_install.py, global_rules.py, the kit's install.sh and the install.py it execs, and scripts/secrets_sync.py. CODESTYLE.md now says a script relying on the contract execs only such a program.
  • The contract is stated. Each --help says Exit status 64 means an argument was refused, so nothing was changed. No other failure exits 64. install-agents.sh puts 64 into the exit-status sentence its help already carried instead. The same contract is stated in host-setup/linux/README.md and in a new CODESTYLE.md "Command-Line Arguments" bullet. That bullet reaches the shell-codestyle and python-codestyle include regions through build_dist.py.
  • The interrupt rule, since the four scripts holding a temporary directory are edited here. upgrade-host.sh, install-tools.sh, install-agents.sh, and setup-github.sh take CODESTYLE.md "Interrupts in Shell". The EXIT trap is set before new INT and TERM traps, 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.py holds the contract for every tracked host-setup/linux/*.sh, read from git ls-files. Its existing unknown-flag check now asserts 64 for those scripts. A new case checks that each --help names the status. It also checks that each refusal no other module covers exits 64 with its message and no effect. And it checks that die_usage exits 64 under the script's own traps, while another command exiting 64 under set -e leaves 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. The install-skills.sh and install-safety-kit.sh cases live here.
  • The existing refusal assertions in test_install_tools.py, test_install_agents.py, and test_restore_secrets.py now pin 64, and each of those refusals is asserted there alone. test_restore_secrets.py also 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 --help loop. The interrupt comment no longer claims the trap runs where sudo's use_pty keeps a Ctrl-C from the script's own shell. A later pass also found that restore-secrets.sh forwards its buckets to secrets_sync.py, whose own refusal of two host- 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 an exec target whose own 64 means a refused argument. An empty --repo, --name, --email, or --shared-checkout value is refused rather than silently read as absent. The interrupt test uses test_pre_commit_hook's group helpers, so a failed case kills what it started.

Local review findings declined

  • tests/test_cli_usage.py sourced_copy duplicates 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.
  • The on_exit remap in the four scripts that end by exec-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 every host-setup/linux script. 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

ptr727 and others added 3 commits November 23, 2026 15:55
… 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]>
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 24, 2026
Copilot AI lite review requested due to automatic review settings November 24, 2026 00:33
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d0c3a2e and 74fbd1c.

Files ignored due to path filters: 6

  • .claude-plugin/fleet-skills/.source-digests/python-codestyle is excluded by !.claude-plugin/fleet-skills/**
  • .claude-plugin/fleet-skills/.source-digests/shell-codestyle is excluded by !.claude-plugin/fleet-skills/**
  • .claude-plugin/fleet-skills/skills/python-codestyle/SKILL.md is excluded by !.claude-plugin/fleet-skills/**
  • .claude-plugin/fleet-skills/skills/shell-codestyle/SKILL.md is excluded by !.claude-plugin/fleet-skills/**
  • .github/skills/python-codestyle/SKILL.md is excluded by !.github/skills/**
  • .github/skills/shell-codestyle/SKILL.md is excluded by !.github/skills/**
Files selected for processing: 16

  • .agents/skills/python-codestyle/SKILL.md
  • .agents/skills/shell-codestyle/SKILL.md
  • CODESTYLE.md
  • host-setup/linux/README.md
  • host-setup/linux/install-agents.sh
  • host-setup/linux/install-global-rules.sh
  • host-setup/linux/install-safety-kit.sh
  • host-setup/linux/install-skills.sh
  • host-setup/linux/install-tools.sh
  • host-setup/linux/restore-secrets.sh
  • host-setup/linux/setup-github.sh
  • host-setup/linux/upgrade-host.sh
  • tests/test_cli_usage.py
  • tests/test_install_agents.py
  • tests/test_install_tools.py
  • tests/test_restore_secrets.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head b70ae7f4f3b896c4eb7d26ef0c09dbeef5fdac5e, the content this pull request carries at that commit against develop, and it recorded 3 findings.

…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]>

Copilot AI 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.

🔵 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

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.35%. Comparing base (b38e084) to head (74fbd1c).
⚠️ Report is 312 commits behind head on develop.

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     
Flag Coverage Δ
python-3.13 79.35% <ø> (-2.26%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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]>
@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 8b5182cf54c977c92ea3fabb01f50b9cdeef85ac, the content this pull request carries at that commit against develop, and it recorded 1 finding.

ptr727 and others added 3 commits November 23, 2026 16:54
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]>
@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 74fbd1c89a148ac0d907aff60c38034eafd6e3ac, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit 307d06e into develop Nov 24, 2026
14 checks passed
@ptr727
ptr727 deleted the burndown/host-setup-usage-exit branch November 24, 2026 01:32
ptr727 added a commit that referenced this pull request Nov 24, 2026
…, 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants