labeler: parse yes/no template fields, keep legacy checkbox fallback#5
Merged
Conversation
The Urgent and High complexity rows in the PR template are switching from
`- [ ] **Urgent** ...` to `- **Urgent** (...): yes|no`. GitHub treats every
`- [ ]` line as a task and rolls them into the "X of Y tasks" indicator on
the PR list, which made the indicator misleading: a normal PR could never
read 100% complete unless the bug was both Urgent and High complexity.
This change teaches `pr_labeler.py` to parse both formats so labels keep
flowing during the rollout:
- New `field_state(body, yesno=..., checkbox=...)` tries the yes/no regex
first and falls back to the legacy checkbox regex.
- The legacy `checkbox_regex` and tests are preserved so in-flight PRs
opened before the template change still get labeled correctly.
- A follow-up will drop the legacy regex once the open-PR queue rolls
over (~2 weeks).
Test coverage goes from 22 to 54 cases, including parametrized yes/no
variants, value validation (must be `yes` or `no`, with word-boundary
guards against words like `nothing`), parenthetical hint handling, and
precedence (yes/no wins when both formats appear in the same body).
This PR is the labeler half of the rollout. The companion template
changes ship in trufflesecurity/.github-private and trufflesecurity/thog.
Made-with: Cursor
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3f53db2. Configure here.
The yesno regex `[-*]\s*[*_`+'`'+`]*\s*<keyword>...` could treat the `*` of an inline `**Urgent**` as a list bullet, so on a legacy line like `- [x] **Urgent**: no further action` it captured `no` from the description and `field_state` returned immediately, flipping a checked box from `on` to `off`. Anchor the yesno regex to the start of a line (`^\s*[-*]`, MULTILINE) so inline bold can't impersonate a bullet, and harden `field_state` to discard any yes/no match whose enclosing line is itself a checkbox line so a future regression in the regex can't reintroduce the same flip. Made-with: Cursor
Contributor
Author
|
If you are the lucky person reviewing this, could you please also check these? They are all related to this one issue. The .github-private PR and the thog PR 6133 both update the actual PR template referred to in this PR. The final thog PR 6134 provides extra clarity for future agents in the project-wide rules. |
dustin-decker
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
The PR template's Review guidance section is switching from checkbox syntax (
- [ ] **Urgent** ...) to ayes/novalue (- **Urgent** (needs same-day review): no). GitHub treats every- [ ]line as a task and rolls them into the "X of Y tasks" indicator on the PR list view, which makes the indicator misleading -- a normal PR could never read 100% complete unless the bug happened to be both Urgent and High complexity.This is the labeler half of the rollout. The companion template changes ship in
trufflesecurity/.github-privateandtrufflesecurity/thog.What changed
pr_labeler.py:field_state(body, *, yesno, checkbox)helper. Tries the new yes/no regex first; falls back to the legacy checkbox regex.yesno_regex(keyword)matches- **Urgent** (...): yes|no(case-insensitive, with word-boundary guards so values likenothingdon't get parsed asno).checkbox_regex(keyword)is retained so in-flight PRs opened before the template change still get labeled correctly.test_pr_labeler.py:TestFieldStateYesNoclass with parametrized yes/no variants, value validation, and parenthetical-hint edge cases.TestCheckboxStatecases are preserved asTestFieldStateLegacyCheckbox.TestFieldStatePrecedenceclass confirms yes/no wins when both formats appear in the same body.54 total tests pass (was 22).
Review guidance
.github/scripts/pr_labeler.py(regex +field_state)Testing
Verified locally with
pytest .github/scripts/test_pr_labeler.py -v-- 54 passed.ruff checkandruff format --checkboth clean.Deployment notes
None. Pure script + tests change; reusable workflow caller signature is unchanged. The legacy regex stays in for ~2 weeks; a follow-up will drop it once the open-PR queue rolls over.
Note
Medium Risk
Changes PR labeling behavior by switching parsing from checkbox-only to yes/no template fields, which could cause incorrect
review/urgent/complexity/highlabels if the new regex misses edge cases. Scope is limited to a GitHub Actions helper script and expanded unit tests.Overview
Updates the PR labeler to derive
review/urgentandcomplexity/highfrom the new PR template format- **Field**: yes|no, while retaining legacy checkbox parsing as a fallback for older PRs.Introduces a new
field_statehelper and anchored yes/no regexes with defensive handling to avoid mis-parsing: yes/notext inside legacy checkbox descriptions, and expands the test suite to cover yes/no variants, legacy behavior, and precedence/edge cases.Reviewed by Cursor Bugbot for commit b648472. Bugbot is set up for automated code reviews on this repo. Configure here.