Repository navigation
Description
Context
integrate.ts confirm refused a candidate whose CI proof passed, because the newest contract run for its head had been cancelled while it was still pending.
The merge path reads contract proof from the newest contract.yml run for the exact head, chosen by highest run id (latestIntegrationRun, scripts/integration-proof.ts:19-26). It refuses unless that run completed with success (scripts/integration-proof.ts:74-75). contract.yml runs on opened, edited, synchronize, reopened, labeled, unlabeled in group contract-<pr> with cancel-in-progress: true (.github/workflows/contract.yml:21-30). It does not run on ready_for_review, so the draft-to-ready transition that confirm performs never produces a contract run.
Observed on 2026-11-04 with #3571, a PR created with gh pr create --draft --label … --label … --milestone …. The creation burst started five contract runs for head 2d239076. The highest id, 41859016578, was cancelled while pending and has no jobs. 41859016504 completed success. No later event started another contract run. Candidate CI run 41859177245 passed every selected job. confirm still exited with Complete current-candidate CI and contract proof required after a full candidate run, and the lease was released. Recovering took a PR edit to start a new contract run, and a second confirmation.
The contract verdict depends on the title and labels, so the newest run must not simply be skipped for an older success: the older run could have checked a title or label set that has since changed.
Scope
Pick one of these and implement it:
- Before requesting confirmation,
confirmchecks that the newest contract run for the exact head completed withsuccess. If it did not, it refuses with the remedy and requests no CI. confirmrequests a fresh contract run itself (for example through aneditedevent) and waits for it as part of the candidate proof.- A cancelled run with no jobs is passed over in favour of the next newer-or-equal run for the same title and labels. This needs those inputs in the run's evidence.
Option 1 is the smallest. It avoids wasting a candidate run without changing what counts as proof.
Out of scope
The contract gate's rules (scripts/check-contract-pr.ts), and CI proof selection.
Acceptance criteria
- A candidate whose newest exact-head contract run is cancelled or missing no longer spends a candidate CI run before being refused. Either it is refused before confirmation is requested, with the remedy named, or a passing contract run is obtained as part of confirmation.
- A test with the existing offline
ghfixture (tests/integration-command.test.ts) covers a newest-run-cancelled inventory. It fails before the change. - No passing older contract run is accepted when a newer run for the same head exists, unless the chosen option proves that both checked the same title and labels.
Verification
bun run test tests/integration-command.test.ts tests/integration-proof.test.ts, plus a mutation receipt.
Contract impact
None. This is repository tooling.
Activity
schlessera commentedon Nov 4, 2026
Choice of fix, 2026-11-04: take the smallest option. Before
confirmrequests candidate CI, check that the newest contract run for the head is current and passed. If it was cancelled or is stale, start a fresh contract run and wait for it, or refuse before using up a CI run. This is a routine implementation choice inside the issue's scope, not a policy ruling, so the issue is now agent-ready. It is a proof-system change, so it lands one at a time after #3303, #3302 and #3270.schlessera commentedon Nov 4, 2026
Second instance, 2026-11-04 18:00 UTC, on #3578. A force-push (
synchronize) followed immediately bygh pr edit --body-file(edited) started two contract runs in the same second for head50a62d37. The higher id, 41882648270, was cancelled; 41882648011 passed. So the creation-time burst is not needed: any push plus body edit, the normal refresh after a rebase, reproduces it. Caught beforeconfirmthis time, by reading the newest contract run first. That is option 1 from the issue done by hand.schlessera commentedon Nov 4, 2026
Claimed (claim token
c3573-f2b7). Branchfix/3573-contract-run-gate. Taking option 1 from the ruling:confirmchecks the newest exact-head contract run before taking a reservation, waits a bounded time if that run is pending, and refuses with the remedy if it is missing, cancelled or failed. This is a proof-system change, so it lands after #3572 (#3270) has merged and main is green.Citations checked against
e08a8a99a. The body's ranges have drifted slightly:latestIntegrationRunis nowscripts/integration-proof.ts:17-24, and the contract check isscripts/integration-proof.ts:73..github/workflows/contract.yml:21-30is unchanged.fix(ci): refuse confirmation before spending candidate CI when the ne…
schlessera commentedon Nov 6, 2026
Delivered by #3587, squash
69f9cb7b9a951a0d6a7eb8f89f8c6114c5dd29f6(parent223ca157a, treec02f52382). The tree is identical to candidate run 42181632676's checkout17a94b481, which passed every selected job. It merged throughintegrate.ts confirm, and the new contract check passed before the lease was taken. Main push run 42183799885 on the squash passed.Merge origin/main into feat/3269-3271-lane-enforcement; rework the wi…