Skip to content

perf(pr-merge): reuse post-merge-dispatch's report by the lane room's rule - #10349

Merged
kyle-sexton merged 9 commits into
mainfrom
perf/postmerge-reuse-report
Oct 26, 2026
Merged

kyle-sexton merged 9 commits into
mainfrom
perf/postmerge-reuse-report

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: pr-merge tick overhead (post-merge check runs 3x per tick)

Summary

The pr-merge merge job never reused post-merge-dispatch's post-merge report. Its shell test needed the report to be under REUSE_MINUTES (6) old, measured from shared.computedAt, but babysit_postmerge.py stamps that time before its 6-8 minute check runs, so every report was already too old when it was uploaded. The test also needed the report's mainSha to equal the merge job's own checkout of main. So every tick ran the ~7 minute, ~225-call check a second time. In run 40382489448 the merge job re-ran for 479 s and produced the same autoMerges for all 130 merges.

The lane room already settles the same report with the gate's Python rule (shared_refusal plus two keeps). This PR moves that decision into one function and has the merge job use it.

Fix

  • babysit_merge_policy.settle_shared holds the reuse decision that was inline in lane_room: shared_refusal at the default branch head, with no self logins, in the lane. It keeps an unverified-stale answer only when _still_current holds, and a demotion-changed one only when read_demotion reads the same demotion. Any other refusal is read again through post_merge, or refused when there is none. lane_room now calls it, and its unreadable messages and its no-keep path without a post_merge are unchanged.
  • babysit_verify_evidence.py settle --repo --postmerge-result --agent-identity applies that rule to the kept report and never reads the report again. It exits 0 when the report stands and 1 when it is refused or a read fails.
  • pr-merge.yml, step "Check earlier lane merges": the report is reused when its code is 0, 1 or 5 and settle exits 0. Otherwise the step runs the check exactly as before, so exit codes (75 included), lane records and needsDispatch are untouched. REUSE_MINUTES is gone.

