Skip to content

Commit b998e20

Browse files
Fix /find-mergeable-claude-prs check-rollup truncation (#1434)
gh pr list --json statusCheckRollup truncates each PR's rollup, so any filter applied to it can falsely accept PRs whose pending/failing checks were dropped. Use the list call only to enumerate candidate claude/* PR numbers, then re-query each one with gh pr view to get the complete rollup before applying the all-green filter. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 506258a commit b998e20

1 file changed

Lines changed: 24 additions & 14 deletions

File tree

.claude/commands/find-mergeable-claude-prs.md

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,40 @@ description: Find Claude-authored PRs with all-green full-sweep validation and c
44

55
Find open PRs authored by Claude (branches starting with `claude/`) whose full-sweep validation has completed all-green, then prompt the user before merging.
66

7-
## Step 1 — fetch open PR status
7+
## Step 1 — list candidate `claude/*` PRs
8+
9+
`gh pr list --json statusCheckRollup` truncates each PR's rollup, so it can't be trusted for the per-check filter. Use it only to get the candidate numbers, then re-query each PR individually.
810

911
```bash
1012
gh pr list --repo SemiAnalysisAI/InferenceX --state open --limit 200 \
11-
--json number,title,headRefName,statusCheckRollup > /tmp/claude_prs.json
13+
--json number,title,headRefName \
14+
--jq '.[] | select(.headRefName | startswith("claude/")) | .number' \
15+
> /tmp/claude_pr_candidates.txt
1216
```
1317

14-
## Step 2 — filter for fully-validated `claude/*` PRs
18+
## Step 2 — per-PR all-green check
1519

16-
A PR qualifies only if **all** of the following hold:
20+
For each candidate, fetch the full rollup with `gh pr view`. A PR qualifies only if **all** of the following hold:
1721

18-
- `headRefName` starts with `claude/`
1922
- No check has conclusion `FAILURE`, `CANCELLED`, or `TIMED_OUT`
20-
- No check has status `QUEUED`, `IN_PROGRESS`, or `PENDING` (i.e. sweep is finished, not still running)
21-
- At least one `Run Sweep` check has conclusion `SUCCESS` (i.e. the sweep actually ran — not all skipped)
23+
- No check has status `QUEUED`, `IN_PROGRESS`, or `PENDING` (sweep finished, not still running)
24+
- At least one `Run Sweep` check has conclusion `SUCCESS` (sweep actually ran — not all skipped)
2225

2326
```bash
24-
jq -r '.[]
25-
| select(.headRefName | startswith("claude/"))
26-
| . as $p
27-
| ([$p.statusCheckRollup[] | (.conclusion // .status)]) as $s
28-
| select(($s | any(. == "FAILURE" or . == "CANCELLED" or . == "TIMED_OUT" or . == "QUEUED" or . == "IN_PROGRESS" or . == "PENDING")) | not)
29-
| select([$p.statusCheckRollup[] | select(.workflowName == "Run Sweep" and (.conclusion // .status) == "SUCCESS")] | length > 0)
30-
| "\(.number)\thttps://github.com/SemiAnalysisAI/InferenceX/pull/\(.number)\t\(.title)"' /tmp/claude_prs.json
27+
: > /tmp/claude_prs_green.txt
28+
while read -r pr; do
29+
is_green=$(gh pr view "$pr" --repo SemiAnalysisAI/InferenceX --json statusCheckRollup --jq '
30+
. as $p
31+
| ([$p.statusCheckRollup[] | (.conclusion // .status)]) as $s
32+
| ($s | any(. == "FAILURE" or . == "CANCELLED" or . == "TIMED_OUT" or . == "QUEUED" or . == "IN_PROGRESS" or . == "PENDING")) as $bad
33+
| ([$p.statusCheckRollup[] | select(.workflowName == "Run Sweep" and (.conclusion // .status) == "SUCCESS")] | length > 0) as $swept
34+
| (($bad | not) and $swept)')
35+
if [ "$is_green" = "true" ]; then
36+
title=$(gh pr view "$pr" --repo SemiAnalysisAI/InferenceX --json title --jq '.title')
37+
printf '%s\thttps://github.com/SemiAnalysisAI/InferenceX/pull/%s\t%s\n' "$pr" "$pr" "$title" >> /tmp/claude_prs_green.txt
38+
fi
39+
done < /tmp/claude_pr_candidates.txt
40+
cat /tmp/claude_prs_green.txt
3141
```
3242

3343
## Step 3 — present the list and ask for confirmation

0 commit comments

Comments
 (0)