Skip to content

ci(pr-triage): unify labeler, priority triage, and label policy - #731

Merged
Astro-Han merged 2 commits into
devfrom
claude/label-policy-pr-only
May 18, 2026
Merged

ci(pr-triage): unify labeler, priority triage, and label policy#731
Astro-Han merged 2 commits into
devfrom
claude/label-policy-pr-only

Conversation

@Astro-Han

@Astro-Han Astro-Han commented May 18, 2026

Copy link
Copy Markdown
Owner

Summary

Merge three parallel pull_request_target workflows (labeler, pr-priority-triage, label-policy) into a single pr-triage workflow. Disable blank issues. Update the meta-test contract.

Why

Three GitHub Actions workflows were racing on every PR opened. labeler wrote routing labels, pr-priority-triage wrote a priority label, and label-policy read labels and checked completeness. They ran in parallel, so label-policy could read labels before the writers finished and fail with "missing priority" or "missing routing." Because pr-priority-triage and labeler both use GITHUB_TOKEN to add labels, those writes do not trigger any downstream workflow run, so the failed label-policy check stayed red until a maintainer re-ran it or a new push arrived. This race produced the first-attempt failure on this PR itself.

Issues opened by external contributors also failed the check, since priority and routing are maintainer-side triage labels the author cannot reasonably set. The red mark looked like an issue-template problem to the reporter. Issue triage is owned by saved-search views, not CI.

The fix moves the three workflows into a single pr-triage workflow with three sequential steps. actions/labeler runs first and writes routing. github-script then computes priority, syncs the P label, posts the recommendation comment, and finally calls validateLabelPolicy against the labels that exist after all writes. The check is physically incapable of racing the writers because there is no parallelism left.

Blank issues are disabled because the bug, feature, and task templates already carry a type label on creation. The blank entry point was the path that produced no-label issues like #728.

Related Issue

No issue. Driven by the failure pattern visible in recent label-policy runs and the race that first-failed this PR.

Human Review Status

Pending. A human should make the final merge decision after reviewing the final diff and verification evidence.

Review Focus

  • pr-triage.yml step order: labeler, checkout, github-script. Confirm this is the intended pipeline and that the final listLabelsOnIssue call in the script sees post-labeler state.
  • pr-priority-triage.js and label-policy-check.js are unchanged. Only the workflow orchestration moves.
  • Meta-test now asserts the three step uses in order, which becomes a stronger contract than the prior assertions.
  • The label-policy script keeps its itemType: "issue" branch and its unit tests, but no production caller invokes it that way anymore. Left in place as a small surface; can be pruned in a follow-up if preferred.

Risk Notes

  • label-policy no longer fires on manual labeled and unlabeled events. Maintainer-introduced label errors after a PR stops receiving pushes are caught by reviewer eyes or by the next push, which re-runs pr-triage. Production data across the last 30 PRs shows zero cases of this scenario.
  • If dev branch protection lists pr-priority-triage or label-policy as a required status check, update those entries to pr-triage after merge.
  • Disabling blank issues removes an escape hatch some users rely on for unusual reports. The three templates cover all current report shapes.

How To Verify

bun test packages/opencode/test/github/pr-triage-workflow.test.ts: 9 pass
node --test .github/scripts/label-policy-check.test.js: 12 pass
YAML parse (pr-triage.yml, config.yml): ok via parseWorkflow
First-attempt label-policy run on this PR (pre-merge): success after re-run; new pr-triage workflow will replace it

Screenshots or Recordings

Not applicable. CI configuration change with no visible UI surface.

Checklist

  • Human review status is stated above as pending, approved, or not required
  • I linked the related issue, or stated why there is no issue
  • This PR has exactly one type label, at least one primary routing label, and exactly one priority label, or I requested maintainer labeling
  • I described the review focus and any meaningful risks
  • I listed the relevant verification steps and the key result for each
  • I did not introduce unrelated refactors, dependencies, generated files, or file changes beyond the stated scope
  • I manually checked visible UI or copy changes when needed, with screenshots or recordings
  • I considered macOS and Windows impact for platform, packaging, updater, signing, paths, shell, or permissions changes
  • I called out docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file changes when relevant
  • I reviewed the final diff for unrelated changes and suspicious dependency changes
  • I am targeting dev, and my PR title and commit messages use Conventional Commits in English

