Skip to content

fix(pr-risk): retire default labels after remap - #253

Closed
huang47 wants to merge 3 commits into
mainfrom
cx/risk-label-map-variable
Closed

fix(pr-risk): retire default labels after remap#253
huang47 wants to merge 3 commits into
mainfrom
cx/risk-label-map-variable

Conversation

@huang47

@huang47 huang47 commented Sep 2, 2026

Copy link
Copy Markdown

Summary:

  • reuse the existing label_map input; add no new configuration surface
  • retire the default risk:R0 through risk:R3 and risk:ungraded labels on the first remapped grade so a PR keeps one grader-owned label
  • document the named-label mapping while keeping R0–R3 as the internal grades

Caller mapping:
R0=risk:low,R1=risk:medium,R2=risk:high,R3=risk:xhigh,unknown=risk:unknown

Validation:

  • ShellCheck passed for all PR-risk scripts and suites
  • all 414 PR-risk assertions passed
  • all 28 pin-contract assertions passed
  • workflow-pin lint passed

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 74aa8c51-1878-416e-800e-b05f6c251d99

📥 Commits

Reviewing files that changed from the base of the PR and between e203fbc and e7b8a69.

📒 Files selected for processing (5)
  • .github/workflows/pr-risk.yml
  • docs/callers/pr-risk.md
  • scripts/pr-risk/README.md
  • scripts/pr-risk/apply-risk-label.sh
  • scripts/pr-risk/tests/test_apply_risk_label.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The risk-label script now owns the five default risk labels and removes them after a custom LABEL_MAP remap. Tests cover stale-label replacement. Caller documentation, README text, and workflow comments describe the updated cleanup behavior.

Changes

Risk label remapping

Layer / File(s) Summary
Default label ownership and cleanup
scripts/pr-risk/apply-risk-label.sh
The script adds risk:R0 through risk:R3 and risk:ungraded to its owned labels. Regrading removes these labels when a custom map is active.
Remapping validation and documentation
scripts/pr-risk/tests/test_apply_risk_label.sh, .github/workflows/pr-risk.yml, docs/callers/pr-risk.md, scripts/pr-risk/README.md
Tests verify that stale default labels are replaced by the mapped label. Comments and documentation describe cleanup of default labels and older custom labels.

Suggested reviewers: mattmillerai

Merge Risk: ⚪ Minimal · up to e7b8a

The change remaps risk labels while retiring the old defaults and documents the caller mapping; no actionable merge-blocking risk remains after normal checks and review.

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cx/risk-label-map-variable
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch cx/risk-label-map-variable

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

@huang47 huang47 changed the title feat(pr-risk): allow repository label maps fix(pr-risk): retire default labels after remap Sep 2, 2026
@huang47
huang47 marked this pull request as ready for review September 2, 2026 01:48
@coderabbitai
coderabbitai Bot requested a review from mattmillerai September 2, 2026 01:49
@mattmillerai mattmillerai added the cursor-review Multi-model cursor review label Sep 2, 2026
@huang47

huang47 commented Sep 2, 2026

Copy link
Copy Markdown
Author

close, just do caller side override Comfy-Org/ComfyUI_frontend#16463

@huang47 huang47 closed this Sep 2, 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.

🔍 Cursor Review — Consolidated panel

Triggered by @mattmillerai.

Found 6 finding(s).

Severity Count
🟡 Medium 1
🟢 Low 3
⚪ Nit 2

Panel: 6/6 reviewers contributed findings.

[ -n "$l" ] || die "LABEL_MAP maps tier '$t' to an empty label"
OWNED+=("$l")
done
OWNED+=("risk:R0" "risk:R1" "risk:R2" "risk:R3" "risk:ungraded")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium — The five default names are appended to OWNED unconditionally and permanently, so in a repo enrolled with a custom label_map a risk:R0..risk:R3/risk:ungraded label this grader never applied — a human triage marker, an org escalation convention, a parallel/legacy labeler — is now silently deleted by the full-set PUT, which breaks the script's own promise that a human's own label is never fought. There is no caller opt-out, and if another actor re-adds one the PR can never satisfy the in-sync short-circuit, so every subsequent run flaps and re-opens the destructive read→PUT window the header claims is confined to grade-changing runs. Consider gating retirement behind an explicit one-time migration input instead of claiming unrelated labels by name.
Raised by 5 of 6 reviewers (claude-opus-5-thinking-max adversarial, gpt-5.6-sol-max adversarial, kimi-k3-high adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-high edge-case).

