Repository navigation
Let an Operational Repository Commit in Place Through a Repo Agent Policy - #3889
Conversation
…licy An operational repository's standard is a direct commit to develop in the live checkout its service reads, by the maintainer and an agent alike. The write guard's primary-checkout rule denied that, leaving only a session-wide override that also lifts reset, stash, and clean. The per-repository review policy becomes one agent policy file, .github/agent-policy.json, with a review section and a guard section. The guard reads its section from origin/main, so only the maintainer's merge grants an exemption, and a listed branch allows explicit-path add, rm, and mv, a commit that stages and amends nothing, and an unforced push of that branch. Everything else the rule denies stays denied. The review reader reads its own section, and a file without one reads the hub default. Closes #3200 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A commit with a pathspec, a push carrying a tag or an unread refspec, a branch switch earlier in the same command, and an add of a directory named through a drive or home spelling each passed the exemption. Each now denies. A move into a directory is allowed, the policy read is tested against a real repository, and a file stating only a guard section reads as the review default in the backlog metrics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A short cluster ending in an attached value, such as -minit, skipped the next word, so a pathspec or a -n after it went unread. The live self-test now tells a read of origin/main from a read of HEAD and skips rather than fails where it cannot commit, and the spec states the commit shapes the code denies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
|
A recorded local strict-review pass covers head |
There was a problem hiding this comment.
🟡 Changes recommended
Four active findings remain, including three critical issues that could allow malformed policy data, an unverified local ref, or ambiguous push targets to bypass the guard.
4 open issues
What changed in this PR
This pull request consolidates repository review settings into .github/agent-policy.json and adds a narrowly scoped, main-controlled exemption for operational repositories committing in place.
Changes:
- Replaces the standalone review policy with unified review and guard policy sections.
- Adds constrained primary-checkout support for approved staging, commit, and push operations.
- Updates the guard, schemas, tests, governance documentation, skills, generated distributions, and digests.
- The review identified four unresolved findings: three critical P1 issues concerning policy validation, local
origin/maintrust, and explicit push refspecs; and one moderate P2 issue involving option scanning after--.
| File | Description |
|---|---|
tests/test_pr_review_policy.py |
Updates review-policy tests for the unified policy file. |
tests/test_backlog_metrics.py |
Updates backlog metrics tests for the renamed policy structure. |
spec/pr-review.schema.json |
Removes the superseded review-only schema. |
spec/pr-review.default.json |
Removes the superseded review-only default. |
spec/agent-policy.schema.json |
Defines the combined review and guard policy schema. |
spec/agent-policy.default.json |
Provides the unified default policy. |
scripts/README.md |
Documents the unified policy location and fallback behavior. |
scripts/pr_review_policy.py |
Reads review settings from the unified policy with default fallback. |
scripts/backlog_metrics.py |
Reports review settings from the unified policy. |
host-setup/agent-safety/README.md |
Documents the primary-checkout exemption contract. |
host-setup/agent-safety/claude/gh-write-guard.py |
Implements policy-controlled in-place Git operations and shared option parsing. |
host-setup/agent-safety/claude/claude-md-safety.md |
Updates host safety guidance for operational repositories. |
GOVERNANCE.md |
Documents operational in-place commits and policy authorization. |
docs/pr-reviewer-reference.md |
Updates reviewer-policy references. |
.github/skills/repo-worktree/SKILL.md |
Documents the operational checkout exception. |
.github/skills/pr-review-conduct/SKILL.md |
Updates the review-policy path. |
.github/skills/branching-and-release-model/SKILL.md |
Documents in-place operational commits. |
.github/copilot-instructions.md |
Updates review-policy references. |
.claude-plugin/fleet-skills/skills/repo-worktree/SKILL.md |
Regenerates distributed worktree guidance. |
.claude-plugin/fleet-skills/skills/pr-review-conduct/SKILL.md |
Regenerates distributed review guidance. |
.claude-plugin/fleet-skills/skills/branching-and-release-model/SKILL.md |
Regenerates distributed branching guidance. |
.claude-plugin/fleet-skills/.source-digests/repo-worktree |
Updates the generated worktree Skill digest. |
.claude-plugin/fleet-skills/.source-digests/pr-review-conduct |
Updates the generated review Skill digest. |
.claude-plugin/fleet-skills/.source-digests/branching-and-release-model |
Updates the generated branching Skill digest. |
.agents/skills/repo-worktree/SKILL.md |
Updates the authored worktree Skill. |
.agents/skills/pr-review-conduct/SKILL.md |
Updates the authored review-conduct Skill. |
.agents/skills/branching-and-release-model/SKILL.md |
Updates the authored branching-model Skill. |
Review effort: Lite
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3889 +/- ##
===========================================
- Coverage 81.60% 77.52% -4.09%
===========================================
Files 26 33 +7
Lines 9070 11736 +2666
===========================================
+ Hits 7402 9098 +1696
- Misses 1668 2638 +970
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:
|
…ption A bare push follows configured push defaults and can update other branches, so the exemption now takes only git push origin <branch>. A policy whose version is not 1 grants nothing, a commit carrying -- is denied, and the hook-bypass scan stops at --. The Windows-path self-test skips the new live case, which builds a real checkout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A recorded local strict-review pass covers head |
… Bot Settings (#3891) ## Summary `repo-config/configure.sh` now renders each repository's `.github/agent-policy.json` from `registry/repos.json`, through the new `scripts/agent_policy.py`. It also applies and checks the bot-side settings the render implies. This is step 1 of the review-cutover track (#3877), built on the `agent-policy.json` shape #3889 introduced. - **Render.** The hub default policy, plus a repo entry's optional `agentPolicy` override (a shallow merge per bot), plus a `guard` section derived from `workflowModel`. An operational repository lists `develop`. `spec/validate.py` refuses a malformed override. - **Rulesets.** The `copilot_code_review` rule lands on the `main` or `develop` ruleset only where the render has an automatic Copilot covering that branch. `repo-config/main.json` stays the template for the rule's parameters. - **`apply --checkout <path>`.** Writes three things into a local checkout of the repository: the policy file, CodeRabbit's `reviews.auto_review.enabled` and `base_branches`, and Qodo's `[config] disable_auto_feedback`. Every other key and comment is kept. A dry run checks the checkout before any API write. The caller commits the files through the ordinary PR flow. - **`check`.** Compares all three files on the default branch with the render. A missing bot file is drift by design: once account-level auto review turns off, a repository without the explicit keys would lose its reviews silently. - **Requirements.** A plain `apply` or `check` derives the facts with the stdlib interpreter, now probed for 3.10. `uv` is needed only for `apply --checkout` and the policy check. ## What to expect after merge - `configure.sh check` reports agent-policy drift on every repository until `apply --checkout` has been run there and the files merged. Today only this hub carries `.coderabbit.yaml` and `.pr_agent.toml`. That rollout is the pilot step on #3877. - On this hub, `apply --checkout` leaves `.coderabbit.yaml` byte-identical. It adds `[config] disable_auto_feedback = false` to `.pr_agent.toml` and writes `.github/agent-policy.json`. ## Local review Three recorded `local-strict-review` passes, at `frontier`. The first found 8 findings and the second found 3. All were fixed except one consolidation in a file this change does not touch, filed as #3890. The third pass, over the final content, found none. ## Pre-existing findings, not filed - `spec/host-tools.json:90` (`pre-existing`): the `why` string says `removesuffix` is called "in spec/audit.py alone", while `scripts/carry.py` and the host-setup scripts call it too. This is a description, not an instruction, and is left as it is. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…t Policy (#3892) ## Summary Promotes #3881, #3884, #3886, #3888, #3889, and #3891 to `main`. Closes #3200. Closes #3885. Closes #3887. - **Per-repository review policy (#3881).** `scripts/pr_review.py` reads which bots review a repository, on which bases, when, and how often, from the repository's own policy, with the hub default reproducing today's behavior. - **Review return on cost (#3886).** `scripts/backlog_metrics.py` measures reviewer cost per useful finding. It is now a uv script, so the metrics server's weekly timer must run it as `uv run --no-project --script scripts/backlog_metrics.py` from this release on. - **After-checks side reviewer (#3888).** An explicit after-checks CodeRabbit or Qodo is asked once CI settles, and ask times compare in UTC. - **Commit in place for an operational repository (#3889).** The policy file became `.github/agent-policy.json`, with its schema under `review` and a `guard` section that lets `gh-write-guard` allow an in-place commit on a listed branch. - **Agent policy rendered from the registry (#3891).** `repo-config/configure.sh` renders `.github/agent-policy.json` from `registry/repos.json` and applies the bot settings it implies: the Copilot ruleset rule, CodeRabbit's auto-review keys, and Qodo's auto-feedback key. Once this is on `main`, `configure.sh check` reports agent-policy drift on every repository until `apply --checkout` has been run there. - **Dependabot (#3884).** The actions-deps group bump. Each feature pull request carried recorded local strict review passes, with every finding fixed, declined with evidence, or filed (#3890). 🤖 Generated with [Claude Code](https://claude.com/claude-code)


Summary
The standard for an operational repository is a direct commit to
developin place, in the live checkout the running service reads. Both the maintainer and an agent work this way. The write guard's primary-checkout rule (requirement 6) denied that commit. The only way around it wasGH_WRITE_GUARD_ALLOW_PRIMARY_CHECKOUT, which lifts every rule-6 denial for the whole session, includingreset,stashandclean.This PR adds a narrow exemption for each repository, recorded in a repo-local agent policy file. That file also holds the review policy that already existed.
.github/pr-review.jsonbecomes.github/agent-policy.json.reviewsection, and a newguardsection sits beside it.spec/agent-policy.schema.jsonandspec/agent-policy.default.json.reviewsection reads the hub default's review, andbacklog_metricsmarks it(default).guard.primaryCheckout.commitInPlace.branches.origin/mainonly, never from the working tree ordevelop. An agent can pushdevelopdirectly in an operational repository, so reading it there would let an agent grant itself the exemption. Reading it frommainmeans only the maintainer's merge grants it.add,rmandmvof explicit paths. Anaddpath cannot be a directory or a run-time word.-a,-p,-i,-oor--amend, nor any of their long forms.origin.branching-and-release-modelandrepo-worktreeskills, the host-wide safety block, and agent-safety requirement 6._skips_hooksnow shares one commit-option reader with the exemption. That fixes a latent bug: a short cluster ending in an attached value, such as-minit, used to skip the word that followed it.Not in this PR: provisioning the file.
repo-config/configure.shwill write.github/agent-policy.jsonfrom the registry, withworkflowModel: operationalfilling in the guard section. That lands in the follow-up provisioning PR on the review-cutover track. Until it does, an operational repository needs the file merged tomainby hand for the exemption to take effect.Verification
gh-write-guard.py --selftestpasses.developwithorigin/mainnot yet moved, gives no exemption. It checks thatorigin/mainlistingdevelopdoes, that a real directory add is denied, and that a malformed policy gives none.HEAD:instead oforigin/mainfails the live case.addandcommitondevelopwhilemaincarried the policy. It denied the same commands on a topic branch, and again once the policy leftmain.spec/validate.py, the installer tests,build_dist.py --checkand the pre-commit gate.local-strict-reviewran three passes:Closes #3200
🤖 Generated with Claude Code