Skip to content

stewards: one project per sidebar RPC, batched reviewer lookup, live workers, per-method stats (BB-100) - #130

Merged
trotterdylan merged 3 commits into
mainfrom
bb/bb-100-stewards-sidebar-rpc-slimming-thr_cgtj4emf7f
Oct 28, 2026
Merged

trotterdylan merged 3 commits into
mainfrom
bb/bb-100-stewards-sidebar-rpc-slimming-thr_cgtj4emf7f

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-100.

The stewards sidebar RPC returned every project's bindings and ran one threads.list per worker of every open binding on each refetch, so a cold call cost seconds and 121 SDK listings. This makes the call take { projectId }, carry only that project's bindings/ended/needs (plus a per-project needsCount for the picker), drop the per-worker reviewer lookup in favour of the live thread tree, filter workers to the live set, and add an in-memory per-method stat readable from bb stewards stats and the Status section.

Merging moves the bb-server 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). Every running thread loses its turn when a server restarts.

Classification

no-review: additive/tweaks, with a plugin-internal RPC contract whose two ends ship in one image. No owner-reviewed trigger from AGENTS.md applies: no cross-repo contract, identity/access, backend/Dockerfile/plugin-list change, production infra, store migration, secret or new dependency. Item 1 changes the sidebar RPC's input/output, which is internal to plugins/stewards; the removed reviewers field stays optional in the zod output for one release.

What changes

  • One project per call (item 1). stewardsSidebar takes { projectId: string | null }; projects becomes { projectId, name, needsCount } for the picker, and bindings, ended, needs and projectStewardThreadId are top-level for the requested project only (first by name when null). needsCount is the open bindings with needsUser(b). StewardsSidebarCore asks for picked ?? boardRoute.projectId ?? activeProjectId and only refetches on a signal naming the shown project. DESIGN.md §21's picker note updated.
  • Drop the per-worker reviewer lookup (item 2). Removed reviewersByWorker, the 5 s reviewerCache and the produced reviewers field (kept optional in the zod output for one release). sidebar.ts no longer reads b.reviewers; a reviewer is a live thread whose parent is a claimed worker, which the fallback tree now attaches (workers are indexed). archiveFinishedWorkers and unhideOnce use one batched experimental_listDescendants call per up-to-200 worker ids instead of one threads.list per worker. The two single-worker reconcile paths (archiveConsumedReviewers, supersedeOlderReviewers) keep reviewersOf because they need a reviewer's own status or its direct-child relationship.
  • Only live workers (item 3). The RPC sends workers whose status is running or finished, plus any other worker whose endedAt is within the last hour. The running count and the "worker finished" phrase read the same fields as before.
  • Per-method stat (item 4). An in-memory table wraps every RPC method and CLI command (count, totalMs, maxMs, lastMs, lastAt) and counts published signals per project in the last hour. Exposed as bb stewards stats (plain text and --json) and in the Status section. The BB-95 debug lines stay.

Testing

  • npm run typecheck in plugins/stewards: pass.
  • npm test in plugins/stewards: pass (746 tests; stewards is in the CI matrix).
  • Added coverage: the sidebar RPC returns one project's bindings and every project's needsCount, null picks the first by name, no threads.list call from the sidebar RPC, a stopped worker older than an hour is absent while running/finished ones are present, and bb stewards stats reports a call and a signal; sidebar.test.ts covers a reviewer from the tree with no reviewers field and a stopped worker absent from the data; sidebar-app.test.tsx covers the pick passing its project, a signal for another project not refetching, and the picker count following needsCount.
  • Not tested: the actual bb-server timing improvement (needs a deployed build); the numbers are the store-read path by construction.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_iztg5w9h9n.

— from bb thread thr_cgtj4emf7f

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at b0484a4)

Owner review required: no — none of the owner-reviewed triggers apply. All four items are the ticket's own slimming of a plugin-internal RPC whose two ends ship together in this PR and one bb-server image; the stats surface is strictly additive. No decide-list entry's paths are touched (source-contract.ts, store.ts, package.json all unchanged — no migration, no dependency, no cross-repo contract), and the rest of the diff is tests and docs.

Blockers

  1. Red against current main on the merge ref. main moved past this PR's base: BB-97 (2b667b0, "rename the report actor me to user") merged after this branched and added a needsUser helper in plugins/stewards/server.test.ts (~line 2595 after the merge) that calls stewardsSidebar with a bare null and reads sidebar.projects[0].bindings. The new input schema rejects a bare null ("expected object, received null"), so the pull_request-event check (run 40704909055, the merge ref that gates the merge) is red: 2 failed / 753 passed. I reproduced it locally by merging origin/main into the head: typecheck passes, same 2 failures in server.test.ts. Fix: merge or rebase onto main and update that helper to the new shape ({ projectId: "p1" } input, top-level bindings output), and grep the merged tree for any other old-shape stewardsSidebar reader BB-97 introduced. The push-event check on the branch alone is green and does not show this.

Suggestions

  • The input schema also rejects the previous image's client: an open tab built from the previous image polls rpc.call("stewardsSidebar", null) every 30 s, and after the server restarts onto this image it will show "Refresh failed" until reload. The reviewers-optional gesture covers the output side only. Consider z.object({ projectId: ... }).nullable() on the input so an old tab degrades to the first-project payload instead of an error, or note the transitional error in the PR body. Cosmetic either way — a reload fixes it.
  • bb stewards stats shows its own row as 0 calls on the very first run (the stat is recorded after statsSnapshot() is taken). Fine, just mildly surprising.

