Skip to content

fix(bot): keep review labels in sync when a fork PR is reviewed - #3121

Merged
ascorbic merged 3 commits into
emdash-cms:mainfrom
danielmlr:fix/bot-review-state-labels
Sep 16, 2026
Merged

ascorbic merged 3 commits into
emdash-cms:mainfrom
danielmlr:fix/bot-review-state-labels

Conversation

@danielmlr

@danielmlr danielmlr commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Moves a fork PR's review/* label when the PR is reviewed, not on the next six-hourly sweep. review-state.yml takes reviews through pull_request_review, which GitHub runs for a fork PR with a read-only token, so the label write fails as a warning while the run passes (example). The same happens after a maintainer's review.

emdash-bot already receives these deliveries, and its App token can write labels on fork PRs. A review on a fork PR now recomputes the label there with the workflow's rules, so the sweep agrees with it. The workflow skips those reviews, where it cannot write labels, and still handles same-repo PRs, so each review has one writer. A PR from a deleted fork has no head repository, so the workflow skips its reviews too and the bot writes its label. Creating the four labels stays with the workflow, which checks for them on every run. The bot skips bot-authored PRs by type: Bot or a [bot] login, the login check it already applies to actors; GitHub App accounts carry both. The bot's own fix PRs are handled as before.

The second commit fills the gaps in what TRIAGE.md says about the bot, as requested in #contributing on Discord: decline, take over / hand back, reopen and reset, the eight lifecycle labels it didn't list, when the review bot skips a PR (drafts, bot-authored PRs, new commits), and a link to the generated BOT_STATE_MACHINE.md. Where the guide said workflows set the review labels, it now says "automatically", and it notes that triage adds area labels to issues. The bot also accepts its commands from triagers (a triager's @emdashbot triage on #3022 started a run within seconds). The guide keeps calling them maintainer commands and doesn't say whether triagers should use them.

Type of change

  • Bug fix
  • Feature (requires maintainer-approved Discussion)
  • Refactor (no behavior change)
  • Translation
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • I have read CONTRIBUTING.md
  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm test passes (or targeted tests for my change)
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • User-visible strings in the admin UI are wrapped for translation (if applicable). Do not include messages.po changes except in translation PRs — a workflow extracts catalogs on merge to main. (n/a: no admin UI change)
  • I have added and reviewed the user-facing changeset (if this PR changes a published package) (n/a: @emdash-cms/emdash-bot is private)
  • New features link to an approved Discussion: https://github.com/emdash-cms/emdash/discussions/... (n/a: bug fix)
  • I have included screenshots below if this PR changes the UI (n/a: no UI change)

AI-generated code disclosure

  • This PR includes AI-generated code — model/tool: Claude Opus 5

Screenshots / test output

Not applicable for screenshots.

  • The new webhook test, a bot review moving a contributor's PR from review/needs-review to review/awaiting-author, fails on main, where the delivery is skipped.
  • pnpm test in infra/emdash-bot: 358 unit and 91 workers-pool tests pass. No CI workflow runs this package, so its tests and typecheck ran locally.

