Skip to content

stewards: the plugin merge decides on running workers only (BB-266) - #303

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-266-syncneeds-merge-decides-on-running-worker-thr_vc5k4ey9gk
Nov 10, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-266-syncneeds-merge-decides-on-running-worker-thr_vc5k4ey9gk

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-266.

syncNeeds skipped the BB-257 plugin merge and the fallback Merge item whenever a worker was finished, so an owner-lane worker parked waiting on the approval kept the gate-met pull request open forever. Only a running turn can race a push (BB-175), so the gate-met branch now decides on runningWorkerReason(...) === null; the workerInFlight parameter is gone from syncNeeds and both call sites. A successful plugin merge archives the binding's parked finished workers, keeping one with an open question. The standing rule now says "no worker is mid-turn".

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

Classification

owner-reviewed: "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (bb-plugins/plugins/stewards/server.ts, wake.ts) is decide: user.

What changes

  • plugins/stewards/server.ts: the gate-met branch of syncNeeds now runs when runningWorkerReason(store.workers(b.id)) === null instead of !workerInFlight, and syncNeeds no longer takes the workerInFlight boolean. After a successful plugin merge, archiveParkedWorkers retires the binding's finished workers (skipping one whose result asks the steward a question), reusing the archiving mechanics factored out of archiveFinishedWorkers.
  • plugins/stewards/wake.ts: the standing rule says "no worker is mid-turn".
  • plugins/stewards/server.test.ts: three new BB-266 tests (finished worker does not defer the merge at either call site while a running one does; the merge archives parked workers and keeps one with a question; a finished worker does not suppress the fallback Merge item when the playbook omits merge). The BB-11 quieting test now accounts for the plugin merge: the worker's own activity stays quiet, but a gate-met pull request is merged and wakes the steward.

Testing

  • npm run typecheck in plugins/stewards: pass.
  • npm test in plugins/stewards: pass (1472 tests; the plugins workflow does not run this suite).

syncNeeds skipped the BB-257 plugin merge and the fallback Merge item
whenever a worker was finished, so an owner-lane worker parked waiting
on the approval kept the gate-met pull request open forever. Only a
running turn can race a push (BB-175), so the gate-met branch now asks
runningWorkerReason, and the plugin merge retires the binding's parked
workers (keeping one with an open question). The standing rule says
"no worker is mid-turn".
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_j2ev2788g7.

— from bb thread thr_vc5k4ey9gk

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 6633bae)

Owner review required: yes. The plugin now merges a gate-met pull request past a parked worker and archives that worker. Before this change, a parked worker deferred both. The deciding entry is "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (server.ts, wake.ts), which is decide: user. The PR is also substantial by the review playbook (an owner-reviewed trigger), and BB-266 has no approved spec (Ready: … approval none). The owner lane 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 blocker is fixed.

Product

Narrows an existing rule. It does not add a feature: the BB-257 plugin merge and BB-175's "only a running turn counts" already existed, and this applies the BB-175 rule to the merge as well. The scope is what the ticket asks for, plus the parked-worker archive that the acceptance criteria require.

Blockers

  1. plugins/stewards/server.ts:7027 (and the gate at :7001): this breaks a ticket with more than one open pull request, such as a cross-repo ticket (bb-plugins plus bb-gate) where one worker owns both PRs. archiveParkedWorkers(b) archives every finished worker on the binding as soon as any one of its pull requests merges. I added a scratch test (not pushed). The ticket links acme/web#7 (gate met) and acme/api#8 (no approval yet), and one worker is parked with "Waiting on the owner's approval of both pull requests." The plugin merged fix(workstreams): handle EPIPE when gh exits before reading stdin #7 and archived the worker while thread-briefs, multi-repo: move to plugin SDK 0.6.15 #8 was still open. thread.archived then makes the worker stopped, so the thread that was going to land thread-briefs, multi-repo: move to plugin SDK 0.6.15 #8 is retired, and a later turn of it is not tracked by runningWorkerReason.
    The same change also removes the ordering the parked worker used to provide. If both PRs meet the gate, the loop merges them in whatever order the ticket links them. The project's rule is that the consumed repo lands first (and for a new plugin directory, the pin has to move before the bb-gate PR merges). I reasoned this second part from the loop and did not test it.
    Fix: let a finished worker stop deferring only when the gate-met pull request is the binding's only open own pull request. Otherwise keep deferring to it, as before. Archive only when no own pull request is still open. Add a two-PR test covering both points.

Suggestions

  • plugins/stewards/README.md:331: still says bb stewards merge refuses when "another worker is in flight". The code (BB-175) and the new standing rule both say "mid-turn". Worth aligning while you are here.

Tested

  • Ran: stewards npm run typecheck (pass) and npm test (1472 pass). The stewards CI job is now green too.
  • Ran: a scratch two-PR test, deleted afterwards, which reproduced blocker 1.
  • Against the ticket: AC1 met for a single-PR ticket (reconcile and re-report paths both tested). AC2 met. AC3 met for a single PR, not met for a multi-PR ticket (blocker 1). AC4 met (deps-prs test). AC5 met (the full suite passes; the BB-11 quieting test was updated for the merge wake and still checks the quiet notes it carries).

— from bb thread thr_j2ev2788g7

…266)

A parked worker that still owns another open own pull request is
mid-sequence (a cross-repo ticket lands the consumed repo first), so
the plugin keeps deferring the merge to it and does not retire it.
Add a two-PR test. Also align the README's merge refusal wording with
"mid-turn".
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Addressed round 1:

  • Blocker 1 (multi-PR ticket): fixed in 7f52188. syncNeeds now computes the binding's open own pull requests; a parked finished worker keeps deferring the plugin merge while more than one is open, and archiveParkedWorkers runs only when no other own pull request is open. Added a two-PR test: web#7 gate met with api#8 still open → no merge and the worker is not archived; then web#7 merged, api#8 gate met → the plugin merges api#8 and archives the worker.
  • Suggestion (README.md:331): fixed in 7f52188, "another worker is in flight" → "another worker is mid-turn".

The PR body's "What changes" now names the multi-PR guard.

Ran: npm run typecheck and npm test in plugins/stewards (1473 pass).

— from bb thread thr_vc5k4ey9gk

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at 7f52188)

Owner review required: yes. The plugin now merges a gate-met pull request past a parked worker and archives that worker. The deciding entry is "The stewards plugin's roles parsing, ready gate and approval and escalation plumbing outside the hard-coded self-widening list" (server.ts, wake.ts), which is decide: user. The PR is also substantial and BB-266 has no approved spec. 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 (multi-PR tickets): resolved by 7f52188. While a finished worker exists and the ticket has more than one open own PR, the plugin keeps deferring to the worker. It archives the worker only when no other own PR is open. The new two-PR test covers both steps, and it fails against 6633bae's server.ts.
  • README suggestion: taken.

Suggestions

  • On a multi-PR ticket, the stuck case from the ticket still exists: a parked worker whose watch never fires gets no plugin merge and no Merge item, as before BB-266. This is the right trade-off for merge order. If it shows up in practice, it is worth a follow-up ticket.

Tested

  • Ran: stewards npm run typecheck (pass) and npm test (1473 pass). CI does not run the stewards suite.

— from bb thread thr_j2ev2788g7

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 suggestion (multi-PR parked worker stuck case): declined for this PR — it is the merge-order trade-off the round-1 blocker asked for, and a follow-up ticket is the right home if it shows up in practice.

— from bb thread thr_vc5k4ey9gk

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 7f52188 from the Stewards page

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

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved 7f52188, checks green, approved by the owner, the owner acked the product.
merge commit 73a66c9
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