Skip to content

docs(workflow): require PRs to mirror their closing issue's triage labels (closes #237) - #238

Merged
cristim merged 1 commit into
mainfrom
docs/issue-237-codify-pr-labeling
Jul 19, 2026
Merged

cristim merged 1 commit into
mainfrom
docs/issue-237-codify-pr-labeling

Conversation

@cristim

@cristim cristim commented May 3, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Closes docs(workflow): require PRs to mirror their closing issue's triage labels #237: codifies three mandatory workflow rules that were present in the system-prompt CLAUDE.md but absent from the feat/multicloud-web-frontend base branch.
  • Post-push CI watcher — arm a background watcher after every git push so CI failures surface within the same turn.
  • CodeRabbit loop — iterate CR passes until zero Actionable items remain before declaring a PR done.
  • PR labeling — mirror the closing issue's triage labels (priority/*, severity/*, urgency/*, impact/*, effort/*, type/*, triaged) onto every new PR via gh pr edit --add-label, before pinging CodeRabbit. Unlabeled PRs are invisible to priority-ordered is:open label:priority/p* queries.

The silent failure that motivated this PR: 10 PRs shipped in two recent batches, all merged-eligible after CR sign-off, none labeled — making them invisible to triage ordering.

Dogfooding

This PR itself is labeled with the issue's triage labels per the new rule (type/docs, priority/p3, severity/low, urgency/eventually, impact/internal, effort/xs, triaged).

Test plan

  • CLAUDE.md contains ## PR labeling — mirror closing-issue labels (MANDATORY) between ## CodeRabbit loop and ## Security Rules
  • Section includes the gh invocation with jq filter for all label classes
  • Multi-close handling (highest priority/severity, union the rest) is documented
  • No-triaged-lie rule is present
  • Closing checkpoint paragraph matches the CI-watcher pattern
  • Post-push CI watcher and CodeRabbit loop sections also present (they were absent from base branch)

Summary by CodeRabbit

  • Documentation
    • Added a mandatory post-push CI monitoring procedure that identifies queued/in-progress runs, reports outcomes, surfaces failure details, and triggers corrective fix-pushes when needed.
    • Introduced a mandatory iterative review loop that repeats until all actionable items are resolved and nitpicks are either fixed or explicitly justified, following defined batching rules.
    • Established PR labeling requirements to mirror associated issue triage labels, including multi-issue handling and clear verification steps for label application.

@coderabbitai

coderabbitai Bot commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3297c8fe-feb2-4cd3-b310-6a961906cf06

📥 Commits

Reviewing files that changed from the base of the PR and between 64fc92a and 30a5a6f.

📒 Files selected for processing (1)
  • CLAUDE.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • CLAUDE.md

📝 Walkthrough

Walkthrough

Documentation adds mandatory post-push CI watching, CodeRabbit review iteration, and closing-issue label mirroring procedures to CLAUDE.md.

Changes

Workflow Procedure Documentation

Layer / File(s) Summary
Post-Push CI Watcher
CLAUDE.md
Lists push-triggered GitHub Actions runs, launches background watchers for queued/in_progress runs, reports failed step digests, and performs automated fix-pushes.
CodeRabbit Review Loop
CLAUDE.md
Defines review triggering, polling, finding triage, fix-push handling, conflict recovery, and repeat-until-clean exit criteria.
PR Labeling — Mirror Closing Issue
CLAUDE.md
Defines closing-issue label mirroring during gh pr create, verification, missing-label handling, multi-issue rules, and final confirmation.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main workflow change: mirroring closing issue triage labels onto PRs.
Linked Issues check ✅ Passed The PR adds the mandatory labeling section, multi-close handling, and cross-references required by #237.
Out of Scope Changes check ✅ Passed The CI watcher and CodeRabbit loop are referenced acceptance criteria, so they are in scope rather than extraneous.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/issue-237-codify-pr-labeling

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

@cristim cristim added type/docs Documentation priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/eventually No deadline impact/internal Team-internal only effort/xs Trivial / one-liner triaged Item has been triaged labels May 3, 2026
@cristim

cristim commented May 3, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
CLAUDE.md (1)

150-153: ⚡ Quick win

Avoid manual PR_NUM entry in a mandatory path.

Using a hand-copied PR number is brittle and easy to misapply to the wrong PR. Prefer deriving it directly from the current branch context.