review-state.yml takes reviews through pull_request_review, and GitHub runs
that event for a fork PR with a read-only GITHUB_TOKEN. The label write fails,
the script logs it as a warning, and the run still passes, so on community PRs
the review/* label waits for the six-hourly sweep. That goes for emdashbot's
reviews and for maintainers' alike.

emdash-bot already receives every pull_request_review delivery and holds a
token that can write labels on fork PRs. A review on a fork PR now recomputes
the label there, with the workflow's rules, so the next sweep agrees with what
the bot set. The workflow skips those reviews and keeps same-repo PRs, so each
review has one writer. Reviews on the bot's own fix PRs are handled as before.
TRIAGE.md described the issue bot's main commands and nine of its labels,
but not the commands a triager needs to stop or undo its work (decline,
take over, hand back, reopen, reset), the verdict and terminal labels an
issue can carry, or where the full generated reference lives. It also left
out when the review bot does not review: drafts, bot-authored PRs, and new
commits.

The guide said the review/* labels are applied by workflows; emdash-bot now
applies them after a review on a fork PR, so both mentions say
"automatically" instead. It also said area labels on issues are a human
call, while the triage pass adds them.
@changeset-bot

changeset-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5624272

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

Scope check

This PR changes 513 lines across 9 files. Large PRs are harder to review and more likely to be closed without review.

If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs.

See CONTRIBUTING.md for contribution guidelines.

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@emdash-cms/admin

npm i https://pkg.pr.new/@emdash-cms/admin@3121

@emdash-cms/auth

npm i https://pkg.pr.new/@emdash-cms/auth@3121

@emdash-cms/auth-atproto

npm i https://pkg.pr.new/@emdash-cms/auth-atproto@3121

@emdash-cms/blocks

npm i https://pkg.pr.new/@emdash-cms/blocks@3121

@emdash-cms/cloudflare

npm i https://pkg.pr.new/@emdash-cms/cloudflare@3121

@emdash-cms/contentful-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/contentful-to-portable-text@3121

emdash

npm i https://pkg.pr.new/emdash@3121

create-emdash

npm i https://pkg.pr.new/create-emdash@3121

@emdash-cms/gutenberg-to-portable-text

npm i https://pkg.pr.new/@emdash-cms/gutenberg-to-portable-text@3121

@emdash-cms/plugin-cli

npm i https://pkg.pr.new/@emdash-cms/plugin-cli@3121

@emdash-cms/plugin-test

npm i https://pkg.pr.new/@emdash-cms/plugin-test@3121

@emdash-cms/plugin-types

npm i https://pkg.pr.new/@emdash-cms/plugin-types@3121

@emdash-cms/registry-client

npm i https://pkg.pr.new/@emdash-cms/registry-client@3121

@emdash-cms/registry-lexicons

npm i https://pkg.pr.new/@emdash-cms/registry-lexicons@3121

@emdash-cms/registry-moderation

npm i https://pkg.pr.new/@emdash-cms/registry-moderation@3121

@emdash-cms/registry-verification

npm i https://pkg.pr.new/@emdash-cms/registry-verification@3121

@emdash-cms/sandbox-workerd

npm i https://pkg.pr.new/@emdash-cms/sandbox-workerd@3121

@emdash-cms/x402

npm i https://pkg.pr.new/@emdash-cms/x402@3121

@emdash-cms/plugin-ai-moderation

npm i https://pkg.pr.new/@emdash-cms/plugin-ai-moderation@3121

@emdash-cms/plugin-atproto

npm i https://pkg.pr.new/@emdash-cms/plugin-atproto@3121

@emdash-cms/plugin-audit-log

npm i https://pkg.pr.new/@emdash-cms/plugin-audit-log@3121

@emdash-cms/plugin-color

npm i https://pkg.pr.new/@emdash-cms/plugin-color@3121

@emdash-cms/plugin-embeds

npm i https://pkg.pr.new/@emdash-cms/plugin-embeds@3121

@emdash-cms/plugin-field-kit

npm i https://pkg.pr.new/@emdash-cms/plugin-field-kit@3121

@emdash-cms/plugin-forms

npm i https://pkg.pr.new/@emdash-cms/plugin-forms@3121

@emdash-cms/plugin-webhook-notifier

npm i https://pkg.pr.new/@emdash-cms/plugin-webhook-notifier@3121

commit: 5624272

@danielmlr
danielmlr marked this pull request as ready for review September 15, 2026 16:47
@github-actions github-actions Bot added the review/needs-review No maintainer or bot review yet label Sep 15, 2026

@emdashbot emdashbot Bot 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.

The approach is the right one: fork-PR reviews get a read-only token in review-state.yml, so moving the label write to the already-trusted emdash-bot GitHub App avoids elevating the workflow to pull_request_target for review events. The review-state rules in infra/emdash-bot/.flue/lib/review-state.ts mirror the workflow's logic (count maintainer/bot reviews, ignore the author's own reviews, ignore merge commits when deciding needs-rereview, etc.), and the new webhook path correctly skips same-repo and bot-authored PRs so there is still only one writer per review under normal circumstances. Tests cover both the normalizer unit cases and a workers-pool end-to-end run for a contributor PR.

I checked the diff, the full changed files, the state machine (machine.ts / BOT_STATE_MACHINE.md), the triage agent skill, and the flue-review auto-review gate. The implementation is clean and the docs line up with the machine. I do have a few edge-case/robustness notes — none of them are blockers for the stated bug fix, but worth tightening before merge.

Comment thread infra/emdash-bot/.flue/lib/webhook.ts
Comment thread .github/workflows/review-state.yml
Comment thread infra/emdash-bot/.flue/lib/review-state.ts
Comment thread infra/emdash-bot/.flue/lib/webhook.ts
@github-actions github-actions Bot added review/awaiting-author Reviewed; waiting on the author to respond and removed review/needs-review No maintainer or bot review yet labels Sep 15, 2026
@ascorbic
ascorbic merged commit b8b8bc1 into emdash-cms:main Sep 16, 2026
82 checks passed
@danielmlr
danielmlr deleted the fix/bot-review-state-labels branch September 16, 2026 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci cla: signed review/awaiting-author Reviewed; waiting on the author to respond size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants