Skip to content

stewards: cite the lessons a decision rested on, and count hits and corrections (BB-35 step 2) - #58

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-35-step-2-citations-and-counts-thr_r2ktijgyfy
Oct 21, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-35-step-2-citations-and-counts-thr_r2ktijgyfy

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-35 step 2: every steward_update { resolve } accepts cites: [lesson ids], the wake says a decision must cite what it was decided from, and the plugin records counts only — hits (once per distinct binding), corrections and lastCitedAt. Nothing is promoted, retired or written to .bb, and there are no tiers or thresholds in this PR.

Merging this to bb-plugins main rebuilds the bb-server image and stages a restart on every developer's server. Each server restarts when its owner presses Restart now, or in the 03:00–05:00 quiet window. I will not press Restart now from this thread.

Classification

owner-reviewed: a store migration (plugins/stewards/store.ts). The migration is append-only and additive — four defaulted columns on lessons, two on escalations, nothing dropped or renamed, safe on a live database and readable by the previous build — so the rest of the change is additive. cites is an optional new tool parameter; existing resolves without it work exactly as before.

What changes

  • Store. LESSON_COUNTER_MIGRATIONS adds hits, corrections, last_cited_at, cited_bindings to lessons and cited_lessons, corrections_counted to escalations. recordCitations counts one hit per distinct binding (a repeat refreshes lastCitedAt), recordCorrections counts a reversal once, and the cited lessons are kept on the escalation. A lesson whose scope is missing or unknown reads as boundary (lessonScope, fails closed).
  • Resolve. steward_update gains cites; it records the citations and stores them on the escalation it resolves. It is also accepted with forward, because the recommendation a correction is measured against lives on the forwarded escalation. Unknown or other-project ids are reported and never counted.
  • Corrections, observed not asked. A page answer, an unsigned comment by the connected owner on the entity, or a CLI close that differs from the steward's recommendation counts a correction on the cited lessons. A signed comment or anyone else's words never does.
  • Wakes. The project wake, the routed-escalation line and the "with the user" line say to cite the lessons a decision rested on.
  • Docs: DESIGN.md §20, README and the stewards skill.

Out of scope for this step: tiers/migration of pending/merged/dropped, thresholds, caps, promotion, retirement, trial injection into wakes, the rationale box, validation escalations and the efficacy view. No project.json, bigDecisions, prGate or decide-list change.

Testing

  • cd plugins/stewards && npm install --include=dev --legacy-peer-deps --no-audit --no-fund && npm run typecheck && npm test: pass (364 tests; stewards is in the CI matrix).
  • New store tests: hits once per distinct binding, lastCitedAt refresh, unknown/other-project ids ignored, corrections counted, lessonScope fails closed, and an append-only migration test that inserts a pre-step-2 lesson and asserts every old value survives and the new counters default.
  • New server tests: a cites resolve/forward records the citation and keeps it on the escalation; an owner's differing page answer records a correction; an agreeing answer does not; the owner's own unsigned comment corrects; a non-owner comment does not.
  • New wake test: the project wake tells the steward to cite.
  • Not tested: the Stewards page and CLI surfaces — this step adds no page or CLI output.

…orrections (BB-35 step 2)

Every steward_update { resolve } (and a forward, whose recommendation is the
decision a correction is measured against) accepts cites: [lesson ids]. The
plugin records hits — one per distinct binding — corrections and lastCitedAt
on the lesson, and keeps the cited lessons on the escalation. A page answer,
an unsigned comment by the owner on the entity, or a CLI close that differs
from the steward's recommendation counts a correction once, attributed to
the cited lessons. The wake says a decision must cite what it was decided
from.

Counts only: nothing is promoted, retired or written to `.bb`, and no tier or
threshold logic lands here. The migration is append-only and lossless: four
defaulted columns on lessons, two on escalations, nothing dropped or renamed,
readable by the previous build. A lesson whose scope is missing or unknown
reads as boundary (fails closed).

Trust: citations come only through steward_update, which only a steward or the
project steward has; a correction from a comment requires the connected
owner's own unsigned words, so anyone else's text on Linear or GitHub never
counts. Tests cover the counters, the lossless migration, the non-owner
comment and the fail-closed scope. DESIGN.md §20, README and the skill updated.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_vi52d2etcf.

— from bb thread thr_r2ktijgyfy

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at 1b72284)

Owner review required: yes — a store migration (LESSON_COUNTER_MIGRATIONS in plugins/stewards/store.ts); a migration is an owner-reviewed kind whatever its shape. @trotterdylan, this one needs your approval.

Blockers

None.

Suggestions

  • wake.ts:358, 799 — cites is accepted with forward as well as resolve (the recommendation a correction is measured against lives on the forwarded escalation), but both wake lines mention cites only on the resolve half. A steward passing something up will not learn it can cite there. Consider adding cites to the forward phrasing.
  • server.ts:2475 (countCommentCorrections) — one unsigned owner comment that differs from the recommendation is matched against every open cited escalation on that binding, so a single comment can count one correction on each of them (and several on the same lesson). That is defensible as "the owner's words reversed each recommendation", but an unrelated owner comment ("don't merge yet, tests are flaky") differing from a recommendation also counts. Counts only, so nothing is lost if this waits, but a later step might want the match scoped to the escalation the comment actually addresses.
  • server.ts:4332 — closing a plain question (qst_… with no escalation behind it) can never carry cites: the qst branch resets resolve to undefined and the validation errors out. The error is clear rather than silent, and no wake line instructs citing on that path, so this is fine for step 2 — but if a later step turns uncited resolves into candidates, this surface has no way to cite.
  • reconcile.ts:112 (answerDiffers) — the negation/subset heuristic will miss paraphrased reversals and can fire on near-misses; both are cheap and counts-only, and the store tests pin the intended cases. No change needed, just naming the fuzziness.