[ -n "$l" ] || die "LABEL_MAP maps tier '$t' to an empty label"
OWNED+=("$l")
done
OWNED+=("risk:R0" "risk:R1" "risk:R2" "risk:R3" "risk:ungraded")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Low — This list hardcodes the values already held in DEFAULT_MAP (line 79), so the two can silently desync: rename a default (say unknownrisk:unlabeled) and the new name is never retired while the stale one stays permanently owned in every repo, with nothing failing to signal it. Deriving the list from DEFAULT_MAP via the existing label_for logic keeps them identical by construction.
Raised by 2 of 6 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

# they are carried through every future PUT beside the new target, and nothing here will clean them
# up. Remapping is a one-time repo-side cleanup (delete the retired label names), not something a
# re-grade heals.
# ONE MORE LIMIT, on a different axis: ownership is defined by the CURRENT LABEL_MAP plus the five

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Low — This rewritten paragraph contradicts the OWNERSHIP CONTRACT at the top of the same file (line 5 still says the script owns "EXACTLY the label names in LABEL_MAP's values", with non-owned labels carried through untouched). That contract is the stated safety justification for the destructive whole-set PUT, so line 5 needs the same "plus the five default names" qualifier or the next maintainer reasons about this write from an invariant that no longer holds.
Raised by 3 of 6 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-high edge-case).

Comment thread docs/callers/pr-risk.md

To show `risk:low` through `risk:xhigh`, pass this `label_map` in the caller:
`R0=risk:low,R1=risk:medium,R2=risk:high,R3=risk:xhigh,unknown=risk:unknown`.
The next grade removes a default `risk:R0`..`risk:R3` or `risk:ungraded` label

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Low — "The next grade removes a default ... label" reads as one-time migration cleanup, but the code makes those five names grader-owned permanently: after adopting a custom map a caller can never keep risk:R0..risk:R3 or risk:ungraded on a PR for any other purpose, since every grade strips them again. Say that outright here, and in the same-understated wording at .github/workflows/pr-risk.yml:117 and scripts/pr-risk/README.md:201.
Raised by 2 of 6 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

# re-dispatch on `pr_number` if a final grade looks wrong). It can no longer leave two contradictory
# labels on a PR under one `label_map`; remapping `label_map` orphans the old names, which is a
# one-time repo-side cleanup. What the shape does cost is a narrower residual: the PUT is built from
# labels on a PR under one `label_map`; the first remapped grade retires the default

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit — "the first remapped grade retires the default risk:R0..risk:R3 and risk:ungraded labels" overstates two ways: a remap that keeps a default name as a live target (the 1-indexed scheme documented in this same file keeps unknown=risk:ungraded) does not retire that name, and retirement happens per-PR on that PR's next grade, not globally on the first remapped grade.
Raised by 1 of 6 reviewers (kimi-k3-high edge-case).

[ -n "$l" ] || die "LABEL_MAP maps tier '$t' to an empty label"
OWNED+=("$l")
done
OWNED+=("risk:R0" "risk:R1" "risk:R2" "risk:R3" "risk:ungraded")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nit — The append does not dedup, so under the default map — the common case, where these names are already in OWNED from the map — each is held twice. Set semantics downstream are unaffected, but the in-sync loop spawns up to ten has() jq subprocesses per PR instead of five and the DRY_RUN log prints a visibly duplicated owned set.
Raised by 1 of 6 reviewers (claude-opus-5-thinking-max edge-case).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cursor-review Multi-model cursor review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants