Skip to content

pstack watch-pr: failures from draft-time runs mark a PR ci-failing (exit 4) while their re-runs are still pending #1240

Open

Description

@jordan-droverinsights

What happens

watch-pr stops with kind: "ci-failing" and exit code 4 on its first poll after a PR leaves draft. It does this even while the runs that will replace the failures are still in progress. Those runs later passed. Every required check passed, and GitHub reported the PR MERGEABLE CLEAN.

How to reproduce

  1. Use a repo whose required checks are thin gate jobs that fail on drafts. For example, Jest runs a step named Require a successful "Run: Jest" (fails on drafts). The real work runs in a separate Run: Jest job, which is skipped while the PR is a draft.
  2. Open a PR as a draft. The gate jobs (Jest, tsc --noEmit, Jest (postgres), Database-backed suites) finish as FAILURE on purpose.
  3. Run gh pr ready <n>. New Run: * jobs start. Each gate job reruns only after its Run: * job finishes.
  4. Run watch-pr --owner <o> --repo <r> --pr <n> while those runs are in progress.

The watcher's first event has kind: "ci-failing". failed lists the four FAILURE contexts from the draft-time runs. pending lists Run: Jest, Run: tsc --noEmit, Run: Jest (postgres) and Run: Database-backed suites as IN_PROGRESS. The same event includes "github": {"kind": "allowed", "mergeStateStatus": "BLOCKED", "headRollupState": "PENDING"}. The process exits with code 4.

Why

In skills/poteto-mode/scripts/watch-pr/policy.ts (0.15.36), any context with kind === "failed" sets ci-failing. That branch is checked before both pending and GitHub's own rollup state. The rollup query reads the latest status of each context, but a gate job's draft-time FAILURE stays the latest result for its name until the rerun starts. That rerun waits on its Run: * job, so for the whole run the old failure is the newest thing the watcher can see.

GitHub did not agree with the watcher. headRollupState was PENDING, not FAILURE. The Babysit playbook says to trust the forge's verdict, not a list of green checks. Here the watcher overrode the forge's verdict and turned it into a terminal failure.

What a fix might look like

These are suggestions, not tested.

  • Treat headRollupState: "PENDING" as non-terminal even when some contexts have failed, and keep polling.
  • Or, when a failed context and pending contexts from the same workflow exist together, report ci-pending and re-check after the pending ones settle.

Either way, a test case where the rollup has a draft-time FAILURE and a newer IN_PROGRESS job from the same workflow would cover it.

Environment

  • pstack 0.15.36, installed through the cursor-plugins marketplace in Claude Code.
  • Run in drive mode with --interval 90 --timeout 3600.

Workaround

Wait on the run ids directly with gh run watch <id> --exit-status.

Related

#731 and #1053 cover the opposite case, where the watcher reports ready too early.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions