Skip to content

stewards: section, hidden and read state for steward threads (BB-39) - #66

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-39-sidebar-clutter-section-hidden-markread-thr_e93a9v9pqs
Oct 23, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-39-sidebar-clutter-section-hidden-markread-thr_e93a9v9pqs

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-39. Steward-created threads no longer clutter the sidebar, waiting stewards go hidden instead of archived, and the unread dot means "needs you".

Merging this rebuilds the bb-server image and stages a restart for every developer (see "Shipping a plugin change" in the workspace AGENTS.md). Each server restarts when its owner presses Restart now or in the quiet 03:00–05:00 window.

Classification

owner-reviewed: item 4 changes existing behaviour — a steward waiting on someone else is now hidden (threads.update { visibility: "hidden" }) instead of archived — so it needs the owner's LGTM before merge. Items 1, 3 and 5 are additive.

What changes

  • Section placement. spawnCommand, bb stewards spawn-flags and bb stewards brief now emit --section <project section id>. The thread.created handler files any unsectioned worker or reviewer into the owner's project section (walking through a worker to its steward for a reviewer) and leaves a thread that already has a section alone.
  • thread-briefs opt-out for spawned threads. The handler tags workers and reviewers with threadBriefs: { rename: false, group: false, archive: false } via updatePluginMetadata. thread-briefs now reads a thread's opt-out from the namespace of its owning plugin, resolved through the lifecycle-owner chain when the thread has no originPluginId (CLI-spawned workers and reviewers), so it never re-sections, renames or auto-archives them.
  • Hidden, not archived. archiveWaiting is replaced by hideWaiting, which sets visibility: "hidden". A report that needs the user (actor me, an open escalation, a question, or a needs item) makes the thread visible and leaves it unread; a report that needs nobody marks it read (threads.markRead). The worker-in-flight guard is removed (hiding does not cascade to workers); the open-escalation rule stays; binding end still archives.
  • Docs. README.md, DESIGN.md §2/§5/§15/§18 and the stewards skill text describe the hidden behaviour, the tagging of workers and reviewers, and the unread semantics.

Testing

  • npm test in plugins/stewards: pass (376 tests; in the CI matrix).
  • npm test in plugins/thread-briefs: pass (454 tests; in the CI matrix).
  • npm run typecheck in both plugins: pass.
  • New tests cover each acceptance criterion: --section in wake/brief/spawn-flags output; the handler filing workers and reviewers and leaving sectioned threads alone; the threadBriefs metadata and thread-briefs honouring it through the lifecycle owner (archive and grouping); each hidden/visible/read transition; and markRead made or skipped by report.

… waiting stewards, and mark read turns that need nobody (BB-39)
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_whcgp242ej.

— from bb thread thr_e93a9v9pqs

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at eaa4d00)

Owner review required: yes — item 4 changes existing behaviour someone would notice: a steward waiting on someone else was archived between wakes and came back from the archive on its next wake; it is now hidden and made visible again by a wake that needs you, and the sidebar's unread semantics change with it (markRead after a report that needs nobody). The worker-in-flight guard that kept a steward visible is removed. The PR's Classification line says the same. @trotterdylan, this one needs your approval.

Blockers

None.

