Repository navigation
Run the Hook Launcher Before Trusting It and Read Short-Option Clusters Through One Helper - #4032
Conversation
…rs Through One Helper The agent-safety installer chose the interpreter it writes into settings.json by presence on PATH, so a stub that runs no script could be registered and the write guard would never run. Each candidate is now run with a probe that must print a token and a version at the 3.11 floor. The install picks the launcher before writing anything and runs each hook's self-test under it. --report runs the launcher each registration names. install.sh reads its probe's output and leaves stderr visible. The write guard read short-option clusters several ways. One helper now cuts a cluster at its first value-taking letter and says whether the next word is the value, and the push, commit, clean, and branch-rename readers go through it. A clean's -e and --exclude values, attached or separated, are no longer read as a dry run. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The forced worktree remove, the checkout and switch force check, the rebase operand count, and the symbolic-ref write check now read through the same helper, so a rebase -x or symbolic-ref -m value is no longer an operand. The retired _operands helper and its value sets go with them. Self-test rows pin commit -u, branch -t, and the rebase and symbolic-ref readings, and a unit test pins an attached commit -S in the in-place check. The launcher probe drops a branch only a forged token reached. Co-Authored-By: Claude Opus 5.5 <[email protected]>
git symbolic-ref reads the words after -- as its name and ref, so a write spelled that way is a branch move again. The in-place -S pin moves into the guard's own in-place case table. 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 38 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 |
There was a problem hiding this comment.
🟡 Changes recommended
Approval is blocked by an unresolved critical repository-targeting bug, additional launcher validation failures, and missing Windows coverage.
4 open issues
What changed in this PR
This pull request hardens agent-safety launcher installation and consolidates Git short-option parsing in the write guard.
Changes:
- Validates Python launchers before installation, self-tests, and registration reporting.
- Updates the shell installer and documentation for launcher probing and fallback behavior.
- Centralizes option-cluster parsing across push, commit, clean, branch, rebase, checkout, and symbolic-ref checks.
- Expands installer and guard regression coverage.
| File | Description |
|---|---|
| host-setup/agent-safety/README.md | Documents the revised Git short-option and clean-command parsing behavior. |
| host-setup/agent-safety/claude/test_install.py | Adds coverage for launcher validation, fallback, installation, reporting, and registration behavior. |
| host-setup/agent-safety/claude/README.md | Documents validated launcher selection, fallback behavior, and stale registration reporting. |
| host-setup/agent-safety/claude/install.sh | Probes POSIX Python candidates against the required version floor before selecting an installer launcher. |
| host-setup/agent-safety/claude/install.py | Validates launchers, uses the selected launcher for self-tests, and checks registered hook launchers. |
| host-setup/agent-safety/claude/gh-write-guard.py | Centralizes short-option cluster parsing and updates guard decisions across affected Git commands. |
Review effort: Lite
…t-safety-launcher-and-clusters
|
A recorded local strict-review pass covers head |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4032 +/- ##
===========================================
- Coverage 81.60% 78.91% -2.70%
===========================================
Files 26 37 +11
Lines 9070 12658 +3588
===========================================
+ Hits 7402 9989 +2587
- Misses 1668 2669 +1001
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:
|
|
@coderabbitai review |
|
/review |
Action not completed
|
…Status (#4041) ## Summary Fixes two of the three P1 findings raised on promotion PR #4039 against the agent-safety launcher probe that #4032 added. Each fix fails closed, and each comes with a test built on constructed input that fails against the code on `develop`. - `host-setup/agent-safety/claude/install.py:498` (`launcher_problem`): a probe that printed the token followed by a non-numeric version, such as `agent-safety-launcher 3a 11`, raised `ValueError` and aborted the install or `--report`. That output is now a refusal, so `hook_launcher()` moves on to the next candidate. - `host-setup/agent-safety/claude/install.sh:16`: the wrapper ignored the probe's exit status, so a stub that printed `ok` and exited 3 was handed `install.py`. The output is now captured with an `&&` status check before it is compared. The exposure was narrower than the finding states, because `install.py`'s own `hook_launcher()` already re-probes the hook launcher and checks its return code. What was at stake is only which interpreter runs `install.py`. ## Deferred finding - `host-setup/agent-safety/claude/install.py:530` (`registered_launcher`) is deferred to #4040, on the maintainer's decision. For the double-quoted shape `hook_command()` writes, the finding is wrong: POSIX `shlex.split` keeps single backslashes, so a quoted `C:\...` launcher splits intact. A UNC launcher loses one of its leading backslashes inside double quotes, and a bare, unquoted hand-written path loses all of them. Whether either of those is a defect depends on which shell runs a hook on native Windows. Under Git Bash the POSIX split matches what actually runs, and under cmd.exe it does not. #4040 settles the executor before the split changes. ## Tests New cases in `TestLauncher` in `host-setup/agent-safety/claude/test_install.py`: - `test_a_malformed_version_is_refused_and_the_next_candidate_tried`: before the fix it raised `ValueError: invalid literal for int() with base 10: '3a'`. - `test_install_sh_passes_over_a_python_that_prints_ok_and_fails`: runs `install.sh --help` with a `python3` stub that prints `ok` and exits 3, placed ahead of a working `python`. Before the fix the wrapper exits 3. `python3 -m unittest test_install` runs 196 tests, all OK. `shellcheck install.sh`, `ruff check`, and `ruff format --check` are clean. ## Local review findings, declined - The local pass judged both fixes over-hardening, saying only a stub written for a test reaches the non-integer branch or prints `ok` while failing. Declined: both are P1 findings verified real on #4039 with constructed inputs, the maintainer kept them, and each fix fails closed in a few lines. A later local pass found that the new `install.sh` test's skip condition carried a redundant `os.name` check. That is fixed in this PR. ## Pre-existing findings, not filed - `host-setup/agent-safety/claude/install.ps1`, the Windows twin of `install.sh`, which this PR does not touch, chooses `py -3` or `python3` without running a version probe. A `python3` app execution alias would be picked and would then fail loudly through `exit $LASTEXITCODE` rather than fall through to the next candidate. `install.py` still enforces the 3.11 floor on its own. Closes on promotion: none 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **Bug Fixes** * Improved installation checks for Python launchers. Invalid version information and checks that fail despite printing a success message are now rejected, allowing the installer to try another candidate and avoid creating an incomplete installation. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…tall on Release, Cleanup and Handoff Fixes (#4039) ## Summary Promotes burndown round 1 of the attended run of 2026-11-10 from `develop` to `main`. - #4035: the prose gate builds its HTML span without slicing markdown-it-py's pattern, and the gate, `backlog_metrics.py`, and the test requirements pin `markdown-it-py` exactly. That ends the import crash 4.3.0 caused on every pull request. - #4032: the agent-safety installer probes each hook launcher before choosing one and installs nothing when none runs. The write guard reads every short-option cluster through one table-driven helper. Merged on the maintainer's go-ahead after reading the diff. - #4029: `merge-and-release` installs the updated host-safety kit in its release step, guarded against rolling a kit back. Where a promotion is already merged under a release scope, it reads the publisher's runs before asking. - #4030: `pr_cleanup.py` names every git-ignored entry a worktree removal deletes before it removes the tree. - #4034: a handoff comment that only quotes a round mark is no longer read as an archived round. `blocked` stays on while a new decision waits, a default handoff pick is confirmed, and a track's final round is written before `close`. ## Closes Fixes #4033 Fixes #3935 Fixes #1172 Fixes #3783 Fixes #3897 Fixes #4019 Fixes #4009 Fixes #4013 Fixes #3679 Fixes #4018 Fixes #3914 Fixes #3841 Fixes #4017 Fixes #4010 Fixes #3791 Fixes #3795 🤖 Generated with [Claude Code](https://claude.com/claude-code)



Closes on promotion: #1172, #3783
Summary
Two maintainer-approved agent-safety fixes, one in the installer and one in the write guard. Merging waits on the maintainer's go-ahead after reading this diff, since it edits
host-setup/agent-safety/.#1172: run the hook launcher before trusting it (approved Option 1)
install.pyno longer picks the interpreter it writes intosettings.jsonby presence onPATH.launcher_problem()runs each candidate with a probe that must print a token and its version, and refuses one below the 3.11 floor. Its stderr is kept in the reason. A stub that exits 0, such as a Windows app execution alias, prints neither, so it is refused.hook_launcher()triespython3, thensys.executable, and returns the reasons each refused candidate failed. The install chooses the launcher before writing anything, prints each candidate it passed over, and installs nothing when none passes.sys.executable, so a pass also proves the launcher runs the hook.--reportruns the launcher each registration names in the<launcher> <path>shape, throughregistered_launcher(). So a host registered before this fix reports STALE once that launcher stops running. Any other command shape is not run.install.shreads its probe's output against the 3.11 floor rather than its exit status, and no longer discards the probe's stderr.#3783: read short-option clusters through one helper (approved design "one shared helper, extended to separated values")
_cluster(word, values, optional)returns a cluster's letters before its first value-taking letter, and whether the value is the next word (only where that letter ends the word)._flags(sub, args)walks a subcommand's words through it, with_OPTION_VALUESholding each subcommand's value letters, optional-value letters, and value-taking long options._push_targets,_skips_hooks(commit and push), the in-place commit check, the primary-checkoutcleanreader, and thegit branchrename check all read through it. So do the other cluster readers in the same file, per the one-primitive-per-class rule: the forcedworktree remove, thecheckout/switchforce check, therebaseoperand count, and thesymbolic-refwrite check. The old_commit_flags,_operands,_REBASE_VALUES,_CHECKOUT_FORCE_CHARS, and the inline regexes are gone. The guard is 2431 lines, under its 2500-line ceiling.cleanreader now skips the value after-eand--exclude, attached or separated. Soclean -fen,-fe.env,-f -e -n, and-f --exclude -nare read as forcing, as git reads them, and are denied in a primary checkout.-Sand-u, branch's-t, and rebase's-Stake an attached value only, as git parses them. Socommit -Snkeyandcommit -unocarry no-n, andbranch -umainis not a rename. Arebase -xorsymbolic-ref -mvalue is no longer counted as an operand, andsymbolic-ref -qdis read as a delete. These changes deny less only where git itself reads no such flag.Verification
gh-write-guard.py --selftestpasses with new rows for each case above, including the in-placecommit -Sa(allowed) and-aS(denied) andsymbolic-ref -- HEAD refs/heads/develop(still a branch move). Against develop's guard the new rows fail for-Snkey,push -o --no-verify,branch -umain,branch -u -m, and the fourcleanexclude forms.cleanrow was checked against git itself in a throwaway repository: the four exclude forms delete an untracked file and-f -e x -nkeeps it.test_install.pypasses, with a newTestLauncherclass covering a stub exiting 0, a stub failing with stderr, a version below the floor, a missing launcher, the fallback past a brokenpython3, no working candidate, an install refusing with nothing written, an install past a brokenpython3, and--reportflagging a registered launcher that cannot run.tests/test_guard_size.pypasses.Local strict review
Three recorded
agent-skillpasses. The first raised four findings, the second two, and the third none. Eachintroducedfinding was fixed on this branch.Pre-existing findings, filed
host-setup/agent-safety/claude/install.ps1, correctness: the Windows wrapper takespython3becauseGet-Commandfinds it rather than because it runs. Filed as Probe Each Interpreter install.ps1 Tries Rather Than Taking the First One Found #4031.🤖 Generated with Claude Code