Skip to content

[Fix] Fork PR review-state labels stay stale until the hourly sweep - #2049

Merged
edelauna merged 2 commits into
mainfrom
fix/fork-review-label-follow-up-0gadx9h5oujtq
Oct 17, 2026
Merged

edelauna merged 2 commits into
mainfrom
fix/fork-review-label-follow-up-0gadx9h5oujtq

Conversation

@zoomote

@zoomote zoomote Bot commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

​Created by Roomote. Follow up by mentioning @roomote, in the web UI, or in Discord.

Related GitHub Issue

Closes #2046

Description

A review on a fork PR runs with a read-only GITHUB_TOKEN. The workflow computes the right label but skips the write, so labels stay stale until the hourly sweep or another trusted event.

This PR implements the fix proposed in the issue:

  1. The workflow now lists its own name in workflow_run.workflows. A fork pull_request_review run's completion then re-triggers the workflow with a privileged token that writes the computed labels.
  2. The resolve job accepts a workflow_run of this workflow only when github.event.workflow_run.event == 'pull_request_review'. This is the loop guard. A run triggered by workflow_run has event workflow_run, so the next level is filtered out and the chain stops after one hop. The guard sits in both jobs' if conditions and in the resolve script, matching the existing issue_comment defense-in-depth pattern.
  3. PR resolution reuses the existing head SHA fallback. Fork runs leave workflow_run.pull_requests empty, and the workflow already resolves those by exact head owner, branch, and SHA.
  4. The privileged follow-up takes no artifact input and does not check out code. It reads only PR metadata through the API, so no untrusted PR code or artifacts are touched.

Reviewers should check with care: the guard keys on workflow_run.name == 'Label PR review state'. A workflow rename must update the guard expressions, the script check, and the workflow_run.workflows list together.

Test Procedure

New tests in src/services/__tests__/pr-review-state-workflow.test.ts (describe block fork review self-follow-up (#2046)):

  • A fork review run writes nothing; the trusted workflow_run follow-up resolves the PR by exact head and writes the label.
  • A self workflow_run triggered by a non-review run (schedule, push, workflow_dispatch, pull_request_target) is ignored.
  • The loop guard holds: a self workflow_run with event workflow_run is ignored, so the chain stops after one hop.

The test harness now models workflow_run.name and workflow_run.event in the event payload. Existing workflow_run tests default to a listed CI workflow and stay outside the guard.

Checks run: the targeted Vitest suite (204 tests) passes. ESLint with --prune-suppressions --max-warnings=0 and tsc --noEmit pass on the changed files. The full pnpm test at the repository root passes (13/13 turbo tasks).

Reviewers can repeat this with: pnpm --dir src exec vitest run services/__tests__/pr-review-state-workflow.test.ts.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I reviewed my own code with care.
  • Writing Style: The PR title and description use Simplified Technical English (ASD-STE100): short sentences, plain words, active voice, one idea per sentence, no contractions.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): Not applicable. This PR changes a GitHub Actions workflow and its tests only; no UI changed.
  • Documentation Impact: I checked if my changes need documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I read and agree to the Contributor Guidelines.

Visual Snapshots

Not applicable. This PR changes CI workflow behavior only; there is no rendered UI state to snapshot.

Videos (interaction / animation only)

Not applicable. No interaction or animation changed.

Documentation Updates

  • No documentation updates are required. This is a GitHub Actions workflow change only; no Zoo Code product functionality changed.

Additional Notes

The alternative from the issue (shortening the sweep interval to 15 minutes) is not implemented. It costs 4 times the API calls against a shared rate-limit pool.

Get in Touch

0x7777777_ on Discord

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository: Zoo-Code-Org/Zoo-Code/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1cdb3eb4-2b03-4480-a0ac-906971783963

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review status

This PR was opened by an automated account. A human maintainer must verify the change intent, provenance, and validation before merging.

Current step: Required CI passed. Waiting for automated review of the latest commit.

If automated review does not start, a maintainer must restart it.

Review-state labels are managed by this workflow; do not edit them manually. community-approved is managed the same way — do not add or remove it manually. It signals a fresh community code approval for the current head as an advisory priority only; maintainer review is still required.

@codecov

codecov Bot commented Oct 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@edelauna
edelauna marked this pull request as ready for review October 17, 2026 01:23
edelauna
edelauna previously approved these changes Oct 17, 2026
@edelauna
edelauna force-pushed the fix/fork-review-label-follow-up-0gadx9h5oujtq branch from e394ec4 to 98b6d89 Compare October 17, 2026 01:23
@edelauna
edelauna enabled auto-merge October 17, 2026 01:23
@edelauna
edelauna force-pushed the fix/fork-review-label-follow-up-0gadx9h5oujtq branch from 98b6d89 to a04e027 Compare October 17, 2026 03:16
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit labels Oct 17, 2026
@edelauna
edelauna added this pull request to the merge queue Oct 17, 2026
Merged via the queue into main with commit 124b12f Oct 17, 2026
17 of 19 checks passed
@edelauna
edelauna deleted the fix/fork-review-label-follow-up-0gadx9h5oujtq branch October 17, 2026 14:44
easonLiangWorldedtech pushed a commit to easonLiangWorldedtech/Zoo-Code that referenced this pull request Oct 18, 2026
…he label workflow (Zoo-Code-Org#2088)

* fix(ci): move fork review follow-up out of label-pr-review-state so GitHub accepts the workflow

GitHub rejects a workflow that lists its own name in workflow_run.workflows,
so no schedule, pull_request_target, issue_comment, or workflow_run runs of
'Label PR review state' started since PR Zoo-Code-Org#2049 merged.

- Remove 'Label PR review state' from its own workflow_run.workflows list.
- Remove the workflow_run.name loop-guard clause from the resolve and
  reconcile job if conditions and from the resolve script.
- Move the privileged fork pull_request_review follow-up (issue Zoo-Code-Org#2046) into
  a new workflow, label-pr-review-state-fork-review-followup.yml, which
  listens for completed 'Label PR review state' runs, keeps the one-hop loop
  guard on workflow_run.event == 'pull_request_review', resolves fork PRs by
  exact head owner, branch, and SHA, and dispatches the reconciliation
  workflow's existing workflow_dispatch entrypoint.
- Add workflow-self-listen.test.ts, which fails when any workflow lists its
  own name in workflow_run.workflows (actionlint does not catch this), and
  wire it plus the new follow-up workflow tests into the test:workflow suite.

Closes Zoo-Code-Org#2086

* fix(ci): handle dispatch failures and widen follow-up tests

---------

Co-authored-by: Roomote <roomote@roomote.dev>
Co-authored-by: Elliott de Launay <edelauna@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit coderabbit-review-active Required CI passed; CodeRabbit review is active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fork PR review events leave labels stale until the hourly sweep

2 participants