What changes and what stays. The old exact-head match and 6-minute age test only decided when the merge job could skip re-running the check. Neither was a gate refusal or a hold. The new rule accepts a moved main that has no new countable lane merge (the new-merge:#N walk), up to SHARED_MAX_AGE (30 min), the same as the lane room does today. Every shared_refusal condition still refuses: identity, self logins, lane, floor-differs, config-unreadable, stale, unverified-stale (past 2 minutes, kept only when nothing it was read from moved), new-merge, merged-history-truncated, merged-unreadable and demotion-changed (kept only on an equal demotion read). SHARED_UNVERIFIED_MAX_AGE is not raised. No gate refusal or hold is narrowed, and the gate's per-candidate assess path is unchanged.

Not shipped: skipping already-verified merges on a re-run. _judge does not treat "verified" as final for a merge commit, so this PR does not skip _judge or the pin read for merges an earlier report verified:

  • A red full run excused by an open quarantine counts as passing. Once the quarantine is older than merge.quarantine-days, expired() / demoting() turn the same check into a regression on time alone (babysit_postmerge.py _Context.expired, _Context.demoting).
  • read_pin returns None for an edited pin, which is read-back-unrecorded, or a failure past 6 hours. A newer pin naming another SHA is a failure.

Verification

  • New tests in test_babysit_lane_room.py, written failing first:
    • SettleShared covers a fresh report at an unmoved head (reused), a moved head with no new lane merge (reused), and a moved head with an uncounted lane merge (new-merge:#9, refused).
    • It also covers unverified-stale: refused with no run check, with a run concluded since, and at a moved head; kept when nothing moved.
    • It also covers demotion-changed (refused on a different demotion, kept on an equal one, refused unread without keeps) and stale (refused even when nothing moved).
    • SettleCommand covers the CLI's bindings and its exit codes.
  • merge-job.test.mjs: the shell tests now use a fake settle. A judged report is reused only when settle exits 0. A refusal, a crash, exit 3 or exit 75 runs the check, and a code that could not judge is never offered to settle.
  • The pinning tests named in the review stay green, including test_an_unusable_answer_with_no_fresh_read_is_unreadable, test_a_failed_recompute_leaves_the_room_unreadable and test_it_prints_the_room_from_the_post_merge_report.
  • After merging origin/main (fix(pr-merge): carry the verifier reads' run cache through its own trusted artifact #10327): python3 -m unittest discover over the babysit-prs scripts ran 3086 tests, OK. node --test .github/scripts/pr-merge/*.test.mjs ran 496 tests, all passing. actionlint .github/workflows/pr-merge.yml is clean.
  • Before that merge, the other workflow tests that cover pr-merge.yml passed: 1092 node tests and scripts/ci-hold-human-gated.test.sh, ci-lanes-pr-hold.test.sh and post-merge-demotion-alert.test.sh.

Related

🤖 Generated with Claude Code

kyle-sexton and others added 4 commits October 26, 2026 15:58
… rule

The merge job's shell test reused this run's post-merge report only under
6 minutes old by shared.computedAt, which is stamped before the 6-8 minute
check runs, and only at the job's own checkout of main. It never passed,
so the merge job re-ran the ~225-call check every tick.

Extract lane_room's reuse decision into babysit_merge_policy.settle_shared
(shared_refusal plus its two keeps: unverified-stale while nothing moved,
demotion-changed while the demotion reads the same) and call it from
lane_room. babysit_verify_evidence.py settle applies it to the kept report
without reading it again; the merge job reuses the report when the code is
0, 1 or 5 and settle exits 0, else runs the check as before. REUSE_MINUTES
is gone.

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

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 🔄 Running since 2026-10-26T21:14:23.297667Z 8b68f50 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-review reviewed d09aba4ada462ad128bbca58341f4562d0aa6422: 0 finding(s), 0 as inline comments.

Incremental review of test_babysit_lane_room.py since dad4dbc: no findings.

The change imports os and adds a module-level loop that pops GIT_DIR, GIT_WORK_TREE and GIT_CONFIG from the environment. It sits before the fixtures that build git repositories. That is the idiom scripts/check-fixture-git-isolation.sh documents. The variable list matches the script's required list, and the loop variable is deleted afterward. It only affects the test process. The popped variables can't leak into the fixtures.

I did not run the tests or the isolation check, and I did not re-review the other nine files, which were reviewed at dad4dbc. The PR spends no prepaid credits or billing.

@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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

No security issues found in the incremental change since dad4dbc.

The change is confined to plugins/source-control/skills/babysit-prs/scripts/tests/test_babysit_lane_room.py. It adds import os and, at import time, removes GIT_DIR, GIT_WORK_TREE and GIT_CONFIG from the test process environment so the git fixtures don't inherit ambient git state. This only affects the test process. It is not a trusted-path file and gates nothing at runtime. No production babysit module, merge hold, trust control or manifest is touched in this range, so there are no manifest lines to report.

critical-findings: 0

kyle-sexton and others added 2 commits October 26, 2026 17:29
post-merge-dispatch now keeps the commit whose code ran its check beside
the report. The merge job's reuse (settle) and enable-auto-merge's lane
room (lane-room) take it as a required --code-sha, and
check_code_unchanged compares the babysit-prs scripts and
docs/conventions/pr-pipeline.yaml there with this checkout's HEAD: a
change, a missing or malformed commit or a git failure refuses the
report, and the lane room reads it again.

settle reads the agent identity from the default branch's config, so the
merge job runs yq only on its fresh-check path, and the keep step's
comment states the new reuse rule.

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

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-review: 1 inline finding(s) on 60e6c6cbc6587a5e46deb4b4deea64f516d740a0; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

claude-security-review: 1 inline finding(s) on 60e6c6cbc6587a5e46deb4b4deea64f516d740a0; the summary is in this lane's pull request comment.

claude-lane: claude-security-review

kyle-sexton and others added 3 commits October 26, 2026 17:45
CHECK_CODE_ROOT took parents[4] of the script, the plugins directory, so
the pathspecs named paths that do not exist and every commit in the
clone read as unchanged. Take the repository root, and pin the default
root with a test that the two checked paths exist under it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…g at HEAD

git diff --quiet exits 0 for a path present at neither commit, so a
renamed or moved guarded path would read as unchanged. Require each path
to exist at HEAD before the diff.

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

CheckCodeUnchanged builds git repositories; an inherited absolute GIT_DIR
would point its writes at the caller's repository. Pop GIT_DIR,
GIT_WORK_TREE and GIT_CONFIG first, as fixture-git-isolation requires.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton enabled auto-merge October 26, 2026 22:37
@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 5f80dae Oct 26, 2026
38 checks passed
@kyle-sexton
kyle-sexton deleted the perf/postmerge-reuse-report branch October 26, 2026 23:10
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