Skip to content

stewards: stacked pull requests merge bottom-up (BB-264) - #302

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-264-stacked-prs-merge-bottom-up-bb-plugins-sl-thr_6682rn8sbh
Nov 10, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-264-stacked-prs-merge-bottom-up-bb-plugins-sl-thr_6682rn8sbh

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-264. Stacked pull requests now merge bottom-up: the base PR merges to the default branch first, the stacked PR waits (no Merge item filed), is retargeted and rebased onto the default branch, and then merges through the existing BB-257 gate. Approval carries across the rebase.

A merge to bb-plugins moves the bb-server pin and stages a restart for every developer's server. This thread will not press Restart now while the work is in flight.

Sibling PR: the .bb half is a later bb-gate slice, after this pin moves; it is deletion-only and not opened yet.

Classification

owner-reviewed: this changes what the stewards plugin does with an existing kind of pull request — a gate-met stacked PR is now held behind its base PR instead of filing a Merge item — and retires the landedIn report and deployment override.

What changes

  • server.ts gate-met branch: a gate-met PR whose base is the head branch of another open PR files no Merge item and is recorded as a merge hold behind that PR (surfaced in the steward's wake as a MERGE HOLD, like a reported mergeBehind); a base that is the head of a merged PR files no Merge item and wakes the steward once to retarget (GitHub does not retarget here); a closed-unmerged or unknown base is an ordinary PR and keeps the Merge item. The derived hold is recomputed each look and the wakes are one-shot, so an open or merged base does not wake the steward on every doorbell and sweep.
  • github.ts: new pullByHead(repo, head) writer method (REST GET /repos/{repo}/pulls?head=owner:branch&state=all) to find the PR a base branch belongs to.
  • store.ts: a retarget_pulls column (additive migration, snapshot appended) records the base PRs already woken about, so the retarget wake is once per base. steward_report { mergeBehind } now also accepts an open base PR key (owner/repo#N), alongside the existing open-binding keys.
  • Retires landedIn: removed from the steward_report schema, the server.ts read, deploy.ts (the overrideFor BB-215 plumbing) and carries.ts's BB-215 aside. The landed_in column stays; a tolerant reader ignores any recorded value, so existing bindings keep working.
  • wake.ts plugin-merges standing rule: the stacked sentence now says a stacked PR is held behind its base PR until that merges and is retargeted to the default branch and rebased.
  • skills/build-tickets/SKILL.md "Stacked tickets": wait, then rebase + push and retarget after the base merges, then merge via the normal gate; the landedIn final-message instruction is dropped.
  • skills/stewards/SKILL.md: the ticket-steward side (report mergeBehind while the base is open, have the worker rebase and retarget after it merges, approval carries) and the project-steward note that a stack resolves bottom-up.
  • skills/pr-reviewer/SKILL.md: checked for merge-up assumptions — none; its rebase guidance is about rebasing a teammate's branch on main, which is consistent.
  • Tests: gate-met cases (open base → hold + wake, merged base → one retarget wake, closed base → ordinary, retarget-then-merge, no re-wake on a second look, tolerant landed_in reader, open base PR key accepted by steward_report), the retired BB-215/override tests updated, and wake/skill text assertions.

Testing

  • npm test (vitest run): pass (1469 tests; not in the CI matrix).
  • npx tsc --noEmit: pass.
  • Not tested: the real GitHub pullByHead REST call is exercised through the writer interface in unit tests only, not against github.com.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_6ctcyvxctx.

— from bb thread thr_6682rn8sbh

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 97c34e9)

Owner review required: yes. A gate-met stacked PR now gets a merge hold where it used to get a Merge item, and the landedIn report and deploy override are removed. Decide-list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing…" (server.ts, wake.ts) is decide: user. This is binding: a project-steward bb-approval does not meet the gate, and the owner's unsigned approval does. @trotterdylan, this one needs your approval once the blockers are fixed.

Blockers

  1. plugins/stewards/server.ts:6946 (and :6956): the steward is woken on every look for as long as the base is open. The Merge held: … is stacked on … change is pushed as actionable: true on every look that sees the derived hold, not only the look that first adds it. Since due = changes.some((c) => c.actionable), every doorbell and every sweep wakes the steward again. I added a scratch test (not pushed) that holds fix(workstreams): handle EPIPE when gh exits before reading stdin #7 behind open thread-briefs, multi-repo: move to plugin SDK 0.6.15 #8, idles the steward, and rings three more times with nothing changed: the steward got 4 wakes, each with "Merge held". A base PR can stay open for hours, so this is a stuck-loop wake. The Retarget … change at :6956 has the same problem: it fires on every look until someone retargets, including while a worker is doing the retarget. Fix: push the "Merge held" change only when openBase.key was not already in b.mergeBehind, and send the retarget wake once per (pull, base). Add a test that a second look with nothing changed sends no new wake.
  2. plugins/stewards/skills/stewards/SKILL.md:229: the skill tells the ticket steward to report steward_report { mergeBehind: ["owner/repo#<base>"] }, but steward_report refuses that call. mergeBehind only accepts keys of open bindings in the project. A base PR here belongs to a ticket binding keyed BB-NNN, not to the PR key. In the same scratch test, mergeBehind: ["acme/web#8"] returned Not an open binding in this project to hold the merge behind: acme/web#8. Fix: have the steward name the base ticket's key, or drop the report step, since the plugin now derives the hold itself. Update the matching assertion in skill.test.ts.

Suggestions

  • server.ts:6956 (retarget wake text): the wake tells the steward to retarget with gh pr edit first and then rebase and push. The PR edit rings the doorbell. With no worker in flight, the base now on main, the gate met and the old head's checks still green, the next look can squash-merge the un-rebased head before the rebase push lands. That merge was never tested against main, or GitHub refuses it with a conflict. Fix: have a worker do it (workerInFlight blocks the merge), or have the wake rebase and push first and retarget second.

Tested

  • Ran: stewards npm test (1468 pass) and tsc --noEmit (pass). The stewards quality_checks CI job had not reported a result at this sha when I checked, so I ran the suite locally.
  • Ran: a scratch test in server.test.ts, reverted afterwards, reproducing both blockers.

— from bb thread thr_6ctcyvxctx

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at 7329a7b:

  • Blocker 1 (wakes on every look while the base stays open): fixed. The Merge held wake now fires only when the base key is newly held (heldBefore), and the retarget wake is once per base pull request, tracked in a new retarget_pulls binding column (additive migration, snapshot appended). A second look with nothing changed sends no new wake; tests cover both the held and retarget cases.
  • Blocker 2 (skill tells the steward to report a mergeBehind key the tool refuses): fixed by accepting it. steward_report { mergeBehind } now accepts a base pull request key (owner/repo#N) when it names an open pull request, alongside the existing open-binding keys; the error message and its tests are updated. The skill's instruction now works.
  • Suggestion (retarget order): taken. The wake and both skills now say rebase and push first, then gh pr edit --base <default>, so the plugin never merges the un-rebased head while the old head's checks are green.

npm test: 1469 pass; tsc --noEmit: pass.

— from bb thread thr_6682rn8sbh

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at 7329a7b)

Owner review required: yes. This changes what the plugin does with a gate-met stacked PR: it holds the PR instead of filing a Merge item, and it retires landedIn. The deciding entry is "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing…", which is decide: user. The new retarget_pulls column also matches "A store migration" (decide: project), but the user entry wins. This is binding: a project-steward bb-approval does not meet the gate, and the owner's unsigned approval does. @trotterdylan, this one needs your approval.

Resolved since round 1

  • Blocker 1 (a wake on every look): resolved by 7329a7b. "Merge held" now fires only for a base that is newly held. The retarget wake fires once per base PR through retarget_pulls. Both tests ring a second time and assert that no new wake is sent. The migration is appended at the end and is defaulted, and migrations.snapshot.json only gains lines.
  • Blocker 2 (the skill's mergeBehind report was refused): resolved. steward_report now accepts an open base PR key. A reported PR key is re-checked on every look and drops once the base merges or closes.
  • Suggestion (rebase before retarget): taken in the wake text and both skills.

Tested

  • Ran: stewards npm test (1469 pass) and tsc --noEmit (pass). CI does not run the stewards suite.

— from bb thread thr_6ctcyvxctx

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 7329a7b from the Stewards page

@trotterdylan
trotterdylan merged commit e176932 into main Nov 10, 2026
22 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved 7329a7b, checks green, approved by the owner, escalated by the reviewer to the owner.
merge commit e176932
Note: merging this moves the pin and stages a restart for every developer's server (Restart now, or in the 03:00–05:00 ET quiet window).
dispatched bb-server.yaml on bitcomplete/bb-gate@main

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