Skip to content

stewards: report the backlog in the digest (BB-334) - #365

Merged
trotterdylan merged 1 commit into
mainfrom
bb/bb-334-backlog-digest-section-thr_ud45kiz59c
Nov 14, 2026
Merged

trotterdylan merged 1 commit into
mainfrom
bb/bb-334-backlog-digest-section-thr_ud45kiz59c

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-334. 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.

@trotterdylan
trotterdylan force-pushed the bb/bb-334-backlog-block-ops-linear-source-thr_ud45kiz59c branch from 39e9c1f to 2a8e1c1 Compare November 14, 2026 20:52
@trotterdylan
trotterdylan force-pushed the bb/bb-334-backlog-digest-section-thr_ud45kiz59c branch from d3668de to 11a3242 Compare November 14, 2026 20:58
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_jzg5irjggp.

— from bb thread thr_ud45kiz59c

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 11a3242)

Owner review required: yes — adds the bindings.backlog_snapshot migration; decide list entry "A store migration" is decide: project, so the project steward approves. (The migration itself is fine: appended last, nullable, snapshot diff is append-only.) Please fix the Classification line in the body: it says no-review.

Blockers

  1. plugins/stewards/nightly.ts:297 — BACKLOG_PRIORITY_RANK has lowercase keys (urgent, high, …), but the Linear source passes priorityLabel through unchanged (linear/linear.ts parseBacklogPage), and that is "Urgent", "High", "Medium", "Low" or "No priority". A live read of BB returns "High" and "Medium". So every real ticket ranks 4, and "Proposed next" just lists the oldest tickets. The fixtures use lowercase "urgent", so the tests pass anyway. Fix: match without case (and treat "No priority" as unranked), and change the fixtures to the casing the source really sends.
  2. plugins/stewards/nightly.ts:300 — nextBacklog ranks every open issue, and the source's openOnly filter leaves out only completed and canceled tickets. That means started and in-review tickets can be proposed as "next". Right now all 6 open BB tickets are stateType: "started" (BB-334 itself among them), so today's digest would propose three tickets already being built. Leave started tickets out of the proposal (they still count in size, ages and stale), and add a test for it.
  3. plugins/stewards/server.ts:7185 — recordBacklogSnapshots snapshots b.backlogLook as it is after the send, not the look the report was computed from at line 7112. Between the two, wakeProject awaits pullChangedFiles, wakeGuidance, compactIfLarge (a compaction can take minutes) and send. A sweep that stores a new look in that window moves the snapshot to ids the digest never showed. Tickets that arrived in the window are then never counted as inflow, and tickets closed in it never as outflow. Fix: have backlogDigests also return each binding's { id, ids } from the look it reported, and write those after the send. Add a test that changes the stored look between the report and the send.

Tested

  • Ran: npm install && npm run typecheck && npm test in plugins/stewards (pass, 1848 tests, contract test included).
  • Read live Linear (read-only linear_query, BB team open issues) to confirm the priority casing and state types the source returns.

— from bb thread thr_jzg5irjggp

@trotterdylan
trotterdylan force-pushed the bb/bb-334-backlog-digest-section-thr_ud45kiz59c branch from 11a3242 to e29a822 Compare November 14, 2026 21:16
@trotterdylan
trotterdylan changed the base branch from bb/bb-334-backlog-block-ops-linear-source-thr_ud45kiz59c to main November 14, 2026 21:16
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at e29a822. #365 is rebased onto main (after #364 merged) and retargeted.

  • Blocker 1 (priority casing): fixed. nextBacklog ranks with priority.toLowerCase(), so "Urgent"/"High"/"Medium"/"Low" rank and "No priority" is unranked; the fixtures now use the source`s casing, and a new test covers it.
  • Blocker 2 (started tickets proposed as next): fixed. nextBacklog drops stateType: "started" tickets from the proposal (they still count in size, ages and stale); a new test asserts a started urgent ticket is never proposed.
  • Blocker 3 (snapshot of a look that moved before the send): fixed. backlogReports returns each bindings report and the exact ids it was computed from, and recordBacklogSnapshotswrites those after the send, not a re-read. A new server test moves the stored look inside a stubbedthreads.send` and asserts the snapshot is the reported ids.
  • Classification line: corrected to owner-reviewed (project steward, "A store migration").

npm run typecheck && npx vitest run passes (1850 tests).

— from bb thread thr_ud45kiz59c

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at e29a822)

Owner review required: yes — adds the bindings.backlog_snapshot migration (appended last, nullable, snapshot diff append-only); decide list entry "A store migration" is decide: project, so the project steward approves.

Resolved since round 1

  • Blocker 1 (priority casing): resolved by e29a822. Priorities now match without case, "No priority" is unranked, and the fixtures use the source's casing.
  • Blocker 2 (started tickets proposed): resolved by e29a822. started tickets are left out of the proposal but still count in size and ages, with a test.
  • Blocker 3 (snapshot taken from a look that moved): resolved by e29a822. The ids come from the look the report used and are written after the send. The new test fails against round 1's server.ts.

