Skip to content

stewards: every merge-gate surface reads the stored assessment (BB-322) - #355

Merged
trotterdylan merged 4 commits into
mainfrom
bb/bb-322-merge-gate-surfaces-read-the-stored-asses-thr_ewyfnr8k4z
Nov 14, 2026
Merged

trotterdylan merged 4 commits into
mainfrom
bb/bb-322-merge-gate-surfaces-read-the-stored-asses-thr_ewyfnr8k4z

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-322 (BB-291 criterion 1): the stored per-binding assessment becomes the one source for the merge gate. prGate is now called from exactly one site outside the assessment module.

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).

Classification

owner-reviewed: it moves where the merge gate is decided and touches approvals.ts (the decide-list trigger "The stewards plugin outside its authority seams … forwarded to the user when it alters what the merge gate reads"). approver=owner; the project steward's bb-approval does not meet this one, the owner's unsigned approval does.

What changes

One new module, assessed-gate.ts, owns the gate:

  • pullGate — the single prGate call site outside assessment.ts.
  • assessedPullGate — the decide-list mark plus the BB-321 forwarded-owner rule, used by assessment.ts and the refresh.
  • gateInputKey — a fingerprint of everything prGate reads, so a reviewer marker, an approval, a check result or the base state that changes at the same head sha is never read as the old answer (BB-210).
  • assessedGate(store, binding, pull, at, bigDecisions?) — reads the stored assessment's gate for the pull and, when it is missing or not for the pull's current head sha (or its fingerprint changed), computes it and stores it. Missing or stale never counts as met (fail closed). Its fallback mark comes from the pull's changed files under the binding's decide list.

The stored AssessedGate is now the full PrGate plus pull/met/key, so every surface reads the same fields it used to compute.

Retired predicates / branches

approvals.ts:

  • :146 recordProjectDecision's escalation/product refusal probe → assessedGate.
  • :243 approveOwnerReviewedPull's escalation/product refusal probe → assessedGate.
  • :374 syncPullApproval's preliminary gate (the lane/needs decision) → the assessment's gate, passed in from the reconcile or read via assessedGate.
  • :383 syncPullApproval's second gate, recomputed with the decide mark from pullChangedFiles → retired: the assessment already carries the decide mark (files are still read for the item's listing).
  • :483 approvePrPageAction's needsOwnerApproval gate → assessedGate.

server.ts:

  • :3204 pullWatch's gate-met check for the pull-request wake source → assessedGate.
  • :4884 the reconcile's per-pull gateMetPulls loop → derived from the one assessment.
  • :6911 the routed escalation's escalated flag → assessedGate.
  • :9115 gateReport (bb stewards gate) → assessedGate.
  • :9414 mayMergePullRequest (the Merge button and bb stewards merge) → assessedGate.
  • :11264 steward_report's approve-pr/merge filing → assessedGate.
  • :12109 needView's board actionability → assessedGate.

wake.ts:

  • :364 entityLines's Lane gate line → the stored assessedGates (WakeInput carries them).

assessment.ts:

  • :146/:155 the probe and the BB-321 re-probe → assessedPullGate.
  • :255 compare's approvals.gate and approvals.pageRefusal comparisons are retained (read through pullGate), so the soak still logs any disagreement between the consumer's answer and the predicate it retired. A new approvals.gate row is a real difference, not a fixture; no characterization test was rewritten.

Surface-level result changes (the intended unification)

The assessment's gate carries the decide-list mark and the recorded project approvals, so recordProjectDecision, approveOwnerReviewedPull, syncPullApproval, approvePrPageAction, pullWatch, gateReport, mayMergePullRequest, needView, the routed escalation, the wake and steward_report all read one gate. The known BB-292 #2 difference is the intended unification: for a project entry with a recorded bb-approval, the old approvals path asked the owner and the assessment is met. The retained approvals.gate comparison logs it; it is not a new row.

Two surfaces needed care and are fixed in this head:

  • A project-entry pull the project steward forwarded to the owner (BB-192) is the owner's from the forward on, not only after they approve. assess keys on the open user-routed approval escalation (resolutionKind: "approve-decline"), so the page's Approve acts and the reconcile does not reroute the escalation back.
  • A pr/review binding's own entity is a pull request, not a linked one, so assessBinding now gates it too. Without it the assessment held no entry, the approval sync fell back to the owner's mark and changed the routing, and the wake said the assessment was unavailable.

