Repository navigation
Fail Closed on an Unread Write Target With No Origin - #3297
Conversation
With no resolvable origin, the write guard now denies a gh write whose target it does not read: a gh write an eval runs, a gh api write to a repositories/<id> endpoint or through a .. segment, and a write taking its repository from a GH_REPO an unread builtin sets. A literal target and a run-time-word target keep the no-origin allow, since there is no owner to compare them against. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Split the sentences the length check flagged, drop the closed list of rules a non-git write meets, and name the no-origin case directly rather than through a pronoun. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… Code Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
A recorded local strict-review pass covers head |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved issues were identified across the reviewed files.
No open issues 🎉
What changed in this PR
Updates the GitHub write guard to fail closed on unread targets when no repository origin resolves.
Changes:
- Moves unread-target detection outside origin-dependent checks.
- Adds no-origin self-test coverage.
- Documents the updated behavior.
| File | Summary |
|---|---|
host-setup/agent-safety/README.md |
Documents no-origin handling. |
host-setup/agent-safety/claude/README.md |
Clarifies opaque-target behavior. |
host-setup/agent-safety/claude/gh-write-guard.py |
Implements and tests fail-closed behavior. |
Review effort: Lite
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #3297 +/- ##
==========================================
Coverage ? 65.49%
==========================================
Files ? 17
Lines ? 10011
Branches ? 0
==========================================
Hits ? 6557
Misses ? 3454
Partials ? 0
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:
|
…ixes to Main (#3299) ## Summary Promotes these pull requests from develop. - [#3297](#3297): the write guard fails closed on an unread write target when no origin resolves. - [#3296](#3296): fixes and pins the Docker task workflow test reader's known limits. - [#3295](#3295): corrects the smoke stub's `enable_*` description in the caller-stub paragraph. - [#3293](#3293): carries a command the user must run inside the prompt's own question. - [#3291](#3291): matches session-handoff's platform-lane exception to the fix-and-verify rule. Closes #3288 Closes #3280 Closes #3282 Closes #3284 Closes #3275 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
With no resolvable origin, the write guard now fails closed on a gh write whose target it does not read. That covers a gh write an
evalruns, agh apiwrite to arepositories/<id>endpoint, and agh apiwrite through a..segment. A literal target keeps the no-origin allow, since there is no owner to compare it against. The run-time-word check and the cross-owner comparison stay inside the origin branch.Changes
classify()inhost-setup/agent-safety/claude/gh-write-guard.pycalls_gh_unread_targetafter theif origin:block rather than inside it. With an origin resolved, the check order and every decision are unchanged. The comment above the block now states which checks need an origin._NO_ORIGIN_CASEStable and_no_origin_selftest()run with_origin_owner_repopinned to resolve nothing. The pin is restored in afinally. The table holds deny cases for each unread shape and allow cases for a literal cross-owner target, a write naming no target, a run-time--repo, and reads.host-setup/agent-safety/README.mdrequirement 3 and the "Opaque targets are unseen" bullet inhost-setup/agent-safety/claude/README.mdnow state the no-origin posture: the owner comparison and the run-time-word check are skipped, and an unread target still fails closed.Scope Note for the Maintainer
_gh_unread_targetalso covers a write taking its repository from aGH_REPOthat an unread builtin sets, such asdeclare -x,read,set -a, aneval, orGH_REPO+=. That shape moves with the call. So outside a checkout,declare -x GH_REPO=stranger/example; gh pr comment 5 -b xis now denied, though the value is written out. This fits "an unread target fails closed", since the hook does not read those builtins. It may differ from what "literal targets keep the no-origin allow" meant. The self-test pins the deny so either answer is a one-line change.Verification
python3 host-setup/agent-safety/claude/gh-write-guard.py --selftest: SELFTEST PASS, including every new no-origin case.python3 host-setup/agent-safety/claude/test_install.py: OK.eval,repositories/<id>,..segment,declare -x GH_REPO), each read as allow. The working tree was never reverted.git show origin/develop:...into a freshmktemp -d, and this branch's guard classified the same constructed corpus undertimeout. The corpus is every command in the guard's*_CASEStables plus the no-origin cases, classified with two resolved origins and with no origin. Every flip is allow to deny, with no origin, through the unread-target deny message. There are zero deny-to-allow flips and zero flips with an origin resolved. The flipped forms are theevalwrite, therepositories/<id>endpoint, the..segment, and the unread-builtinGH_REPOshapes.prose_lint.py --diff origin/develop(with--check sentence-lengthtoo),repo_gate.py --check eolandeol-coverage,docker_lint.py,spec/validate.py, andruff checkplusruff format --check.The comment lines this change adds need the
commentslabel.Closes #3288
🤖 Generated with Claude Code