Safer PR number resolution
-PR_NUM=<the number gh just printed>
+PR_NUM=$(gh pr view --repo LeanerCloud/CUDly --json number --jq '.number')
 ISSUE_NUM=<the issue this PR closes>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CLAUDE.md` around lines 150 - 153, Replace the brittle manual PR_NUM
assignment after `gh pr create` with automatic resolution: capture the created
PR number programmatically (e.g., parse `gh pr create` output or call `gh pr
view` for the current branch) and set PR_NUM from that value; reference the
variables PR_NUM and ISSUE_NUM and the command `gh pr create` in your changes so
the script derives PR_NUM from the current branch/PR context rather than
requiring manual entry.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CLAUDE.md`:
- Around line 154-160: The script currently unconditionally runs gh pr edit
"$PR_NUM" --add-label "$LABELS", which fails when LABELS is empty; change it to
guard the call by checking the LABELS variable first (the LABELS assignment and
the gh pr edit "$PR_NUM" --add-label "$LABELS" invocation), e.g., only call gh
pr edit with --add-label when LABELS is non-empty and otherwise surface the
triage gap deterministically (for example add a specific fallback label like
"triage-needed" or post a comment) so the workflow does not break on empty label
payloads.

---

Nitpick comments:
In `@CLAUDE.md`:
- Around line 150-153: Replace the brittle manual PR_NUM assignment after `gh pr
create` with automatic resolution: capture the created PR number
programmatically (e.g., parse `gh pr create` output or call `gh pr view` for the
current branch) and set PR_NUM from that value; reference the variables PR_NUM
and ISSUE_NUM and the command `gh pr create` in your changes so the script
derives PR_NUM from the current branch/PR context rather than requiring manual
entry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 00bc1995-90e3-4a99-982a-b2b93e9aaacd

📥 Commits

Reviewing files that changed from the base of the PR and between c84fd02 and 7dbe911.

📒 Files selected for processing (1)
  • CLAUDE.md

Comment thread CLAUDE.md
@cristim

cristim commented May 3, 2026

Copy link
Copy Markdown
Member Author

Added a follow-up commit (188012004) extending the CR-loop section with explicit subagent-delegation guidance — exit criteria for fork prompts, not just human workflows. Surfaced by the catch-up CR-loop pass on PRs #227–#236 (none of those forks ran the CR loop because my prompts stopped at the @coderabbitai review ping). @coderabbitai review

@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@cristim: Understood — triggering a review pass to cover commit 188012004 and the subagent-delegation exit-criteria additions to the CR-loop section.

[review]

cristim added a commit that referenced this pull request May 19, 2026
…nd manual PR_NUM

Address CodeRabbit review on PR #238:

1. Actionable (Major): `gh pr edit --add-label ""` fails on empty payload,
   silently breaking the MANDATORY label-mirror flow when the closing issue
   has no priority/severity/urgency/impact/effort/type labels. Guard the
   call with `if [ -n "$LABELS" ]` and emit a clear WARN otherwise that
   directs the operator to triage the issue first and surface the gap.

2. Nitpick (Quick win): `PR_NUM=<the number gh just printed>` is brittle
   and easy to misapply to the wrong PR. Derive it from the current branch
   context via `gh pr view --json number --jq '.number'` instead, so the
   snippet works without any hand-editing after `gh pr create`.

Both changes are in the prescriptive CLAUDE.md snippet only. The labels
flow itself is unchanged behaviorally for the happy path (issue has the
expected triage labels); the new branches harden the unhappy paths.

Refs #237.
@cristim

cristim commented May 19, 2026

Copy link
Copy Markdown
Member Author

CodeRabbit pass 1 — both findings addressed

Pushed commit 64fc92a addressing both items from the 2026-05-03 review:

Actionable (Major) — empty $LABELS guard

Fixed. gh pr edit --add-label "" does fail (silently breaks the MANDATORY flow), so I added an if [ -n "$LABELS" ] guard with a clear WARN fallback that names the missing classes and tells the operator to triage the issue first. Matches your proposed hardening with slightly more informative output (the WARN message explicitly references the issue number and the expected label classes, so the operator knows what's missing without re-reading CLAUDE.md).

Nitpick (Quick win) — manual PR_NUM entry

Fixed. Replaced PR_NUM=<the number gh just printed> with PR_NUM=$(gh pr view --repo LeanerCloud/CUDly --json number --jq '.number') exactly as you suggested. Removes the hand-copy step entirely — the snippet now works without any operator edits after gh pr create (since gh pr view defaults to the current branch).

ISSUE_NUM is intentionally kept as a placeholder — there's no reliable way to auto-derive the closing-issue number from the branch alone, and the PR body's Closes #N line isn't structured enough to parse safely. The operator still has to fill that in once.

CI green on the previous head; watchers armed for 64fc92a. No behavioural changes to the happy path.

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Fetch the CLAUDE.md from the PR branch
git log --oneline -8
echo "---"
cat CLAUDE.md

Length of output: 19004


@cristim: Full review complete on commits 7dbe911 + 1880120 + 64fc92a. Both prior findings are cleanly resolved and the three new CLAUDE.md sections satisfy all acceptance criteria from #237.


Review summary

✅ Empty $LABELS guard (was Actionable/Major)

The if [ -n "$LABELS" ] guard is correct. When the closing issue has no labels in the selected classes, jq's join(",") on an empty array produces "", which fails [ -n "" ], and the WARN path fires with a message that names the issue number and the expected label classes. No silent breakage of the MANDATORY flow.

✅ PR_NUM auto-derivation (was Nitpick)

PR_NUM=$(gh pr view --repo LeanerCloud/CUDly --json number --jq '.number') is correct. gh pr view defaults to the current branch's PR (which exists by the time this runs, since it's post–gh pr create). The hand-copy step is gone.

✅ ISSUE_NUM as intentional placeholder

Keeping ISSUE_NUM=<the issue this PR closes> is the right call. There is no reliable machine-parseable link between a branch name and its closing issue number, and parsing the PR body's Closes #N`` line is fragile at creation time. One manual fill-in is a reasonable trade-off.

✅ jq filter correctness

[.labels[].name | select(test("^(priority|severity|urgency|impact|effort|type)/")) ]
+ (if [.labels[].name] | any(. == "triaged") then ["triaged"] else [] end)
| join(",")
  • any(. == "triaged") desugars to any(.[]; . == "triaged") — valid jq, correctly detects the triaged label.
  • gh issue view --json labels always returns a labels array (never null), so no null-dereference risk.
  • join(",") on the concatenated array produces a gh pr edit --add-label-compatible comma-separated string.

✅ Acceptance criteria from #237

Criterion Status
"PR labeling — mirror closing-issue labels (MANDATORY)" section ✅
Exact gh invocation with jq filter for all label classes ✅
Multi-close handling (highest priority/severity, union rest) ✅
No-triaged-lie rule ✅
"Before declaring done" checkpoint mirrors CI-watcher pattern ✅
Post-push CI watcher section present ✅
CodeRabbit loop section present ✅
Subagent-delegation exit criteria in CR-loop ✅

No actionable items remain. The PR is ready to merge.

[approve]

@cristim

cristim commented May 20, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 20, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Comments resolved. Approval is disabled; enable reviews.request_changes_workflow to allow explicit top-level @coderabbitai resolve or @coderabbitai approve commands.

@cristim

cristim commented May 21, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 21, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 22, 2026

Copy link
Copy Markdown
Member Author

CR finding verification - PR_NUM auto-derivation

Both findings from the CodeRabbit review (2026-05-03) against commit 7dbe911 are already addressed in commit 64fc92a:

Nitpick (lines 150-153): brittle manual PR_NUM
Fixed by replacing PR_NUM=<the number gh just printed> with:

PR_NUM=$(gh pr view --repo LeanerCloud/CUDly --json number --jq '.number')

This derives the PR number automatically from the current branch context.

Major (lines 165-180): unconditional gh pr edit --add-label on empty LABELS
Fixed by guarding with if [ -n "$LABELS" ] and printing a deterministic warning when no matching triage labels exist on the closing issue.

No new commits are needed. Current HEAD is 64fc92a on branch docs/issue-237-codify-pr-labeling.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

@cristim: Confirmed — your verification summary matches the conclusions from the full review pass on 64fc92a:

  • Nitpick (lines 150–153): PR_NUM auto-derivation via gh pr view --repo LeanerCloud/CUDly --json number --jq '.number' correctly resolves the hand-copy fragility. ✅
  • Major (lines 165–180): The if [ -n "$LABELS" ] guard with the informative WARN path (naming the issue number and expected label classes) correctly prevents silent failure on an empty label set. ✅

Both fixes were already validated in the prior review, all acceptance criteria from #237 are satisfied, and no actionable items remain. Triggering a fresh incremental pass to cover the current HEAD.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented May 22, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

@cristim have exceeded the limit for the number of chat messages per hour. Please wait 38 minutes and 37 seconds before sending another message.

@cristim

cristim commented Jun 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 6, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jun 7, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@cristim
cristim changed the base branch from feat/multicloud-web-frontend to main June 9, 2026 15:52
@cristim
cristim force-pushed the docs/issue-237-codify-pr-labeling branch from bbba22b to c3ae487 Compare June 19, 2026 15:43
cristim added a commit that referenced this pull request Jun 19, 2026
…nd manual PR_NUM

Address CodeRabbit review on PR #238:

1. Actionable (Major): `gh pr edit --add-label ""` fails on empty payload,
   silently breaking the MANDATORY label-mirror flow when the closing issue
   has no priority/severity/urgency/impact/effort/type labels. Guard the
   call with `if [ -n "$LABELS" ]` and emit a clear WARN otherwise that
   directs the operator to triage the issue first and surface the gap.

2. Nitpick (Quick win): `PR_NUM=<the number gh just printed>` is brittle
   and easy to misapply to the wrong PR. Derive it from the current branch
   context via `gh pr view --json number --jq '.number'` instead, so the
   snippet works without any hand-editing after `gh pr create`.

Both changes are in the prescriptive CLAUDE.md snippet only. The labels
flow itself is unchanged behaviorally for the happy path (issue has the
expected triage labels); the new branches harden the unhappy paths.

Refs #237.
@cristim

cristim commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Jul 9, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim force-pushed the docs/issue-237-codify-pr-labeling branch from c3ae487 to 29c2c16 Compare July 10, 2026 14:30
cristim added a commit that referenced this pull request Jul 10, 2026
…nd manual PR_NUM

Address CodeRabbit review on PR #238:

1. Actionable (Major): `gh pr edit --add-label ""` fails on empty payload,
   silently breaking the MANDATORY label-mirror flow when the closing issue
   has no priority/severity/urgency/impact/effort/type labels. Guard the
   call with `if [ -n "$LABELS" ]` and emit a clear WARN otherwise that
   directs the operator to triage the issue first and surface the gap.

2. Nitpick (Quick win): `PR_NUM=<the number gh just printed>` is brittle
   and easy to misapply to the wrong PR. Derive it from the current branch
   context via `gh pr view --json number --jq '.number'` instead, so the
   snippet works without any hand-editing after `gh pr create`.

Both changes are in the prescriptive CLAUDE.md snippet only. The labels
flow itself is unchanged behaviorally for the happy path (issue has the
expected triage labels); the new branches harden the unhappy paths.

Refs #237.
cristim added a commit that referenced this pull request Jul 17, 2026
…nd manual PR_NUM

Address CodeRabbit review on PR #238:

1. Actionable (Major): `gh pr edit --add-label ""` fails on empty payload,
   silently breaking the MANDATORY label-mirror flow when the closing issue
   has no priority/severity/urgency/impact/effort/type labels. Guard the
   call with `if [ -n "$LABELS" ]` and emit a clear WARN otherwise that
   directs the operator to triage the issue first and surface the gap.

2. Nitpick (Quick win): `PR_NUM=<the number gh just printed>` is brittle
   and easy to misapply to the wrong PR. Derive it from the current branch
   context via `gh pr view --json number --jq '.number'` instead, so the
   snippet works without any hand-editing after `gh pr create`.

Both changes are in the prescriptive CLAUDE.md snippet only. The labels
flow itself is unchanged behaviorally for the happy path (issue has the
expected triage labels); the new branches harden the unhappy paths.

Refs #237.
@cristim
cristim force-pushed the docs/issue-237-codify-pr-labeling branch from 29c2c16 to 194f63c Compare July 17, 2026 18:32
…oses #237

Add project-specific guidance to CLAUDE.md for the post-push CI watcher
(mandatory for all commits on CUDly PRs due to 9-15 min pre-commit job
runtime) and label-mirroring rule (PRs must carry the same priority/severity/
urgency/impact/effort/type labels as their closing issues).

Resolves conflict by including main's "Known Issues" section alongside
the new sections added by this PR.
@cristim
cristim force-pushed the docs/issue-237-codify-pr-labeling branch from 194f63c to 30a5a6f Compare July 19, 2026 19:00
@cristim
cristim merged commit 95ecd19 into main Jul 19, 2026
19 checks passed
@cristim

cristim commented Jul 19, 2026

Copy link
Copy Markdown
Member Author

Rebased onto origin/main, all CI checks passed, squash-merged.

@cristim
cristim deleted the docs/issue-237-codify-pr-labeling branch July 27, 2026 11:09
cristim added a commit that referenced this pull request Sep 27, 2026
…oses #237 (#238)

Add project-specific guidance to CLAUDE.md for the post-push CI watcher
(mandatory for all commits on CUDly PRs due to 9-15 min pre-commit job
runtime) and label-mirroring rule (PRs must carry the same priority/severity/
urgency/impact/effort/type labels as their closing issues).

Resolves conflict by including main's "Known Issues" section alongside
the new sections added by this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/xs Trivial / one-liner impact/internal Team-internal only priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged type/docs Documentation urgency/eventually No deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(workflow): require PRs to mirror their closing issue's triage labels

1 participant