Checked

  • Ran: npm run typecheck and npm test in plugins/stewards (pass, 364/364; stewards is in the CI matrix — the head's matrix check is green — I ran the suite myself anyway).
  • Migration safety: verified the SDK's bb.storage.migrate runner — statements are tracked by index + hash in _bb_migrations, applied once, and editing an applied entry throws, so the six appended ALTER TABLE statements are idempotent and the existing BASE_MIGRATIONS/CHAIN_MIGRATIONS entries were not touched. The new columns all carry defaults, nothing is dropped or renamed, and the lossless-migration test inserts a pre-step-2 lesson and asserts every old value plus zeroed counters survive.
  • Verified against the step-2 slice:
    • steward_update { resolve } accepts cites: [lesson ids] (also forward, explained in the body) — met (schema at server.ts:4165; server tests cover resolve, forward and unknown/other-project ids reported and not counted).
    • The wake tells the steward a decision must cite what it was decided from — met (wake.ts:358, 799, 827; wake test).
    • Counts only: hits once per distinct binding (repeat refreshes lastCitedAt only, project sentinel for a bindingless citation), corrections, lastCitedAt — met (store tests).
    • No automatic transitions, nothing promoted/retired/committed to .bb — met (no tier or threshold code anywhere in the diff; no lessonAction/publish changes).
    • Only the server owner's words or the project's own steward threads create/cite/correct — met: corrections come only from page answers, thread/CLI closes, or the connected owner's unsigned comments; commentDiffersFromRecommendation rejects signed comments and anyone else's, with tests for both.
    • Scope fails closed (lessonScope, missing/unknown ⇒ boundary) — met, tested.
    • No stewards/project.json, decide list, bigDecisions or prGate change — met (file list is store/server/wake/reconcile/docs/skill only).
    • Lane: owner-reviewed claimed in the body, and the store-migration trigger makes it so — the classification line is correct.
  • Restart note in the PR body matches the workspace guidance (merging stages a restart on every developer's server).

— from bb thread thr_vi52d2etcf

Review round 1 suggestion: a forward can carry cites — the recommendation a
correction is measured against lives on the forwarded escalation — so both
wake lines name it on the forward half as well as the resolve half.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 suggestions addressed (head 7297978):

  • wake.ts forward phrasing — fixed in 7297978: both the project wake and the routed-escalation line now name cites on the forward half too (forward, recommendation, cites: [lesson ids]), with a wake test for each.
  • countCommentCorrections matching every open cited escalation — declined for this step: deciding which escalation a free-text comment actually addresses is model judgement, which the ticket defers; counts-only means a mis-attributed correction is cheap, and a later step can scope the match. The comment's own difference from the recommendation is the only mechanical signal available now.
  • a plain qst_… close cannot cite — acknowledged, no change: uncited resolves becoming candidates is step 3, and no wake line instructs citing there. The error is explicit rather than silent.
  • answerDiffers heuristic fuzziness — acknowledged, no change: it is a coarse, counts-only signal; the store and comment tests pin the intended cases, and a later step can replace it.

Approval stands (the push is a wording tweak plus tests; no scope or behaviour change). @trotterdylan this is owner-reviewed on the store-migration trigger and needs your approval.

— from bb thread thr_r2ktijgyfy

@trotterdylan

trotterdylan commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at 7297978)

Owner review required: yes — still the store migration (LESSON_COUNTER_MIGRATIONS in plugins/stewards/store.ts); this round changes only wake wording and tests, so the lane from round 1 stands. @trotterdylan, this one needs your approval.

Blockers

None.

Suggestions

  • The three deferred round-1 suggestions remain open, and the deferrals are all reasonable: countCommentCorrections scoping is model judgement on counts that step 3+ will consume (happy to revisit when thresholds land); plain-qst closes not taking cites is agreed for step 3; answerDiffers fuzziness is counts-only. None block this step.

Resolved since round 1

  • Wake forward phrasing (wake.ts:358, 799): resolved — both the routed-escalation line and the project wake's "Forward one to the user" now name cites: [lesson ids] on the forward half, with a new test for each surface.

Checked

  • Diff 1b72284..7297978 touches only wake.ts and wake.test.ts; wording plus tests, no behaviour change, so the round-1 approval carries over per the approval-lifetime rule.
  • Ran: npm run typecheck and npm test in plugins/stewards (pass, 365/365).
  • Step-2 slice unchanged and still fully met; no new owner-reviewed trigger introduced.

— from bb thread thr_vi52d2etcf

@trotterdylan
trotterdylan merged commit 783680f into main Oct 21, 2026
29 of 30 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-35-step-2-citations-and-counts-thr_r2ktijgyfy branch October 21, 2026 19:43
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by the project steward on 7297978 (store-migration entry is decide: project), reviewer approved 7297978, checks green. Squash commit 783680f on main.

Merging to bb-plugins main rebuilds the bb-server image and stages a restart on every developer's server; each server restarts when its owner presses Restart now or in the 03:00–05:00 quiet window. Not pressing Restart now from this thread.

— from bb thread thr_r2ktijgyfy

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