Skip to content

fix(pr-merge): carry the verifier reads' run cache through its own trusted artifact - #10327

Merged
kyle-sexton merged 4 commits into
mainfrom
fix/verify-run-cache-artifact
Oct 26, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
fix/verify-run-cache-artifact

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

No related issue: regression from #10292 (empty run-cache artifact chain), .work/poteto-review/stall-2026-10-26-1740.md

Summary

#10292 moved pr-merge's carried run cache from actions/cache to the pr-merge-run-cache artifact, which carry-run-cache.mjs read takes from the newest trusted pr-merge run on main. Only the merge job uploads that artifact, and its gate never reads lane verdicts (not-read-in-pr-merge-lane), so it adds no run records. The enable-auto-merge job's verifier reads are the only ones that fill run-record, and that job never uploaded them. After #10292 the chain started empty ("no earlier run cache to carry") and stayed empty (carried-run-record=0). Every verifier read started cold (~100-120 calls), hit the 4-minute VERIFY_TIMEOUT_MS (SIGTERM, "its verifier verdict could not be read"), and the PRs after it got "no time left". Lane PRs stopped being armed.

Fix

  • pr-merge.yml enable-auto-merge: after "Arm and disarm auto-merge", a scheduled or hand-started run keeps its run cache through carry-run-cache.mjs (the merge job's keep step and helper) and uploads it as pr-merge-verify-run-cache (retention-days: 1, the same upload-artifact pin). The upload runs only when the keep step reports kept=true, so an empty file never hides an older one.
  • carry-run-cache.mjs main(): adds kept=true beside carried=true when any carried-* entry was kept. carried=true keeps its meaning (the file was written), so the merge job's "Keep the refusals the next run may skip" and its pr-merge-run-cache upload are unchanged.
  • carry-run-cache.mjs read: takes each artifact from the newest trusted run on main holding it, with the same newestTrustedRun, onMain (main-tag check included), sharedReads and ghDownload helpers. It clears CARRY_TO first, as before. It adds only the verify file's carried-* sections to the merge file (withCarried). The merge file's other sections, skip-unchanged included, keep their values. With no verify file, the merge file is written byte for byte. With one, the file is re-serialized by JSON.stringify, so the skip section is value-identical, not byte-identical: spacing changes, 1.0 reads 1, and integer keys sort first. babysit_merge_skip.py compares parsed values only (the key digest string, an integer skips, the reason strings; prior, _row), so it reads the same records. A verify file that does not read is logged as a warning and leaves the merge file as it is. "Start the run cache from them" still filters every entry through carry(), so a carried read still only counts a FAIL.
  • Both jobs keep reading the combined file through their existing read step. The merge job's next keep carries the verify records forward in its own artifact too.
  • Changelog fragments: pr-pipeline, plus source-control for a comment in babysit_verify_evidence.py that now names both artifacts.

Verification

On base bf7fff8d71 with the new tests, 6 fail: 5 new tests (upload, merge, one-artifact, bad verify file, warm tick) and the updated "carries file to file" (kept=true). The untrusted-run test and the kept test pass on base by construction, since base never reads a verify file or writes kept. They are regression guards, not fail-first. All pass on the head:

Criterion Test
enable-auto-merge uploads the verify run cache merge-job.test.mjs "enable-auto-merge uploads its verifier reads for the next run" (order after the arm step, schedule/dispatch only, kept == 'true' gate, name, path, retention)
read merges carried-* from the verify artifact, skip section unchanged carry-run-cache.test.mjs "read adds the verify file's carried sections to the merge file, every other section as it was" (the verify file's own skip-unchanged and run-record are not taken)
a run with only one of the two artifacts still yields its carried sections "read yields the carried sections of a run holding only one of the two files"
nothing from an untrusted or non-main run "read takes no verify file from an untrusted run or one off main" (pull_request_target, push, off-main head, a tag named main)
no empty upload "keep reports kept=true only when it kept a read"
a bad verify file does not drop the merge file "read writes the merge file as it is when the verify file does not read"
a second tick starts warm "a second tick starts its run cache from the first tick's verifier reads". Tick 1's merge keep yields carried=true with no kept. The arm keep yields kept=true. Tick 2's read then starts its run cache at carried-run-record=1 carried-fail-head-ref=0 carried-on-branch=1, where it was 0 0 0 before this change.

Checks on the head:

  • node --test .github/scripts/pr-merge/*.test.mjs: 487 pass. This includes "no token-holding job in pr-merge.yml restores a cache" and "no job holding id-token or a lanes App token restores a cache by a bare prefix".
  • babysit-prs Python suite (pytest, xdist): 3073 pass.
  • actionlint on pr-merge.yml: clean. zizmor --offline: no findings.
  • scripts/check-affected.sh --tests: 13 passed, 1 skipped.

Left out: a live run. The first scheduled run after merge finds no pr-merge-verify-run-cache yet and reads cold, as today. Its enable-auto-merge job uploads the first file, and the next tick should start warm.

Related

  • #10292: the change that introduced the regression. Its security property is kept: only the newest trusted run's own uploads are read, with the main-tag check, and carried entries can only count a FAIL.
  • .work/poteto-review/stall-2026-10-26-1740.md (local diagnosis): section 2 and fix 1.

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 26, 2026 14:00
…usted artifact

Only the merge job uploaded pr-merge-run-cache, and its gate reads no lane
verdict, so after the move from actions/cache the carried chain started
empty and stayed empty: every enable-auto-merge verifier read was cold and
hit the 4-minute read timeout.

enable-auto-merge (scheduled or hand-started runs) now keeps its run cache
through carry() and uploads it as pr-merge-verify-run-cache, only when it
kept a read. carry-run-cache.mjs read takes each artifact from the newest
trusted run on main holding it and adds only the verify file's carried-*
sections to the merge job's file; the skip refusals are unchanged and
carry() still filters every entry. main() adds kept=true beside
carried=true, whose meaning is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A verify artifact that fails to read now warns and leaves the merge job's
file as it is, instead of dropping both. Comments in the tests and in
babysit_verify_evidence.py name both artifacts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 26, 2026 18:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-26T18:26:56.351395Z 90c950b Draft marked ready
ℹ️ 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.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 64c63948d737225019d6a9a8fbde8b6898449bda: 0 finding(s), 0 as inline comments.

No security findings. critical-findings: 0

I read the whole diff, the PR context, and the surrounding carry-run-cache.mjs and pr-merge.yml code. The change touches the pr-merge.yml steps that feed the merge hold, babysit_verify_evidence.py (comment only) and the merge-hold carry path. A trusted-path match is not a finding, so I judged each change on its code.

  • No merge hold is weakened. The only new data path is pr-merge-verify-run-cache.
    • Every entry still goes through carry() on write and again on the "Start the run cache from them" pass. carry() checks the key, the timestamp and the origin of each entry. A run record must be a pr-verify.yml workflow_run on main in this repository with a 40-character head SHA. A head ref must be a plain string. An on-branch entry must be exactly true.
    • Carried entries are used only where a FAIL is counted, per the comments in babysit_verify_evidence.py. A forged or stale carried entry can therefore only block a merge, not allow one.
    • withCarried takes only the three carried-* sections of the verify file. skip-unchanged, run-record and anything else in it are ignored, so the verify artifact cannot add a refusal-skip. The merge file's own entries win on a key collision.
    • The merge { ...extra[section] } spread copies own properties only. A __proto__ key in a downloaded file does not pollute any prototype.
  • Read trust is unchanged. Both artifacts go through the same newestTrustedRun (schedule or dispatch events only), the same onMain check (including the main-tag check), and ghDownload on a run other than the current one. A verify file from a pull_request_target or push run, from an off-main head, or from a run whose head SHA is only reachable through a tag named main is not read. The new tests cover each of these cases. Both downloaded files must parse as JSON objects before they are used.
  • Failure paths fail closed. A verify file that does not read leaves the merge file as it was. CARRY_TO is still cleared first, and write errors only log a warning.
  • The new workflow steps add no authority.
    • The keep step runs only on schedule or workflow_dispatch, from the .base checkout. It receives no token. Its env is two runner-temp paths.
    • The upload step uses the same pinned upload-artifact SHA as the other uploads and a fixed artifact name. It has 1-day retention and uploads only the file carry() wrote.
    • steps.arm.outcome refers to an existing step (id: arm), and the new steps do not touch permissions: or the token request.
    • kept is a step output written by the script from its own computed data, with no untrusted text interpolated.

Spend: the extra artifact upload and the warm read cache change run duration and API calls only, and nothing billed. This is not a hold.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed 64c63948d737225019d6a9a8fbde8b6898449bda: 0 finding(s), 0 as inline comments.

No findings. I read the full diff and the PR context, and checked the workflow wiring in .github/workflows/pr-merge.yml. I did not run the tests or the workflow. The pass counts in the PR description are author-claimed and unverified.

What I checked

  • Step references resolve. The new enable-auto-merge keep step is gated on steps.arm.outcome, and id: arm exists on "Arm and disarm auto-merge" (pr-merge.yml:1715). CARRY_FROM is the same babysit-run-cache.json that the arm step's BABYSIT_RUN_CACHE writes (:1726). The upload step reads steps.carry.outputs.kept, which main() now emits.
  • Merge job unchanged. Its keep, refusals and upload steps still gate on carried == 'true', so kept only adds an output.
  • read order. The "Read the verdict reads the last run kept" and "Start the run cache from them" steps in enable-auto-merge run before the arm step. The combined file therefore seeds the run cache that the new keep step later re-carries.
  • Trust model kept. Both artifacts go through newestTrustedRun, onMain and sharedReads. withCarried takes only the carried-* sections and gives the merge file's entries precedence. carry() still filters every entry on the start-from-carried pass, and carried reads still count only toward a FAIL. The upload action uses the same pinned SHA as the merge job, with 1-day retention.
  • Bad verify file. It is caught and logged, and it leaves the merge file as it was.
  • Manifests, closing issue and rules. No plugin.json or marketplace.json changes, so no manifest lines apply. The PR context states no closing issue, so there are no criteria to check. Both changelog fragments use bump: patch, which fits a fix and a comment-only change.
  • Cost. The change uses no paid resources. One extra 1-day artifact upload per scheduled or dispatched run is within the existing GitHub Actions allowance.

@kyle-sexton
kyle-sexton enabled auto-merge October 26, 2026 18:44
kyle-sexton and others added 2 commits October 26, 2026 15:36
…rd scan passes

The local helper was named fetch, which the rate-guard test reads as an
unguarded network call. It only downloads through ghDownload and the
shared GitHub client.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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