Repository navigation
stewards: route the worker-busy and liveness predicates through the assessment (BB-329) - #361
Conversation
|
Independent review running in bb thread @thread:thr_gpf6j2kz2z. — from bb thread thr_885vv4w5us |
Review round 1 (Claude Opus 5.5, at 8c8feb2)Owner review required: yes. This routes the merge gate's worker-busy input ( Blockers
Tested
— from bb thread thr_gpf6j2kz2z |
0b85b73 to
0931fe0
Compare
8c8feb2 to
1450233
Compare
|
Round 1 addressed at 1450233 (rebased onto #358's new head 0931fe0, now main-based).
— from bb thread thr_885vv4w5us |
Review round 2 (Claude Opus 5.5, at 1450233)The PR body at this head still says Blockers
Resolved since round 1
Tested
— from bb thread thr_gpf6j2kz2z |
1450233 to
ee9c03a
Compare
|
Round 2 addressed at ee9c03a (rebased onto #358's new head 7bdfc7f).
— from bb thread thr_885vv4w5us |
Review round 3 (Claude Opus 5.5, at ee9c03a)Owner review required: yes. This routes the merge gate's worker-busy input without changing what the gate reads. Decide-list entry "The stewards plugin outside its authority seams … forwarded to the user when it alters what the merge or spec gate reads" is Resolved since round 2
Tested
Looks good. — from bb thread thr_gpf6j2kz2z |
ee9c03a to
21db8fb
Compare
21db8fb to
cdfdc3e
Compare
|
Merged: owner-reviewed lane, reviewer approved ee9c03a, checks green, approved by the project steward. |
Implements [BB-329](https://linear.app/bit-complete/issue/BB-329/stewards-one-worker-busy-predicate-and-an-explicit-parked-state-bb-291), the behaviour slice (slice 2 of 2) of BB-291 criterion 2. Slice 1 is the refactor, [#361](#361); this PR is **stacked on that branch** and retargets to `main` once #361 merges. > **Restart note.** Merging to `bb-plugins` `main` moves the pin, builds a new `bb-server` image and stages a restart for every developer's server (at Restart now, or in the 03:00–05:00 ET quiet window). ## Classification owner-reviewed: a new tool and the merge-gate/authority seam (`assessment.ts` worker state, the parked-worker merge deferral), the `bigDecisions`/`prGate`-adjacent surface. The reviewer classifies via `bb stewards gate`. ## What changes - **New tool `worker_park { waitingOn }`** (one additive string argument). It sets only the calling worker's own park on its own open binding, files nothing for the user, and meets no gate. A refused call (a non-worker thread, an ended binding) returns an error, never a silent no-op. The worker's next turn (`thread.active`, a retry) clears the park. - **`assessment.worker.parked` is now explicit**, driven by that call. A `finished` worker that did not park is a new `finished` state, not `parked`. `inFlight` is unchanged (running-or-finished); `reason` is unchanged. - **Retires the worker-text regexes** `ERROR_REPORT`/`workerReportedError` and `WAITING`/`workerWaiting`, and every consumer: the finish handler, the quiet-archive, the parked-worker merge deferral, and the idle wake. Every surface now reads `assessment.worker`. - **Skills and docs**: `build-tickets` and `pr-reviewer` tell a worker to end a waiting turn with `worker_park` instead of relying on prose; `DESIGN.md` (BB-52 rule 3 and BB-83) and `README.md` are corrected where they still said a final message's error report or "waiting" text keeps a finish quiet. - Store: one append-only migration, `ALTER TABLE workers ADD COLUMN parked_waiting_on TEXT` (appended at the end of `MIGRATIONS`, `migrations.snapshot.json` extended). ### Predicates, flags, regexes and silent branches retired - `wake.ts` `ERROR_REPORT` / `workerReportedError` — deleted. - `wake.ts` `WAITING` / `workerWaiting` — deleted. - `server.ts` finish handling: `workerReportedError(result)` and `workerWaiting(result)` — replaced by the explicit `worker.parkedWaitingOn`. - `archiveFinishedWorkers`'s `!workerWaiting(w.result)` filter — replaced by `w.parkedWaitingOn === null`. - `archiveParkedWorkers`'s "any finished worker" filter — narrowed to `w.parkedWaitingOn !== null`. - `server.ts` `parkedWorkerOwnsAnother`'s `store.workers(b.id).some(w => w.status === "finished")` — replaced by `assessment.worker.parked`. - No silent branch: a refused `worker_park` returns `isError`, and the parked flag is written by one method (`store.parkWorker`). ### Named exceptions (unchanged, per the project steward's amendment) - `namesUserAsBlocker` (BB-213 refusal) stays in `reconcile.ts` and its `steward_report` refusal. - `unheardWait` on steward text stays in `reconcile.ts`, read by the wake flags and the board flags. - `ops.ts`'s `BAD_WAITING` is an unrelated k8s reason set. - Check: `grep -nE 'WAITING|ERROR_REPORT|unheardWait|namesUserAsBlocker' plugins/stewards/*.ts` matches only tests, `BAD_WAITING`, and the two named exceptions. Neither exception's check got weaker. ### Intended gate differences (proposed as a Revision on BB-291) 1. **A worker finish with no `worker_park` call is a plain finish**, whatever its text says ("waiting", "parked", "awaiting" in prose changes nothing). It is archived and no longer keeps the binding non-idle. **In-flight case:** a worker started before the restart (or whose prompt predates the new skill) finishes without the call, so a "waiting" final message becomes a plain finish — it is archived and its pull-request activity is no longer quieted by it. 2. **`workerReportedError` is retired, not replaced.** A final message beginning "Error:" / "Unable to" / "I could not" no longer wakes the steward; it is a plain finish. A hard failure still arrives through `thread.failed`. (The spec's shape amendment retired the regex rather than replacing it.) 3. **`parkedWorkerOwnsAnother` reads explicit parked.** A plain-finished worker with a second open own pull request no longer defers the plugin merge; only a worker that called `worker_park` does. Previously any `finished` worker deferred. 4. **`archiveFinishedWorkers` no longer keeps a worker for its final text**, and `archiveParkedWorkers` only retires explicit parked workers; the quiet-archive's predicate is the same in spirit but keyed on the call. 5. **Derived `state`**: a finished worker that did not park is named `finished` (new value) rather than `parked`. `parked` is the explicit sub-state. `inFlight` and `reason` are unchanged. 6. **Read count**: the fixture falls 194 → 193 store reads (48.5 → 48.25 per reconcile): `parkedWorkerOwnsAnother` now reads the assessment the reconcile already built instead of calling `store.workers(b.id)` again. No source calls added. ## `bb stewards divergences` (before starting) The log shows worker-state rows only in the parked-worker shape: `workerInFlight` `in-flight → parked`, `runningWorkerReason` `not-mid-turn → parked`, `idleInActiveStage` `idle → parked`, `hasLiveWakeSource` `no-live-source → parked`, across the live bindings that hold a `finished` worker (the known BB-292 parked-worker fixtures and the parked workers of other bindings). No other worker-state disagreement. The `noWakeSource` rows are the separate surface BB-247 introduced, unchanged by this PR. ## BB-291 Baseline (recorded 2026-11-14) - Live: 18.8 store reads / 1.4 source calls per reconcile; 16.2 store reads / 0 source calls per wake. - Handler maxima: `stewardsBoard` 1513 ms, `stewardsSidebar` 3271 ms, `stewardsRing` 2 ms. - Fixture (`read-counts.test.ts`, 4 bindings): 45.75 reads per reconcile, 15 per wake, 3.0 source calls per reconcile, 0 per wake. This PR: **no added network reads.** The derivation reads only the worker row the reconcile already holds (`parkedWaitingOn` is a column on it). The fixture is now **193 store reads / 4 = 48.25 per reconcile, 12 source calls / 4 = 3.0, wake 15 / 1 = 15 reads, 0 source calls** — one store read *fewer* than the refactor branch (194), from reading the assessment instead of `store.workers(b.id)` a second time. The `worker_park` tool is one column write. The live handler maxima are unchanged in kind; the reconcile gains no read and the tool is not on a handler path. (`live` numbers are the recorded baseline; the live server runs the pre-change build, so they are not re-measured here.) ## Testing - `npm test` in `plugins/stewards`: pass (1829 tests; also run by the CI matrix's `quality_checks (stewards)` job, green on this PR). - `npm run typecheck`: pass. - `read-counts.test.ts` pins the new fixture (193/12/4, wake 15/0). - `store.test.ts` pins the append-only migration (the new group is last; `migrations.snapshot.json` extended). - New tests: a parked worker and a second open own pull request in the gate-met fixture; a plain finish whose text says it waits, with a second open own pull request, is archived and does not defer the plugin merge; a `worker_park` call with final text that does not say it waits stays unarchived; `worker_park` on a non-worker thread and an ended binding refused; the next turn clears the park; a plain finish with "Error:" text is not a park. - `grep -nE 'WAITING|ERROR_REPORT|unheardWait|namesUserAsBlocker' plugins/stewards/*.ts` matches only tests, `BAD_WAITING`, and the two named exceptions. - Not tested: the live handler latencies (the live server runs the pre-change build). ## Stacking Base is `bb/bb-329-refactor-pr-one-worker-busy-predicate-thr_885vv4w5us` (#361), not `main`. Rebase onto it whenever it moves; after #361 merges, rebase onto `main` and retarget before merging (no new approval needed). The head branch is not deleted (`--delete-branch` is not used): BB-328's PR is stacked on this one until retargeted.
Implements BB-329 (BB-291 criterion 2), slice 1 of 2: the pure refactor. Every binding-level surface that decides a worker is busy now reads the one derivation in
assessment.ts(assessWorker,assessIdle,assessLiveWakeSource); the predicate call sites inserver.tsare gone. No behaviour changes, no test changes, no regexes touched (they are slice 2).Sibling PR: the behaviour PR (slice 2) follows on this branch — it adds the one-argument
worker_park { waitingOn }tool, the explicitparkedstate, and removes theWAITING/ERROR_REPORTworker-text regexes. This slice must land first.Classification
owner-reviewed: it routes the worker-busy predicate that the merge gate (
mayMergePullRequest), the idle wake, thesyncNeedsmerge deferral, the board's Merge actionability and the schedule's at-work judgement all read, and it touchesbb-plugins/plugins/stewards/server.ts. The decide list's matched entry is "The stewards plugin outside its authority seams … forwarded to the user when it alters what the merge or spec gate reads" (decide: project); the change does not alter what the merge or spec gate reads, so the project steward approves.approver=project(round 1 corrected the earlierapprover=owner).What changes
assessment.tsgains two exported entry points and keeps the existing one;server.tsreads them:assessWorker(already existed) — the one worker-state derivation:state,running,parked,failed,inFlight,reason.assessIdle(idleBinding, observed, now)— the one idle derivation (BB-83);assessand the reconcile's idle wake both call it.assessLiveWakeSource(sources)— the one live-wake-source derivation (BB-154);assessand the report path'sliveWakeSourceForboth call it.Retired predicate call sites
server.ts::4942the reconcile'sconst workerInFlight = anyWorkerInFlight(workers)→assessment.worker.inFlight(falling back toassessWorker(workers).inFlightwhen the assessment failed).:5144the start-now backstop!anyWorkerInFlight(store.workers(b.id))→!assessWorker(store.workers(b.id)).inFlight.:8351syncNeeds' worker-mid-turn merge deferralrunningWorkerReason(store.workers(b.id)) !== null→assessWorker(store.workers(b.id)).reason !== null.:8445the gate-met-stuckunattendedcheck →assessWorker(store.workers(b.id)).reason === null.:9574mayMergePullRequest'sbusy→assessWorker(…).reason.:12289needView's Merge actionabilitybusy→assessWorker(store.workers(b.id)).reason.:4982the idle wakeidleInActiveStage(…)→assessIdle(…).:3225liveWakeSourceFor'shasLiveWakeSource(wakeSourcesFor(…))→assessLiveWakeSource(wakeSourcesFor(…)).:3139atWorkWithRead'srunninginline.some((w) => w.status === "running")→assessWorker(store.workers(b.id)).running.:3159conflictsFresh'srunningWorkerinline filter →assessWorker(store.workers(c.with.id)).running.:7707the schedule withdrawal's "the work has started" inline check →assessWorker(store.workers(b.id)).running.:8199parkedWorkerOwnsAnother's inline.some((w) => w.status === "finished")is left inline (not routed) in this slice.assessWorker(…).parkedis!running && some(finished), while this capturessome(finished)before the per-pull loop's awaits; a running worker that ends its turn inside that window would flip the answer and could merge one of several open own pull requests out of order (the BB-266 guard). The behaviour PR, which adds the explicitparkedstate, reshapes it.:11589the report path'sstartDueinline!store.workers(b.id).some((w) => w.status === "running")→!assessWorker(store.workers(b.id)).running.server.tsno longer importsanyWorkerInFlight,runningWorkerReason,idleInActiveStageorhasLiveWakeSource.reconcile.tsandwake-source.tskeep them for their unit tests and for the shadowcompare, which still calls the old predicates to log any disagreement; that is deliberate, so a bug in the new derivation is still caught by the soak. Per-worker checks (workerInFlight(worker)on one worker) and display lists/counts (runningWorkers, titles) are not binding-level busy decisions and stay.No predicate, flag, regex or silent branch is retired in this slice.
WAITING,ERROR_REPORT,unheardWaitandnamesUserAsBlockerare untouched; the explicitparkedsemantics and the regex removal are the behaviour PR. No new tool, nosteward_reportshape change, nosource-contract.tschange, no store migration.Intended gate differences
None. The routed functions return exactly the old answers today:
assessWorker(ws).inFlightisanyWorkerInFlight(ws),assessWorker(ws).reasonisrunningWorkerReason(ws),assessWorker(ws).runningis the inline.some(status === "running"),assessWorker(ws).parkedis the inline.some(status === "finished")where it is read (the branch after no worker is running),assessIdleisidleInActiveStage,assessLiveWakeSourceishasLiveWakeSource. No consumer's result changes.Divergences (
bb stewards divergences, checked before starting)279 rows. The worker-state rows —
workerInFlight46,runningWorkerReason46,idleInActiveStage28,hasLiveWakeSource26 — are 146 rows, and every one has at least onefinished(parked) worker in itsinputs.states(finished,finished,stopped,stopped,finished, …): the known BB-292 parked-worker fixtures, nothing else. The remaining rows are the known fixtures too:noWakeSource(the report-time flag vs the rows),approvals.pageRefusal, andapprovals.gate(the intended unification rows plus the one BB-321 bb-plugins#330 shadow defect from 2026-11-11, never seen again). No unexpected worker-state row, so the slice proceeded.Testing
npm run typecheckinplugins/stewards: pass.npm testinplugins/stewards: pass (39 files, 1815 tests; the plugin suite is not in the CI matrix, so it was run here). Re-run after routing the round-1 sites: pass.git diff --name-only origin/mainlists onlyplugins/stewards/assessment.tsandplugins/stewards/server.ts.read-counts.test.ts(the fixture baseline): pass, unchanged at 191 store reads / 12 source calls over 4 reconciles, 15 reads per wake, 0 source calls per wake. The existing gate-met fixtures (a parked worker and a second open own PR) pass unchanged.Latency / load (BB-291 Baseline, recorded 2026-11-14)
read-counts.test.ts): baseline 45.75 store reads per reconcile (183), 15 per wake, 3.0 source calls per reconcile (12), 0 per wake. Measured here: 47.75 (191/4), 15, 3.0 (12/4), 0 — the rise from the baseline is BB-323/BB-327 (archiveWorkers' reviewer lookup, andassessBinding's remembered-delegate reads), already onmain, not this change. This change adds and removes no read: every routed call reads the same rows as the predicate it replaced (and the reconcile's idle keeps its own reads, which is why the fixture count is unchanged). No new store read, no new network read.stewardsBoard1513 ms,stewardsSidebar3271 ms / last 12 ms,stewardsRing2 ms) are live-server handler times and cannot be re-measured from this worker; the change adds no work per handler call beyond the same rows already read, so no regression is expected.— from bb thread thr_885vv4w5us