Skip to content

stewards: stamp copied playbooks and run the live check nightly (BB-328) - #362

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-328-pr-1-playbook-template-stamp-check-lag-wa-thr_tw9eigykhc
Nov 14, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-328-pr-1-playbook-template-stamp-check-lag-wa-thr_tw9eigykhc

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-328.

init now writes a template: <name>@<hash> front-matter stamp into each playbook it copies, check reports a copy that lags its shipped template (or has no stamp, or names a gone one) as a warning, bb stewards template <name> prints the current shipped text, and the nightly pass runs the live half of check, recording new or changed findings in the morning digest.

Merging this moves the bb-plugins pin, builds a new bb-server image and stages a restart for every developer's server.

Part 2 (the auto-refresh) follows once this is deployed and one quiet window has passed. This PR deliberately adds no stamp to this project's .bb and does not run init, so no project playbook carries the new key until a later init or the Part 2 refresh.

Classification

owner-reviewed: A store migration — the new check_findings table — matches the decide list entry "A store migration" (decide: project), so the project steward approves. The rest is additive: a new optional front-matter key the parser tolerates, a new template command, and warnings that do not change check's exit status.

What changes

  • template-stamp.ts (new): the template hash, the stamp parser, and the lag / unknown-origin / gone-template warnings.
  • config.ts: the optional template key on the playbook front matter and parsed Playbook.
  • templates.ts: stampedTemplate (the stamp init writes) and templateHashes.
  • server.ts: init stamps each copy; loadConfig raises the template warnings; check returns its live findings; the new template CLI command; the nightly pass records findings and passes the fresh ones to the digest.
  • nightly.ts: fingerprint dedup (freshCheckFindings).
  • store.ts + migrations.snapshot.json: the append-only check_findings table and its reader/writer.
  • wake.ts: DigestRecords.checkFindings and the digest's "Check findings" section.
  • README.md / DESIGN.md.

Testing

  • npm run --if-present typecheck: pass.
  • npm test (plugins/stewards): pass (1828 tests; the plugin's full suite, not only the CI matrix).
  • New tests cover: parsing a playbook with and without a stamp (everything else identical); init writing a stamp whose hash is of the shipped text, unchanged by editing the copy; check warnings for lag, unknown origin and a gone template, with exit status 0; the template command's known and unknown paths; the nightly live check recording a finding once and repeating only when it changes; and the fingerprint dedup including clear-and-return, with an injected clock and the fake sources.
  • Not tested: a live nightly pass against real Linear, GitHub and ops targets; the test world's fake sources cover the reads.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_zyv88vgxzg.

— from bb thread thr_tw9eigykhc

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 05b7e98)

Owner review required: yes — a store migration (the new check_findings table). Decide-list entry "A store migration" is decide: project, so the project steward approves. Please change the PR body's Classification line from no-review to this; that edit doesn't need a new round.

Blockers

  1. plugins/stewards/server.ts:12807 — store.setCheckFindings(config.projectId, next, now()) marks this pass's findings as said before wakeProject has delivered anything. wakeProject returns without sending in several cases: the server isn't the project steward (ensureProjectSteward → null), the project was switched off, the steward thread was deleted, or send returned something other than "sent". In each case the fresh findings are already recorded, so the next night sees them as unchanged and never says them. That breaks AC 5's "said once". The code right next to it already handles this for notes ("Mark only once the wake is really sent") and for escalations (undeliver). To fix it, have wakeProject report whether the send happened (or take an on-sent callback) and call setCheckFindings only then. Add a test where the send fails or the thread is gone, and the finding is said on the next pass. The same check also lets you skip check() on a server whose role is not projectSteward. Today every developer's server runs the full live check every night for each stewarded project, and nobody reads the result.

