Skip to content

fix(pr-pipeline): count a stack layer's merge into main as merged - #15406

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/stack-layer-merge-evidence
Nov 11, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/stack-layer-merge-evidence

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #15400

Summary

An upper layer of a native stack that lands with the layers below it keeps the lower layer's branch as its base.ref, while its merge commit lands on main. Two merge-counting sites read only base.ref == main, so they missed such a merge. Part of owner decision Q40 (lanes accept native stack layers into main).

Fix

  • .github/scripts/lib/done-evidence.mjs: a merged pull request counts when base.ref is the default branch, or when GitHub's compare of its merge commit with the default branch reads ahead or identical. The merge commit must still close the issue, after the issue opened. The SHA path reuses the same onBase check.
  • plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py: the lift query reads stack{baseRefName}, and a referencing pull request counts when baseRefName or stack.baseRefName is main. The existing green.on_main(oid) check still requires the merge commit on main.

Verification

Sandbox probe, melodic-software/pr-pipeline-sandbox stack 333: layer #332 carried Closes #330; gh stack merge 332 landed #331 and #332 through the merge queue together. After the merge, #332 reads base.ref probe/stack-close-l1, merge_commit_sha d8a1dab0…, compare with main identical, REST stack.base.ref main (base SHA null once merged), GraphQL stack.baseRefName main; issue #330 closed completed two seconds after the merge.

Tests (each new case red before the change):

  • node --test .github/scripts/work-resolve-issue/report-outcome.test.mjs: 420 pass. New: a layer whose merge commit compares ahead or identical counts; diverged and an unreadable compare do not. The existing control (merged into release/3.x, no compare) stays false.
  • python3 -m unittest on test_babysit_lift.py (23 OK), test_babysit_merge_policy.py, test_babysit_postmerge.py: OK. New: a layer with stack.baseRefName main lifts the record; baseRefName another branch with no stack, a null stack, or a stack into release lifts nothing.
  • scripts/run-ruff.sh check on both Python files: clean.

Related

Follow-ups

  • Pre-existing (advisory): native auto-merge refuses every stack member, so enable-auto-merge.mjs cannot arm a layer; a stack lands only through the asynchronous merge API.
  • Pre-existing (advisory): the issue lane (report-outcome.mjs, check-blockers.mjs) does not yet open a stacked layer on a blocker's open PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQb9Q2ceZLXhTR4d1vkTCe

