Repository navigation
Expand Stepped and Signed Brace Ranges in the Write Guard - #4596
Conversation
Bash steps an alphabetic range as it steps a numeric one, so
`git commit -{a..z..2} x` runs with `-a`. The guard's lexer left a
stepped alphabetic range literal and let that blanket commit through
requirement 11. It now takes the optional step on both kinds of range.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bash takes a leading + on a range's endpoints and step, so
`git commit -{A..z..+32} x` runs as `git commit -A -a x`. Both range
patterns now share one signed-integer fragment. The regression row now
carries no literal `a` of its own, since the old row was denied even
without the fix.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
A recorded local strict-review pass covers head |
`git status {+1..65}` expands past the brace cap in bash, so the guard
must read its signed endpoint. The new row fails once the numeric
pattern loses its `+` sign, which no row caught before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A recorded local strict-review pass covers head |
There was a problem hiding this comment.
🟡 Changes recommended
A test is still needed for signed numeric brace expansion because a regression could bypass the 64-word cap while all existing self-tests continue to pass.
1 open issue
What changed in this PR
This PR closes brace-expansion gaps in the write guard by supporting stepped alphabetic ranges and signed integer range syntax, preventing blanket-operation bypasses.
Changes:
- Adds a shared signed-integer pattern for numeric and alphabetic range endpoints and steps.
- Expands stepped alphabetic ranges, including signed steps, while preserving Bash-compatible behavior.
- Adds a regression case for
git commit -{A..z..+32} x. - A test-coverage finding remains for the untested signed numeric expansion path.
| File | Description |
|---|---|
| host-setup/agent-safety/claude/gh-write-guard.py | Extends brace-range parsing for signed and stepped numeric and alphabetic ranges and adds related write-guard self-test coverage. |
Review effort: Lite
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #4596 +/- ##
========================================
Coverage 79.07% 79.07%
========================================
Files 52 52
Lines 17360 17360
========================================
Hits 13728 13728
Misses 3632 3632
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 performed
|
…Hook-Path Denials (#4594) ## Promoted pull requests - #4590: Read the attention lists under a fine-grained token. The full check read still runs first. A token refused `contexts` or `checkSuites` gets a lean read of the same page and every later one. That read names failing pull requests from the head's Actions runs and the jobs of each run's listed attempt, and it records what went unread. - #4592: Deny a commit or push whose text sets GIT_CONFIG*, HOME, or XDG_CONFIG_HOME (each can change which hooks run), and read unquoted bash brace expansion in the guard's lexer so brace-expanded blanket adds and `commit -a` are refused under requirements 6 and 11. - #4596: Expand stepped alphabetic and signed brace ranges in the write guard, as bash does, so `git commit -{A..z..+32} x` is refused as the blanket commit it runs (fixes a Copilot finding raised on this promotion against #4592). - #4597: Show every write-guard denial in the decision-flow diagram, the brace cap and requirement 11 included, and split one self-test table through `_rows` (fixes this promotion's local review findings against #4592). - #4593: Let `cleanup` remove a worktree holding a populated submodule once a strict proof shows nothing is lost: every submodule repository clean, untracked files included, no stash, paused operation, linked worktree or shallow history, and every commit and tag its refs and HEAD reflog reach held by its own remote after a fetch. Anything it cannot show refuses and routes to the maintainer. The clearing lives in scripts/pr_cleanup_clear.py. - #4599: Answer the second local review of this promotion. The guard's docs state its fail-closed behavior without a closed list, one set of state-changing builtins serves both guard sites, and the attention read tolerates a check suite's unread `workflowRun` as the review gate does, marking only the pull request it names. ## Promotion review findings Copilot raised one finding on head ed0326f, that the lean retry could hide an unrelated null node. It was declined in its thread with the code path: the lean re-read tolerates nothing, so a null that persists still fails the read and exits 1. Copilot raised three findings on head 9acbb87, all against #4592: - Stepped alphabetic brace ranges were left literal. This was real, and #4596 fixed it (`6797d691`). The fix also reads a leading `+` sign as bash does. Copilot's own example, `-{a..z..2}`, was already denied, since its literal word carries an `a`, so the regression rows use cases that `develop` really allowed. - An empty brace word must be kept. Declined, because bash drops the empty word: `printf "[%s]" {,--all}` prints `[--all]`. - The zero-padded self-test fixture was wrong. Declined, because the fixture creates the directory `01` and the self-test passes. Copilot's round on head 6797d69 opened on a verdict naming no defect: that synthetic tests cannot establish live behavior. It was answered with the live evidence and acknowledged as declined. A local `frontier` pass against `main` at head 6797d69 raised two findings against #4592, and #4597 fixed both (`9a5af3f9`). The decision-flow diagram lacked the brace-cap denial, and requirement 11 as well, as #4597's own review found. One self-test table was split by hand rather than through `_rows`. A second local `frontier` pass against `main` at head 9a5af3f raised four findings, and #4599 fixed them (`e60890ad`). They were the brace cap missing from the guard's fail-closed docs, a phrase with no referent, two drifted lists of state-changing builtins, and a refused `workflowRun` failing the attention read. Closes #4584 Closes #4582 Closes #4514 Closes #4583 🤖 Generated with [Claude Code](https://claude.com/claude-code)

Answers a Copilot finding on the promotion PR #4594 against #4592 (issue #4514).
What changed
The write guard's lexer expands unquoted brace ranges as bash does, so a blanket commit hidden in a range is still refused under requirement 11. Two range forms bash accepts were left literal:
_sequencetook..steponly on numeric ranges. Bash runsgit commit -{A..z..32} xasgit commit -A -a x, and the guard allowed it.+on a range's endpoints and step, sogit commit -{A..z..+32} xruns the same way. Both patterns now share one signed-integer fragment,_BRACE_INT.Copilot's own example,
git commit -{a..z..2} x, was already denied ondevelop, since its literal word carries ana. The regression row isdeny:git commit -{A..z..+32} x, whose literal has none. With that row in place, the self-test fails ondevelopand on this branch's first commit, and passes on its head.Verification
_sequencematches GNU bash 5.2 for each of these:{a..e..2},{e..a..2},{a..e..-2},{a..e..0},{A..z..+32}{+1..3},{+01..3}(unpadded, as bash does),{1..5..+2},{-01..1}(padded)gh-write-guard.py --selftestpasses, as dotests/test_guard_size.py,tests/test_cli_usage.pyandtests/test_pr_review_policy.py. Ruff and mypy are clean.Local review
Recorded
local-strict-reviewpasses ran at thefrontiertier. The pass over4f73652braised two findings, both fixed in15632ee5: the regression row was denied even without the fix, and a leading+still slipped past. The pass over15632ee5raised one more, fixed ineab7c6d1: no self-test row reached the signed half of the numeric pattern. The new rowdeny:4514:git status {+1..65}fails once that half is reverted. The pass overeab7c6d1found nothing, and it is attested on the head.🤖 Generated with Claude Code
Summary by CodeRabbit