Support optional formal PR review decisions (APPROVE / REQUEST_CHANGES) #27

Closed
opened 2026-10-07 18:59:37 +01:00 by nimmo · 0 comments
Owner

Extend the reviewer to optionally submit formal pull request review decisions (APPROVE, REQUEST_CHANGES, or COMMENT) via the Forgejo reviews API, governed by explicit repository configuration.

Context & Motivation

Currently, the reviewer publishes findings as an advisory markdown issue comment (issues/{number}/comments). Issue #19 describes publishing formal reviews with the COMMENT event. For automated workflows where a passing review could unblock branch protection or merge requirements, repositories may want the bot to submit APPROVE when clean, or REQUEST_CHANGES when blocking defects are detected.

Because automated reviewers can produce false positives or partial analyses, this capability must be strictly opt-in and configurable per repository.

Proposed Configuration

In .forgejo/ai-review.yml:

review:
  formal_review: false            # true to use /pulls/{n}/reviews instead of /issues/{n}/comments
  allow_approval: false           # true to submit event: "APPROVE" when verdict is "Ready to merge"
  allow_request_changes: false    # true to submit event: "REQUEST_CHANGES" on blocking findings
  min_approval_confidence: high   # only approve if no findings remain at or above this confidence

Scope

  • Update publish() in reviewer.py to support POST /api/v1/repos/{owner}/{repo}/pulls/{number}/reviews.
  • Map the calculated review verdict (Ready to merge vs Requires further work) to Forgejo review events:
    • If allow_approval: true and verdict is "Ready to merge": event APPROVE.
    • If allow_request_changes: true and blocking findings exist: event REQUEST_CHANGES.
    • Otherwise (or if disabled): event COMMENT.
  • Preserve the existing issue-comment update mechanism as the default when formal_review: false.
  • Add test fixtures verifying event selection and configuration precedence.

Acceptance Criteria

  • Setting formal_review: false retains the current advisory comment behavior without behavioral change.
  • When enabled, clean reviews submit an APPROVE review event and blocking reviews submit REQUEST_CHANGES.
  • A repository can enable formal reviews without granting approval authority (allow_approval: false, formal_review: true -> COMMENT).
Extend the reviewer to optionally submit formal pull request review decisions (`APPROVE`, `REQUEST_CHANGES`, or `COMMENT`) via the Forgejo reviews API, governed by explicit repository configuration. ### Context & Motivation Currently, the reviewer publishes findings as an advisory markdown issue comment (`issues/{number}/comments`). Issue #19 describes publishing formal reviews with the `COMMENT` event. For automated workflows where a passing review could unblock branch protection or merge requirements, repositories may want the bot to submit `APPROVE` when clean, or `REQUEST_CHANGES` when blocking defects are detected. Because automated reviewers can produce false positives or partial analyses, this capability must be strictly opt-in and configurable per repository. ### Proposed Configuration In `.forgejo/ai-review.yml`: ```yaml review: formal_review: false # true to use /pulls/{n}/reviews instead of /issues/{n}/comments allow_approval: false # true to submit event: "APPROVE" when verdict is "Ready to merge" allow_request_changes: false # true to submit event: "REQUEST_CHANGES" on blocking findings min_approval_confidence: high # only approve if no findings remain at or above this confidence ``` ### Scope - Update `publish()` in `reviewer.py` to support `POST /api/v1/repos/{owner}/{repo}/pulls/{number}/reviews`. - Map the calculated review verdict (`Ready to merge` vs `Requires further work`) to Forgejo review events: - If `allow_approval: true` and verdict is "Ready to merge": event `APPROVE`. - If `allow_request_changes: true` and blocking findings exist: event `REQUEST_CHANGES`. - Otherwise (or if disabled): event `COMMENT`. - Preserve the existing issue-comment update mechanism as the default when `formal_review: false`. - Add test fixtures verifying event selection and configuration precedence. ### Acceptance Criteria - Setting `formal_review: false` retains the current advisory comment behavior without behavioral change. - When enabled, clean reviews submit an `APPROVE` review event and blocking reviews submit `REQUEST_CHANGES`. - A repository can enable formal reviews without granting approval authority (`allow_approval: false, formal_review: true` -> `COMMENT`).
nimmo closed this issue 2026-10-07 21:14:36 +01:00
Sign in to join this conversation.
No labels
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
nimmo/forgejo-auto-pr-review#27
No description provided.