Skip to content

ci: confirm spends a candidate run when the newest contract run was cancelled pending #3573

Closed

Description

@schlessera

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:

  1. Before requesting confirmation, confirm checks that the newest contract run for the exact head completed with success. If it did not, it refuses with the remedy and requests no CI.
  2. confirm requests a fresh contract run itself (for example through an edited event) and waits for it as part of the candidate proof.
  3. 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 gh fixture (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

  1. added this to the 0.45.0 milestone on Nov 4, 2026
  2. added
    type: fixSomething is broken and must behave the way it is documented.
    area: ciCI workflows, the gates they run, release scripts, packaging.
    priority: p1Scheduled into the current or next milestone.
    on Nov 4, 2026
  3. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    Choice of fix, 2026-11-04: take the smallest option. Before confirm requests 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.

  4. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    on Nov 4, 2026
  5. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    Second instance, 2026-11-04 18:00 UTC, on #3578. A force-push (synchronize) followed immediately by gh pr edit --body-file (edited) started two contract runs in the same second for head 50a62d37. 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 before confirm this time, by reading the newest contract run first. That is option 1 from the issue done by hand.

  6. self-assigned this
    on Nov 4, 2026
  7. schlessera commented on Nov 4, 2026

    @schlessera
    OwnerAuthor

    Claimed (claim token c3573-f2b7). Branch fix/3573-contract-run-gate. Taking option 1 from the ruling: confirm checks 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: latestIntegrationRun is now scripts/integration-proof.ts:17-24, and the contract check is scripts/integration-proof.ts:73. .github/workflows/contract.yml:21-30 is unchanged.

  8. added a commit that references this issue on Nov 6, 2026
    8ab96fe
  9. schlessera commented on Nov 6, 2026

    @schlessera
    OwnerAuthor

    Delivered by #3587, squash 69f9cb7b9a951a0d6a7eb8f89f8c6114c5dd29f6 (parent 223ca157a, tree c02f52382). The tree is identical to candidate run 42181632676's checkout 17a94b481, which passed every selected job. It merged through integrate.ts confirm, and the new contract check passed before the lease was taken. Main push run 42183799885 on the squash passed.

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

Metadata

Metadata

Assignees

Labels

agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ciCI workflows, the gates they run, release scripts, packaging.priority: p1Scheduled into the current or next milestone.type: fixSomething is broken and must behave the way it is documented.

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions