Skip to content

Commit d1bfb9b

Browse files
feat: add secure Covencat autoreview repair loop
1 parent 658e542 commit d1bfb9b

7 files changed

Lines changed: 1050 additions & 134 deletions

File tree

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ The deployment expects secrets and mutable state to be supplied outside git:
6464
- `COVEN_CODE_BIN` - absolute coven-code path inside that rootfs
6565
- `COVEN_RUNTIME_NETWORK=shared` - explicit opt-in required when the Codex
6666
provider needs network access; the default is `none`
67-
- `COVEN_REVIEW_FIX_LOOPS` - optional bounded review-fix loop count, clamped
68-
between `0` and `5`; defaults to `0` so hosted repair loops are opt-in
67+
- Automatic review and repair are repository-policy controls, not ambient
68+
environment switches. `autoreview.enabled` and `repair.enabled` must each be
69+
opted into explicitly; `kill_switch` stops new routing and repair pushes.
6970
- Codex OAuth tokens under the deployed account's `.coven-code` directory
7071

7172
Do not commit private keys, webhook secrets, OAuth tokens, generated task state,
@@ -185,7 +186,9 @@ connection guide in
185186
sandbox.
186187
- Uses repository-scoped installation tokens: parent Git gets only
187188
`contents:read`, PR evidence gets read authority, and publication write
188-
authority is minted only after isolated execution has finished.
189+
authority is minted only after isolated execution has finished. An opted-in
190+
repair mints a separate short-lived token with only `contents:write` and
191+
`pull_requests:read`; the model never receives it.
189192
- Persists `publication_pending` before GitHub writes and resumes interrupted
190193
publication on startup or duplicate webhook delivery without rerunning the
191194
agent.
@@ -198,6 +201,12 @@ connection guide in
198201
- Publishes non-PR task results and operational notices as issue comments,
199202
including structured `reviewed_files`, `supporting_files`, findings, test
200203
evidence, no-findings rationale, and limitations.
201-
- When `COVEN_REVIEW_FIX_LOOPS` is greater than `0`, reruns `coven-code` with
202-
prior structured review findings as explicit repair instructions until no
203-
findings remain or the configured loop count is exhausted.
204+
- With explicit `autoreview.enabled`, routes opened, ready-for-review, reopened,
205+
and synchronized pull-request revisions by repository, PR number, and exact
206+
head SHA. Drafts remain excluded unless `include_drafts` is enabled.
207+
- With separate `repair.enabled`, an evidence-complete REQUEST_CHANGES review
208+
may launch a file-write-only hosted repair. The trusted host rejects forks,
209+
protected branches and paths, oversized or unrelated diffs, stale heads, and
210+
failed validation; it then creates a Covencat-attributed non-force commit and
211+
queues a fresh review of the new SHA. The loop stops after the configured
212+
`max_attempts` (clamped to 1-3) or on repeated findings or non-progress.

config/example-policy.json

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"issues.labeled",
99
"issue_comment.created",
1010
"pull_request_review_comment.created",
11+
"pull_request.opened",
12+
"pull_request.ready_for_review",
1113
"pull_request.synchronize",
1214
"pull_request.edited",
1315
"pull_request.reopened",
@@ -31,8 +33,36 @@
3133
]
3234
},
3335
"publication": {
34-
"mode": "record_only"
35-
}
36+
"mode": "record_only",
37+
"validation_commands": [
38+
"npm test"
39+
],
40+
"validation_timeout_seconds": 300
41+
},
42+
"autoreview": {
43+
"enabled": false,
44+
"include_drafts": false
45+
},
46+
"repair": {
47+
"enabled": false,
48+
"max_attempts": 2,
49+
"max_changed_files": 8,
50+
"max_diff_bytes": 262144,
51+
"allowed_paths": [
52+
"src/**",
53+
"tests/**"
54+
],
55+
"protected_branches": [
56+
"release/**"
57+
]
58+
},
59+
"protected_paths": [
60+
".github/**",
61+
"CODEOWNERS",
62+
"**/CODEOWNERS"
63+
],
64+
"kill_switch": false,
65+
"enabled": true
3666
}
3767
}
3868
}

docs/coven-github-connection.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ blocked until the mandatory runtime sandbox below passes its executable probe.
118118
For decisive native reviews, also configure a bounded list of trusted
119119
validation commands under `publication.validation_commands`; a runtime-authored
120120
claim without a matching successful sandbox receipt is published as COMMENT.
121+
The adapter replaces model-authored `tests_run` claims with signed host receipts;
122+
file reads, searches, PR text, and model narratives are never execution proof.
123+
124+
Autoreview and branch repair are independent repository opt-ins. Configure
125+
`autoreview.enabled` for exact-SHA reviews and optionally `include_drafts`.
126+
Configure `repair.enabled` only for trusted same-repository branches, with
127+
`max_attempts` from 1 through 3, bounded `allowed_paths`, `protected_paths`,
128+
`protected_branches`, `max_changed_files`, and `max_diff_bytes`. Repair sessions
129+
receive file tools only; the host performs validation, commit, and non-force push
130+
with a fresh repository-scoped installation token. Set `kill_switch` at the
131+
repository route to stop both new tasks and any in-progress repair before push.
132+
The GitHub App installation must grant repository Contents read/write for repair;
133+
the adapter requests that authority only in the fresh repair token and does not
134+
reuse the publication or runtime token.
121135

122136
## Runtime Checklist
123137

0 commit comments

Comments
 (0)