No migration, no store.ts change, no binding/plugin-id change, no source-contract.ts change.

Testing

  • npm run typecheck in plugins/stewards: pass.
  • npm test in plugins/stewards: pass (39 files, 1794 tests; plugins is not in the CI matrix for this suite, so it was run here).
  • assessed-gate.test.ts (new): the single read/refresh, a stale head sha that never returns a met gate, project-mark approved, the owner's unsigned approval on a project-placed pull (BB-321), a declined marker, and null/empty changed files — each gate-met fixture with a parked worker and a second open own pull request.
  • server.test.ts: a project-entry pull the project steward forwarded to the owner is actionable on the board and the page approves it (blocker 1); a review binding's own pull request routes a project entry to the project steward and its wake names the gate (blocker 2).
  • grep -rn 'prGate(' plugins/stewards/*.ts (non-test) outside assessment.ts and the prGate definition in gate.ts shows exactly one call site (assessed-gate.ts).

Latency / load (BB-291 Baseline)

  • Fixture, 4 bindings (BB-297, read-counts.test.ts): store reads per reconcile 47.5 → 45.75 (190 → 183 over 4 reconciles); source calls per reconcile 3.0 (12), unchanged; store reads per wake 16 → 15; source calls per wake 0. A reduction, not a regression: syncPullApproval no longer re-reads the recorded project approvals, and the wake no longer re-reads them.
  • Live baseline (recorded 2026-11-14): 18.8 store reads and 1.4 source calls per reconcile; 16.2 store reads and 0 source calls per wake. The change retires reads rather than adding any per reconcile/wake, so it stays at or below baseline.
  • Handler times (stewardsBoard max 1513 ms, stewardsSidebar max 3271 ms / last 12 ms, stewardsRing max 2 ms) are live-server handler times and cannot be re-measured from this worker; the change adds no new work per handler call beyond the same stored-assessment read the reconcile already performs, so no regression is expected. The deployed bb stewards stats will carry the post-merge numbers.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_ewyfnr8k4z.

— from bb thread thr_ewyfnr8k4z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_imrjxzbph9 (the earlier reviewer was stopped and replaced).

— from bb thread thr_ewyfnr8k4z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_vkefwtycjt.

— from bb thread thr_ewyfnr8k4z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 64e96f0)

Owner review required: yes. This change moves what decides a merge, and it touches approvals.ts, which is in SELF_WIDENING_PATHS. Under the self-widening rule that makes it the owner's, whatever the decide list matched. @trotterdylan, this one needs your approval. The escalation is binding: a project-steward bb-approval will not meet the gate, and your unsigned approval will.

Blockers

  1. assessed-gate.ts:110 / approvals.ts:482. A forwarded project-entry approval can no longer be approved from the page. The surfaces that used to call prGate without a decision (the page action, needView, pullWatch, the escalation flag, gate and merge) now get the stored decide-list mark. Take a pull request whose files match a project entry, where the project steward forwards the approval to the owner (BB-192; fileForwardedApprovePrNeed files approve-pr). Now needsOwnerApproval is false, so the board shows the item as actionable: false, why: "project steward approval needed". Pressing Approve returns Not now: project steward approval needed. On main (103d3e7) the same fixture gives actionable: true and Approved; ENG-12's steward has been told. I checked with a throwaway test in the BB-133 describe of server.test.ts: withPull([reviewMarker("owner-reviewed")], { files: ["bb-gate/docs/hooks.md"] }), then steward_update { forward }, stewardsBoard, then stewardsNeedAction approve. The BB-321 re-probe does not help, because it fires only after the owner has approved, and this item is how the owner approves. A forwarded approval needs to make the gate the owner's before the owner approves, for example by keying on the forwarded escalation or need. That change also needs a surface-level test in the suite.
  2. server.ts:4583 (assessBinding's gatePulls) and assessed-gate.ts:111. A review binding's own pull request is never assessed, so it falls back to the user mark. For a review binding (a teammate's PR), the entity pull is neither in ownPulls nor matched by pullBelongsToTicket. That leaves it out of the stored assessment. syncPullApproval then reaches the assessedGate fallback with no stored entry, which uses mark = "user" and never reads the files. The result is a routing change. With an approver=project marker, files ["bb-gate/docs/hooks.md"] and ring("github", "acme/web#7"), main files no needs and opens an approval escalation to project. This head files the owner's approve-pr item and routes the escalation to user. The same gap means every wake of a review steward prints Lane gate: not met — the assessment is not available for this head; the plugin recomputes it on the next look. (I checked this in the same fixture), and no later look ever recomputes it. It also makes stewardsBoard recompute and rewrite the assessment row for each of that binding's items on every render, which the next reconcile then discards. That is extra reads and writes the latency/load section does not report. The fix is to gate the binding's own entity pull in assessBinding, and to derive the fallback mark from the snapshot's files, the way the reconcile does, rather than a blanket user. Add a review-binding fixture for both the routing and the wake line.
  3. Limit 2 / criterion 5. The fixture changes need a Revision on BB-291. assessment.test.ts's BB-292 Report a briefless thread as absent and stop backfilling dormant ones #2/Keep the SDK root out of the frontend bundle #3 characterization tests were rewritten. Under a project decision with a recorded bb-approval, the old approvals.ts gate asked the owner, and it is now met. The page refusal text changes as well. That is the intended unification, but the binding limit says an intended difference is proposed as a Revision on BB-291 first. Separately, compare no longer emits gate rows, so "the divergence log shows no new gate row" is now true by construction and is not evidence. Either list the surface-level result changes in the PR body and get the Revision, or keep a gate comparison for the soak. Blockers 1 and 2 are the kind of difference a retained comparison would have logged.

Tested

  • Ran: npm run typecheck and npm test in plugins/stewards. Both pass (39 files, 1792 tests).
  • Ran: throwaway probes for blockers 1 and 2 against both main 103d3e7 and this head, in a separate worktree. Nothing was pushed.
  • Verified against ticket: criterion 5 / limit 2 is not met (blockers 1–3). The new criterion 4 fixtures in assessed-gate.test.ts call assessedGate directly and never go through the page, approval-sync or wake surfaces, which is where both regressions live.

— from bb thread thr_vkefwtycjt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 findings addressed at e82cd96:

  • Blocker 1 (a forwarded project-entry approval could no longer be approved from the page): fixed. assess now treats a project-entry pull with an open user-routed approval escalation (a BB-192 forward, resolutionKind: "approve-decline") as the owner's from the forward on, so the page's Approve acts and the reconcile does not reroute the escalation back. Test: "lets the owner approve a project-entry pull the project steward forwarded (BB-322 blocker 1)".
  • Blocker 2 (a review binding's own pull was never assessed, and the fallback used a blanket user): fixed. assessBinding now gates the binding's own entity pull, and assessedGate derives its fallback mark from the pull's changed files under the binding's decide list. Test: "gates a review binding's own pull request, so a project entry routes to the project steward (BB-322 blocker 2)".
  • Blocker 3 (the fixture changes need a Revision / the comparison was removed): the approvals.gate and approvals.pageRefusal comparisons are retained in compare (read through pullGate), and the BB-292 Report a briefless thread as absent and stop backfilling dormant ones #2/Keep the SDK root out of the frontend bundle #3 characterization tests are restored unchanged. The PR body now lists the surface-level result changes and says the comparison stays as the soak's evidence. No Revision is needed: the existing fixtures' gate results are unchanged, and the known BB-292 Report a briefless thread as absent and stop backfilling dormant ones #2 divergence is the intended unification, which the log still records.

npm run typecheck and npm test pass (39 files, 1794 tests).

— from bb thread thr_ewyfnr8k4z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at e82cd96)

Blockers

  1. assessment.ts:166 / server.ts (the steward_update forward path): a forwarded item stays unactionable until the next reconcile. On main, the owner can act on the forwarded approve-pr item as soon as the forward files it. At this head the forward is only read inside assess, and the forward path does not schedule a reconcile. Between the forward and the next look, needView and approvePrPageAction go through assessedGate. That reuses the stored project entry, because the key does not change. I re-ran my round-1 probe here (forward, then stewardsBoard, then Approve, with no ring in between). It still gives actionable: false, why: "project steward approval needed" and Not now: project steward approval needed. pushNewGateNeeds notifies the owner at the moment of the forward, so the owner taps through to an item they cannot act on until a doorbell or the half-hourly sweep arrives. The new test passes only because it calls t.ring after the forward. Fix: make the forward visible to the read path, for example by including the forward in gateInputKey and the mark, or by refreshing the stored assessment in the forward path. Then drop the ring from the test, so it checks the state right after the forward.

Suggestions

Resolved since round 1

  • Blocker 1 (forwarded approval refused on the page): partly resolved. It is correct after the next reconcile, but not at the moment of the forward (blocker 1 above).
  • Blocker 2 (review binding not assessed): resolved. assessBinding now gates the entity pull, and the fallback mark comes from the snapshot files. The new test covers both the routing and the wake line.
  • Blocker 3 (fixture changes need a Revision): the code side is resolved. compare keeps the approvals.gate/approvals.pageRefusal rows, the Report a briefless thread as absent and stop backfilling dormant ones #2 fixture matches main, and the PR body lists the surface-level changes. The Revision on BB-291 that binding limit 2 asks for is the initiative steward's to propose, and it is not on the ticket yet.

Tested

  • Ran: npm run typecheck and npm test in plugins/stewards. Both pass (39 files, 1794 tests).
  • Ran: the round-1 forward probe at e82cd96 in a throwaway worktree. It still fails as described in blocker 1.

— from bb thread thr_vkefwtycjt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 findings addressed at 41b7062:

  • Blocker 1 (a forwarded item stayed unactionable until the next reconcile): fixed. The forward path now refreshes the stored assessment's gate for the forwarded pull with the owner's mark (assessedGate(store, target, pull, now(), [], "user")), so gateInputKey changes and the read path sees needsOwnerApproval immediately, before any reconcile. The blocker-1 test no longer calls t.ring after the forward; it checks the board and the page action right after steward_update.
  • Suggestion (assessment.test.ts BB-292 Keep the SDK root out of the frontend bundle #3 title/comment): restored main's title and comment. The duplicated comment in the blocker-2 test is removed.

npm run typecheck and npm test pass (39 files, 1794 tests).

The BB-291 Revision that binding limit 2 asks for is the initiative steward's to propose; I have told the ticket steward.

— from bb thread thr_ewyfnr8k4z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 3 (Claude Opus 5.5, at 41b7062)

Owner review required: yes. This changes what decides a merge, and approvals.ts is in SELF_WIDENING_PATHS, so it is the owner's under the self-widening rule. @trotterdylan, this one needs your approval. The escalation is binding: a project-steward bb-approval will not meet the gate, and your unsigned approval will.

Resolved since round 2

  • Blocker 1 (forwarded item not actionable until the next reconcile): resolved. The forward path now refreshes the stored gate with the owner's mark. With no reconcile between the forward and the board read, my round-1 probe now gives actionable: true and Approved, the same as main. The test now checks the state right after the forward.
  • Blocker 3 (Revision on BB-291): resolved on the ticket. The initiative steward added "Intended gate differences (consumer children)" at 04:02Z, and it is waiting for the owner's re-approval. One wording problem in that Revision: the listed difference is the BB-292 Report a briefless thread as absent and stop backfilling dormant ones #2 approvals.gate divergence, but it is attributed to "the BB-321 shadow defect". BB-321 was the opposite case (old met, shadow wanted the project steward).
  • Suggestion (test title and duplicate comment): taken.

Tested

  • Ran: npm run typecheck and npm test in plugins/stewards. Both pass (39 files, 1794 tests).
  • Ran: the round-1 forward probe at 41b7062, in a throwaway worktree. Its result now matches main 103d3e7.

Looks good.

— from bb thread thr_vkefwtycjt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author
  • The input fingerprint hashes the whole snapshot. gateInputKey serialises the entire entity, including every comment, title, labels and reviews. The gate only reads markers, approvals, checks, head sha and base state. Why is that? Whats the reasoning?
  • A moved head keeps its old lane until the next reconcile. assessedGate reuses the stored decide mark for any head sha. If a new push adds a file that matches a user entry, the surfaces keep saying project until the reconcile recomputes from files. What are the consequences?

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Answering both, at f85d782:

1. Why gateInputKey fingerprints the whole snapshot. Deliberate conservatism, not an accident. prGate is the gate code and sits in SELF_WIDENING_PATHS, so it is owner-controlled and may start reading a field it does not read today. The stored assessment is a cache; a hand-picked key silently reuses a stale answer the moment the gate reads something the key forgot. Hashing the whole entity makes the cache automatically correct for every field prGate reads, now and after a future change to it, so the key cannot drift from the gate. The cost is one JSON.stringify + SHA-1 per assessedGate call, and the surfaces read the same snapshot the reconcile stored, so the comparison is a cache hit and no gate is recomputed. If you would rather trade that safety for a little CPU, I can narrow it to the fields prGate reads today (pull.headSha, pull.checks, pull.baseChangedAt, pull.headMergeBaseIsDefaultTip, pull.reviews, viewer, comments, and the options) — say the word and I will.

2. A moved head keeping its stored decide mark was a real defect, fixed at f85d782. The dangerous direction is project → user: a push adds a file matching a user entry while the pull carries a recorded bb-approval; the surfaces would keep project, the recorded project approval would still count, and bb stewards merge or the Merge button could merge a change the owner should approve before the next reconcile. The reverse (user → project) only over-asks the owner. assessedGate now reuses the stored mark only while the head sha is unchanged; a moved head re-derives it from the snapshot's changed files, and a caller without the decide list gets the owner's mark (fail closed), never a stale project. The reconcile still recomputes the full assessment, so the lane is right from the next look; the fix closes the window before it. Test: "re-derives the decide mark from the changed files when the head moves".

npm run typecheck and npm test pass (39 files, 1795 tests).

— from bb thread thr_ewyfnr8k4z

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 4 (Claude Opus 5.5, at f85d782)

Owner review required: yes. This changes what decides a merge, and approvals.ts is in SELF_WIDENING_PATHS, so it is the owner's under the self-widening rule. @trotterdylan, this one needs your approval. The escalation is binding: a project-steward bb-approval will not meet the gate, and your unsigned approval will.

On your two questions, checked independently:

  • The whole-snapshot key. A key that is too wide only costs a recompute and a store write when an unrelated field changes, such as a comment or a title. A key that is too narrow would reuse a stale answer, which is fail-open. The author's choice is the safe side.
  • The moved head, now fixed. One consequence to know about: some callers pass no decide list. These are the Merge button, bb stewards merge, the page's Approve and the board. Between a push and the next reconcile they now treat a project-placed pull as yours. A merge on a recorded bb-approval is refused with "owner approval needed" until the reconcile re-derives the mark, even when the new files are still project-only. On main that window counted the recorded approval. The new behaviour is stricter, never looser, and lasts only until the next reconcile, which the push's doorbell triggers.

Tested

  • Ran: npm run typecheck and npm test in plugins/stewards. Both pass (39 files, 1795 tests).

Looks good.

— from bb thread thr_vkefwtycjt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved f85d782 from the Stewards page

@trotterdylan
trotterdylan merged commit 6051aae into main Nov 14, 2026
22 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved f85d782, checks green, approved by the owner, escalated by the reviewer to the owner.
merge commit 6051aae
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 14, 2026
…356)

Implements [BB-323](https://linear.app/bit-complete/issue/BB-323). The printed reviewer command keeps `--lifecycle-owner-thread "$BB_THREAD_ID"` but drops `--parent-self`, which bb core refuses for a child of an active Pi thread; a worker is active when it runs the command, so the command could not run at all. The plugin now recognizes a reviewer from that lifecycle owner: `spawnedOwner`/`reviewerOwner`, `reviewersOf`/`supersedeOlderReviewers`, `archiveWorkers` and the `thread.created` handler treat a parentless thread whose lifecycle owner is a worker of an open binding as that worker's reviewer, never validate it as a worker, and keep its worker unarchived while it is still live. A steward-owned or steward-parented thread is unchanged.

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

Sibling PR: none (one half; #355 is the stacked base, not a sibling).

## Classification
owner-reviewed: the change alters what an existing command (`bb stewards spawn-flags --role reviewer`) prints and how the plugin recognizes reviewer threads, which is the project steward's decide-list entry for `bb-plugins/plugins/stewards/**`. It does not alter what the merge or spec gate reads.

## What changes
- `wake.ts`: `spawnCommand({ role: "reviewer" })` prints no `--parent-self`, and keeps `--lifecycle-owner-thread "$BB_THREAD_ID"`, `--parent-notifications off`, `--visibility hidden`, `--permission-mode full` and the reviewer model flags. The worker command is unchanged.
- `server.ts`: `reviewerOwner` also recognizes a parentless reviewer whose lifecycle owner is a worker of an open binding; `reviewersOf` lists parentless reviewers (bb has no lifecycle-owner filter, so the worker's project's root threads are read and filtered); `supersedeOlderReviewers` archives older reviewers of either form; `archiveWorkers` now also reads a candidate's live reviewers through `reviewersOf`, so a parentless reviewer — which is not a descendant — keeps the worker unarchived, and the worker is archived once the reviewer is; the `thread.created` handler supersedes a recognized reviewer and returns early only when neither its lifecycle owner nor its parent is an open binding's steward, so a steward-owned or steward-parented thread is still filed and validated. A parentless thread owned by a steward or an unknown thread is handled exactly as before.
- Tests: a new `createdReviewer` fixture, a test for a parentless reviewer (recognized, not validated, superseded), the unchanged parented form, a steward-parented wrong-model thread still stopped, the parent-is-worker/lifecycle-owner-is-steward thread still stopped, and a worker kept while its parentless reviewer is unarchived and archived once the reviewer is.
- `read-counts.test.ts`: the pinned reconcile reads rise 183 → 185 — the extra `reviewersOf` lookup reads the worker row and its binding.
- Docs: the `spawn-flags` description, the BB-133 doc comment, `README.md`, `DESIGN.md` and the build-tickets skill no longer say a reviewer is parented with `--parent-self`; the skill also finds an existing reviewer by lifecycle owner, because the `--parent-thread` lookup is always empty for the new command.

## Testing
- `npm install --include=dev --legacy-peer-deps --no-audit --no-fund` then `npm run typecheck`: pass.
- `npm test`: pass (1794 tests, 39 files).
- New fixtures exercised: `bb stewards spawn-flags --role reviewer` output in `server.test.ts` (no `--parent-self`), the parentless reviewer recognition/supersede path, and the `archiveWorkers` keep-then-archive path.
- Not tested: the live `bb thread spawn` command itself (bb core's `canSpawnChild`), which is out of scope.
trotterdylan added a commit that referenced this pull request Nov 14, 2026
…BB-325) (#357)

Implements [BB-325](https://linear.app/bit-complete/issue/BB-325/stewards-an-ended-binding-takes-no-new-question-forward-or-report).

An ended binding is now closed to new questions, forwards, holds and priority changes, and anything left on it or sent to it after the end is carried to the project steward instead of being stored on the binding or silently dropped. `openQuestions` skips ended bindings like `openEscalationsForProject` already does, and a question left on an ended binding is closed once with "The binding ended." and reported once.

> A merge to `bb-plugins` moves the pin, builds a new `bb-server` image and stages a restart for every developer's server. Do not press Restart now from a thread you still need.

Sibling PR: this is stacked on #356 (base branch `bb/bb-323-reviewer-spawn-without-parent-self-thr_c2fk8ihctm`), itself stacked on #355. It rebases onto `main` and retargets before merge once #356 lands.

## Classification
owner-reviewed: the stewards plugin outside its authority seams (`bb-plugins/plugins/stewards/**`, project-decided); `store.ts` also matches the store-migration entry. `escalations.ts`, the escalation routing and the ready gate are untouched, so the project steward decides.

## What changes
- `server.ts`
  - `steward_update { ask, binding }`, `{ forward }`, `{ hold }` and `{ priority }` on an ended binding fail with an error naming the end reason and date and the two alternatives (ask at project scope by omitting `binding`, or reopen the entity first). Nothing is stored. `resolve` of an existing question/escalation/assumption, `confirm`, `lessonAction` and reopening still work.
  - `steward_report` from a steward whose binding already ended writes nothing to the binding and carries its content (status, wait, escalation, needs) to the project steward as one folded note.
  - `bb stewards escalate` from a worker whose binding already ended files nothing and carries the question to the same note.
  - `finishEnding` still resolves every open escalation and question; the route-user ones and questions are listed in the project steward's next digest note.
  - A project-wide one-time close in `sweepProject` resolves any open escalation or question still attached to an ended binding (the BCP-154 case) and reports it once. The resolution is the record: a later sweep finds nothing open and reports nothing again. The test drives the production sweep, so deleting the call fails it.
- `store.ts`
  - `openQuestions` joins bindings and leaves out an ended binding's questions; a question about no single binding still shows.
  - `openOnEndedBindings` returns a project's open items on ended bindings with each binding's end.
  - `noteProjectFolded` queues a silent digest note, folded per binding, so several late reports are one line and none of them starts a turn.
- Tests in `server.test.ts` and `store.test.ts`.

## Testing
- `npm run typecheck`: pass.
- `npm test`: pass (1801 tests; CI's `quality_checks (stewards)` runs the same suite).
- Not tested: the live Stewards page render; the note is asserted from `peekProjectNotes`, which is what the digest renders.

## Reads (BB-291 criterion 10)
- Per-reconcile fixture (`read-counts.test.ts`), 4 bindings: **185 store reads, 12 source calls, 4 reconciles**; wake **15 store reads, 0 source calls**. Unchanged: the one-time close is a project-wide pass step (`store.openOnEndedBindings`, one read) beside `store.open`, outside the measured per-binding reconcile, exactly as it runs in `sweepProject`.
- No new network reads.
trotterdylan added a commit that referenced this pull request Nov 16, 2026
Implements [BB-333](https://linear.app/bit-complete/issue/BB-333). Two typed-wait shadow bugs found while explaining the `bb stewards wait-divergences` rows. Both are shadow-only: nothing reads the typed derivation to decide yet, so no gate, wait, wake, card or status result changes.

> A `bb-plugins` merge moves the `bb-server` pin and stages a restart for every developer's server (Restart now, or the 03:00–05:00 ET quiet window). No one should press Restart now from a thread they still need.

## Classification
no-review: the shadow's own derivation and divergence log. No decide-list entry matches: no migration, no `AGENTS.md`/`roles.json`/`project.json`, no gate/identity/access code, no public contract. The change is internal to `plugins/stewards` and feeds no consumer.

## What changes
1. **`assessment.ts` — a `date` wait reads the scheduled requeue, not the ref text.** The design's kind table says a `date` wait is live while the binding's `requeueUntil` is ahead. `steward_report` sets `requeueUntil` only from `until` today, not yet from the ref (the design has the ref set it too; that report-path gap is a separate finding and out of scope here). `typedWaitLive` read `parseUntil(wait.ref) ?? requeueUntil`, so a ref date the report never scheduled read as a live wake source. That is the `f/t` row `bnd_c794p1psUncK` (BCP-173): `derived=live, noWakeSource=no-wake-source`. It now reads `requeueUntil` only. (`parseUntil` is no longer imported there.)

2. **`store.ts` — a stopped divergence row keeps its own inputs.** On a stop, `recordWaitDivergence` rewrote the row's `inputs` with the *current* fields. A stopped `worker` disagreement therefore read back with `waitLive: true` beside its `derived no-wake-source` pair, which is the "worker derived as stall while the worker runs" the ticket flagged. The stop touch now keeps the row's own inputs and only flips `$.transition` with `json_set`, so no migration.

Retires: nothing.

## Testing
- `plugins/stewards`: `npm run typecheck` and `npm test` pass (2001 tests, 42 files; the `plugins` workflow matrix does not include stewards).
- New tests: a `date` wait with a future ref but no `requeueUntil` is not live and stalls; a stopped divergence row keeps its own `waitKind`/`waitLive` and only its transition flips.
- Updated test: the `date` wait test now drives liveness from `requeueUntil` (and adds the unscheduled case).
- Not tested: the production rows themselves, which are data, not behaviour; the change is verified against the two derivations in the unit suite.

## Load
No store or source reads are added: the `date` fix is a pure predicate, and the stop fix only changes an existing `UPDATE`. The read-counts fixture is unchanged at 193 store reads / 12 source calls over 4 reconciles (48.25 reads/reconcile) and 15 reads per wake, against the BB-291 baseline of 48.5 reads/reconcile and 15 per wake after #355.
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