Skip to content

fix(pr-triage): count only the newest run of each check in the readiness step - #246

Merged
bketelsen merged 3 commits into
mainfrom
lucilla/readiness-newest-check-run
Nov 14, 2026
Merged

bketelsen merged 3 commits into
mainfrom
lucilla/readiness-newest-check-run

Conversation

@frostyard-machines

@frostyard-machines frostyard-machines commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The readiness step of pr-triage.yml removed ready-for-human from pull requests whose checks were all green.

Cause: the step reads check-runs?filter=latest. That filter gives the latest run of each check name per check suite, and each workflow run is a check suite of its own. When a newer workflow run of a check cancels an older one (a concurrency group with cancel-in-progress, for example a PR-title check that re-runs on edited), the cancelled run stays in the list. The step counted it as not green.

Evidence: frostyard/updex#515 at bb9c272. All 19 checks pass, but filter=latest lists 3 Conventional PR title runs (ids 132236621585 success, 132237066225 cancelled, 132237129379 success). Run 43530255879 logged readiness: not green {"kind":"check run","name":"Conventional PR title","state":"cancelled"} and removed the label at 23:52Z; the same happened at 23:32Z.

Fix:

  • scripts/lib/pr-triage.mjs: new export newestCheckRuns. Per check name and app (app.id, else app.slug), it keeps only the run with the highest id (GitHub gives check run ids in creation order). evaluateChecks uses it after it leaves out the pr-triage runs. A cancelled, failed or unfinished newest run still counts as not green. When a run of a group has no integer id, the group keeps every run (the old behaviour).
  • docs/specs/pr-triage.md rule D: replaces the false statement that filter=latest gives 1 run per check name, and states the new rule.
  • scripts/lib/risk-paths.mjs: comment only, on listCheckRuns (same false statement). No code or export change.
  • .github/workflows/pr-triage.yml: the embedded copies, rewritten by npm run sync:risk-paths-workflow.
  • test/pr-triage.test.mjs: 5 tests. The updex#515 test (the 3 real runs) fails without the fix; others pin a cancelled newest run, an in-progress newest run, the same name from 2 apps, and newestCheckRuns itself.
  • Correction record in .memory/corrections/ (ADR-0081).

Rollout: each caller pins pr-triage.yml to a core SHA (ADR-0021), so the fix reaches a repository only when its caller's pin moves to the merge commit of this PR. 35 callers today: 32 pin c996ea3, 3 pin 267421d (apt-publisher, pocket, bketelsen/fleet). The pin bumps follow in 1 PR per repository after this merges.

Risk tier

Risk tier: 3 — risk:high. Paths that match .github/risk-paths.json, and why the change is safe:

  • .github/workflows/pr-triage.yml (L2, .github/workflows/**): only the 2 embedded library blocks change, byte-for-byte equal to the libraries (npm run check:risk-paths passes). No trigger, permission, action or step change.
  • scripts/lib/pr-triage.mjs (L2): the readiness step can now only keep a label it removed before when the not-green run has a newer run of the same name and app at the same head. It removes no new label and changes no other step (levels, shadow).
  • scripts/lib/risk-paths.mjs (L2): a comment only. Exports and their results do not change; vendored copies with a sha256 pin keep working at their pinned bytes.

Verification

  • make verify green locally (851 tests, 0 fail; check:docs, check:corrections, check:risk-paths ok)
  • Without the library change, the updex#515 test and the newestCheckRuns test fail
  • Workflows changed? No action or permission change; embedded copies synced

Cross-review

  • Coder: anthropic/claude-opus-5-5. Reviewer: openai/gpt-6.1-sol (read only).
  • Initial review at bee643e3d634168802713a38387ca8ddaac050a0 (base a9694f7ec745b0bcb1012cf98fdc2cfeb23c64d3): Ready, Blocking: none. 1 low finding: rule D did not name the app.slug fallback and the safe-integer id. Fixed in cdf1a5c.
  • Re-review 1 of the bee643e..cdf1a5c delta: no findings. Ready, Blocking: none.
  • Revert test: scratch worktree at bee643e, scripts/lib/pr-triage.mjs and the workflow restored from a9694f7 (with newestCheckRuns as the identity function), node --test test/pr-triage.test.mjs: fails a cancelled run that a newer run of the same check replaced does not count (updex#515) and newestCheckRuns keeps the highest id per name and app, ... on assertions. At the head: 128 pass, 0 fail.

…ess step

filter=latest gives the latest check run per check suite, and each
workflow run is its own check suite. A run that a newer workflow run of
the same check cancelled stayed in the list, so the readiness step saw
a cancelled check and removed ready-for-human although every check was
green (frostyard/updex#515 at bb9c272).

The step now keeps only the newest run (highest id) of each check name
and app. A cancelled, failed or unfinished newest run still counts as
not green.
@github-actions github-actions Bot added level:L2 Read the diff risk:high Touches a path in .github/risk-paths.json labels Nov 14, 2026
@frostyard-machines frostyard-machines added the ready-for-human Reviewed, CI green: ready for Brian to review and merge label Nov 14, 2026
@bketelsen
bketelsen merged commit 981e7ae into main Nov 14, 2026
6 checks passed
@bketelsen
bketelsen deleted the lucilla/readiness-newest-check-run branch November 14, 2026 00:06
This was referenced Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:L2 Read the diff ready-for-human Reviewed, CI green: ready for Brian to review and merge risk:high Touches a path in .github/risk-paths.json

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants