Skip to content

stewards: merge a gate-met pull request instead of filing a Merge item (BB-257) - #296

Merged
trotterdylan merged 4 commits into
mainfrom
bb/bb-257-re-land-plugin-merge-on-bb-256-re-land-thr_ymps6s3bn2
Nov 9, 2026
Merged

trotterdylan merged 4 commits into
mainfrom
bb/bb-257-re-land-plugin-merge-on-bb-256-re-land-thr_ymps6s3bn2

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-257. The gate-met branch of syncNeeds now takes the merge step instead of filing the plugin's own Merge item: when the binding's playbook permits merge, it calls the shared mergePullRequest path (the one bb stewards merge and the page's Merge button use). A ticket binding always merges; a pr binding only when its may includes merge; a review binding (a teammate's) is unchanged.

This is a re-land of the reviewed bitcomplete/bb-plugins#293. That PR was approved and merged into BB-256's stacked branch (bb/bb-256-mergebehind-hold-stewards-thr_vaxkrw2h9u), which was never re-landed on main, so the diff is not on main. It is stacked here on BB-256's re-land bitcomplete/bb-plugins#295 (bb/bb-256-mergebehind-reland-thr_k2uwubpyfp), which has now squash-merged to main as 80a4d2e; this PR is rebased onto main and retargeted to main, so the diff is only the BB-257 change. #293's review and approval cover this diff; the only conflict against the re-landed code was the test fake's return object, resolved by keeping BB-256's extra fields and adding #293's setMoveHeadOnMerge — no behaviour changed.

bitcomplete/bb-plugins#297 (BB-258, rename goal stewards to initiative stewards) was stacked on this PR and has merged into this branch, so this landing carries it to main too; #297's own review and owner approval cover its diff.

Note: a merge to bb-plugins main moves the pin and stages a restart for every developer's server (Restart now, or in the 03:00–05:00 ET quiet window).

Sibling PR: the .bb half on bb-gate (stewards/playbooks/deps-prs.md and AGENTS.md), bitcomplete/bb-gate#102 — already merged.

Classification

owner-reviewed: "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (user), the decide-list entry the plugin matched. This changes what the plugin does once the gate is met.

What changes

  • plugins/stewards/server.ts — in the gate-met branch of syncNeeds, when bindingMayMerge (new, exported from wake.ts) is true, the plugin calls the shared mergePullRequest path instead of filing a Merge item. On success it notes the merge into this look's changes and schedules a reconcile, so the steward's wake carries the merge note and it proceeds to the deployment watch. A steward-filed Merge item is left alone (the hand-off shape) and no merge happens over it.
  • plugins/stewards/server.ts — the plugin merges only into the repository's default branch. A stacked pull request's base is another pull request's branch, which may already be merged and left dead, so auto-merging it there would strand the change off the default branch (how stewards: raise the per-turn brief cap to bb 0.49's 32768 limit (BB-254) #290/stewards: a merge hold a steward reports with steward_report mergeBehind (BB-256) #291/stewards: merge a gate-met pull request instead of filing a Merge item (BB-257) #293 were stranded). A stacked pull request keeps the plugin-filed Merge item and a person or worker merges it into its parent; a default-branch read that fails is treated as not the default, so the item is filed. This guard was added after review round 1 on this PR.
  • plugins/stewards/server.ts — the merge is skipped while Pause stewards is on (the item is filed as before), and mergePullRequest passes the head it judged (gate.headSha) as the merge PUT's sha, so a push between the look and the merge makes GitHub refuse with 409 and the plugin waits for the next look instead of merging a head whose checks have not run.
  • plugins/stewards/server.ts — a refused merge (conflict, branch protection) is recorded against the head sha plus the reviewer marker and lane (mergeAttemptKey). One note and one stuck escalation per refusal; the same gate is not retried and not re-raised on later looks. A push or a new review round changes the key and a fresh attempt follows; the escalation names bb stewards merge <key> as the manual retry. The head-moved refusal is matched by status (failed: 409), never a bare 409 in a URL path.
  • plugins/stewards/wake.ts — one exported bindingMayMerge decides it, so the worker skill line and the gate-met branch cannot disagree; a standing rule tells the steward the plugin merges once the gate is met and not to file a Merge item for a pull request its playbook may merge.
  • plugins/stewards/github.ts — squashMerge takes the judged head sha and sends it as the merge PUT's sha.
  • Tests cover: a ticket binding merging itself (note, comment, no item); a pr binding under github-prs merging; a pr binding under a deps-prs playbook without merge still filing the item; a deps-prs playbook with merge merging; a steward-filed item left alone; the refusal recorded once and not retried until the head moves; the head moving between the look and the merge; Pause stewards suppressing the merge; the merge hold still suppressing both; a 409 in the URL path not read as a head-moved refusal.

Testing

  • cd bb-plugins/plugins/stewards && npm run typecheck: pass.
  • npx vitest run: pass (1441 tests; the two new ones cover the stacked-base guard). CI's quality_checks (stewards) runs the same suite.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_kppcmr55iq.

— from bb thread thr_ymps6s3bn2

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at a005bfa)

Owner review required: yes. This changes what the plugin does once the gate is met. Decide-list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" is decide: user. @trotterdylan, this one needs your approval. Your approval of #293 on 2026-11-09 covers the code that is the same here. The fix for the blocker below adds behaviour, so look at that part again. The escalation is binding: a project-steward bb-approval will not meet the gate.

I checked the re-land claim. The +/- lines of #296 match #293's line for line, except the test fake's return object, which is resolved as the body says. #295's base differs from the old BB-256 branch only in BB-254/255 code (retry consent, queued retries, brief cap). None of that touches syncNeeds or mergePullRequest.

Blockers

  1. plugins/stewards/server.ts:6900 — the plugin now merges a gate-met stacked pull request with no check on its base. mergePullRequest squash-merges into whatever pull.base is. It then runs mergeDispatches, posts the "moves the pin / stages a restart" note, and the merge note wakes the steward toward the deployment watch. Here is the failure case. The parent PR has already merged and its branch was left in place. The child PR's gate is met with no worker in flight. On its next look the plugin squash-merges the child into the dead branch, and the change is off main with no one involved. That is how stewards: raise the per-turn brief cap to bb 0.49's 32768 limit (BB-254) #290, stewards: a merge hold a steward reports with steward_report mergeBehind (BB-256) #291 and stewards: merge a gate-met pull request instead of filing a Merge item (BB-257) #293 were stranded today (lesson lsn_qI7t), and it is the reason for this re-land. BB-258 is stacked on this PR right now. It also misses the project steward's spec guidance of 12:39 on BB-257, item 3: for a stacked PR, merge into the parent branch, but run no mergeDispatch and give no deployment-watch wake. Suggested fix: when pull.base is not the repo's default branch, auto-merge only if an open PR has pull.base as its head. In that case skip mergeDispatches and the restart note, and word the change as "merged into , report landedIn". Otherwise do not merge, and raise the stuck escalation ("base branch's PR is not open; retarget to main"), keyed like a refusal so it fires once. Add a test for each case.

Tested

  • Ran: npm run typecheck and npx vitest run in plugins/stewards at a005bfa. Pass (1439 tests). CI's quality_checks (stewards) was still running when I ran them.

— from bb thread thr_kppcmr55iq

…m (BB-257) (#293)

Implements [BB-257](https://linear.app/bit-complete/issue/BB-257/stewards-merge-a-gate-met-pull-request-instead-of-filing-a-merge-item). The gate-met branch of `syncNeeds` now takes the merge step instead of filing the plugin's own Merge item: when the binding's playbook permits `merge`, it calls the shared `mergePullRequest` path (the one `bb stewards merge` and the page's Merge button use). A ticket binding always merges; a `pr` binding only when its `may` includes `merge`; a `review` binding (a teammate's) is unchanged.

> Note: a merge to `bb-plugins` `main` moves the pin and stages a restart for every developer's server (Restart now, or in the 03:00–05:00 ET quiet window).

Sibling PR: the `.bb` half on `bb-gate` (`stewards/playbooks/deps-prs.md` and `AGENTS.md`), bitcomplete/bb-gate#102.

owner-reviewed: "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (user), the decide-list entry the plugin matched. This changes what the plugin does once the gate is met.

- `plugins/stewards/server.ts` — in the gate-met branch of `syncNeeds`, when `bindingMayMerge` (new, exported from `wake.ts`) is true, the plugin calls the shared `mergePullRequest` path instead of filing a Merge item. On success it notes the merge into this look's changes and schedules a reconcile, so the steward's wake carries the merge note and it proceeds to the deployment watch. A steward-filed Merge item is left alone (the hand-off shape) and no merge happens over it.
- `plugins/stewards/server.ts` — the merge is skipped while **Pause stewards** is on (the item is filed as before), and `mergePullRequest` passes the head it judged (`gate.headSha`) as the merge `PUT`'s `sha`, so a push between the look and the merge makes GitHub refuse with 409 and the plugin waits for the next look instead of merging a head whose checks have not run.
- `plugins/stewards/server.ts` — a refused merge (conflict, branch protection) is recorded against the head sha plus the reviewer marker and lane (`mergeAttemptKey`). One note and one `stuck` escalation per refusal; the same gate is not retried and not re-raised on later looks. A push or a new review round changes the key and a fresh attempt follows; the escalation names `bb stewards merge <key>` as the manual retry.
- `plugins/stewards/wake.ts` — one exported `bindingMayMerge` decides it, so the worker skill line and the gate-met branch cannot disagree; a standing rule tells the steward the plugin merges once the gate is met and not to file a Merge item for a pull request its playbook may merge.
- Tests cover: a ticket binding merging itself (note, comment, no item); a `pr` binding under `github-prs` merging; a `pr` binding under a deps-prs playbook without `merge` still filing the item; a deps-prs playbook with `merge` merging; a steward-filed item left alone; the refusal recorded once and not retried until the head moves; the head moving between the look and the merge; Pause stewards suppressing the merge; the merge hold still suppressing both.

- **BB-254** (`#292`): gate met (reviewer approved `81a5fec`, checks green, owner approved), no merge hold, waiting on the 0.49 restart after the 2026-11-10 03:00–05:00 ET window. If BB-257 lands while it is still waiting, the plugin would merge #292 early. Please set a BB-256 merge hold on it before this lands.

The PR is based on `bb/bb-256-mergebehind-hold-stewards-thr_vaxkrw2h9u` (BB-256 / #291). #291 and #290 merged into their parent branches rather than `main`; `main` has BB-253/BB-255 only, and #292 re-lands BB-254 on `main` without BB-256. BB-257 needs BB-256's `mergeBehind`, so it stays stacked until BB-256 re-lands; the project steward has asked that it be retargeted onto BB-256's re-land branch once that opens, then onto `main`. It must not merge before #292 (BB-254) has merged.

- `cd bb-plugins/plugins/stewards && npm run typecheck`: pass.
- `npx vitest run`: pass (1435 tests). CI's `quality_checks (stewards)` runs the same suite and is green on this head.
A gate-met stacked pull request keeps the plugin-filed Merge item: its base
is another pull request's branch, which may already be merged and dead, so
auto-merging it there strands the change off the default branch (the
#290/#291/#293 failure). A person or worker merges a stacked pull request
into its parent. A default-branch read that fails is treated as not the
default, so the item is filed.
@trotterdylan
trotterdylan force-pushed the bb/bb-257-re-land-plugin-merge-on-bb-256-re-land-thr_ymps6s3bn2 branch from a005bfa to b9397b1 Compare November 9, 2026 15:28
@trotterdylan
trotterdylan changed the base branch from bb/bb-256-mergebehind-reland-thr_k2uwubpyfp to main November 9, 2026 15:28
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed in b9397b1 (rebased onto main at 80a4d2e; #296 retargeted to main).

  • Blocker 1 (a stacked PR auto-merges into a non-default base): fixed. The plugin now merges only when pull.base equals the repository's default branch (github.defaultBranch). A stacked pull request keeps the plugin-filed Merge item, so a person or worker merges it into its parent, and a default-branch read that fails is treated as not the default (the item is filed). This is the simpler guard the project steward asked for over the suggested "merge into the parent when an open PR has that base" path: the parent's branch may already be merged and dead, so the plugin does not merge stacked PRs at all. Added two tests — a gate-met stacked PR files the item and records no merge, and the same PR merges once retargeted to the default branch. npm run typecheck and npx vitest run pass (1441 tests).
  • The guard adds behaviour beyond stewards: merge a gate-met pull request instead of filing a Merge item (BB-257) #293, so the owner should look at it again; the rest of the diff is stewards: merge a gate-met pull request instead of filing a Merge item (BB-257) #293's, unchanged.

— from bb thread thr_ymps6s3bn2

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at b9397b1)

The rebase is clean. aee2c3d is the same patch as a005bfa, and main at 80a4d2e has the same tree as #295's head 3102eef.

Blockers

  1. plugins/stewards/wake.ts:47 — the new standing rule is now wrong for stacked pull requests. It says the plugin squash-merges any gate-met pull request whose playbook permits merge. It also says a Merge item on the page means only one of two things: a playbook without merge, or a merge GitHub refused. After b9397b1, a gate-met stacked pull request on a ticket binding gets a plugin-filed Merge item and no merge. A steward reading this rule will either wait for a merge that never comes or read the item as a refusal. Every steward's brief carries this rule. Fix: limit the first sentence to a pull request based on the repo's default branch, and add stacked pull requests to the list of cases the item is for ("a stacked pull request, which the worker or a person merges into its parent's branch while that pull request is open"). The wake.test.ts assertion on this rule should then match the new text.

Resolved since round 1

  • Blocker 1 (auto-merge into a stacked base): resolved by b9397b1. pullBaseIsDefault fails closed, and a stacked pull request keeps the plugin-filed item, so nothing is dispatched or watched for it. This is narrower than item 3 of the spec guidance (merge into an open parent's branch) but safe. The two new tests fail without the guard.

Tested

  • Ran: npm run typecheck and npx vitest run in plugins/stewards at b9397b1. Pass (1441 tests).

— from bb thread thr_kppcmr55iq

…d cases (BB-257)

The rule now says the plugin merges a gate-met pull request only when its
base is the repository's default branch, and lists a stacked pull request
among the cases that keep the plugin-filed Merge item (the worker or a
person merges it into its parent's branch).
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 addressed in 214418b.

  • Blocker 1 (standing rule wrong for stacked PRs): fixed. The rule now says the plugin merges once the gate is met when the pull request targets the default branch, and lists a stacked pull request among the cases that keep the plugin-filed Merge item ("the worker or a person merges it into its parent's branch while that pull request is open"). wake.test.ts now asserts the default-branch and stacked wording. npm run typecheck and npx vitest run pass (1441 tests).

— from bb thread thr_ymps6s3bn2

Implements [BB-258](https://linear.app/bit-complete/issue/BB-258/rename-goal-stewards-to-initiative-stewards). Renames the goal steward concept to the initiative steward: `GOAL_LABEL`/`GOAL_PLAYBOOK` become `INITIATIVE_LABEL`/`INITIATIVE_PLAYBOOK` = `initiative`, and the progress flag in the project steward's binding list and digest changes from `goal met 3/7` to `criteria 3/7`. A server on the new image recognises `initiative` only; there is no backward compatibility for `goal`.

> Merging this moves the `bb-plugins` pin and builds a new `bb-server` image, which stages a restart for every developer's server.

Sibling PR: this is the `bb-plugins` half of BB-258. The `bb-gate` half (`.bb/stewards/playbooks/goal.md` → `initiative.md`) lands later, after the owner's server has restarted onto this image. Stacked on #296 (this PR's base), which is stacked on #295.

## Classification
owner-reviewed: renames an existing feature's label, playbook routing and digest text (`config.ts`, `wake.ts`, `skills/stewards/SKILL.md`). Per `.bb/AGENTS.md`, a change to a default or to what an existing feature does is owner-reviewed even when the ticket asks for it.

## What changes
- `config.ts`: `GOAL_LABEL`/`GOAL_PLAYBOOK` → `INITIATIVE_LABEL`/`INITIATIVE_PLAYBOOK` = `initiative`; comment block updated.
- `wake.ts`: `goalProgress`/`goalProgressFlag` → `initiativeProgress`/`initiativeProgressFlag`; the digest flag now renders `criteria 3/7` (`criteria 3` with no `Criteria` heading, `criteria unknown` when no `**Met:**` comment could be read, `criteria ≥3/7` when the comment page was full); the project steward intro bullet is reworded.
- Tests (`wake.test.ts`, `reconcile.test.ts`, `config.test.ts`, `server.test.ts`): `goal` / `goal:awaiting-outcome` / `label:goal:awaiting-outcome` fixtures move to `initiative` and the assertions move to the `criteria` text; describe blocks and fixture names follow. The generic BB-246 ticket-watch fixtures named `goals` are renamed too, so the acceptance grep is clean; the thread-briefs `goals: 0` activity fixtures in `app.test.tsx` and `sidebar-app.test.tsx` are untouched.
- `skills/stewards/SKILL.md`: "If you are a goal steward" becomes "If you are an initiative steward", with the one-line note that an initiative here is a labelled issue, not a Linear Initiative. The three endings, comment prefixes and rules are unchanged.
- `DESIGN.md`: the one mention.

## Testing
- `npm run typecheck`: pass.
- `npm test`: pass (1439 tests, 31 files; not in the CI matrix).
- `grep -rn '\bgoal' plugins/stewards --exclude-dir=node_modules`: returns only the two thread-briefs `goals: 0` activity fixtures.
- Not tested: `bb stewards check` on `.bb/stewards/playbooks/initiative.md` — that is the `bb-gate` half of BB-258 and out of scope for this slice.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 3 (Claude Opus 5.5, at 214418b)

Owner review required: yes. This changes what the plugin does once the gate is met. Decide-list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" is decide: user. @trotterdylan, this one needs your approval. Your approval of #293 covers the code this re-lands. This PR adds one rule on top of it: the plugin auto-merges only a pull request that targets the default branch. A stacked pull request keeps the plugin-filed Merge item (b9397b1). The escalation is binding: a project-steward bb-approval will not meet the gate.

Resolved since round 2

  • Blocker 1 (standing rule): resolved by 214418b. The rule now limits the plugin's merge to a pull request that targets the default branch, and it lists a stacked pull request as a case that keeps the item. wake.test.ts asserts both.

Tested

  • Ran: npm run typecheck and npx vitest run in plugins/stewards at 214418b. Pass (1441 tests). CI's quality_checks (stewards) was still running.

Looks good.

— from bb thread thr_kppcmr55iq

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved aaa6864 from the Stewards page

@trotterdylan
trotterdylan merged commit 9fd0b01 into main Nov 9, 2026
22 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved 214418b, checks green, approved by the owner, escalated by the reviewer to the owner.
since then: the head moved to aaa6864
merge commit 9fd0b01
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