feat: policy-gated PR review triggers with supersession (#10) - #38
Merged
Conversation
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
…ession (#10) New adapter-internal TaskKind::ReviewPullRequest briefs through the locked v2 vehicle — trigger pr_review_comment, adapter-authored instruction, and review_context built from the PR files API. A review-generation registry in TaskStore lets the worker silently skip queued reviews that a newer PR event has superseded, before any GitHub call is spent. Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Signed-off-by: Val Alexander <bunsthedev@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends coven-github with policy-gated automatic PR review triggering and queue supersession, while also adding typed parsing + fixture tests for pull_request lifecycle and push webhooks (with push execution intentionally deferred to a future headless contract).
Changes:
- Add
[review]config policy (global + per-repo overrides) anddoctorvalidation for the PR review lane’s configured reviewer familiar. - Parse
pull_requestlifecycle +pushevents into typed events with new JSON fixtures and field-level tests; route PR events into a newTaskKind::ReviewPullRequestwith loop-prevention + draft gating + label opt-in. - Implement PR review supersession via a
TaskStoreregistry so stale queued reviews are skipped, and inject PR changed-file context into the v2 brief for hosted reviews.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates trigger documentation to distinguish implemented vs planned lanes and reflect PR review support. |
| crates/worker/src/lib.rs | Skips superseded PR review tasks early; injects PR files + audit instruction into the session brief; extends target resolution/title helpers and tests. |
| crates/worker/src/brief.rs | Adds hosted review context support and briefs ReviewPullRequest through the contract v2-compatible pr_review_comment vehicle plus review_context. |
| crates/webhook/tests/parse_fixtures.rs | Adds parse tests for new pull_request lifecycle fixtures and push fixtures, including an unsupported action test. |
| crates/webhook/tests/fixtures/push_feature_branch.json | New push fixture (forced push on feature branch). |
| crates/webhook/tests/fixtures/push_default_branch.json | New push fixture (default branch push). |
| crates/webhook/tests/fixtures/push_branch_deleted.json | New push fixture (branch deletion). |
| crates/webhook/tests/fixtures/pull_request_synchronize.json | New PR fixture (synchronize with new head SHA + draft flag). |
| crates/webhook/tests/fixtures/pull_request_ready_for_review.json | New PR fixture (ready_for_review leaving draft state). |
| crates/webhook/tests/fixtures/pull_request_opened.json | New PR fixture (opened). |
| crates/webhook/src/routes.rs | Routes PullRequestChanged into ReviewPullRequest under policy/label gating, registers supersession before enqueue, and adds review-lane unit tests. |
| crates/webhook/src/events.rs | Extends webhook payload parsing to support pull_request lifecycle actions and push into typed events. |
| crates/github/src/tasks.rs | Adds PR-review supersession registry (review_heads) and updates task list formatting for ReviewPullRequest. |
| crates/github/src/repo.rs | Adds GitHub API call to list PR changed files (first page) for hosted review context. |
| crates/github/src/lib.rs | Introduces PrChangedEvent, PushEvent, and TaskKind::ReviewPullRequest in the shared API types. |
| crates/config/src/lib.rs | Adds ReviewConfig with per-repo overrides and doctor validation that enabled lanes resolve to a known familiar id; adds tests. |
| config/example.toml | Documents the new [review] configuration section and example overrides. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+148
to
+152
| /// Lists the changed-file paths of a pull request for hosted-review context | ||
| /// (issue #10). Fetches the first 100 files only; larger PRs surface the gap | ||
| /// through the runtime's review `limitations` evidence. | ||
| pub async fn get_pull_request_files_with_base_url( | ||
| api_base_url: &str, |
Comment on lines
+46
to
+50
| pub async fn register_pr_review(&self, repo: &str, pr_number: u64, task_id: &str) { | ||
| self.review_heads | ||
| .write() | ||
| .await | ||
| .insert(format!("{repo}#{pr_number}"), task_id.to_string()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10.
What ships
[review]trigger policy (config): reviewer familiar,pull_requestlane toggle,include_drafts(default off),audit_instruction, per-repo overrides keyedowner/name.coven-github doctorvalidates that an enabled lane resolves to a configured familiar.pull_request(opened / synchronize / reopened / ready_for_review / labeled →PrChangedEventwith event-time head/base refs, author, draft flag) andpush(PushEventwith branch, before/after SHAs, deleted/forced) — six new webhook fixtures with field-level parse tests.TaskStorekeyedowner/repo#pr; the webhook registers the newest task id before enqueueing, the worker checks at dequeue and silently skips stale queued reviews. Synchronize bursts coalesce to the newest head.TaskKind::ReviewPullRequestbriefs through the v2-sanctioned vehicle —trigger: pr_review_comment, adapter-authored instruction,review_context {kind: pull_request, files}fromGET /pulls/{n}/files(first 100 files; larger PRs surface via reviewlimitations), and policyaudit_instruction. Review results land in the Check Run; publication gates are Add structured review output and deterministic publication gates #11.Deliberately deferred
Plan and grooming trail: #10 (comment)
Local gates:
cargo check --all-targets+cargo clippy --all-targets -- -D warnings+cargo test --all(113 passed, 0 failed; 25 new tests).🤖 Generated with Claude Code