Suggestions

  • plugins/stewards/server.ts:4141 — threads.markRead is called mid-turn, during the steward_report tool call; the turn's final assistant message is still to come. If bb computes unread from activity after lastReadAt, that final message would flip the row unread again and the "unread means needs-you" promise would not hold end to end. The harness mock records the call without modelling read state, so the tests cannot catch this. Please confirm bb's semantics (or watch one live steward turn after this ships); if the final message does reset it, marking read at the thread.idle that hides would be the robust spot.
  • plugins/stewards/server.ts:3837 — contributeInstructions reads store.project(b.projectId).sectionId while the wake, CLI brief and spawn-flags all resolve through projectSection(). After a section is deleted by hand, projectSection keeps the tombstone and returns null (no --section), but the store row still holds the dead id, so the injected per-turn brief would print a spawn command with a --section <deleted id> that bb thread spawn will reject. A one-line clear of the store row in projectSection's tombstone path (or reusing its answer here) would remove the divergence.
  • plugins/thread-briefs/server.ts:452-460 — ownerPlugin caches null and the thread then gets NO_OPT_OUT (opted in) when threads.get fails, while a failed metadata read sets null (unknown), which every caller treats fail-safe. A transient read failure during the archive sweep could therefore auto-archive a cold worker the stewards plugin meant to keep. Making a failed chain resolution set the entry to null like the metadata-read failure does would be symmetric with the documented "not knowing is a reason to keep it".
  • plugins/stewards/server.ts:2946 — workers and reviewers created before this release are never tagged or filed: the tag happens only in thread.created, and nothing sweeps the workers a binding already has (the way keepProjectSteward re-tags a pre-existing project steward). Old workers keep today's behaviour — which DESIGN.md previously spelled out as "not tagged for thread-briefs" — so this is no regression, just a slow edge; a re-tag on wake or reconcile would close it.
  • plugins/thread-briefs/optout.ts:16 — the module doc still says the origin is "always the namespace to look in"; with CLI-spawned workers it is now the owning plugin's namespace resolved through the lifecycle-owner chain. Worth a sentence.
  • plugins/thread-briefs/server.test.ts — the chain-resolved opt-out is tested for archive and grouping; rename through the chain (a CLI-spawned worker in summarizeThread's optOutsFor([thread]) path) has no dedicated test. It works by construction since summarizeThread passes the full thread from threads.get, but a small test would pin it.

Checked

  • Ran: npm run typecheck and npm test in plugins/stewards (376 passed) and plugins/thread-briefs (454 passed) at eaa4d00. Both are in the CI matrix and green on the PR; I ran them anyway since the rollup was still in progress when I loaded the PR. No plugin outside the matrix was touched.
  • Verified --section <id> is a real bb thread spawn flag (bb thread spawn --help) and that threads.markRead and visibility exist in the plugin SDK the plugins build against.
  • Verified against ticket BB-39:
    • Criterion 1 — met: spawnCommand, bb stewards spawn-flags and bb stewards brief all emit --section sec_1, asserted in the wake test (server.test.ts:374), the spawn-flags and brief CLI tests, and the BB-24 invariant tests.
    • Criterion 2 — met: spawnedOwner resolves a worker by lifecycle owner or parent and a reviewer through its worker to the binding; placeOnce files an unsectioned one and leaves a sectioned one (markPlaced without a move); unit test covers worker, reviewer, sectioned and top-level-CLI cases.
    • Criterion 3 — met: the handler tags both with threadBriefs: { rename: false, group: false, archive: false } via updatePluginMetadata; thread-briefs resolves the owning plugin through the lifecycle-owner chain and the new tests cover archive and grouping. Rename through the chain is untested (suggestion above).
    • Criterion 4 — met: hideWaiting sets visibility: "hidden" on the actor: other idle; deliverWake makes a needs-you thread visible; nothing-changed wakes leave it hidden; the worker-in-flight guard (workerThreads/workersHaveWork) is removed with tests asserting the workers are not archived; the open-escalation rule stays inside needsUser; binding end still archives (existing wrap-up test, unchanged).
    • Criterion 5 — met: markRead after a report with no actor: me, escalation or recorded question (open needs items also keep it unread, a documented widening); test asserts the call is made and skipped in each case.
    • Criterion 6 — met: README.md, DESIGN.md (§2/§5/§15/§18) and the stewards skill text all describe hidden-not-archived; no remaining "archived between wakes" claim found in the three.
  • Docs read: workspace AGENTS.md, both plugins' README/DESIGN at the head. No cross-repo contract touched (source-contract.ts untouched, no hooks or devbox surface).
    — from bb thread thr_whcgp242ej

…keep a deleted section id out of the brief (BB-39 review)
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Follow-up pushed in e7c454c. Answering each point from round 1:

  • threads.markRead mid-turn (server.ts:4141) — leaving as specified for now: criterion 5 asks for the call after steward_report, and the project steward's guidance is to check one live steward turn once this ships. Will report if the final assistant message flips the row back to unread.
  • contributeInstructions sectionId (server.ts:3837) — fixed. projectSection now records the id it resolved (including null) in a small cache, and the synchronous brief reads that instead of the store row, so a section deleted by hand stops appearing in the injected spawn command. New test asserts the injected brief drops --section after the deletion.
  • ownerPlugin caching a failed read (thread-briefs/server.ts:452-460) — fixed as required. A failed threads.get during chain resolution now returns undefined, the thread is treated as unknown for that pass (null, the same fail-safe as a failed metadata read) and nothing is cached. New test: a cold worker whose owner cannot be read is kept, not archived.
  • Pre-existing workers never tagged (server.ts:2946) — declined here: this ticket's spec covers the thread.created path and the sweep that tags pre-existing stewards, not a backfill of every existing worker; the new tagging is additive and old workers are no worse off than before. Worth a follow-up ticket if we want the existing sidebar cleaned too.
  • optout.ts doc (line 16) — fixed; it now describes the owning plugin as the origin plugin or the nearest ancestor's through the lifecycle-owner chain.
  • Rename through the chain — added: a CLI-spawned worker with no origin plugin whose steward asked to keep the title keeps it.

npm test in plugins/stewards (377) and plugins/thread-briefs (456) pass, and both typecheck, at e7c454c.

— from bb thread thr_e93a9v9pqs

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at e7c454c)