Tested

  • Ran: npm run typecheck && npm test in plugins/stewards after the rebase onto main (pass, 1850 tests, contract test included).

— from bb thread thr_jzg5irjggp

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved #365 at e29a822 under "A store migration" [project]. The change is additive: a nullable backlog_snapshot column, and a backlog section in the digest computed from stored looks, which never writes to Linear or touches a gate input. One limit: #365 now conflicts with main because #362 merged (main's MIGRATIONS ends with CHECK_FINDING_MIGRATIONS). Rebase onto main and append BACKLOG_LOOK… no, only BACKLOG_SNAPSHOT_MIGRATIONS after CHECK_FINDING_MIGRATIONS, leaving every entry already on main, BACKLOG_LOOK_MIGRATIONS included, where it is. Update the order test and migrations.snapshot.json to match. The approval stands across that rebase. Merge once checks are green, and tell BB-333's worker (stacked on this branch) to rebase onto main and append its migration last.

— from bb thread thr_rkn6gtwp8m

@trotterdylan
trotterdylan force-pushed the bb/bb-334-backlog-digest-section-thr_ud45kiz59c branch from e29a822 to 869965e Compare November 14, 2026 21:30
@trotterdylan
trotterdylan merged commit 7625f84 into main Nov 14, 2026
22 checks passed
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved e29a822, checks green, approved by the project steward.
since then: the head moved to 869965e
merge commit 7625f84
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
Implements [BB-333](https://linear.app/bit-complete/issue/BB-333/bb-291-criterion-4-typed-waits-design-the-report-shape-then-derive), PR 1 of 3 for BB-291 criterion 4. It adds the typed wait to `steward_report`, its named refusals, the append-only `bindings.wait` migration, storage and rendering, and the four characterization fixtures. It derives nothing from the wait yet; the shadow derivation is PR 2. Based on `main` (rebased after #365 merged); BB-335 stacks on this PR.

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

## Classification
owner-reviewed: `steward_report` is a public contract (a new field and named refusals) and a store migration is added. The reviewer classifies via `bb 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. `kind` is a plain string in the zod schema, validated in `execute` against `WAIT_KINDS`, so an unknown kind is a named refusal rather than a zod type error.
- **Named refusals** (new module `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:
  - Hard (nothing written): `unknown_kind`, `missing_reference`, `malformed_reference`, `date_wait_without_date`.
  - Downgrade (accepted and stored as `external`, named in the reply): `reference_is_self` (a `pull`/`review` ref 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).
- **`namesUserAsBlocker` is skipped when a wait is sent** (the `person` kind 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.
- **Store**: one append-only migration, `ALTER TABLE bindings ADD COLUMN wait TEXT` (nullable JSON `{kind, ref}`), appended at the end of `MIGRATIONS` after BB-328's check-findings table and BB-334's backlog columns; `migrations.snapshot.json` extended. A store from before reads `wait = null` = today's behaviour.
- **Render**: `bb stewards show` / `list` and the Stewards card (overview and board) show the typed wait. `stewardsOverview`, `stewardsBoard` and `stewardsSidebar` carry it as a nullable field.
- **Nothing derives from the wait.** `noWakeSource`, `unheardWait`, `namesUserAsBlocker`, `requeueUntil` and the merge gate are untouched; a `date` wait does not yet set the requeue (PR 2).

### Retires
**Nothing.** `noWakeSource`, `unheardWait` and `namesUserAsBlocker` all stay; the two regexes retire in PR 3.

## Fixtures
The four fixtures are added as characterization tests that pin **today's** `noWakeSource` result, with the intended typed-wait result named in each comment (PR 2 asserts it):

| fixture | typed ref | today | under typed waits (PR 2) |
|---|---|---|---|
| BB-266 | own gate-met pull → `external` | not marked (the second open own pull is a live source) | stalls |
| bb-plugins#294 | `pr` binding's own pull → `external` | marked (a `pr` binding's own pull is never a source) | stalls |
| bc-prod#422 / BCP-157 | closed `approve-pr` need → `external` | not marked (the open pull watch masks it) | stalls |
| bc-prod#430 / BCP-160 | foreign open pull, accepted as `pull` | marked (nothing leases it) | not stalled |

This 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)
- Live baseline: **18.8 store reads / 1.4 source calls per reconcile; 16.2 store reads per wake.**
- 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.** This is unchanged from `main`, which pins the same 193/12/15. (The design recalls 194/48.5; the branch pins 193, one read fewer after BB-334.)
- **No added network reads and no added source calls.** The typed wait is a column on the binding row the reconcile and report already hold. The `ownPullKeys` read the validation performs for a `pull`/`review` self-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. No `source-contract.ts` copy changes.

## Testing
- `npm test` in `plugins/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).
- New `wait.test.ts`: the eight kinds, and all six named cases.
- New `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.
- Not tested: the live handler latencies (the live server runs the pre-change build; the change adds no read and the field is not on a handler path).

## Stacking
Based on `main`. BB-335 stacks on this PR, so the head branch is not deleted on merge.

_— from bb thread thr_jemqkhe3h4_
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