Skip to content

fix(ci): read draft state when the Check run starts - #45

Merged
kixelated merged 2 commits into
mainfrom
quest/m0/ci-ready-race
Nov 10, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest/m0/ci-ready-race

Conversation

@kixelated

@kixelated kixelated commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Completes quest/m0/ci-ready-race.md: after quest ready flips a PR, the required Check on its head reports the real source and platform results, so auto-merge can land it without a draft round-trip.

Summary

Source and Tests (*) now skip based on the PR's draft state when the run starts, read through the API by a new Draft state job, instead of the draft field in the event payload. Everything else stays the same. The edited trigger and the single cancel-in-progress group per ref are unchanged, and a draft run still fails Check, so skipped jobs can never satisfy protection.

Why not the plan's recommended option

The quest recommended keying the concurrency group by draft state. The run data from kixelated/token-max#41 (head b7a890a) rules that out:

  • At 07:14:24 the ready_for_review run (42773891405) and the edited run (42773891510) were created together. The edited run was created second, so it cancelled the ready run, but its payload still said draft: true. It skipped its jobs and failed Check.
  • Re-running the cancelled ready run produced a passing Check at 07:16:56. Auto-merge was armed at 07:22:21 and still did not land. The PR stayed blocked until it was converted to draft and back at 07:23:55.

So GitHub judged the PR by the newer run's failing Check, not by the later passing check run from the older run. With a draft-keyed group, both runs would finish, and the newer draft-payload run would still fail Check, which is the same blocked state as after the re-run. Reading the state at run start fixes the race itself. Each run reads after it is created, so the newest run always sees the state after the last flip and validates a PR that is ready.

Other options considered:

  • Drop edited: it was added in kixelated/token-max#4 so that a retargeted PR is checked against its new base, so it stays.
  • Change quest ready to mark the PR ready before editing the body (moq-dev/quest): this would avoid the race for quest ready only. A human edit made while marking ready would still hit it. I made no change upstream. The suggestion is below.

Cost: one extra small ubuntu job (a single gh api call) on every run. It uses the default token, which can read this public repository's PRs. It requests no pull-requests permission, because release.yml calls this workflow with contents: read only and a nested job cannot ask for more. If the read fails or returns anything other than false, validation is skipped and Check fails (fail closed).

Validation

  • nix shell nixpkgs#actionlint --command actionlint on check.yml and release.yml: clean.
  • nix develop --command quest gate just check: passes.
  • Real-PR verification: this PR's own quest ready flip runs the new workflow, since pull_request runs use the PR's workflow file. The flip edits this body while still a draft, then marks it ready, as quest ready does. The result is recorded in a comment below.

Choices made without asking

  • The quest's priority (m0) and the decision to plan it were made by /quest-complete while the maintainer was away. Neither is confirmed. This PR goes ahead on them.
  • I chose the run-time draft read over the plan's recommended draft-keyed concurrency group, for the evidence above.

Suggested follow-ups

  • moq-dev/quest: have quest ready mark the PR ready before it edits the body, so a ready flip triggers one fewer run. Recommendation: drop it. With this fix it only saves one redundant run, and it would need approval to change outside kixelated.

Public API and wire impact

None. CI only.

Caused by

  • kixelated/token-max#4 - added the edited trigger, which shares the cancel-in-progress group with ready_for_review while the jobs read the draft flag from the payload. The payload check itself dates to the initial scaffold commit.

Models

Size: S
Implementer: Claude Code, claude-opus-5-5, medium effort

(Written by Claude Opus 5.5 with medium)

Review

Rewritten by quest review after each round.

  • Reviewer: Codex, gpt-6.1-sol, medium effort
  • Session: 01a1c68e-871e-7651-988b-0263de48db9c, round 1
  • Head: 2c869ec
  • Base: origin/main at 7001e82
  • Score: 10/10, The change reads current draft state, preserves the required validation gate, and remains compatible with the release workflow; no actionable regressions were found.
  • Findings: none

kixelated and others added 2 commits November 10, 2026 09:40
Quest-Claim: 7ded99f99e912751
A body edit just before marking a PR ready can create its run after the
ready_for_review run, cancel it, and still carry draft: true in its payload,
leaving the newest required Check failed. Gate validation on the PR's current
draft state instead of the event payload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Keep the ready-for-review Check from losing to a draft edit fix(ci): read draft state when the Check run starts Nov 10, 2026
@kixelated
kixelated marked this pull request as ready for review November 10, 2026 17:44
@kixelated

Copy link
Copy Markdown
Collaborator Author

Verification on this PR's head 2c869ec. I edited the body while it was still a draft and marked it ready right after, the same sequence quest ready uses.

  • The edited run 42867957023 was cancelled by the ready_for_review run 42867960931. That run's Draft state read false, so Source, macOS and Windows ran, and the required Check passed.
  • quest status reports merge-state clean. The only failing entry is an optional job in the cancelled run.

Limit: GitHub delivered the events in their usual order this time, so this run did not reproduce the reversed order seen on kixelated/token-max#41 (edited run created after the ready run). In that order, the newer run's Draft state also reads after the flip, so it validates rather than skipping. I did not arm auto-merge; landing is left to /quest-merge.

(Written by Claude Opus 5.5 with medium)

@kixelated
kixelated merged commit 16d78c9 into main Nov 10, 2026
11 of 21 checks passed
@kixelated
kixelated deleted the quest/m0/ci-ready-race branch November 10, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant