Skip to content

feat(ci): reuse proven CI results (receipts, push skip, queue shadow) - #199

Merged
DamianReeves merged 12 commits into
mainfrom
DamianReeves/ci-reuse-proven-results
Oct 21, 2026
Merged

DamianReeves merged 12 commits into
mainfrom
DamianReeves/ci-reuse-proven-results

Conversation

@DamianReeves

Copy link
Copy Markdown
Member

Summary

CI no longer runs checks again when it has already proven them on the same code (beads morphir-ukvn.5.90.1, plan morphir-ukvn.5.90.1.1, Tasks 1-6).

  • Receipts. When ci-ok passes, it writes a JSON receipt (scripts/ci-gate.mbtx --receipt, mise task ci:gate:receipt). The receipt records the run, the tested commit and tree, the selection and the job results. For a pull request, it also records the head and the base that the run tested, which is the first parent of the merge commit. The workflow uploads the receipt as ci-receipt-<sha> (30 days, overwrite: true).
  • Verification. The new scripts/ci-reuse.mbtx finds the receipt that covers a merge-queue run or a push run and checks it through gh api and git. It accepts no fork PRs and no PRs that change CI policy (workflows, actions, scripts/ci-, mise config, toolchain setup). The run must be the newest green ci.yml run for the PR's current head. ci-ok must be green in the receipt's attempt. The receipt base must be an ancestor of the current base. Each gh call times out after 20 s. Any failure gives an untrusted verdict with a reason, and the run then selects as today.
  • Push skip (enforced). A push to main whose commits each have a green merge_group run runs only the always-run jobs (changes, lint, format-check, validate-config). These jobs still save the setup-moonbit tool caches that PR runs read.
  • Queue and bypass reuse (shadow). scripts/ci-changes.mbtx re-runs a check only when both the changes landed since the PR run and the PR's own changes select it. In this PR it only logs the decision on stderr (ci-changes: reuse: ...). Stdout and GITHUB_OUTPUT do not change. Enforcement waits for five queued PRs whose shadow log matches the real result (morphir-ukvn.5.90.1.1.7).
  • Stacked PRs. pull_request now runs for PRs into any base branch, so a stacked child gets CI.
  • ci-gate and ci-changes now parse arguments with moonbitlang/core/argparse. ci-changes --json prints the selection as one JSON object. Existing callers do not change.

Replay (last 25 merged PRs)

Measure Value
PRs that could reuse results (no CI-policy change, nothing significant landed) 18 of 25
Queue runs where a check the rule skips failed 0 of 12
Admin-bypass pushes where a skipped check failed on an unchanged tree 3: #195 Build (js); #167 and #161 Installed signed provider. All flaky, owned by morphir-ukvn.5.90.5. Bypass reuse stays in shadow mode.
Push runs that re-tested a SHA already green in the queue 11, median 29 min, 341 min in total. This PR skips them.

Test plan

scripts/ci-reuse.mbtx prints a verdict for a merge-queue or push run. A
receipt is trusted only when the GitHub API confirms it: the PR head
branch is in this repository, the newest ci.yml pull_request run of the
current PR head succeeded, its one receipt artifact names the run, the
PR head and this repository, and ci-ok succeeded in the latest attempt.
Jobs that passed only in a re-run attempt are listed. A merge group
with more than one commit, or a PR that changes CI policy, is not
trusted. A push of a commit that a merge_group run proved is exact; an
admin-bypass push of one commit from one merged PR uses that PR's
receipt. Every failure is an untrusted verdict with the reason, and the
script exits 0 for every verdict.
The ci-ok job writes the receipt through a mise task, so a PR that
changes mise configuration (.config/mise/, .mise/, mise/, mise.toml and
its variants) is a CI-policy PR and gets no reuse. The receipt's PR base
must be a commit that Git places at or before this run's base, the
receipt must come from the attempt in which ci-ok passed, and the queue
ref must name the merge group's base. gh calls time out after 20 s with
an API-error reason.
A re-run of a green run uploads ci-receipt-<sha> again in the same run.
upload-artifact refuses a duplicate name, so ci-ok, the only required
check, failed. Overwrite replaces the earlier receipt and keeps one per run.
A pull_request run tests a merge commit whose first parent is the base it
tested; the payload base can differ from it. ci-gate reads the parent with
git cat-file, which works in a depth-1 checkout, and records it as pr.base.
The payload base is kept as pr.payloadBase only when it differs.
An exact push now needs a green merge_group run of ci.yml for every commit
of before..sha on the first-parent line, not only for sha; the run of sha
still supplies the receipt. A commit without one makes the verdict
untrusted with the reason.

Changes to .tool-versions, mise-tasks/, .mise-tasks/,
scripts/moonbit-core.mbtx and tests/fixtures/core-pin/ are CI policy too:
ci-ok's setup-moonbit runs the core pin script and its fixtures.
ci-changes now writes the notes of a ci-reuse child that exits 0 to the
reuse log, not only the error of one that fails. The mise impact of the
landed changes logs as "ci-changes: reuse: landed mise: ", so it is not
mistaken for the run's own mise log. stdout and GITHUB_OUTPUT do not change.

New tests pin that an exact verdict in a merge_group run does not skip,
and that a receipt which proved code but not full re-runs full.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T17:13:47.483166Z bbdc7af PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@DamianReeves
DamianReeves added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 21, 2026
@DamianReeves
DamianReeves added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 21, 2026
@DamianReeves
DamianReeves added this pull request to the merge queue Oct 21, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Oct 21, 2026
@DamianReeves
DamianReeves merged commit ad0d5bd into main Oct 21, 2026
63 checks passed
@DamianReeves
DamianReeves deleted the DamianReeves/ci-reuse-proven-results branch October 22, 2026 00:15
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