Skip to content

stewards: a merge hold a steward reports with steward_report mergeBehind (BB-256) - #295

Merged
trotterdylan merged 1 commit into
mainfrom
bb/bb-256-mergebehind-reland-thr_k2uwubpyfp
Nov 9, 2026
Merged

trotterdylan merged 1 commit into
mainfrom
bb/bb-256-mergebehind-reland-thr_k2uwubpyfp

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-256. This is a clean re-land of bitcomplete/bb-plugins#291, which merged as 7ddfe64 into the stale BB-254 stack branch (bb/bb-254-raise-stewards-brief-cap-to-32-768-limit-thr_d393j5txua) instead of main, so no bb-server image carries it. Same diff, rebased onto current main (881fa58, which includes BB-254's #292).

A ticket steward that must not merge yet had no structured way to say so: once the gate was met and the worker finished, the plugin filed its own Merge item and the effort read as "needs you" for hours. This adds steward_report { mergeBehind: [keys] }: a merge hold behind open bindings in the same project. While it stands the plugin files no Merge item (and closes its own if one is open), the effort ranks as held, and the hold is a live wake source, so removing the item does not turn the wait into a stall. It lifts itself, noting and waking the steward, once every named binding has merged its pull requests or ended; the next look files the Merge item again if nobody merges, so a stuck loop still surfaces.

A merge to bb-plugins main moves the pin, builds a new bb-server image and stages a restart for every developer's server. This is a bb-plugins merge, so it does.

Re-land: #291's reviewer round 1 approved the change at 06e2b82, and the owner approved 06e2b82c04986b4ce59907ede5ab6f16a88157f4 ("Approved 06e2b82 from the Stewards page") on 2026-11-09. A re-land of the approved change needs no fresh owner approval; the reviewer re-reviews this head.

Classification

owner-reviewed: plugins/stewards/server.ts and wake.ts are under the user decide-list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list"; store.ts also matches "A store migration".

What changes

  • store.ts: an append-only merge_behind column (BB-256 group at the end of MIGRATIONS), its Binding field, and the migrations.snapshot.json hash.
  • wake-source.ts: mergeBehind is a live wake source, so the free-text wait beside it is not marked noWakeSource and no stall is raised.
  • server.ts: steward_report { mergeBehind } validated like steward_update's behind, replaced on each report and cleared by []; the gate-met branch of syncNeeds skips the plugin-filed Merge item while the hold stands and closes an open plugin-filed one with "held behind X" (a steward-filed item survives); a level-triggered lift plus releaseMergeBehind (shared by the target's own releaseBehind) clear it with a note and a wake; the three presentation RPCs derive a hold so the sidebar and Stewards page rank the effort as held with the steward's waitingOn; bb stewards show prints MERGE HOLD: behind ....
  • wake.ts: one standing rule ("a spec that says 'do not merge before X is Done' is a merge hold") and a merge-hold line in section 3.
  • .bb/stewards/playbooks/linear-tickets.md gets the same one-liner in a separate bb-gate PR (stewards: bb stewards needs lists the needsYou set (BB-69) #101, already on main).

Testing

  • plugins/stewards: npm install --include=dev --legacy-peer-deps --no-audit --no-fund, npm run typecheck pass, npm test pass (31 files, 1433 tests; stewards is in the CI matrix, so quality_checks (stewards) runs on this head).
  • Rebased onto main at 881fa58 (stewards: raise the per-turn brief cap to bb 0.49's 32768 limit (BB-254) #292); the small server.ts conflict was resolved keeping both stewards: raise the per-turn brief cap to bb 0.49's 32768 limit (BB-254) #292's BRIEF_MAX_CHARS = 30000 and this change. The diff against main is only stewards: a merge hold a steward reports with steward_report mergeBehind (BB-256) #291's nine files.
  • New tests cover: report/refuse (unknown, self, ended)/clear; no plugin Merge item while held and an open one closed with "held behind ENG-13", a steward-filed one surviving; the sidebar and board rows showing the derived hold and bb stewards show printing the merge hold; a live source with no stall across two requeue-only wakes; the lift on the target's merge (note + wake + the Merge item on the next look); and hasLiveWakeSource.
  • Not tested: the page's Merge button and bb stewards merge are deliberately unchanged (BB-170's Dependabot Merge-item test still passes).

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_3xh45u2k3t.

— from bb thread thr_6anmnm7jju

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 3102eef)

Owner review required: yes — the diff touches plugins/stewards/server.ts and wake.ts, matching the user decide-list entry "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (the store.ts migration also matches "A store migration", decide: project, but a user entry wins). The change is also substantial with no approved spec, so product is a second reason. The owner's approval of 2026-11-09 stands: it was given on #291 at 06e2b82, and I verified this PR's diff against that approved diff — the content is byte-identical (only hunk offsets from the rebase onto main at 881fa58, with the #292 conflict resolved in context only). A re-land of the approved change needs no fresh approval.

Product

A steward that must not merge yet (a spec saying "do not merge before X is Done") had only free-text waitingOn, so once the gate was met the plugin filed its Merge item and the effort read "needs you" with a Merge button that would have merged early. This adds steward_report { mergeBehind: [keys] }: a stored, validated hold that suppresses the plugin-filed Merge item while it stands, ranks the effort as held with the steward's wait text, counts as a live wake source (no stall escalation), and lifts itself with a note and a wake when every named binding has merged or ended — after which the safety net returns. I searched the plugin and the repo for any existing merge-hold mechanism (hold/holdBehind are start-work holds; mergeBehind appears nowhere on main) and there is none; the need is real and this is the minimal structured version. Scope matches the ticket exactly: one plugin, the playbook line deliberately in a separate bb-gate PR (#101, already merged).

Tested

  • Ran: npm install --include=dev --legacy-peer-deps + npm run typecheck + npm test in bb-plugins/plugins/stewards — all pass (31 files, 1433 tests; stewards is in the CI matrix, so CI also ran it, and both are green on this head).

The migration is append-only (MERGE_BEHIND_MIGRATIONS at the end of MIGRATIONS, defaulted '[]', snapshot hash appended after the previous last line with only its comma changed), and both lift paths (edge via releaseBehind's cascade on merge or end, and the level-triggered reconcile check) mirror holdBehind's. No blockers, no suggestions.

Looks good.

— from bb thread thr_3xh45u2k3t

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 3102eef from the Stewards page

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

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved 3102eef, checks green, approved by the owner, the owner acked the product.
merge commit 80a4d2e
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

trotterdylan added a commit that referenced this pull request Nov 9, 2026
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 added a commit that referenced this pull request Nov 9, 2026
…m (BB-257) (#296)

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.

This is a re-land of the reviewed [#293](#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 [#295](#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.



[#297](#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](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 #290/#291/#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.
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