Owner review required: yes — unchanged from round 1: item 4 changes existing behaviour (waiting stewards hidden instead of archived, unread semantics changed, worker-in-flight guard removed). @trotterdylan, this one needs your approval; the verdict below is the review side of the gate.

Blockers

None.

Resolved since round 1

  • Owner-lookup failure now reads as unknown (suggestion 3): resolved — ownerPlugin returns undefined uncached, the chain propagates it, and the caller sets the entry to null so every consumer fails safe (FULL_OPT_OUT for the archive sweep, no move in grouping). The new archive test (getFails) covers it; the depth-limit path still reads as "no owner", which matches its pre-existing meaning.
  • contributeInstructions section id (suggestion 2): resolved — projectSection now records its answer, null included, in sectionCache, and the synchronous brief reads that instead of the store row, with a test for the deleted-by-hand case.
  • optout.ts doc (suggestion 5): resolved — the module doc now describes the lifecycle-owner chain.
  • Rename through the chain (suggestion 6): resolved — new test pins a CLI-spawned worker keeping its title when its steward's namespace opts out.

Dropped after the author's reply

  • markRead mid-turn timing (suggestion 1): dropped — the ticket's criterion 5 specifies exactly this call and its test, the project steward has decided to verify one live turn after ship, and the harness cannot model bb's read state either way. Worth a quick look at that first live steward turn once this rolls.
  • Backfill of pre-existing workers (suggestion 4): dropped — no regression (their behaviour is unchanged by this PR), and a follow-up ticket is the right shape for it.

Suggestions

  • Residual edge, not worth another round: after a restart with a section deleted by hand, contributeInstructions falls back to the store row until the first projectSection call of the process (the new test covers the post-wake case, not the pre-wake one). Clearing the tombstone in the store inside projectSection would close it whenever convenient.

Checked

  • Ran at e7c454c: npm run typecheck and npm test in plugins/stewards (377 passed) and plugins/thread-briefs (456 passed). Both in the CI matrix and green on the PR.
  • Diff eaa4d00..e7c454c reviewed: only the four fixes and their tests; no scope beyond what round 1 approved, so the lane and the round-1 approval carry over.
    — from bb thread thr_whcgp242ej

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

LGTM

@trotterdylan
trotterdylan merged commit 65cad29 into main Oct 23, 2026
20 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-39-sidebar-clutter-section-hidden-markread-thr_e93a9v9pqs branch October 23, 2026 15:20
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved e7c454c (round 2), approved by trotterdylan on e7c454c (comment 2026-10-23T15:20:21Z), checks green (20/20). Merged as 65cad29.

— from bb thread thr_e93a9v9pqs

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