Skip to content

fix(pr-status): make --watch usable on a draft PR - #238

Merged
CybotTM merged 1 commit into
mainfrom
fix/pr-status-draft-watch
Aug 26, 2026
Merged

fix(pr-status): make --watch usable on a draft PR#238
CybotTM merged 1 commit into
mainfrom
fix/pr-status-draft-watch

Conversation

@CybotTM

@CybotTM CybotTM commented Aug 26, 2026

Copy link
Copy Markdown
Member

Closes #228.

The issue's proposed fix was not enough, so this goes one step further. Adding ready to the --ignore-action allowlist (the issue's ask) would have made the flag accepted but the watch still useless: draft sat near the top of the NEXT ladder, so on a parked PR every poll answered ready and a red check, an open thread, or a conflict could never surface — with or without the flag. The ladder placement is the actual defect.

Change. draft now ranks below the real-work branches (conflicts, stale base, red checks, open threads) and above the review/merge advice, mirroring the queue-entry placement and its rationale. Checks actually running report wait — the watch holds and returns on the first real event. Everything else answers ready, now in ACTIONABLE: the watch returns handing over gh pr ready, and --ignore-action ready takes the name (on a settled draft that return is labelled SETTLED per the #165 semantics). This makes the back-to-draft-on-resume convention (#227) and --watch compatible; the reference now says so.

Review round caught a regression in the first cut, verified by the reviewer with a stubbed probe: gating ready on checks_settled left it unreachable for a draft with zero registered check contexts or a never-dispatched required context (workflows that skip drafts or trigger on ready_for_review, fork runs awaiting approval) — an endless wait of the very shape this PR removes. ready is now gated only on nothing actually running, and the why names undispatched required contexts when present.

investigate joins ACTIONABLE too — same family: it is the terminal check-branch-protection-manually verdict on settled checks, so a watch heartbeating on it idles into the timeout on a state that waiting cannot change. Observed on #226, where classic-protection CodeQL contexts kept mergeState=BLOCKED through an hour of waiting: lines. rules-unavailable stays a heartbeat on purpose: an API blip can heal on the next poll, and --max-wait bounds the true-failure case. Known trade-off (reviewer-flagged, accepted): right after the last check greens, one poll can catch mergeStateStatus still at BLOCKED and return investigate where the next poll would say merge — a cheap exit-and-re-arm, preferred over the unbounded heartbeat.

Tests. tests/test_pr_status_draft_watch.sh (stubbed gh, no network) pins the ladder — hold on running checks; return on a thread, a red check, on ready; ready reachable with zero registered checks and with a ghost required context; plain status names a red check instead of ready — and pins the action vocabulary: every action:"…" literal must be ACTIONABLE or a declared waiting heartbeat, and every ACTIONABLE entry must actually be emitted. Watched failing against the respective pre-fix states: 9 assertions red on the original script, 5 more on the version before the checks_settled correction. Full tests/*.sh suite green, shellcheck clean.

Assisted by claude-code:claude-fable-5 — Session

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions github-actions Bot added the skill label Aug 26, 2026
@CybotTM
CybotTM force-pushed the fix/pr-status-draft-watch branch 2 times, most recently from ce91209 to 17c348e Compare August 26, 2026 09:40
@CybotTM
CybotTM marked this pull request as ready for review August 26, 2026 09:40
Copilot AI lite review requested due to automatic review settings August 26, 2026 09:40

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Draft sat near the top of the NEXT ladder and always answered ready,
masking conflicts, red checks and open threads on a deliberately parked
PR; ready itself was missing from ACTIONABLE, so the watch could
neither return on it nor hold through it — --ignore-action refused the
name and the loop heartbeated waiting: draft into the timeout. The
back-to-draft-on-resume convention (#227) and the watcher were mutually
exclusive.

Draft now ranks below the real-work branches and above the review and
merge advice, mirroring the queue-entry placement: a red check or an
open thread surfaces normally, checks actually running report wait (the
watch holds), and everything else answers ready — which is ACTIONABLE
now, so the watch returns on it and --ignore-action can hold through
it. checks_settled is deliberately not the gate for ready: it demands
at least one registered context and zero undispatched required ones,
which a draft often cannot satisfy (workflows that skip drafts or
trigger on ready_for_review, fork runs awaiting approval) — the review
round caught that gating on it left ready unreachable there, an endless
wait of the very shape this commit removes.

investigate joins ACTIONABLE too: it is the terminal
check-branch-protection-manually verdict on settled checks, and a watch
that heartbeats on it idles into the timeout on a state waiting cannot
change (observed 2026-08-26 on #226, where classic-protection CodeQL
contexts kept mergeState BLOCKED for over an hour of waiting lines).

tests/test_pr_status_draft_watch.sh pins the ladder against a stubbed
gh (hold on running checks; return on a thread, a red check, ready;
ready reachable with zero registered checks and with a never-dispatched
required context; plain status names a red check instead of ready) and
pins the action vocabulary against every action literal the script
emits. Watched failing against the respective pre-fix states: 9
assertions on the original script, 5 more on the version before the
checks_settled correction.

Closes #228.

Assisted-by: claude-code:claude-fable-5
Agent-Session: https://claude.ai/code/session_01C7S9rbgu5giqCwnzwafrHA
Agent-Host: 0493f0
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@CybotTM
CybotTM force-pushed the fix/pr-status-draft-watch branch from 17c348e to 3320d13 Compare August 26, 2026 09:42
@sonarqubecloud

Copy link
Copy Markdown

@CybotTM

CybotTM commented Aug 26, 2026

Copy link
Copy Markdown
Member Author

Self-review: 3320d13

The review this pull request demands is unsatisfiable (Copilot quota wall or repeated bot failures on this head). Per the documented fallback, the diff on this head was reviewed by the PR author; this comment is the on-the-record attestation the merge gate reads back. It stops matching on the next push.

@CybotTM
CybotTM merged commit 05c4774 into main Aug 26, 2026
23 checks passed
@CybotTM
CybotTM deleted the fix/pr-status-draft-watch branch August 26, 2026 09:44
@CybotTM CybotTM mentioned this pull request Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pr-status.sh --watch unusable on a draft PR: NEXT emits "ready", --ignore-action rejects it

2 participants