The label-policy workflow ran on every issue and on every PR
synchronize, producing two kinds of noise:

- Issues opened by external contributors failed the check because
  priority and routing are maintainer-side triage labels the author
  cannot reasonably set. The red check looked like an issue-template
  problem to the reporter.
- PRs with a wrong label combination (e.g. P1+P2 on #729) failed
  again on every commit push because synchronize re-triggered the
  workflow even when labels had not changed.

Scope the check to PR events that actually change labels
(opened, labeled, unlabeled, reopened) and stop running it on
issues. Issue triage is owned by saved-search views, not CI.

Also disable blank_issues_enabled so issue authors must go through
a template, which guarantees a type label (bug/enhancement/task)
on creation. The #728 untriaged-issue case came from the blank
entry point.

Update the meta-test to lock the new trigger contract and to drop
the issues: read permission assertion.
@coderabbitai

coderabbitai Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@Astro-Han has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 29 minutes and 7 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 840d6dff-6b5f-40ba-8c26-77059a044ae6

📥 Commits

Reviewing files that changed from the base of the PR and between 6102419 and eff0da6.

📒 Files selected for processing (6)
  • .github/ISSUE_TEMPLATE/config.yml
  • .github/workflows/label-policy.yml
  • .github/workflows/labeler.yml
  • .github/workflows/pr-triage.yml
  • packages/opencode/test/github/label-policy-workflow.test.ts
  • packages/opencode/test/github/pr-triage-workflow.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/label-policy-pr-only

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 and usage tips.

@github-actions github-actions Bot added ci Continuous integration / GitHub Actions harness Model harness, prompts, tool descriptions, and session mechanics task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work P2 Medium priority labels May 18, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggested priority: P2 (includes non-doc, non-test paths outside the low-risk bucket).

P1/P0 are reserved for maintainer confirmation. Please relabel manually if this is a release blocker, security issue, data-loss risk, or updater/runtime failure.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request disables blank issues and updates the label policy workflow tests to target pull requests on the 'dev' branch while removing issue triggers. A review comment identifies that removing the 'issues: read' permission will likely cause a 403 Forbidden error because the workflow still utilizes the Issues API to list labels, and suggests restoring this permission to ensure the workflow functions correctly.

Comment thread packages/opencode/test/github/label-policy-workflow.test.ts Outdated
The labeler, pr-priority-triage, and label-policy workflows all
fired on pull_request_target opened in parallel. label-policy
read labels before labeler and pr-priority-triage had finished
writing them, then failed on missing priority or routing. Because
GITHUB_TOKEN label writes do not trigger downstream workflows,
the failed run stuck until a maintainer re-ran it or a new push
arrived. This is the race that produced the first-attempt
failure on PR #731.

Merge the three workflows into a single pr-triage workflow.
Labeler runs first, then the github-script step computes the
priority label, syncs it, posts the recommendation comment, and
finally calls validateLabelPolicy against the labels that exist
after all writes. The check is now physically incapable of
racing the labelers.

Trade-off: label-policy no longer fires on manual labeled /
unlabeled events. Maintainer-introduced label errors after a PR
stops receiving pushes are caught by reviewer eyes or by the
next push (which re-runs pr-triage). Production data across 30
recent PRs shows zero cases of this scenario, so the gap is
acceptable; if it ever bites, restoring a tiny labeled-event
workflow is a five-line follow-up.

Also rename so the workflow name reflects its actual scope, and
update the meta-test contract to match.

If dev branch protection lists pr-priority-triage or label-policy
as a required status check, update those entries to pr-triage.
@Astro-Han Astro-Han changed the title ci(label-policy): scope to PRs and disable blank issues ci(pr-triage): unify labeler, priority triage, and label policy May 18, 2026
@Astro-Han
Astro-Han merged commit c744a61 into dev May 18, 2026
30 checks passed
@Astro-Han
Astro-Han deleted the claude/label-policy-pr-only branch May 18, 2026 09:07
Astro-Han added a commit that referenced this pull request May 18, 2026
Astro-Han added a commit that referenced this pull request May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continuous integration / GitHub Actions harness Model harness, prompts, tool descriptions, and session mechanics P2 Medium priority task Narrow execution, audit, spike, migration, tracking, or upstream follow-up work

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant