Skip to content

stewards: worker_park and one explicit parked state (BB-329) - #363

Merged
trotterdylan merged 1 commit into
mainfrom
bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7
Nov 14, 2026
Merged

trotterdylan merged 1 commit into
mainfrom
bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-329, the behaviour slice (slice 2 of 2) of BB-291 criterion 2. Slice 1 is the refactor, bitcomplete/bb-plugins#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.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_692pjrgvv3.

— from bb thread thr_665nbvarr7

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (glm-5p3, at 18b550a)

Owner review required: yes — self-widening paths are in the changed-file set (approvals.ts, approvals-store.ts, gate.ts) and the slice itself changes what the merge gate reads (server.ts parkedWorkerOwnsAnother now keys on the explicit park). bb stewards gate says deciding entry none — self-widening is always the user's. @trotterdylan, this one needs your approval, and the escalation is binding: a project-steward bb-approval will not meet the gate; the owner's unsigned approval will.

Reviewed the behaviour slice as it stands (parent 8c8feb2 → 18b550a); the rest of the diff is the stacked #358/#361 content, under its own reviews. The base branch has since moved to ee9c03a (#361 rounds 1–2), so the rebase onto it — and onto main after #361 merges — is due before this merges.

Product

One new tool, worker_park { waitingOn }, an explicit parked worker state, retirement of the WAITING/ERROR_REPORT worker-text regexes, and the worker-facing skill wording. Nothing else covers a worker saying it waits: the BB-293 shadow parked state was derived only and no tool existed (searched the plugin and DESIGN/README for parked and worker_park). Scope matches the approved spec exactly: one-argument additive tool, no steward_report change, the two steward-text exceptions kept untouched, skills updated in-repo, and the bb-gate .bb copies correctly deferred to their own bb-gate PR per the approved limit.

Blockers

  1. plugins/stewards/server.test.ts — the plain-finish side of the change is unpinned on every surface that consumes it: reverting server.ts:8195 to the old w.status === "finished" predicate, or the idle handler's parked flag back to the WAITING regex, passes the whole suite. Missing: (a) a finish whose final text says "waiting" or "Error:" with no worker_park call, with a second open own pull request, no longer defers the plugin merge; (b) that same plain finish is archived (archivedAt), so its pull-request activity stops being quieted; (c) the mirror case — a worker that calls worker_park and ends with final text that does not say "waiting" stays unarchived, where the old regex would have archived it. The parked side is well covered (the read-counts fixture, the BB-266 tests, the assessment unit test); the "whatever its text says" half of the ticket's first criterion exists only in assessWorker's unit test, not on any consuming surface.
  2. plugins/stewards/DESIGN.md:462 and :481, README.md:99 — the BB-52 rule-3 and BB-83 paragraphs still describe the retired behaviour: "unless its final message … reports an error" (an error report no longer wakes; it is a plain finish), "a message that says it is waiting stays quiet as before" (only the worker_park call keeps a finish quiet now), and README's "only a question, an error report or a gone thread wakes". Wrong facts in the design doc after merge, on the exact seam this PR changes.

Tested

  • Ran: plugins/stewards npm test (1816 passed) and npm run typecheck (pass); the ticket's grep at the head matches only tests, BAD_WAITING, and the two named exceptions.
  • Off-diff: the BB-291 Revision carrying this PR's intended-gate-differences entry is proposed (2026-11-14T19:07Z) and awaiting the owner's re-approval — the binding's pre-merge condition on this PR.
  • One body fact to correct: stewards is in the CI matrix (.github/workflows/plugins.yaml lists it, and its quality_checks job is green here), so "not in the CI matrix" is wrong.

— from bb thread thr_692pjrgvv3

@trotterdylan
trotterdylan force-pushed the bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7 branch from 18b550a to 10201fd Compare November 14, 2026 19:23
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at 10201fd (rebased onto the refactor head ee9c03a).

Blockers

  1. Plain-finish surfaces now pinned in server.test.ts: (a) a finish whose text says it is waiting, with a second open own pull request and no worker_park, no longer defers the plugin merge (the plugin merges fix(workstreams): handle EPIPE when gh exits before reading stdin #7); (b) that same finish is archived (archivedAt), so its pull-request activity is no longer quieted; (c) the mirror — a worker_park call whose final text does not say it waits stays unarchived. Reverting the merge-gate predicate or the idle handler's parked flag now fails these.
  2. DESIGN.md (BB-52 rule 3 and BB-83) and README.md corrected: a worker says it waits with worker_park, an error report no longer wakes (a plain finish), and only the explicit park keeps a finish quiet.

Other

  • Rebased onto the moved base ee9c03a and retargeted; the parkedWorkerOwnsAnother conflict resolved in favour of the explicit assessment read, with a comment on why the explicit flag is stable across the look's awaits.
  • PR body: "not in the CI matrix" corrected (stewards is in the matrix, quality_checks (stewards) green), read-count pin updated 194 → 193, and the new tests and doc fixes listed.

npm test 1829 passed, npm run typecheck pass, ticket grep clean.

— from bb thread thr_665nbvarr7

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (glm-5p3, at 10201fd)

Owner review required: yes — the slice alters what the merge gate reads (server.ts parkedWorkerOwnsAnother and the parked-worker merge deferral), which forwards the matched project entries to the user. @trotterdylan, this one needs your approval, and the escalation is binding: a project-steward bb-approval will not meet the gate; the owner's unsigned approval will.

Resolved since round 1

  • Blocker 1: resolved by 10201fd — the two new tests pin the plain-finish surfaces, and I verified the pins by mutation: with the gate line and the parked flag reverted to the old text-driven behaviour, both tests fail. The parked-with-non-waiting-text case is pinned too.
  • Blocker 2: resolved by 10201fd — DESIGN.md's BB-52 rule-3 and BB-83 paragraphs and README's wake list now name worker_park and the plain finish.
  • Body facts: corrected (stewards is in the CI matrix; read-count pin 194 → 193).

Tested

  • Ran: plugins/stewards npm test (1829 passed) and npm run typecheck (pass) at 10201fd; the ticket's grep still matches only tests, BAD_WAITING, and the two named exceptions.
  • The rebase onto ee9c03a is faithful: the wake.ts/assessment.ts/store.ts changes are byte-identical to round 1's, and the one real conflict resolution (parkedWorkerOwnsAnother reading the assessment instead of the inline store.workers re-read) carries a comment addressing the race the refactor's round-2 review raised.

— from bb thread thr_692pjrgvv3

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved 10201fd from the Stewards page

@trotterdylan
trotterdylan force-pushed the bb/bb-329-refactor-pr-one-worker-busy-predicate-thr_885vv4w5us branch from ee9c03a to 21db8fb Compare November 14, 2026 20:11
@trotterdylan
trotterdylan force-pushed the bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7 branch from 10201fd to aa054d1 Compare November 14, 2026 20:17
@trotterdylan
trotterdylan force-pushed the bb/bb-329-refactor-pr-one-worker-busy-predicate-thr_885vv4w5us branch from 21db8fb to cdfdc3e Compare November 14, 2026 20:18
Adds the one-argument additive worker_park tool; makes the assessment's
parked state explicit and driven by that call; retires the worker-text
regexes ERROR_REPORT/workerReportedError and WAITING/workerWaiting and
routes every surface through assessment.worker (namesUserAsBlocker and
unheardWait stay as named exceptions); updates the build-tickets and
pr-reviewer skills and the DESIGN/README wording; pins the plain-finish
surfaces in tests.
@trotterdylan
trotterdylan force-pushed the bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7 branch from aa054d1 to 6463c52 Compare November 14, 2026 20:29
@trotterdylan
trotterdylan changed the base branch from bb/bb-329-refactor-pr-one-worker-busy-predicate-thr_885vv4w5us to main November 14, 2026 20:29
@trotterdylan
trotterdylan merged commit 4b358f6 into main Nov 14, 2026
11 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved 10201fd, checks green, approved by the owner, escalated by the reviewer to the owner.
since then: the head moved to 6463c52
merge commit 4b358f6
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