Skip to content

feat(review): request human reviewers for spec PRs from external contributors#387

Open
captainsafia wants to merge 1 commit intomainfrom
oz-agent/spec-pr-reviewer-ping
Open

feat(review): request human reviewers for spec PRs from external contributors#387
captainsafia wants to merge 1 commit intomainfrom
oz-agent/spec-pr-reviewer-ping

Conversation

@captainsafia
Copy link
Copy Markdown
Collaborator

Summary

Spec-only PRs (markdown-only) from external contributors previously received an automated agent review as a COMMENT but no human reviewer was ever pinged. This PR wires up reviewer pinging for spec PRs from non-members so the right maintainers are notified.

Changes

  • _MAX_SPEC_REVIEWERS = 2 — new constant capping reviewers pinged for a single spec PR
  • _resolve_spec_reviewer_request() — new helper that extracts recommended_reviewers from review.json for spec-only non-member PRs (capped at 2, filtered to STAKEHOLDERS)
  • is_spec_non_member — new flag in main() (spec_only and _is_non_member_pr(pr)) that selects the spec reviewer path without entering the APPROVE/REQUEST_CHANGES gate
  • Prompt section — when is_spec_non_member, the agent receives a "Spec Reviewer Request" section instructing it to identify 1-2 best-fit reviewers from .github/STAKEHOLDERS based on the spec content and path patterns
  • Reviewer request — after posting the COMMENT review, the workflow calls create_review_request with the normalized reviewer list (best-effort; errors are logged but don't fail the workflow)
  • Short-circuit update — the empty-review short-circuit now only fires when there are no reviewers to request, so spec PRs with reviewers always get their review + request posted
  • Completion message_format_review_completion_message now returns a spec-specific message when event is COMMENT but reviewers are present
  • Tests — new ResolveSpecReviewerRequestTest class (6 cases) and a new test_comment_with_reviewers_mentions_logins case; all 59 tests pass

Behavior

PR type Before After
Spec PR from org member COMMENT, no ping COMMENT, no ping (unchanged)
Spec PR from external contributor COMMENT, no ping COMMENT, request 1-2 STAKEHOLDERS reviewers
Implementation PR from external contributor APPROVE/REQUEST_CHANGES + ping on APPROVE Unchanged

Conversation: https://staging.warp.dev/conversation/dec82960-2e0e-456d-ae79-8870b7433ae3
Run: https://oz.staging.warp.dev/runs/019dd0a6-6894-78c9-868b-0481c96f3ec2

This PR was generated with Oz.

…ributors

When a spec-only PR (markdown-only) is opened by an external contributor,
the review agent now identifies 1-2 human reviewers from .github/STAKEHOLDERS
based on the spec content and path patterns, and requests their review.

Previously, spec PRs from non-members received an automated COMMENT review
but no human ping. This change adds a new is_spec_non_member path that keeps
the COMMENT event (no approval gate) while also asking the review-spec agent
to populate recommended_reviewers in review.json. The workflow then calls
create_review_request with up to _MAX_SPEC_REVIEWERS (2) logins so the right
maintainers are always notified when external contributors submit spec changes.

Changes:
- Add _MAX_SPEC_REVIEWERS = 2 constant for spec reviewer cap
- Add _resolve_spec_reviewer_request() helper to extract reviewers for spec PRs
- Add is_spec_non_member variable to main() alongside existing is_non_member
- Load STAKEHOLDERS and build Spec Reviewer Request prompt section for spec
  non-member PRs instead of the existing Non-Member Review Action section
- Extract recommended_reviewers from review.json for spec non-member PRs and
  call create_review_request after posting the COMMENT review
- Update short-circuit condition to not skip posting when there are reviewers
- Update _format_review_completion_message to handle COMMENT+reviewers case
- Add tests for _resolve_spec_reviewer_request and COMMENT+reviewers message

Co-Authored-By: Oz <oz-agent@warp.dev>
@captainsafia captainsafia marked this pull request as ready for review April 27, 2026 20:52
@oz-for-oss
Copy link
Copy Markdown

oz-for-oss Bot commented Apr 27, 2026

@captainsafia

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and posted feedback on this pull request.

Powered by Oz

Copy link
Copy Markdown

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

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

Overview

This adds a dedicated spec-only non-member path so the workflow can keep COMMENT reviews for spec PRs while still requesting 1-2 human reviewers from .github/STAKEHOLDERS. The split between the implementation-PR gate and the new spec-reviewer flow is clear, and I did not find any separate security issues in the changed code.

Concerns

  • _normalize_reviewer_logins() still de-duplicates case-sensitively, so the new spec-reviewer path can preserve mixed-case duplicates like Alice/alice and hand the same GitHub reviewer to create_review_request() twice. Because reviewer requests are best-effort here, a GitHub validation failure would silently drop the human ping this change is trying to add.
  • I could not execute test_review_pr.py in this environment because the github dependency is not installed, so the review is based on the diff plus the added unit coverage.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Powered by Oz

Reviews are capped at ``_MAX_SPEC_REVIEWERS`` to avoid over-notifying
maintainers on a single spec change.
"""
return _normalize_reviewer_logins(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ [IMPORTANT] This new path inherits _normalize_reviewer_logins()'s case-sensitive dedupe, so a reviewer list like ['Alice', 'alice'] will survive normalization and can hand the same GitHub account to create_review_request() twice. Because reviewer requests are best-effort here, that can silently drop the human ping this PR is trying to add. Please normalize the dedupe key to lowercase and add a mixed-case regression test for the spec reviewer path.

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.

2 participants