Checked

  • Ran at the head: npm run typecheck (pass) and npm test in plugins/stewards (pass, 746 tests). stewards is in the CI matrix, so no plugin suite was skipped by CI. Ran the same on a local merge of origin/main into the head: typecheck pass, the 2 failures above.
  • Verified experimental_listDescendants in the pinned plugin SDK: it exists, takes 1–200 threadIds per call with includeHidden/includeArchived, returns { threadId, descendantIds } — the 200-id batching and the hidden-included/archived-omitted semantics match the old reviewersOf reading.
  • Verified against ticket:
    • Item 1 ✓ — input { projectId }; projects is { projectId, name, needsCount } for every stewarded project; bindings/ended/needs/projectStewardThreadId top-level for the requested project, first by name on null; StewardsSidebarCore asks for picked ?? boardRoute.projectId ?? activeProjectId and the usePolled load depends on it (stale answers are dropped by the latest guard); the realtime handler refetches only for the shown project; buildSidebar still builds a tab per live project with data for one; the picker count reads needsCount.
    • Item 2 ✓ — reviewersByWorker, REVIEWER_CACHE_MS and the produced field are gone; reviewers stays optional in the zod output; sidebar.ts indexes workers so the fallback tree attaches reviewers under them; archiveFinishedWorkers and unhideOnce use one batched experimental_listDescendants per ≤200 ids (conservative on failure: no archiving / marker left unset); the two single-worker reconcile paths keep reviewersOf, which is not a per-worker loop.
    • Item 3 ✓ — workers filtered to running/finished plus any other with endedAt within the last hour; the new test covers old-stop absent and running/finished/new-stop present.
    • Item 4 ✓ — in-memory per-RPC-method and per-CLI-command stat (count/totalMs/maxMs/lastMs/lastAt) wrapped around every handler and command, plus per-project signals in the last hour (pruned on publish, filtered on read); exposed as bb stewards stats (text and --json) and in the Status section; the BB-95 debug lines are kept.
    • Leave-outs respected ✓ — no changes to source-contract.ts or its copies, channels.ts (the channel string), or stewardsBoard's shape.
  • Tests named in the ticket are all present (one project + needsCount for all, null first by name, no threads.list from the sidebar RPC, live-worker set, bb stewards stats, reviewer-from-tree, stopped-worker-still-a-child, picking passes the project, other-project signal no refetch, picker count follows needsCount), and each would fail if its item were reverted.

— from bb thread thr_iztg5w9h9n

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed.

Blocker 1 (red against current main) — fixed in 9722e00. Merged origin/main (2b667b0) into the branch and updated BB-97's needsUser helper in server.test.ts to callRpc("stewardsSidebar", { projectId: "p1" }) and the top-level bindings output. Grepped the merged tree for any other old-shape stewardsSidebar reader; none. npm run typecheck and npm test (755 tests) pass on the merge.

Suggestions:

  • Make the input .nullable() for an old tab's poll — declined. The old client also validates the output against its old contract (per-project bindings/needs), which the new payload cannot satisfy, so accepting a bare null does not restore it. The ticket's input is { projectId } and the new client always sends an object; a reload is the fix, the same transitional cost the ticket's reviewers-optional gesture assumes.
  • bb stewards stats shows its own row as 0 on the first run — declined as out of scope: the stat is recorded after statsSnapshot() so a run cannot count itself; the row appears from the second run.

New head 9722e00; asking for round 2.

— from bb thread thr_cgtj4emf7f

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at 9722e00)

Owner review required: no — unchanged from round 1: the PR's net diff against main is still only the BB-100 changes (the BB-97 actor-rename and its store migration came in through the merge of main, already landed there as #128); no decide-list entry's paths are touched, no cross-repo contract, migration, dependency or access change, and the plugin-internal RPC's two ends ship in one image.

Resolved since round 1

  • Blocker 1 (red on the merge ref): resolved by 9722e00 — origin/main (2b667b0) is merged in (I verified the merge commit is byte-for-byte the automatic merge, so nothing was hand-resolved away), and BB-97's needsUser helper now calls stewardsSidebar with { projectId: "p1" } and reads the top-level bindings. No other old-shape reader remains in the tree. Both the push and the pull_request (merge-ref) stewards checks are green on this head.

Checked

  • Ran at 9722e00: npm run typecheck (pass) and npm test in plugins/stewards — 755 passed, matching CI.
  • Re-reviewed the new changes themselves: the merge brings only already-landed main code, and the fix commit is the two-line helper update; no new behaviour, no new risks.
  • Disputed suggestions, accepted as declined:
    • Input .nullable(): one premise in the dispute is off — the old client has no runtime zod for this contract (type-only import), so it does not "reject" the new payload; it would render degraded/empty tabs. But the conclusion stands: with the current schema an old tab shows an explicit "Refresh failed" until reload, which is at least as good a nudge, and either mode self-heals on reload. Dropped as cosmetic.
    • The stats command's own row counting from the second run: dropped, trivial.
  • All round-1 verification of items 1–4, the batched experimental_listDescendants use, the leave-outs and the test coverage still holds — none of it changed.

No blockers remain; the change does what BB-100 asks and the tests pass. No-review lane: merge when checks are green.

— from bb thread thr_iztg5w9h9n

@trotterdylan
trotterdylan merged commit 3de863f into main Oct 28, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-100-stewards-sidebar-rpc-slimming-thr_cgtj4emf7f branch October 28, 2026 14:34
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: no-review lane, reviewer approved 9722e00, checks green.

Merging to bb-plugins main moves the bb-server 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). Every running thread loses its turn when a server restarts.

merge commit 3de863f

— from bb thread thr_cgtj4emf7f

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