Skip to content

Add event-driven PR workflow labels - #3786

Open
wasphin wants to merge 6 commits into
apache:masterfrom
wasphin:add-pr-workflow-labels
Open

wasphin wants to merge 6 commits into
apache:masterfrom
wasphin:add-pr-workflow-labels

Conversation

@wasphin

@wasphin wasphin commented Nov 29, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: N/A

Problem Summary:

Open PRs need a filterable indication of their next action so authors,
reviewers, AI agents and maintainers can hand work back and forth without
losing track of pending reviews or decisions.

Implements the workflow discussed in
#3719 using ordinary GitHub Actions,
without a hosted AI triage service, shared personal AI token or per-PR command.

What is changed and the side effects?

Changed:

  • Define six next-action status labels in a portable review skill and document
    them in CONTRIBUTING.md. Add an interactive agent entry point for the skill.
  • Synchronize lifecycle events, formal review notifications and author replies
    using deterministic API checks. Maintainers retain semantic review decisions
    and final merge readiness; the workflow never approves or merges a PR.
  • Receive fork review notifications through a read-only relay. Label writes use
    default-branch code and do not execute PR code or consume workflow artifacts.
  • Track the head accepted as ready to merge and revoke stale readiness after a
    head change or an unmet required merge condition.
  • Rotate through at most 20 PRs per batch. Skip PRs without workflow labels
    after 90 days without updates, configurable through PR_WORKFLOW_IDLE_DAYS.
    Existing workflow states, direct events and explicit PR requests bypass this
    age filter.
  • Add 40 functional regression cases and a dedicated workflow to run them.

Side effects:

  • The status workflow needs the built-in token's pull-requests write permission
    to manage labels and readiness bookkeeping comments. Semantic interpretation,
    AI review scheduling and abandoned-review detection remain manual.
  • Performance effects: Adds event-driven Actions and a half-hourly bounded
    reconciliation batch; no impact on the brpc runtime.
  • Breaking backward compatibility: None for brpc APIs or runtime behavior.

Check List:

Track the next PR action with ordinary GitHub events instead of hosted
AI triage and a shared personal token. Keep semantic review and merge
acceptance with reviewers and maintainers.

Use default-branch code for label writes, relay fork review notifications
without privileged PR execution, and invalidate readiness when the head
or required merge conditions change.
Default batch enrollment to PRs updated within 90 days, configurable via
PR_WORKFLOW_IDLE_DAYS. Keep existing workflow states under observation
and always process direct events and explicit PR requests.
Upgrade github-script to v8 to avoid the Node.js 20 deprecation warning
seen in the demo workflow. Keep the runtime update separate from PR
eligibility changes.

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.

🟡 Changes recommended

Unresolved critical issues can leave the ready-to-merge label in place despite outside or unauthorized feedback and can abort classification of non-collaborator reviews.

4 open issues
What changed in this PR

Adds an event-driven GitHub Actions workflow for tracking pull-request next actions through standardized status/* labels while keeping review interpretation and merge decisions with maintainers.

Changes:

  • Documents six workflow states, handoff rules, and triage guidance.
  • Adds trusted lifecycle, review-signal, readiness, and reconciliation workflows.
  • Implements deterministic synchronization with regression tests.
File Description
CONTRIBUTING.md Documents the six PR workflow labels and review handoff rules in English and Chinese.
.github/​workflows/​pr-workflow-checks.yml Runs regression tests for the PR workflow implementation.
.github/​workflows/​pr-status-label.yml Coordinates lifecycle, review, CI, scheduled, and manual synchronization using trusted default-branch code.
.github/​workflows/​pr-review-signal.yml Relays pull-request review activity without privileged permissions or pull-request code execution.
.github/​skills/​pr-workflow/​SKILL.md Defines workflow states, review handoffs, and GitHub usage guidance.
.github/​scripts/​pr-status-label.test.cjs Provides functional regression coverage for lifecycle, review, readiness, concurrency, batching, and security behavior.
.github/​scripts/​pr-status-label.cjs Implements PR selection, label transitions, review handling, readiness tracking, and merge-condition checks.
.github/​agents/​pr-triage.agent.md Adds a read-only interactive entry point for PR workflow triage.

Review effort: Lite

Comment on lines +204 to +207
if (context.eventName === 'pull_request_target' && event.action === 'labeled'
&& event.label?.name === READY && event.pull_request.head.sha === pr.head.sha) {
if (!unchanged(pr, await readPr())) return;
await recordTracker(pr.head.sha);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in df536cf. The label event sender must have write, maintain or admin permission before a readiness record is created; triage/read/none and missing senders hand off to awaiting-maintainer. Write is intentionally accepted because the workflow uses repository write access as its maintainer decision boundary, rather than requiring GitHub's specifically named Maintain role. The skill now states this boundary explicitly, with functional coverage for each role.

Comment on lines +280 to +281
} else if (state === READY) {
await checkReadiness();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a94bad6. A validated current-head COMMENTED review now moves an already-ready PR to awaiting-maintainer and removes its readiness record. It requires interpretation rather than preserving readiness solely because required checks still pass. Optional APPROVED reviews continue to preserve readiness.

Comment on lines +280 to +281
} else if (state === READY) {
await checkReadiness();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in a94bad6. A validated current-head outside CHANGES_REQUESTED review now revokes readiness and hands off to awaiting-maintainer. Trusted unanswered changes requests still route directly to awaiting-author. Regression coverage verifies both outside feedback paths and readiness-record cleanup.

Comment thread .github/scripts/pr-status-label.cjs Outdated
Comment on lines +264 to +267
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({
owner, repo, username: review.user.login,
});
if (['write', 'maintain', 'admin'].includes(data.permission)) requests.push(review);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Handled in df536cf: 404 is treated as no decision permission, while 403 and other API failures still propagate without changing labels. The premise is not universal: a read-only query for the Copilot reviewer in this repository returned 200 with permission: none. Both normal untrusted responses and the 404 fallback are supported; tests also verify that unrelated API errors are not swallowed.

Require write, maintain or admin permission before recording the head
accepted as ready to merge. A triage-only labeler must hand the decision
to a maintainer. Treat missing collaborators as untrusted and propagate
other permission lookup failures.
Return a ready PR to maintainer evaluation after a new COMMENT review
or outside changes request. Preserve readiness after optional positive
reviews; trusted unanswered changes requests still route to the author.
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