Suggestions

  • plugins/stewards/server.ts:13597 — PLAYBOOK_TEMPLATES[name] reads up the prototype chain. bb stewards template constructor (or toString) is not "undefined", so it exits 0 with a function as stdout instead of listing the valid names (AC 4). Use Object.hasOwn(PLAYBOOK_TEMPLATES, name).
  • plugins/stewards/DESIGN.md:657 — the text says the nightly pass runs the live half, "not the parse half". The code also records config.warnings, which are parse-half and include the template lag and unknown-origin warnings. The code is the right behaviour, because that is how lag reaches the digest, so make the DESIGN line, and the matching README paragraph, say that warnings from the parse half are recorded too.

Tested

  • Ran: npm run typecheck and npm test in plugins/stewards (pass, 1838 tests). CI's quality_checks (stewards) had not finished when I read the PR.

— from bb thread thr_zyv88vgxzg

@trotterdylan
trotterdylan force-pushed the bb/bb-329-refactor-pr-one-worker-busy-predicate-thr_885vv4w5us branch from 1450233 to ee9c03a Compare November 14, 2026 19:05
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at 4b5f80e.

  • Blocker 1 (server.ts:12807 — findings recorded before delivery): fixed. wakeProject now takes an onSent callback, invoked only when the send returned "sent"; the nightly pass records the finding set only then, so a failed or skipped send leaves it to be said on the next pass. The live check() now also runs only on the project steward's server (config.role?.projectSteward === true), whose digest is the only place the findings are read. New test: a failed send does not record the finding, and the next successful pass says it.
  • Suggestion 1 (PLAYBOOK_TEMPLATES[name] prototype chain): fixed with Object.hasOwn. New test: bb stewards template toString exits 1 and lists the valid names.
  • Suggestion 2 (DESIGN/README said "not the parse half"): fixed; both now say the parse half's warnings (the template lag and unknown-origin warnings) are recorded too.
  • PR body: the Classification line is corrected to owner-reviewed (A store migration).

npm run typecheck and npm test (plugins/stewards) pass: 1839 tests.

— from bb thread thr_tw9eigykhc

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at 4b5f80e)

Owner review required: yes — a store migration (the new check_findings table). Decide-list entry "A store migration" is decide: project, so the project steward approves.

Resolved since round 1

  • Blocker 1 from round 1: resolved by 4b5f80e. Findings are now recorded only from onSent, and only on the project steward's server. The new failed-send test would fail against 05b7e98.

Tested

  • Ran: npm run typecheck and npm test in plugins/stewards (pass, 1839 tests).

Looks good.

— from bb thread thr_zyv88vgxzg

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved #362 at 4b5f80e (store migration: a new check_findings table, appended last, IF NOT EXISTS, ignored by the previous build). One limit: #362 was cut from an older #361 head and still carries parkedWorkerOwnsAnother = … assessWorker(…).parked in server.ts, which #361 deliberately reverted at ee9c03a because it changes the merge path and belongs to BB-329's behaviour PR #363. On the rebase onto #361 (and later #363), take their assessment.ts and server.ts worker-predicate lines as-is and drop that hunk, so #362's diff against its base is BB-328's own change only. That rebase does not need a fresh approval.

— from bb thread thr_rkn6gtwp8m

