✨ feat(pr-signals): --wait polls until CI settles on two agreeing polls, and keep-going names it

Merged
AT
2d ago
+398-29

Slice: #695

niyam pr-signals <pr> --wait [--timeout <minutes>] polls until CI settles, prints the JSON once, and exits with the verdict. keep-going now names it. This is slice 2 of #693's spec v1, on top of #707 (#694). Alok approved it with a šŸ‘ on its Proposal: comment.

Change:

  • src/pr-signals.ts
    • signalArgs takes --wait and --timeout <minutes>: whole minutes from 1, 60 by default, and only with --wait.
    • Each poll is a light read: the pull request, the head's check runs and statuses, and the base's rules, judged as #694 does. It reads no logs, threads or findings.
    • Polls run every 30 s. A green wait ends at two polls in a row that agree (agreed). Each must be settled (pollOf): every run completed, no status pending, and a known mergeable_state. They must show the same head, the same check-run ids and the same verdict. failed, conflicted and unjudged end early, at two polls with the same head and verdict, whatever still runs. short never ends it.
    • A moved head is said on standard error, and the count starts again.
    • Then one full read, as today, and the exit for the full read's verdict: 0 green, 5 failed, 6 conflicted, 7 unjudged or short, 8 pending. A merge or close during the wait exits 3 or 4, with phase: "wait".
    • At the timeout it exits 7 if the last poll was short, else 8. It prints the last poll's ci under { "ok": false, "reason": "ci-not-settled" }.
    • The plain read still exits 0.
  • src/run.ts: pr-signals takes up to five arguments; the usage names --wait and its exits.
  • src/keep-going.ts: the open pull request line names niyam pr-signals <n> --wait as a background task. In print mode it names the foreground with --timeout 9, run again until it ends.
  • README.md: the wait and its exit table, and the keep-going line.

Choices the slice left open:

  • "Ends early" does not wait for other runs. Point 3 ends the wait early on conflicted, failed and unjudged, because waiting cannot change a conflicted head and the agent can start fixing a failure. If those also had to settle, a required check failing at minute 2 under a 34-minute Lane (src) would report at minute 34. In print mode, --timeout 9 would return 8 again and again with verdict: failed. So those three end at two polls with the same head and verdict. Only green waits for every run, as the slice's "Why" asks, so that a late failure is not missed.
  • Five arguments, beyond the slice's four. The slice says run.ts takes up to four. That covers 7 --ci-only --wait and 7 --wait --timeout 9, but not all three flags at once: 7 --ci-only --wait --timeout 9 is five. Five lets that through and nothing else, since signalArgs refuses any flag given twice. I asked the session that started this one and had no answer before pushing.
  • The exit comes from the full read's verdict, not the last poll's, so the exit and the printed JSON always agree. A run that starts between the last poll and the full read exits 8, with that run in ci.
  • At the timeout, only short exits 7. Every other verdict exits 8, as not settled, including a lone green poll that no second poll confirmed.

Evidence:

  • Mutation, pnpm exec agnipariksha --lane src --files src/pr-signals.ts,src/run.ts,src/keep-going.ts --no-reuse:
    • Before the early end, the run killed 2675 of 2677. run.ts and keep-going.ts had no survivors.
    • The two survivors in pr-signals.ts sat on the timeout's unjudged branch, which the early end made dead. It is gone now.
    • The last run, on src/pr-signals.ts, killed 1187 of 1187.
    • The test fakes throw past 200 check-run reads, so a mutant that never ends the loop dies at once. One timeout was left.
  • Real waits, run from a veda worktree with this branch's build on 2026-11-27, against pull requests whose mutation lanes were still running:
    • pr-signals 654 --ci-only --wait --timeout 5 (https://github.com/veda-hq/veda/pull/654) polled for 5 minutes and exited 8. It printed ⚠ CI on #654 did not settle within 5 minute(s); the last poll read it as pending and "Lane (dvara)" still running.
    • pr-signals 646 --ci-only --wait --timeout 3 (https://github.com/veda-hq/veda/pull/646) exited 8 on "Lane (pariksha)". Its 10 required checks were read, Mutation missing while its lanes ran.
    • pr-signals 707 --wait here exited 3 at once: merged.
  • pnpm check exits 0, with 3255 of 3255 and 207 of 207 tests passing.
  • Cubic's monthly allowance ran out (its check on #707: "AI review line limit reached", 80,073 of 80,000 lines; reviews resume 9 December 2026). So this pull request, like #707, gets a neutral Cubic check and no review.

Guards: none. No guard file changes.

šŸ¤– Generated with Claude Code


Summary by cubic

Adds --wait to niyam pr-signals, which polls CI until it settles, prints the JSON once, and exits with the verdict. keep-going now names the wait as a background task and, in print mode, as a foreground --timeout 9 run.

New Features

  • --wait [--timeout <minutes>] polls every 30 seconds until two consecutive polls agree; green requires two settled polls on the same head, check-run ids, and verdict, while failed, conflicted, and unjudged end early after two polls with the same head and verdict.
  • Exits 0 green, 5 failed, 6 conflicted, 7 unjudged or still short, 3 merged, 4 closed, and 8 when the timeout (default 60 minutes) passes while still pending.
  • A moved head restarts the count with a message; a short head is polled until the timeout, since a late required check can look missing at first.
  • After the wait, one full read runs as before; the exit comes from that full read's verdict, so the exit and the printed JSON always agree.