✨ feat(pr-signals): say whether CI is green, by the required checks' newest runs

Merged
AT
2d ago
+728-72

Slice: #694

niyam pr-signals <pr> now says whether CI is green, and never says so below the minimum. This is slice 1 of #693's spec v1. Alok approved it with a šŸ‘ on its Proposal: comment.

Change, all in src/pr-signals.ts, its test and README.md:

  • ci gains verdict, required and minimum. verdict is one of green, pending, failed, conflicted, short and unjudged, judged in that slice's order. When the rules cannot be read, it is unjudged with reason.
  • The required checks come from GET /repos/{o}/{r}/rules/branches/{base} on the pull request's own base.ref, every page, each part of the branch encoded, as scripts/guard.mjs reads them. A refusal or an answer it cannot read is unjudged, never "no required checks". Guard's own SHARED_CHECK is not added: only the rulesets decide.
  • The newest run of each name and app decides. "Newest" is the highest check-run id. A rule's integration_id is matched against the run's app.id. A commit status counts by its context. success, neutral and skipped pass.
  • Without a ruleset, every name and status on the head decides. "signals": { "minCheckRuns": N } sets the floor: runs that finished and were not skipped. Without it, the floor is one GitHub Actions run that was not skipped. signalSettings accepts the key as a whole number from 1.
  • A failing signal whose newest run of the same name and app passed carries superseded: true. When dedupe folds copies, the signal stays superseded only if every copy was.
  • One line on standard error for any verdict but green. It replaces ciWarning's two warnings and names what failed, is missing or still runs. The exit code stays 0.

Choices the slice left open:

  • A mergeable_state GitHub gives no value for (null) is read like unknown, so it is pending.
  • A run counts as finished only when its status is completed. A run with no status is still going.
  • When the verdict is unjudged, required is [] and minimum is settings or default, since no ruleset was read.

Evidence:

  • The fixtures follow real answers read on 2026-11-27. niyam main's rules name 7 checks, each with an integration_id (15368 for Actions, 1082092 for Cubic). #692's head has 48 runs, two of them niyam-guard / judge: 140086611192 from the first push's suite, and 140086934755 from a later one. GitHub hands out run ids as runs are created, so the highest id of a name is the newest run.
  • A real read, run from a veda worktree with this branch's build (pnpm exec node .tmp/niyam/dist/cli.js pr-signals 654 --ci-only) against https://github.com/veda-hq/veda/pull/654 while its CI ran. It read veda main's 10 required checks from the ruleset. Typecheck, test, build was pending, Mutation missing (it waits on its lanes), and the rest passed (cubic as neutral). The verdict was pending, and standard error got ⚠ CI on #654 is pending: "Lane (dvara)", "Typecheck, test, build" still running on 67dfda4…. It exited 0.
  • Mutation: pnpm exec agnipariksha --lane src --files src/pr-signals.ts --no-reuse killed 1041 of 1041 mutants. The first run left 12 alive and the second 2. Each one was a literal or test that nothing read, and both are fixed in the code.
  • pnpm check exits 0, with 3227 of 3227 and 207 of 207 tests passing.

Guards: none. No guard file changes. .github/niyam.json and onboard are untouched.

šŸ¤– Generated with Claude Code


Summary by cubic

niyam pr-signals <pr> now says whether CI is green, judging the base branch's rulesets' required checks by each one's newest run.

  • ci gains verdict (green, pending, failed, conflicted, short, unjudged), required and minimum, plus reason when unread.
  • Required checks come from GET /repos/{owner}/{repo}/rules/branches/{base}; a refusal is unjudged, never "no required checks".
  • The newest run of each name and app decides; success, neutral and skipped pass, and a run counts as finished only when its status is completed.
  • Without a ruleset, every run and status on the head decides, with "signals": { "minCheckRuns": N } as the floor, else one GitHub Actions run that was not skipped.
  • A failing signal whose newer run of the same name and app passed carries superseded: true, and dedupe keeps it only when every copy is superseded.
  • Standard error gets one line for any verdict but green; the exit code stays 0.