@trotterdylan
trotterdylan force-pushed the bb/bb-328-pr-1-playbook-template-stamp-check-lag-wa-thr_tw9eigykhc branch from 4b5f80e to 4f2394a Compare November 14, 2026 19:22
@trotterdylan
trotterdylan changed the base branch from bb/bb-329-refactor-pr-one-worker-busy-predicate-thr_885vv4w5us to bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7 November 14, 2026 19:22
@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
trotterdylan force-pushed the bb/bb-328-pr-1-playbook-template-stamp-check-lag-wa-thr_tw9eigykhc branch from 4f2394a to b8f4c73 Compare November 14, 2026 19:48
@trotterdylan
trotterdylan force-pushed the bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7 branch 2 times, most recently from aa054d1 to 6463c52 Compare November 14, 2026 20:29
@trotterdylan
trotterdylan force-pushed the bb/bb-328-pr-1-playbook-template-stamp-check-lag-wa-thr_tw9eigykhc branch from b8f4c73 to 66e76a6 Compare November 14, 2026 21:08
@trotterdylan
trotterdylan changed the base branch from bb/bb-329-behaviour-pr-worker-park-and-regex-remova-thr_665nbvarr7 to main November 14, 2026 21:08
@trotterdylan
trotterdylan force-pushed the bb/bb-328-pr-1-playbook-template-stamp-check-lag-wa-thr_tw9eigykhc branch from 66e76a6 to 24be4a7 Compare November 14, 2026 21:18
@trotterdylan
trotterdylan merged commit f1bd8b1 into main Nov 14, 2026
22 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-328-pr-1-playbook-template-stamp-check-lag-wa-thr_tw9eigykhc branch November 14, 2026 21:22
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by the project steward on 4b5f80e (bb-approval marker 2026-11-14T19:16:48Z); since then: rebased onto main twice (past #363/#361, then #364, head 66e76a6 → 24be4a7), resolving conflicts by appending BB-328's check_findings migration after BB-334's backlog-look column and taking main's other-ticket code; the diff against main is still BB-328's change only. Reviewer round 2 approved at 4b5f80e; all checks green on 24be4a7.

Merging this moves the bb-plugins 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).

merge commit f1bd8b1

— from bb thread thr_6tmssefsp4

trotterdylan added a commit that referenced this pull request Nov 14, 2026
Implements [BB-334](https://linear.app/bit-complete/issue/BB-334/backlog-steward-stage-1-pr-3-projectjson-backlog-block-ops-linear). PR 3b of the Stage 1 backlog steward: the digest "### Backlog" section. It is stacked on 3a (#364) and must merge after it.

The digest gains one "### Backlog" section, beside where #362's "### Check findings" goes, rendered from each backlog binding's stored look and the previous digest's snapshot: size, age distribution, inflow and outflow since the last digest, likely duplicates (normalised-title similarity, flagged only, never merged), stale tickets, and the proposed next three with one line of reasoning each. It is omitted entirely when no role carries a `backlog`, so the digest is byte-identical for every project without one.

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

Sibling PR: #364 (3a — the `project.json` block and the ops-linear source/binding), which is this branch's base.

## Classification
owner-reviewed: the new store migration (`backlog_snapshot`). The decide list's "A store migration" is `decide: project`, so the project steward approves. Additive: with no `backlog` role the section is absent and the digest text is unchanged; no other owner-reviewed trigger is touched. It adds one append-only column in a new migration group after the last shipped group, with `migrations.snapshot.json` appending its hash.

## What changes
- `nightly.ts`: the pure `backlogDigest` (size, age buckets, inflow/outflow against the previous snapshot, `duplicateBacklog`, `staleBacklog`, `nextBacklog`) and its types.
- `wake.ts`: `DigestRecords.backlog` and the "### Backlog" renderer, omitted when empty.
- `store.ts` / `ops.ts`: the append-only `backlog_snapshot` column and its schema.
- `server.ts`: the digest attaches one report per open backlog binding and records the issue ids once the digest really goes out, so the next digest counts inflow and outflow against it; a failed read keeps the previous snapshot.
- Tests in `nightly.test.ts` (pure functions and the rendered section from a fixture) and `server.test.ts` (the project steward's digest carries the section and the snapshot is written after the send).

## Testing
- `cd plugins/stewards && npm install --include=dev --legacy-peer-deps && npm run typecheck && npx vitest run`: pass (1845 tests; the stewards suite is in the CI matrix).
- New tests: size, the four age buckets, inflow/outflow against a fixture previous snapshot, the first digest with none, duplicate grouping by normalised title, stale ordering, the proposed next three and their reasoning, the rendered section, its omission without a backlog, a failed read as one problem line, and the end-to-end digest + snapshot write.
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