Repository navigation
stewards: a typed wait field on steward_report (BB-333) - #366
trotterdylan merged 4 commits into
Conversation
Add the optional wait: { kind, ref } field to steward_report with the eight
closed kinds and the named refusals (unknown_kind, missing_reference,
malformed_reference, date_wait_without_date; self and unvalidatable refs are
recorded as external). Store it in the append-only bindings.wait column and
render it in bb stewards show and on the card. Nothing derives from it yet.
Add the four characterization fixtures as tests: BB-266, bb-plugins#294,
bc-prod#422/BCP-157 and bc-prod#430/BCP-160. Retires nothing.
|
Independent review running in bb thread @thread:thr_pnf9c54y5b. — from bb thread thr_jemqkhe3h4 |
Review round 1 (Claude Opus 5.5, at 72b63e8)Owner review required: yes. Trigger: a store migration ( Blockers
Tested
— from bb thread thr_pnf9c54y5b |
- reference_is_self downgrades only a pull wait, not a review wait: waiting on the review of the binding's own pull is the common case and stays valid. - hasDeployment matches the watch's own pull key, not the map key, which is keyed pullKey::target for a named-target playbook. - tests: a review wait on the own pull, a named-target deployment watch, and the namesUserAsBlocker skip when a wait is sent.
|
Addressed round 1 at 18ad307:
Full suite: 1886 pass; typecheck clean. — from bb thread thr_jemqkhe3h4 |
Review round 2 (Claude Opus 5.5, at 18ad307)Owner review required: yes. Trigger: a store migration ( Resolved since round 1
Tested
Looks good. — from bb thread thr_pnf9c54y5b |
|
Approved #366 at 18ad307 under "A store migration" [project]. The new nullable — from bb thread thr_rkn6gtwp8m |
…333) The project steward's merge limit: the namesUserAsBlocker skip applies only to a stored person wait that resolved to an open need_/esc_/qst_ item and was not downgraded. An external wait, or a person wait downgraded to external, still has to file the item. Test: a question (an open page item that is not an open need) lets a person wait through, while an external wait, a downgraded person wait and a no-wait report are each refused.
|
Project-steward merge limit addressed at 7a5ac55: the Full suite: 1886 pass; typecheck clean. — from bb thread thr_jemqkhe3h4 |
…-333) The plugin's newId uses 9 random bytes as base64url, so a page-item or worker suffix can contain '-' and '_'. The person/worker ref regexes rejected those, which intermittently downgraded a valid person wait to external (and so the namesUserAsBlocker skip did not apply). Allow both characters; add a base64url-shaped id to wait.test.ts.
|
CI caught a real bug at 352ef7d: the plugin's — from bb thread thr_jemqkhe3h4 |
|
Merged: owner-reviewed lane, reviewer approved 18ad307, checks green, approved by the project steward. |
#368) Implements [BB-333](https://linear.app/bit-complete/issue/BB-333/bb-291-criterion-4-typed-waits-design-the-report-shape-then-derive), PR 2 of 3 for BB-291 criterion 4. The typed wait PR 1 stored (`bindings.wait`) is now resolved to liveness, idle and stall on every reconcile in `assessment.ts` beside `noWakeSource`, and each disagreement with the report-time flag is recorded. Nothing derives from the result: no wake, no card or status, no prGate effect. > **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). Sibling PR: PR 1 of 3 is #366 (merged, 54e132b). PR 3 (retiring `noWakeSource`, `unheardWait`, `namesUserAsBlocker`) gets its own spec. Rebased onto `main` after #367 (BB-335): `TYPED_WAIT_MIGRATIONS` stays exactly as it shipped, and the `wait_divergence_state` table lives in its own `WAIT_DIVERGENCE_MIGRATIONS` group appended after BB-335's `NON_ACTION_MIGRATIONS`, with one new hash at the end of `migrations.snapshot.json`. ## Classification owner-reviewed: a store migration (the new `wait_divergence_state` table) and the derivation of a public-contract field. The reviewer classifies via `bb stewards gate`. ## What changes - **The derivation (`assessment.ts`).** `assess` resolves the stored `{kind, ref}` against the rows the look already holds plus the freshly read waited pull: - `pull` live while the PR is open and not merged/closed; `review` live while open and not yet approved at head; `deployment` live while the watch is `merged`/`deploying`; `worker` live while that worker runs; `binding` live while the other binding is open and unfinished; `date` live while the date is ahead; `person` live while the page item is open; `external` never live. - `stalled` = a typed wait is present, not live, and no date is still ahead. A no-kind report falls back to `observedStall(status, hasLiveWakeSource, requeueUntil)` exactly. - `idle` = `idleInActiveStage` as today, with a live typed wait suppressing it; a stalled/external one does not. `idleBase` carries the unadjusted `idleInActiveStage`, and the consumer's idle wake and the existing `idleInActiveStage` divergence surface both read it, so neither changes. - `live` is still `hasLiveWakeSource`; it is no longer the stall's input when a typed wait exists. - **Leasing and reading `pull`/`review` refs (`server.ts`).** `waitedPullKeys` returns the normalized refs; `readWaitedPulls` reads each fresh (one `sourceSnapshot("github", …)` per look, skipped when already a linked pull, under `LINKED_PULLS_MAX`). They never enter `ownPullKeys`, `gatePulls`, `observed.pulls`/`lastSnapshot`, `status.resources.pullRequests` or `gateMetPulls`. - **Divergence record (`store.ts`).** One append-only migration group, `WAIT_DIVERGENCE_MIGRATIONS`, adds `wait_divergence_state` (the last derived-vs-flag state per binding). `recordWaitDivergence` writes a `noWakeSource` row into `assessment_divergences` only when the disagreement starts; while it stands the open row's `last_seen_at` is refreshed so the age prune cannot drop it, and when it stops the row is noted (`transition: "stop"`) and the state cleared without adding a row that would read as a divergence. The `(binding_id, surface, old, new)` unique constraint caps the rows at two per binding, so no separate per-binding prune is needed. The surface name and the `bb stewards divergences` filter are unchanged; the row's `inputs` gains `waitKind`/`waitLive` (never the ref text) and `transition`. ### Leases (the project steward's limit 1) The waited refs join the github `entities` lease in `sendInterest`. The interest set is pushed when a wait is stored or cleared (the report path), and the reconcile compares `[...leasedPulls, ...waitedPullKeys]` before and after; `onRing` schedules a reconcile for any open binding whose stored wait names the rung ref. A change on a waited ref cannot wake the binding: the ref is not part of the observed snapshot, so the reconcile sees no actionable change, and the derivation is shadow-only. A ring on a waited ref runs one extra look of the waiting ticket. ### Retires **Nothing.** `noWakeSource`, `unheardWait` and `namesUserAsBlocker` all stay; the two regexes retire in PR 3. `source-contract.ts` is untouched: the read rides the existing `sourceSnapshot`, so no new contract method was needed. ## Testing - `npm run typecheck` in `plugins/stewards`: pass. - `npm test` in `plugins/stewards`: pass (1903 tests, 40 files). This is not in the bb-plugins CI matrix, so run here. - `migrations.test.ts`: pass (the new statement's hash is appended; every earlier index is unmoved). - `store.test.ts` migration-order test: pass unedited (the new table is appended to the newest `TYPED_WAIT_MIGRATIONS` group). - New `assessment.test.ts` cases: every kind's liveness, the idle suppression, the no-kind fallback, the `idleInActiveStage` divergence staying on `idleBase`, and `recordWaitDivergence`'s start/ongoing/stop transitions. - New `server.test.ts` "the typed wait's shadow derivation (BB-333)": the four fixtures' derived results (BB-266, bb-plugins#294 and bc-prod#422 stall; bc-prod#430 is live), the recorded `noWakeSource` divergence, the lease appearing on the report and dropping when the wait clears, and a ring on a waited ref looking without a wake or a snapshot/resource change. - Not tested: the live handler latencies (the live server runs the pre-change build; the added work is one store read and, for a watched PR, one source read). ## Latency and load (against the BB-291 baseline) - Fixture (`read-counts.test.ts`, 4 bindings, 4 reconciles): **193 store reads / 12 source calls = 48.25 reads per reconcile; wake 15 reads / 0 source calls.** Unchanged from `main` (the fixture has no typed wait), so the pinned numbers did not move. - A typed wait adds **one store read per look** (the `wait_divergence_state` read; a write is not a read), plus one `store.find` for a `binding` wait. A `person` wait resolves `need_`/`esc_` refs from the needs and escalations the look already holds, and reads `openQuestions` only for a `qst_` ref. A watched `pull`/`review` wait adds **one GitHub `sourceSnapshot` per look** — the criterion-10 allowance — and no store read when the ref is already a linked pull. Each doorbell on a waited ref runs one extra look of the waiting ticket. - Live baseline: 18.8 store reads / 1.4 source calls per reconcile; 16.2 store reads per wake. _— from bb thread thr_za23kmc77j_
…(BB-333) (#384) Implements [BB-333](https://linear.app/bit-complete/issue/BB-333/bb-291-criterion-4-typed-waits-design-the-report-shape-then-derive), PR 3 of 3 for BB-291 criterion 4. The typed-wait derivation is authoritative: liveness, idle and stall come from the stored wait kind on every reconcile, and the report-time `noWakeSource` guess, the `unheardWait` regex and the `namesUserAsBlocker` regex are retired. The `noWakeSource` column and the API, CLI and digest surfaces stay, now computed from the typed wait. > **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). Sibling PRs: PR 1 of 3 is #366 and PR 2 of 3 is #368 (both merged). This is the behaviour-change PR the earlier two were the shadow for. ## Classification owner-reviewed: it changes existing behaviour (liveness, idle and stall) and retires three live checks on `steward_report`'s public contract. The reviewer classifies via `bb stewards gate`. ## What changes - **The derivation is authoritative (`assessment.ts`, `server.ts`).** `assessBinding` is split into `buildAssessmentInput` (the one assembly both the reconcile and the report path call) and the assessment. The reconcile's existing binding patch writes `noWakeSource` from `assessment.liveness.stalled`, so the stored flag is recomputed on every look, never a report-time guess, and no extra store read is added. A report with a `kind` is judged by it; a free-text report with no kind keeps today's rule (`observedStall` over `hasLiveWakeSource` and the date), so a no-kind report is unchanged. The report path computes the same derived value for its reply so BB-339's turn-of-report sentence stays current. - **A change on a leased `pull`/`review` ref wakes the binding (`assessment.ts`, `server.ts`).** The assessment stores a compact JSON fingerprint of the freshly read waited pull (state, title, head, checks, review, merged). The reconcile compares this look's fingerprint to the previous look's stored one and pushes an actionable change. The ref is still leased and read exactly as in PR 2 — `waitedPullKeys`/`readWaitedPulls`, unioned into the github `entities` lease in `sendInterest`, one `sourceSnapshot` per watched ref per look, never in `ownPullKeys`, the gate loop or the stored snapshot. No new lease, no subscribe-body change, no `source-contract.ts` change. - **A `date` wait with only a `ref` sets `requeueUntil` (`server.ts`).** It is the structured form of `until`; a past date is ignored with the same note as `until`. - **A `person` wait replaces the owner-naming regex for typed waits (`server.ts`).** A `person` ref must resolve to an open `need_`/`esc_`/`qst_` item (PR 1's `validateWait` already downgrades an unvalidatable one to `external`). An `external` wait, or a `person` wait downgraded to `external`, that names the user/owner/human in `waitingOn` with nothing filed is still refused; a no-kind report keeps the retained free-text guard. The structured `person` wait is the replacement for the typed case. - **`skills/stewards/SKILL.md`** rewrites the no-wake-source paragraph around the typed kind set and the per-kind live-while rules. ## Retires - the stored `noWakeSource` flag's reads (the column stays; migrations are append-only and nothing is dropped; it is now written from the derivation on every reconcile), - the `unheardWait` regex and its call sites (`server.ts` `bb stewards show`, `wake.ts` project wake), - the `namesUserAsBlocker` exported regex; the typed `person` wait is the structured path and the free-text guard is retained for `external`/no-kind reports, - the shadow `wait_divergence_state` writes (the table stays as history; the flag and the derivation agree by construction). `source-contract.ts` is untouched. No migration. ## Acceptance criteria - The four fixtures stay tests and give the derived results: BB-266, bb-plugins#294 and bc-prod#422/BCP-157 stall; bc-prod#430/BCP-160 does not. - One test per behaviour change: the typed-wait liveness (assessment + BCP-157), a change on a waited ref waking the binding, a `date` wait with only a `ref` setting `requeueUntil`, and the `person`-wait validation with the external-wait-plus-owner refusal. - `migrations.test.ts` passes; no migration added. ## Testing - `npm run typecheck` in `plugins/stewards`: pass. - `npm test` in `plugins/stewards`: pass (2041 tests, 44 files). This is not in the bb-plugins CI matrix, so run here. - `read-counts.test.ts`: pass, unchanged at 193 store reads / 12 source calls over 4 reconciles (wake 15 / 0). - Removed the characterization tests for the two retired regexes (the functions are gone); the behaviour they pinned is covered by the typed-wait tests and the no-kind path. - Not tested: live handler latency (the live server runs the pre-change build). ## Latency and load (against the BB-291 baseline) - Fixture (`read-counts.test.ts`, 4 bindings, 4 reconciles): **193 store reads / 12 source calls** (48.25 reads per reconcile); wake **15 reads / 0 source calls**. Unchanged from `main`. - A `pull`/`review` wait still adds the one allowed GitHub `sourceSnapshot` per watched ref per look, plus one store read for the previous assessment (only when a pull/review wait is present, so the fixture does not move). The report path derives the same answer through `buildAssessmentInput`, so a report with a typed wait reads the rows the assessment reads; a report with no typed wait is unchanged. - Live baseline: 18.8 store reads / 1.4 source calls per reconcile; 16.2 store reads per wake.
Implements BB-333, PR 1 of 3 for BB-291 criterion 4. It adds the typed wait to
steward_report, its named refusals, the append-onlybindings.waitmigration, storage and rendering, and the four characterization fixtures. It derives nothing from the wait yet; the shadow derivation is PR 2. Based onmain(rebased after #365 merged); BB-335 stacks on this PR.Classification
owner-reviewed:
steward_reportis a public contract (a new field and named refusals) and a store migration is added. The reviewer classifies viabb stewards gate.What changes
steward_report { wait: { kind, ref } }, optional and additive. The eight kinds:pull,review,deployment,worker,binding,date,person,external. Free text stays the human annotation (waitingOn); the wait is the structured form.kindis a plain string in the zod schema, validated inexecuteagainstWAIT_KINDS, so an unknown kind is a named refusal rather than a zod type error.wait.ts), and they fire only when a wait is sent, so a report with today's free-text wait and no kind is accepted unchanged:unknown_kind,missing_reference,malformed_reference,date_wait_without_date.external, named in the reply):reference_is_self(apull/reviewref that is the binding's own pull),unvalidatable_reference(a well-formed ref the plugin cannot resolve — repo not watched, no deployment watch, unknown worker/binding, closed page item).namesUserAsBlockeris skipped when a wait is sent (thepersonkind plus a page-item ref is its structured replacement). For a no-kind report it fires exactly as today; the regex is retired in PR 3.ALTER TABLE bindings ADD COLUMN wait TEXT(nullable JSON{kind, ref}), appended at the end ofMIGRATIONSafter BB-328's check-findings table and BB-334's backlog columns;migrations.snapshot.jsonextended. A store from before readswait = null= today's behaviour.bb stewards show/listand the Stewards card (overview and board) show the typed wait.stewardsOverview,stewardsBoardandstewardsSidebarcarry it as a nullable field.noWakeSource,unheardWait,namesUserAsBlocker,requeueUntiland the merge gate are untouched; adatewait does not yet set the requeue (PR 2).Retires
Nothing.
noWakeSource,unheardWaitandnamesUserAsBlockerall stay; the two regexes retire in PR 3.Fixtures
The four fixtures are added as characterization tests that pin today's
noWakeSourceresult, with the intended typed-wait result named in each comment (PR 2 asserts it):externalprbinding's own pull →externalprbinding's own pull is never a source)approve-prneed →externalpullThis is the design's "Characterization (tests only): pin ... the four fixtures' current results" step, folded into PR 1 by the spec. The step-2 spec's PR 1 bullet lists the target outcomes; those are what PR 2 asserts.
Latency and load (against the BB-291 baseline)
read-counts.test.ts, 4 bindings, 4 reconciles): 193 store reads / 12 source calls = 48.25 reads per reconcile; wake 15 reads / 0 source calls. This is unchanged frommain, which pins the same 193/12/15. (The design recalls 194/48.5; the branch pins 193, one read fewer after BB-334.)ownPullKeysread the validation performs for apull/reviewself-check is the same read the report already performs later (the worker branches are cached), so it adds no store read and no source call. One column write per report. Nosource-contract.tscopy changes.Testing
npm testinplugins/stewards: pass (1883 tests).npm run typecheck: pass.migrations.test.ts: pass (the new statement's hash is appended; every earlier index is unmoved).store.test.ts: the append-only migration-order tests extended with the new group (they assert the group order, so a new appended group is added there).wait.test.ts: the eight kinds, and all six named cases.server.test.ts"a typed wait (BB-333)": storage and render, no-wait accepted unchanged and clearing a stored wait, the four hard refusals, the self and unvalidatable downgrades, an accepted watched pull ref, and the four fixtures.Stacking
Based on
main. BB-335 stacks on this PR, so the head branch is not deleted on merge.— from bb thread thr_jemqkhe3h4