Repository navigation
Fail Closed When the Write Guard Cannot Read the Remote Names - #3037
Conversation
A bare push whose @{push} target is a remote-tracking ref is read against
the remote names `git remote` lists, so a remote named up/stream loses both
its segments. A failed `git remote` read fell back to an empty list, which
left refs/remotes/up/stream/develop read only as stream/develop and
up/stream/develop, so a push to a protected develop could be allowed. The
failed read now answers unresolved, which the push check denies.
A self-test case makes only the `git remote` read fail under a slash-named
remote and asserts the unresolved deny.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The unresolved deny gave only a directory that does not resolve and an earlier command that may move the branch as its causes. A bare push in a valid checkout whose `git remote` read fails now reaches that same deny, so the message names that cause too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
A recorded local strict-review pass covers head |
There was a problem hiding this comment.
🟢 Approval recommended
The focused change reaches the existing denial path and has targeted regression coverage.
0 open findings
What changed in this PR
This PR makes the write guard deny a bare push when it cannot read remote names, rather than risk missing a protected destination branch.
Changes:
- Treat a failed
git remoteread as an unresolved push target while preserving successful empty reads. - Clarify the denial message and add a regression self-test for a slash-named remote.
| File | Description |
|---|---|
| host-setup/agent-safety/claude/gh-write-guard.py | Fails closed on remote-read errors and tests that path. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3037 +/- ##
===========================================
+ Coverage 60.98% 61.00% +0.01%
===========================================
Files 17 17
Lines 9010 9014 +4
===========================================
+ Hits 5495 5499 +4
Misses 3515 3515
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:
|
…ng, and backlog-burndown Re-Dispatch Rules to Main (#3030) - #2997 adds an updater that keeps the coding-agent tools already installed on a host current, without installing a tool the maintainer has not chosen - #3017 brings the agent-safety READMEs up to the write guard's #3011 readings: `--admin` read inside a quoted `eval` argument, clustered and cut-short push options, `--branches` as `--all`, `refs/` pattern destinations, and a double-quoted list expansion as a directory or commit value failing closed - #3022 pairs a Copilot overview-table or `Review findings:` entry with a review thread by the file it names, replacing word overlap, compares the headline count against everything the round and the pull request account for, and makes `pr_review.py cleanup` read every page of the head pull requests, counting only this repository's own - #3018 has `backlog-burndown` name a new branch when an issue is dispatched again, name the open pull request a pushed branch still heads when cleanup reports it, and splits the long cleanup sentence - #3028 keeps an abandoned group's issue out of the `backlog-burndown` ranking while that group is stopped for the maintainer, and records the release on the claim comment - #3023 makes `gh-write-guard` read a `heads/` push destination as the branch git completes it to, read `--prune` beside a pattern, `:`, `--all`, or bare push as a delete of each branch matched, read `--mirror` as a force and a delete, and read the `@{push}` target against the configured remote names. A differential against the previous guard found no deny-to-allow flip - #3032 subtracts every thread id an open entry links, back-references included, from the earlier threads `pr_review.py`'s headline shortfall counts, so a back-referenced thread is no longer counted twice - #3035 covers the bootstrap upgrade handoff on Linux and Windows, the root and elevated skips included, and has `bootstrap.ps1` say when the agent tools report fails - #3037 makes `gh-write-guard` fail closed when a push target resolves but the remote names cannot be read After this merges, the host-safety installer payload changes, so the maintainer runs the installer after promotion. Fixes #3009 Fixes #2985 Fixes #3003 Fixes #2993 Fixes #3016 Fixes #3005 Fixes #3007 Fixes #2973 🤖 Generated with [Claude Code](https://claude.com/claude-code)
… Narrative Findings, and Bootstrap Handoff Tests to Main (#3051) - #3042 brings the agent-safety READMEs up to the write guard's #3023 and #3037 readings: `--prune` beside a pattern, `:`, `--all`, or a bare push, a `--mirror` push with no refspec, a `heads/` destination outside `refs/`, the full `@{push}` read, and a bare push denied when `git remote` cannot list the remotes - #3041 has `backlog-burndown` keep an abandoned group's claim comment until cleanup decides its release, say stopped on each path that sends a group to the maintainer, and name a branch no pull request has used when a claim comment first names it - #3044 tests `bootstrap.sh`'s `--report` handoff to the agent tools step, tests the `--agents` handoff on Linux and through `Invoke-AgentsInstall` under `pwsh`, and moves the unprivileged-root probe into `tests/host_capability.py` - #3045 makes `pr_review.py` read an `Open findings remain:` list in a Copilot review and count each entry no thread of the round accounts for, pairing by severity tier and file, so the count can only rise - #3049 makes `gh-write-guard` read a bare push's destination from `push.default` and `branch.<name>.merge`, read a persisted `remote.<name>.mirror`, deny when the `@{push}` read times out or cannot run, give a dash-named word after `--` or `--end-of-options` a reading as a remote or refspec, and judge a push moved into another checkout against that checkout's origin as well. A differential against the previous guard found no deny-to-allow flip. It addresses one item of #2943, which stays open - #3054 makes `gh-write-guard` answer unresolved, and so deny, when its `push.default` read times out or cannot run, a promotion fix for this pull request's first review - #3062 brings both agent-safety READMEs up to #3054: an unset `push.default` is read as `simple`, both destinations are read for a value git does not define or a read exiting with any other error, and a read that times out or cannot run is denied - #3059 bumps `actions/create-github-app-token` from 3.2.0 to 3.3.0 After this merges, the host-safety installer payload changes, so the maintainer runs the installer after promotion. Fixes #3021 Fixes #3026 Fixes #3027 Fixes #3039 Fixes #3033 Fixes #3038 Fixes #3034 Fixes #3031 Fixes #3019 Fixes #3020 Fixes #3029 Fixes #3036 Fixes #3052 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
Answers the Copilot finding on the promotion pull request #3030 at
host-setup/agent-safety/claude/gh-write-guard.py, which showed that a failedgit remoteread could let a bare push to a protected branch through._read_branchread a failedgit remoteas an empty remote list. A remote namedup/streamthen kept a segment, so a push target ofrefs/remotes/up/stream/developwas read only asstream/developandup/stream/develop, and the branch-rule lookup never sawdevelop.git remoteread now answers_UNRESOLVED._bare_push_branchpasses it through, and both of its callers in_push_targetsalready turn it into theunresolveddeny. Agit remoteread that succeeds with no output still reads as no remotes.unresolveddeny message now names a failed remote read as one of its causes, since a plaingit pushin a valid checkout can reach it that way._push_remote_read_selftest, builds a constructed repository whose push target sits under the slash-named remoteup/stream. It makes only thegit remoteread fail and asserts the unresolved deny. With the fix reverted, the case fails asallow.Differential against develop
The guard on
origin/developand the guard on this branch were each run over every_PUSH_DIR_CASESand_PUSH_NAME_CASESrow plus the new case, once withgit remoteworking and once with it failing. That makes 282 rows in all.git remoteworking, no verdict changes.git remotefailing, 6 rows change fromallowtodeny, each anunresolveddeny on a remote-tracking push target. Those are the new case and the 5 name cases whose push target is a remote-tracking ref that the first-segment read does not turn intodevelop.Local Review
Two
local-strict-reviewpasses ran. The first raised two findings. The deny message's stated causes are fixed in this branch. A failed@{push}read falling back to the local branch name is pre-existing and filed as #3036. The second pass raised no findings.Verification
gh-write-guard.py --selftestpasses.test_install.pypasses, as do the roottests/suite,spec/validate.py, ruff format and check, mypy,prose_lint.py, and therepo_gate.pygates.🤖 Generated with Claude Code
Summary by CodeRabbit