Repository navigation
Render Each Repository's Agent Policy From the Registry and Apply Its Bot Settings - #3891
Conversation
… Bot Settings repo-config/configure.sh now renders .github/agent-policy.json from registry/repos.json through the new scripts/agent_policy.py. The render is the hub default policy, plus a repo entry's optional agentPolicy override per bot, plus a guard section derived from workflowModel. - The Copilot code review rule lands on the main or develop ruleset only where the rendered policy has an automatic Copilot covering it. - apply --checkout writes the policy file and the CodeRabbit and Qodo auto-trigger keys into a local checkout, preserving every other key and comment, after a dry-run preflight that runs before any API write. - check compares all three files on the default branch with the render. - spec/validate.py rejects a malformed agentPolicy entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A plain apply or check derives the policy facts with the stdlib interpreter, so uv is needed only for apply --checkout and the policy check. - A checkout must be its work tree's top level. - An automatic Qodo must cover main and develop, since it reviews every pull request. - CodeRabbit base branches are anchored, since CodeRabbit searches where the policy full-matches. - An emptied base_branches keeps the comment block before the next key. - The policy check reads through pr_review_policy.contents_reader, the origin URL is parsed by the new gh_graphql.origin_slug, and an unreadable file exits 2 rather than the drift code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- configure.sh's interpreter probe asks for 3.10, the oldest the policy render runs on, so a stock macOS 3.9 is refused with a message rather than a traceback. - anchored() wraps any base carrying an alternation, so CodeRabbit's search covers exactly what the policy's full match does. 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
Several active critical and moderate findings leave normal configuration files rejected or crashed on invalid shapes and permit unsafe writes or checkout verification, so changes are required before approval.
7 open issues
Sanitize Git environment during checkout verification · New Accept TOML table objects when updating config · New Reject symlinked checkout targets before writing · New Handle non-mapping YAML as drift without crashing · New Handle non-table TOML config as drift without crashing · New Restrict remote parsing to GitHub origins · New Preserve existing line endings when rewriting bot files · New
What changed in this PR
This pull request makes repository agent policies registry-driven and synchronizes the resulting Copilot, CodeRabbit, Qodo, and operational settings across repositories.
Changes:
- Adds
scripts/agent_policy.pyto render, validate, write, and check repository policy files. - Updates
repo-config/configure.shto apply policy-derived bot settings and Copilot rulesets. - Adds registry validation, tests, dependencies, and documentation for the new configuration flow.
| File | Summary | Review findings |
|---|---|---|
tests/test_gh_graphql.py |
Tests remote URL slug parsing. | No findings recorded. |
tests/test_configure_usage.py |
Tests interpreter probing and configure setup. | No findings recorded. |
tests/test_configure_project.py |
Tests checkout and policy preflight behavior. | No findings recorded. |
tests/test_cli_usage.py |
Adds CLI usage coverage for the policy script. | No findings recorded. |
tests/test_agent_policy.py |
Tests rendering, writing, checking, and ruleset composition. | No findings recorded. |
tests/requirements.txt |
Adds YAML and TOML test dependencies. | No findings recorded. |
spec/validate.py |
Validates registry agent-policy overrides. | No findings recorded. |
spec/host-tools.json |
Documents the updated Python interpreter floor. | No findings recorded. |
scripts/README.md |
Documents the agent-policy utility and policy-driven reviews. | No findings recorded. |
scripts/gh_graphql.py |
Adds shared remote URL parsing. | [P2, moderate, 2 votes] Restrict remote parsing to supported GitHub origins. |
scripts/agent_policy.py |
Implements policy rendering, bot-setting updates, checkout writes, and drift checks. | [P1, critical, 1 vote] Accept TOML table objects when updating Qodo configuration. [P2, moderate, 4 votes] Report non-mapping YAML as drift instead of crashing. [P2, moderate, 4 votes] Report non-table TOML sections as drift instead of dereferencing them. [P1, moderate, 1 vote] Preserve empty bot files for drift checking. [P1, critical, 2 votes] Refuse symlinked checkout targets before writing. [P2, nit, 2 votes] Preserve existing line endings when rewriting bot files. [P1, critical, 1 vote] Sanitize Git’s inherited environment before verifying the checkout. |
repo-config/README.md |
Documents policy application, checking, and ruleset behavior. | No findings recorded. |
repo-config/configure.sh |
Applies policy files and derives Copilot ruleset configuration. | No findings recorded. |
registry/repos.schema.json |
Defines registry-level policy overrides. | No findings recorded. |
pyproject.toml |
Configures type-checker handling for new dependencies. | No findings recorded. |
docs/pr-reviewer-reference.md |
Updates reviewer configuration guidance. | No findings recorded. |
Review effort: Lite
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3891 +/- ##
===========================================
- Coverage 81.60% 77.87% -3.74%
===========================================
Files 26 34 +8
Lines 9070 12085 +3015
===========================================
+ Hits 7402 9411 +2009
- Misses 1668 2674 +1006
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:
|
The writer read each existing file with its line endings intact, then wrote the planned text as LF, flattening a CRLF checkout's files. The plan now writes CRLF wherever the file it replaces is CRLF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A recorded local strict-review pass covers head |
|
Correction to my decline on the "Refuse symlinked checkout targets before writing" thread (scripts/agent_policy.py): repo-config/README.md "Agent Policy" says the caller commits the files "through the ordinary pull request flow". It does not itself say the branch is created from develop. The decline rests on the fleet branching model, where that flow is a feature branch off develop holding the maintainer's own merged content. Its conclusion is unchanged. |
The Windows unit test job failed eight tests: - The YAML and TOML planners parsed a CRLF file and emitted mixed endings, since the round-trippers keep a carriage return inside a comment. They now parse LF text, and plan() restores CRLF on write. - The contents reader and interpreter probe tests put a /bin/sh shim on PATH, which native Windows does not run. The reader now takes an injectable runner, and the probe test shadows py and python3 with bash functions. - The ruleset composition test passed unquoted Windows paths to bash, which dropped their backslashes. They are now quoted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
A recorded local strict-review pass covers head |
…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
repo-config/configure.shnow renders each repository's.github/agent-policy.jsonfromregistry/repos.json, through the newscripts/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 theagent-policy.jsonshape #3889 introduced.agentPolicyoverride (a shallow merge per bot), plus aguardsection derived fromworkflowModel. An operational repository listsdevelop.spec/validate.pyrefuses a malformed override.copilot_code_reviewrule lands on themainordevelopruleset only where the render has an automatic Copilot covering that branch.repo-config/main.jsonstays the template for the rule's parameters.apply --checkout <path>. Writes three things into a local checkout of the repository: the policy file, CodeRabbit'sreviews.auto_review.enabledandbase_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.applyorcheckderives the facts with the stdlib interpreter, now probed for 3.10.uvis needed only forapply --checkoutand the policy check.What to expect after merge
configure.sh checkreports agent-policy drift on every repository untilapply --checkouthas been run there and the files merged. Today only this hub carries.coderabbit.yamland.pr_agent.toml. That rollout is the pilot step on Session Handoff [review-cutover]: #3898 Released as 2.0.1357, Hub Explicit-Review Override Next #3877.apply --checkoutleaves.coderabbit.yamlbyte-identical. It adds[config] disable_auto_feedback = falseto.pr_agent.tomland writes.github/agent-policy.json.Local review
Three recorded
local-strict-reviewpasses, atfrontier. 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): thewhystring saysremovesuffixis called "in spec/audit.py alone", whilescripts/carry.pyand the host-setup scripts call it too. This is a description, not an instruction, and is left as it is.🤖 Generated with Claude Code