Skip to content

feat: policy-gated PR review triggers with supersession (#10) - #38

Merged
BunsDev merged 5 commits into
mainfrom
feat/issue-10-review-triggers
Jul 6, 2026
Merged

feat: policy-gated PR review triggers with supersession (#10)#38
BunsDev merged 5 commits into
mainfrom
feat/issue-10-review-triggers

Conversation

@BunsDev

@BunsDev BunsDev commented Jul 6, 2026

Copy link
Copy Markdown
Member

Closes #10.

What ships

  • [review] trigger policy (config): reviewer familiar, pull_request lane toggle, include_drafts (default off), audit_instruction, per-repo overrides keyed owner/name. coven-github doctor validates that an enabled lane resolves to a configured familiar.
  • Event parsing: pull_request (opened / synchronize / reopened / ready_for_review / labeled → PrChangedEvent with event-time head/base refs, author, draft flag) and push (PushEvent with branch, before/after SHAs, deleted/forced) — six new webhook fixtures with field-level parse tests.
  • Routing: policy-gated auto-review; a review label is an explicit per-PR opt-in (works with the lane off, including drafts). Loop prevention: PRs authored by any configured familiar bot are never auto-reviewed, and drafts are skipped by default — two independent guards against the adapter reviewing its own draft PRs.
  • Supersession: a review-generation registry in TaskStore keyed owner/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.
  • Execution under locked contract v2: new adapter-internal TaskKind::ReviewPullRequest briefs through the v2-sanctioned vehicle — trigger: pr_review_comment, adapter-authored instruction, review_context {kind: pull_request, files} from GET /pulls/{n}/files (first 100 files; larger PRs surface via review limitations), and policy audit_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

BunsDev added 5 commits July 6, 2026 16:42
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>
Copilot AI review requested due to automatic review settings July 6, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) and doctor validation for the PR review lane’s configured reviewer familiar.
  • Parse pull_request lifecycle + push events into typed events with new JSON fixtures and field-level tests; route PR events into a new TaskKind::ReviewPullRequest with loop-prevention + draft gating + label opt-in.
  • Implement PR review supersession via a TaskStore registry 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 thread crates/github/src/repo.rs
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());
@BunsDev
BunsDev merged commit 0024952 into main Jul 6, 2026
2 checks passed
@BunsDev
BunsDev deleted the feat/issue-10-review-triggers branch July 6, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement PR, push, and commit review triggers

2 participants