Repository navigation
stewards: every merge-gate surface reads the stored assessment (BB-322) - #355
Conversation
|
Independent review running in bb thread @thread:thr_ewyfnr8k4z. — from bb thread thr_ewyfnr8k4z |
|
Independent review running in bb thread @thread:thr_imrjxzbph9 (the earlier reviewer was stopped and replaced). — from bb thread thr_ewyfnr8k4z |
|
Independent review running in bb thread @thread:thr_vkefwtycjt. — from bb thread thr_ewyfnr8k4z |
Review round 1 (Claude Opus 5.5, at 64e96f0)Owner review required: yes. This change moves what decides a merge, and it touches Blockers
Tested
— from bb thread thr_vkefwtycjt |
…he soak comparison (BB-322)
|
Round 1 findings addressed at e82cd96:
— from bb thread thr_ewyfnr8k4z |
Review round 2 (Claude Opus 5.5, at e82cd96)Blockers
Suggestions
Resolved since round 1
Tested
— from bb thread thr_vkefwtycjt |
…he soak fixtures (BB-322)
|
Round 2 findings addressed at 41b7062:
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 |
Review round 3 (Claude Opus 5.5, at 41b7062)Owner review required: yes. This changes what decides a merge, and Resolved since round 2
Tested
Looks good. — from bb thread thr_vkefwtycjt |
|
|
Answering both, at f85d782: 1. Why 2. A moved head keeping its stored decide mark was a real defect, fixed at f85d782. The dangerous direction is
— from bb thread thr_ewyfnr8k4z |
Review round 4 (Claude Opus 5.5, at f85d782)Owner review required: yes. This changes what decides a merge, and On your two questions, checked independently:
Tested
Looks good. — from bb thread thr_vkefwtycjt |
|
Approved f85d782 from the Stewards page |
|
Merged: owner-reviewed lane, reviewer approved f85d782, checks green, approved by the owner, escalated by the reviewer to the owner. |
…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.
…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.
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.
Implements BB-322 (BB-291 criterion 1): the stored per-binding assessment becomes the one source for the merge gate.
prGateis now called from exactly one site outside the assessment module.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'sbb-approvaldoes not meet this one, the owner's unsigned approval does.What changes
One new module,
assessed-gate.ts, owns the gate:pullGate— the singleprGatecall site outsideassessment.ts.assessedPullGate— the decide-list mark plus the BB-321 forwarded-owner rule, used byassessment.tsand the refresh.gateInputKey— a fingerprint of everythingprGatereads, 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
AssessedGateis now the fullPrGatepluspull/met/key, so every surface reads the same fields it used to compute.Retired predicates / branches
approvals.ts::146recordProjectDecision's escalation/product refusal probe →assessedGate.:243approveOwnerReviewedPull's escalation/product refusal probe →assessedGate.:374syncPullApproval's preliminary gate (the lane/needs decision) → the assessment's gate, passed in from the reconcile or read viaassessedGate.:383syncPullApproval's second gate, recomputed with the decide mark frompullChangedFiles→ retired: the assessment already carries the decide mark (files are still read for the item's listing).:483approvePrPageAction'sneedsOwnerApprovalgate →assessedGate.server.ts::3204pullWatch's gate-met check for the pull-request wake source →assessedGate.:4884the reconcile's per-pullgateMetPullsloop → derived from the one assessment.:6911the routed escalation'sescalatedflag →assessedGate.:9115gateReport(bb stewards gate) →assessedGate.:9414mayMergePullRequest(the Merge button andbb stewards merge) →assessedGate.:11264steward_report'sapprove-pr/mergefiling →assessedGate.:12109needView's board actionability →assessedGate.wake.ts::364entityLines's Lane gate line → the storedassessedGates(WakeInputcarries them).assessment.ts::146/:155the probe and the BB-321 re-probe →assessedPullGate.:255compare'sapprovals.gateandapprovals.pageRefusalcomparisons are retained (read throughpullGate), so the soak still logs any disagreement between the consumer's answer and the predicate it retired. A newapprovals.gaterow 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 andsteward_reportall read one gate. The known BB-292 #2 difference is the intended unification: for aprojectentry with a recordedbb-approval, the old approvals path asked the owner and the assessment is met. The retainedapprovals.gatecomparison logs it; it is not a new row.Two surfaces needed care and are fixed in this head:
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.assesskeys on the open user-routedapprovalescalation (resolutionKind: "approve-decline"), so the page's Approve acts and the reconcile does not reroute the escalation back.pr/reviewbinding's own entity is a pull request, not a linked one, soassessBindingnow 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.tschange, no binding/plugin-id change, nosource-contract.tschange.Testing
npm run typecheckinplugins/stewards: pass.npm testinplugins/stewards: pass (39 files, 1794 tests;pluginsis 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) outsideassessment.tsand theprGatedefinition ingate.tsshows exactly one call site (assessed-gate.ts).Latency / load (BB-291 Baseline)
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:syncPullApprovalno longer re-reads the recorded project approvals, and the wake no longer re-reads them.stewardsBoardmax 1513 ms,stewardsSidebarmax 3271 ms / last 12 ms,stewardsRingmax 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 deployedbb stewards statswill carry the post-merge numbers.