Skip to content

perf(pr-pipeline): carry pr-merge's lane-dispatch answers between runs - #9453

Merged
kyle-sexton merged 11 commits into
mainfrom
perf/postmerge-carry-dispatch-records
Oct 23, 2026
Merged

kyle-sexton merged 11 commits into
mainfrom
perf/postmerge-carry-dispatch-records

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #9297

Summary

pr-merge's post-merge check re-read every lane-dispatch record on every run: a name-filtered artifact listing plus a run read per full run since the merged-since floor. The answers never change once read. On today's 104-record window that was 217 requests per check, made by three GITHUB_TOKEN checks (post-merge-dispatch, the merge job's "Check earlier lane merges", and the failed-merge record) plus the gate's own check on the lane token. Measured on run 39977943551: 202 workflow calls and 321 gate calls. That's about 2,000 GITHUB_TOKEN requests an hour, growing every day until the floor moves.

Fix

  • lane-records.mjs writes and reads a pr-merge-lane-records artifact. It holds, per dispatched run id, the facts _lane_record derives: only for runs that completed, with an unexpired, listed artifact, created at or after the floor.
  • It is read only from the newest scheduled or hand-started pr-merge.yml run on main whose head commit is on main (newestTrustedRun + onMain, as in perf(source-control): carry untied FAIL head refs between pr-merge runs #9416), never through actions/cache. It is uploaded only when that run's artifact listing could be read, with retention 1 day.
  • babysit_postmerge.py uses a carried answer in place of the two reads; anything not carried is read fresh as today. A malformed file is ignored whole, with a warning.
  • Trust: a carried yes for lane_dispatched or lane_rerun can let a merge verify, so the source binding is the same as perf(source-control): carry untied FAIL head refs between pr-merge runs #9416's head-ref map. A carried record reads present even when today's fresh read would fail on a 5xx or an empty-twice listing: the same exception perf(source-control): carry untied FAIL head refs between pr-merge runs #9416 takes, stated in both changelog fragments.

Verification

  • babysit-prs suite 2611 OK; node --test .github/scripts/pr-merge/*.test.mjs 222/222; pinned ruff check and format exit 0; actionlint and zizmor clean on pr-merge.yml; scripts/check-affected.sh --tests: 13 passed, 1 skipped.
  • Requests per check on 104 records: 217 before, 9 after (babysit-gh-calls counter). The Node read adds about 5 REST requests per job.
  • 12 new Python tests, 7 new node tests. Each of 5 mutants fails at least one test: carry lookup disabled, no completed-sender check, no expiry check, a loosened carried-entry check, no floor pruning.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 7 commits October 23, 2026 11:52
The post-merge check listed every pr-merge-dispatched and pr-merge-rerun
record since the floor and read the run that uploaded it, on every run:
two GITHUB_TOKEN requests per record, 208 for the 104 records of run
39972998315. A record that is present stays present, so each scheduled
or hand-started merge job now uploads the records the checks proved as
the pr-merge-lane-records artifact, read back only from the newest
trusted pr-merge run on main whose head commit is on main (as the
head-ref map is), and the check answers those with no request after
running their sender through its own rule again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Matches the other per-run pr-merge artifacts: only the next run reads it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…isting

As the head-ref map does: a record no longer listed is dropped, and with
no listing nothing is uploaded, so the next run reads an older file. The
fragments also name the one decision that moves: where today's read of a
held record fails, the carried record reads present.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…den the carry

- Each check's save merges with the file as it is now and keeps records at
  or after the lowest floor any check of the run used, so a later check
  under a higher floor (the gate's, from the base's history and the
  pr-merge authority) or a concurrent writer drops nothing still valid.
- Any failure to parse the file, a nesting too deep to read included, is
  no file; warnings print record names escaped.
- lane-records.mjs removes a file left at its path before reading, and
  keeps a record only when the listed artifact's id, name and uploading
  run all match it.
- README: a deleted record artifact stays carried until a later upload's
  listing drops it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kyle-sexton and others added 4 commits October 23, 2026 13:04
A run with no candidates saves no artifact listing, so the write step
threw, warned every scheduled run and uploaded nothing; the carry then
aged out. With no listing, keep records by expiry alone: each was listed
unexpired when the check proved it, so the listing only prunes. An
unreadable listing still writes nothing.

The post-merge check no longer writes back a record it read in but never
asked for once another check of the run has dropped it from the file.

Adds a test that finds a record's artifact by id when the listing holds
its name under another id. The old no-listing case moves to its own
test, since it now uploads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Python check writes the file through save_lane_records, lane-records.mjs
writes it on, and the check loads the result, so a change to the record
name pattern or version on one side fails the test.

The texts now say that with no listing file, whether no candidates or a
listing the run could not read, unexpired records are carried as they are
and pruned on the next run that saves a listing; only a listing file that
cannot be parsed writes nothing. The header also says the sender rule runs
on the stored sender fields, with only head-commit ancestry read live.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-23T17:36:18.145927Z 3845471 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

Copy link
Copy Markdown
Contributor

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

No security issues found in this pull request.

critical-findings: 0

What I reviewed. I read all 9 files of the diff and the PR context. Only the PR description and the diff were available; I did not read the unchanged callees (newestTrustedRun, onMain, _lane_sender, ghDownload) or the docs/conventions/instruction-exception-register file. My conclusions about them rest on how the diff and the PR text describe them. The change adds a pr-merge-lane-records artifact carry. lane-records.mjs reads and writes the artifact, babysit_postmerge.py answers lane-dispatch and re-run records from it, and pr-merge.yml gets the read, write and upload steps. This is a trust-boundary change: a carried "present" record can let a merge verify.

Trust-boundary analysis.

  • Source binding. The file is read only from the newest scheduled or hand-started pr-merge.yml run on main whose head commit is on main. This is the same pattern as the head-ref map. It goes through actions/upload-artifact and gh run download, never actions/cache.
    • Only a run's own steps can upload its artifacts, and the upload step is gated to the schedule and workflow_dispatch events.
    • A hand-started run on a non-main branch cannot feed the read, because the read filters on branch=main.
  • Validation of the file. Both the JS parser (parseRecords) and the Python loader (load_lane_records) reject any other shape.
    • They check version and repo, an exact lane-record name regex, zoned dates, a positive integer artifact id, a completed sender with an integer id, and an exact sender field set.
    • A malformed file is dropped whole and the check reads each record as before.
    • The JS $ and Python fullmatch name anchors are equivalent, so a trailing-newline name cannot slip through.
  • Carried records are re-checked. _carried_record re-applies expiry and _lane_sender to the stored sender fields on every use. A failing entry is deleted and added to lane_rejected, so it is never written back. Records are proved only through _prove, which needs a completed sender, an unexpired listed artifact and a passing _lane_sender.
  • Revocation gap. A deleted artifact stays carried until a later upload's listing prunes it. The PR description and the pr-pipeline docs state this and accept it, matching perf(source-control): carry untied FAIL head refs between pr-merge runs #9416. Retention is 1 day, so the gap is bounded. I treat it as a documented design choice, not a finding.
  • Output injection. Error text reaches ::warning through escapeCommand in JS, which strips CR, LF and %. In Python the stderr message is stripped and truncated. Neither places file-controlled text at the start of a line. A test covers a record name carrying \n::error::.
  • Write path. Writes go through a temp file and rename. The Python temp name includes the pid, so concurrent gate processes cannot corrupt the file, and a lost update only costs extra reads. The read step first removes any file already at the path, so a planted file is never used.
  • Workflow. Permissions are unchanged. The new steps use continue-on-error, a pinned actions/upload-artifact SHA, and no github context expressions inside run: blocks. The write step runs only for schedule and workflow_dispatch. It runs from the .base main checkout, which the PR description says runs no pull request code.

Manifest fields. No plugin.json or marketplace.json is touched, so there are no manifest <field> lines.

Instruction-surface deletions. None. The diff adds text and removes no standing instruction.

Hold. None. No trust-gate path is touched and there are no CRITICAL findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 3845471bbfad7355658925af982f44a6ed3bd55d: 0 finding(s), 0 as inline comments.

Code review: #9453 (carry pr-merge lane-dispatch records between runs)

Result: no findings. I read the whole diff (.claude-lane/pr.diff, 9 files) and the PR context. I also read the surrounding check() and _Context code in babysit_postmerge.py and the post-merge-dispatch and merge job setup in pr-merge.yml. I ran no tests, so the PR body's test and request-count numbers are author-claimed and unverified by me.

What I checked

  • Node and Python agree on the file shape. parseRecords in lane-records.mjs and load_lane_records in babysit_postmerge.py apply the same name pattern, zoned dates, positive integer artifact id and completed sender. Python is stricter and re-validates on read, and an invalid file is treated as no file. The test that passes a file between both languages covers this.
  • Failures fall back to today's reads.
    • The read step removes any file already at its path before it does anything else.
    • main catches every error and warns.
    • The Python side wraps its file read in _read_lane_file, which catches any exception, so a bad file cannot raise past the finally in check().
    • save_lane_records only touches the file on the read-and-write path.
  • Trust binding.
    • A carried record is used only while unexpired, and only when its stored sender passes _lane_sender again. That includes the event set, so a push-run sender cannot answer a re-run record.
    • The file is read only from the newest scheduled or hand-started pr-merge.yml run on main whose head commit is on main. It never goes through actions/cache.
    • The upload step runs only on scheduled or hand-started runs of the merge job.
    • Carrying a record past the deletion of its artifact until the next listing prunes it is stated in the changelog and in the docs. The PR names this as the same gap the head-ref map accepts.
  • Floor and merge logic.
    • save_lane_records is called with merged_since, which is at or below the per-check floor. That only keeps more records.
    • The merge of the on-disk file with the carried and proved records preserves what another check in the same run added or dropped. Tests cover both directions.
    • The earlier any(...) over senders became a loop that breaks at the first accepted sender. The verdict is unchanged.
  • Workflow wiring. Both read steps sit before the first check in their job, and each job names the file in BABYSIT_POSTMERGE_LANE_RECORDS for every check, the gate included. post-merge-dispatch already holds actions: write, which covers the artifact read. The upload step is gated on the write step succeeding. merge-job.test.mjs pins the step order, the environment and the if: conditions.
  • Changelog fragments. Both fragments are bump: patch. That fits a performance-only change with an opt-in environment variable and no behaviour change without it.

Closing issue: the PR says Refs: #9297, which is not a closing issue. There was no closing-issue section in the PR context, so no acceptance criteria were checked.

Manifests: the diff changes no plugin.json or marketplace.json, so no manifest lines apply.

Hold: none. The PR adds no model or API spend, touches no trusted-actors, CODEOWNERS or .gitmodules files, and has no critical security finding.

Not reviewed: security-lane concerns, since a separate security lane exists. Paved-path rows and path-scoped rules were not resolved. I limited the work to the diff and the files it touches.

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