When a native stack lands together, an upper layer merges with base.ref
still the lower layer's branch while its merge commit lands on main
(sandbox stack 333: #332 merged at d8a1dab, compare with main
identical, and its Closes line closed issue #330).

- done-evidence.mjs takes a merged pull request whose merge commit is on
  the default branch, by compare, when base.ref is another branch.
- babysit_merge_policy.py's lift reads stack.baseRefName beside
  baseRefName; the merge commit must still be on main.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQb9Q2ceZLXhTR4d1vkTCe
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 11, 2026 17:50
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T17:52:05.570750Z 605754f 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-review reviewed 605754f069e3aface65254e65cddcfe6f1055a6b: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15406, merging a stack layer into main now counts as merged

No blocking or advisory findings. I read every hunk of all 6 changed files. Prior findings: none, and this is not a blocking-only review.

What changed

  • .github/scripts/lib/done-evidence.mjs: a merged pull request now counts when base.ref is the default branch, or when its merge_commit_sha compares ahead/identical with the default branch. The new onBase helper also replaces the copy of that compare in the SHA path, and both paths behave as before. Every other gate still applies: merged_at, a well-formed merge SHA, and tied (the commit message closes the issue and the merge came after the issue opened or was last reopened). A compare that fails returns null, which counts as not on base, so a failed read does not count as evidence.
  • plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py: LIFT_PULL now asks for stack{baseRefName}, and the _lift filter accepts main as either baseRefName or stack.baseRefName. json_object(None) handles a null stack. The later green.on_main(oid) check (L2549-L2551) still requires the merge commit to be on main. So a layer merged alone into its lower branch does not lift a record until that commit reaches main.

Notes

  • Wider than stacks (looks intended): in done-evidence.mjs, any merged pull request whose merge commit later lands on the default branch now counts. That includes one merged into release/x that was later merged into main. This matches what the SHA path already accepted, and the closes-the-issue and timing gates still apply, so I'm not raising it as a finding.
  • Tests: the new JS cases cover ahead, identical, diverged and an unreadable compare. The existing release/3.x control still has no compare route. The new Python cases cover a stack into main, no stack, a null stack, and a stack into release. Each assertion matches the code path it targets. I did not run them: the author says 420 JS passes, 23 Python OKs and a clean ruff check, all unverified by me.
  • GraphQL field (unverified): that PullRequest.stack{baseRefName} exists in the GraphQL schema is the author's claim, from a sandbox probe I could not reproduce. If the field were missing, every lift query would error, and _lift raises on a failed read rather than lifting.
  • Changelog fragments: bump: patch for both pr-pipeline and source-control fits a bug fix. No plugin manifest changed.
  • Closing issue: the PR uses Refs: #15400 and closes no issue, so there are no acceptance criteria to check. The PR context had no embedded instructions.
  • Spend: one extra REST compare call per cited merged pull request whose base is not the default branch. That is negligible API budget and causes no billing.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 605754f069e3aface65254e65cddcfe6f1055a6b: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

I read every hunk of all 6 changed files. Two of them match trusted paths, and I read each one's whole change and what it gates.

.github/scripts/lib/done-evidence.mjs (the already-done evidence that report-outcome and check-trusted-trigger's isTrustedClose both rely on)

  • What changed: a merged pull request whose base.ref is not the default branch now counts when GitHub's compare of its merge_commit_sha with the default branch reads ahead or identical (L75).
  • Why this lets nothing new through: the SHA path at L83-L91 already accepted any commit on the default branch whose message closes the issue and was committed after it opened. A reason could already cite that same merge commit by SHA. The new PR path is held to the same checks:
    • merged_at is set.
    • The merge SHA is a 40-hex value.
    • The commit is an ancestor of the default branch, checked through the shared onBase helper (L61-L64).
    • tied still requires a merge after the issue opened and a message that closes it.
  • Failure handling: a failed compare is caught and returns null, so an unreadable compare counts as not on main. The new test at report-outcome.test.mjs L98 pins that case.
  • Moving the SHA-path compare into onBase is a refactor and changes no behaviour.

plugins/source-control/skills/babysit-prs/scripts/babysit_merge_policy.py (_lift, which lifts a demotion record)

  • What changed: a referencing pull request now also qualifies when GitHub's stack.baseRefName is main (L2528-L2532).
  • That value comes from GitHub's GraphQL API, not from text the pull request author controls.
  • All the other checks are unchanged:
    • same-repository nameWithOwner
    • a 40-hex merge oid
    • merged after the record was created
    • the reference made before the merge by a write-access person or the agent identity
    • the read-back check
    • green.on_main(oid) at L2550, so the merge commit must still be on main.
  • A layer merged only into its lower branch fails on_main. json_object(None) handles a null stack, which the new test covers.
  • I read this as a merge-hold path. It does not weaken the hold: a lift still needs a merge actually on main by a trusted actor.

Trust controls: neither change lets through anyone or anything the base version stopped. Neither touches the trusted-actor list, a lanes token scope, the kill switch, or what untrusted text reaches a lane.

Other files: the two .changes/ changelog notes and the two test files have no security surface.

PR context: it contains no embedded instructions aimed at this lane.

Spend: none. This change spends no prepaid credit and can cause no charge.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit 373d2ad Nov 11, 2026
88 of 102 checks passed
@kyle-sexton
kyle-sexton deleted the fix/stack-layer-merge-evidence branch November 11, 2026 18:53
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant