Skip to content

stewards: the built-in local ticket source (BB-361) - #407

Merged
trotterdylan merged 3 commits into
mainfrom
bb/bb-361-feature-pr-local-ticket-source-thr_9zr73qxgcr
Nov 18, 2026
Merged

trotterdylan merged 3 commits into
mainfrom
bb/bb-361-feature-pr-local-ticket-source-thr_9zr73qxgcr

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-361. This is PR 3 of 3 (the feature); the contract PR (#399) is merged and deployed, and the gate-key PR was skipped because the gate already accepts LOCAL-<n>.

A third source, local, is served by the stewards plugin itself in-process over source-contract.ts, backed by two new tables. A local ticket is filed with the neutral ticket_file in unit local, is adopted by state rather than by label (Backlog parked, Ready-or-later adopted), and from then on every ticket-binding consumer works unchanged. Writes ring the reconcile loop in-process: no webhook, no lease, no bb-gate-hooks.

A merge to bb-plugins main moves the pin, builds a new bb-server image and stages a restart for every developer's server.

Sibling PR: none; this is the last half of BB-361. PR 1 (#399, contract) is merged.

Classification

owner-reviewed: a new migration and two store tables, and source-contract.ts and its two byte-identical copies (the cross-repo contract entry, project-decided in bigDecisions). The contract change is one additive field (below); the rest is the feature. The reviewer decides the lane from the diff.

What changes

  • Store (store.ts). local_tickets and local_comments appended as a new migration group; migrations.snapshot.json gains the four new hashes. Comments carry the authoring bb thread, or null for an owner page comment.
  • Tools (ticket-tools.ts). ticket_file with no unit now files a local ticket, per the ticket's "(or defaulted)"; this replaces the old "the only configured unit" default, so a project with one GitHub repo and no local unit named files local rather than that repo. The tool description names the change.
  • Source (local-source.ts). sourceSnapshot, sourceCreateIssue, sourceUpdateIssue (state and parent only; labels/priority/relations error), sourceComment (refuses an unsigned body), sourceAdoptable (by state), sourceSearchIssues, and the owner page comment / description edit / state control. Keys are <prefix>-<n> (default LOCAL, localPrefix in project.json, refused when it equals a Linear team key), numbered server-wide so two projects cannot collide.
  • Server (server.ts). sourceRpc("local", …) is dispatched in-process; adoptionKind/maybeAdopt/projectFor/lifecycle adopt a local ticket by state; bindingPlaybook/playbookFor route it by the snapshot's optional playbook; sourceForKey reads the local prefix; the stewardsLocalTicket/stewardsLocalEditDescription/stewardsLocalComment/stewardsLocalSetState RPCs for the page; the bb stewards tickets list|show|file|comment|update|close|export CLI; and bb stewards detach <local key> sets Backlog.
  • Playbook (templates.ts, config.ts). A built-in local-tickets playbook (states Backlog/Ready/In Progress/In Review/Done/Canceled), overridable by .bb/stewards/playbooks/local-tickets.md; frontMatterSchema.source gains local; playbookFor resolves the name a local ticket filed under (initiative, say).
  • Contract (source-contract.ts ×3). sourceCreateIssue.input gains an optional playbook. This is the one place the feature needed a contract field the first PR did not add: a local ticket names its playbook at filing, and the creation RPC had no field for it. Linear and github ignore it; the copies stay byte-identical.
  • Owner comments are the spec (reconcile.ts). isSpecComment/specText/specHash take an optional owner, so an unsigned comment authored by the viewer counts as the user's spec; an agent comment (signed by any thread) never does. ticket_update only moves a local ticket to Ready in a turn the owner started (a plain client turn); a plugin wake or a Slack participant's forward lands it in Backlog.
  • App (app.tsx). The detail view grows a local-ticket panel: the description editor, the state control and the owner's comment box.
  • Skills and docs. The stewards skill documents local tickets; the onboarding skill mentions localPrefix; the README and the CLI help follow.

Testing

  • plugins/stewards: npm run typecheck pass; npm test pass (2166 tests, 49 files; in the CI matrix).
  • plugins/linear: npm run typecheck pass; npm test pass (164 tests).
  • plugins/github-watcher: npm run typecheck pass; npm test pass (123 tests).
  • Added: local-source.test.ts (the source's contract behaviour against a real in-memory SQLite); local-ticket.test.ts (ticket_file → tickets show, adoption/detach/resume, the non-owner adoption rule for Ready/In Progress, playbook routing, the owner-vs-agent comment rule, the default unit, the CLI); a reconcile.test.ts gate test that a PR citing an approved LOCAL-1 passes the product check and one without an approval is escalated; and an app.test.tsx test for the editor, state control and owner comment.
  • Not tested: a live Linear/GitHub write, and the page against a real server (the app test drives the RPC mocks).

🤖 Generated with Claude Code

Implements BB-361: a third source, local, served by the stewards plugin
itself in-process over source-contract.ts, backed by local_tickets and
local_comments. A local ticket is filed with ticket_file in unit local,
adopted by state rather than by label, and runs local-tickets (or the
playbook it named at filing). Writes ring the reconcile loop in-process.

- Store: the two tables and their migration, with the snapshot updated.
- Source: create/snapshot/update/comment/adoptable/search, state-only
  adoption, owner page comments, and the prefix from project.json.
- Server: sourceRpc dispatch for local, adoption by state, playbook
  routing by the snapshot field, the local-tickets built-in playbook,
  sourceForKey, the CLI and the detail-view RPCs.
- Tools/skills/app: ticket_file's local unit and playbook, the CLI
  commands, the description editor and state control, and the docs.

A merge to bb-plugins main moves the pin, builds a new bb-server image
and stages a restart for every developer's server.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_g9s4u7htpy.

— from bb thread thr_9zr73qxgcr

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 1ec4937)

Owner review required: yes — reconcile.ts changes which spec comment is the user's (isSpecComment/specText/specHash gain an owner branch). Under the standing rule that makes it the owner's, although the matching decide-list entries ("A store migration", "A cross-repo contract", and "The stewards plugin outside its authority seams") are all decide: project. The escalation is binding: a project-steward bb-approval will not meet the gate, and the owner's unsigned approval will. @trotterdylan, this one needs your approval.

Product

Adds a third ticket source, local. Tickets live in the stewards SQLite store (two new tables), are adopted by state, and come with a bb stewards tickets CLI and a local-ticket panel on the detail view (description editor, state control, owner comment box). I searched the stewards plugin and the deployed plugins for local tickets. The only hit is workstreams (not deployed), which keeps a ticket→effort name map, so it is not an overlap. Scope matches BB-361 apart from blockers 3 and 4.

Blockers

  1. ticket-tools.ts:394, server.ts:16352, server.ts:11198 — binding limit 3 is enforced for the literal state "Ready" only. A local ticket is adopted in any state that is not Backlog and not terminal (adoptionKind, adoptedBySource). A non-owner turn can therefore call ticket_update { state: "In Progress" } or bb stewards tickets update --state "In Review" and the ticket is adopted. A scratch test reproduced this: the steward's own wake turn (no owner turn) moved LOCAL-1 from Backlog to In Progress, and a binding was created. Done → In Progress likewise reopens an ended binding. stewardsLocalSetState also has no caller.kind !== "client" check, unlike its two siblings. Fix: guard every move from Backlog or a terminal state into an adopted state, in one place that the tool, the CLI and the RPC all go through. Require a client caller on stewardsLocalSetState. Add a test for the In Progress case.

  2. reconcile.ts:99 — binding limit 2 is not met: an agent comment signed by a user thread still counts as the user's spec. The signed branch of isSpecComment is unchanged. A local ticket_comment from any thread isUserThread accepts (every thread that is not a binding, worker or project steward, including one a Slack participant's message started) therefore counts as the user's spec comment. diffObserved marks it byUser, and server.ts:5881 then approves the spec under approval: user. Scratch test: specHash changes for a comment signed thr_user with isUserThread true. Neither of the PR's limit-2 tests covers this. One signs with thr_w1, which is not a user thread. The other signs with the steward thread and checks against "thr_s", so it passes trivially. Fix: for source === "local", only an unsigned comment authored by the owner (the page path) counts as the user's. Pin the user-thread-signed case in a test.

  3. server.ts:4869, 4872, 5814 — the owner branch also changes the spec gate for Linear and GitHub tickets. specHashFor, specTextFor and diffObserved pass entity.viewer for every source. On Linear, viewer is account.user.name and a comment's author is personName(c.user), the same display name. On GitHub, both are the login. Scratch test: an unsigned "Spec: …" comment by the viewer on a Linear issue now changes the hash. Two effects:

    • Once this deploys, every in-flight Linear or GitHub binding with such a comment has its approval voided and the approve-spec need raised again.
    • From then on, an unsigned comment from the owner's account counts as the user's spec. Every agent that uses the linear tools or gh posts from that account, and under approval: user such a comment self-approves.

    The ticket did not ask for this, and limit 2 confines the rule to the Stewards page. Fix: pass the owner only when entity.source === "local". Add a test that a Linear or GitHub snapshot's hash is unchanged by an unsigned viewer comment.

  4. ticket-tools.ts:62 — ticket_file's default unit. The ticket says ticket_file defaults to the local unit when the thread is in a project. The PR instead appends local as one more unit, so the default applies only when local is the project's only unit. As a side effect, a project with a single GitHub repo (which defaulted to that repo before) now errors with "lists several units (acme/web, local)". Implement the ticket's rule, so that no unit means local. That replaces the existing single-unit default, so name the change in the PR body. Add a test.

Tested

  • Ran: npm run typecheck && npm test in plugins/stewards (49 files, all pass; the CI job was still running), plugins/linear (164 pass) and plugins/github-watcher (123 pass), the last two not in the CI matrix. The three source-contract.ts copies are byte-identical (cmp). The migration is append-only, and the snapshot diff only appends lines.
  • Ran: one scratch vitest file, not committed, reproducing blockers 1–4.
  • Verified against ticket: "ticket_file with unit local (or defaulted)" — the defaulted half is not met (blocker 4).

— from bb thread thr_g9s4u7htpy

- The adoption guard is on every move out of Backlog or a terminal state
  into an adopted state, in the source's update, so the tool, the CLI and
  the page RPC all pass through it; stewardsLocalSetState is client-only.
- A local comment is the owner's spec only when unsigned and authored by
  the viewer; a signed comment from any thread never counts, and the owner
  branch is not used for Linear or GitHub.
- ticket_file with no unit files a local ticket, per the ticket, replacing
  the single-unit default.
- Tests for the In Progress move, the user-thread-signed comment, the
  Linear/GitHub hash unchanged, and the default unit.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed in 4e63cad. All four blockers fixed:

  1. Binding limit 3 (adoption guard). The guard now lives in local-source.ts's update, so ticket_update, bb stewards tickets update and stewardsLocalSetState all pass through it: a move out of Backlog or a terminal state into an adopted state (Ready/In Progress/In Review) lands in Backlog unless ownerTurn is true. stewardsLocalSetState now requires caller.kind === "client". Added tests for the In Progress move (tool and source) and the terminal→adopted move.
  2. Binding limit 2 (agent comments). For source === "local", isSpecComment counts only an unsigned comment authored by the viewer; the signed branch is not used. Pinned the user-thread-signed case (thr_user with isUserThread true) in reconcile.test.ts.
  3. Linear/GitHub unchanged. specHashFor/specTextFor/diffObserved pass the owner only when entity.source === "local", and isSpecComment's owner branch is local-only. Added a test that an unsigned viewer comment does not change a Linear snapshot's hash.
  4. ticket_file default unit. With no unit, ticket_file now files a local ticket, per the ticket's "(or defaulted)", replacing the single-unit default. The PR body names the change; server.test.ts covers the default and the explicit local unit.

Also made the new app.test.tsx local-ticket test wait for the description to load, so it is not timing-flaky.

— from bb thread thr_9zr73qxgcr

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

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

Blockers

  1. reconcile.ts:105 — for a local ticket, the steward's own spec comments no longer count toward the spec. The source === "local" branch now returns true only for an unsigned owner comment, so the steward's signed "Spec:" comments are dropped from specText/specHash as well. The built-in local-tickets playbook (templates.ts:216, 233) tells the steward to "post it as spec comments" and to start them with "Spec:" "so it counts toward the spec an approval is pinned to". So the project steward's approval pins only the description and leaves out the acceptance criteria and plan the steward wrote, and a later steward Spec comment that changes the scope does not void it ("A new spec needs approval again" stops holding). Limit 2 is about what counts as the owner's spec. Keep c.signedBy === stewardThreadId counting for local and drop only the isUserThread branch; byUser stays false for it, because a steward thread is never a user thread. Add a test that a steward-signed local Spec comment changes the hash and a user-thread-signed one does not.

Resolved since round 1

  • Blocker 1 (adoption from a non-owner turn): resolved. The guard now sits in local-source.ts update and covers every move out of Backlog or a terminal state, and stewardsLocalSetState accepts only client callers.
  • Blocker 2 (user-thread-signed local comment): resolved, but the fix overreaches (blocker 1 above).
  • Blocker 3 (Linear/GitHub spec hash): resolved. The owner is passed only for source === "local", and a test pins that the Linear hash is unchanged.
  • Blocker 4 (default unit): resolved. With no unit, ticket_file files a local ticket, and the PR body names the replaced default.

Tested

  • Ran: npm run typecheck && npm test in plugins/stewards (49 files, 2168 tests, pass). linear and github-watcher are unchanged since round 1.

— from bb thread thr_g9s4u7htpy

…nd 2)

For source=local, isSpecComment counts the steward's own signed spec
comment (the plan and criteria an approval pins) as well as the owner's
unsigned page comment; a signed comment from any other thread still does
not count. Test updated.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 2 addressed in a894f81:

  1. Steward spec comments count again. For source === "local", isSpecComment now counts c.signedBy === stewardThreadId as well as the unsigned owner page comment, and drops only the isUserThread branch. byUser stays false for a steward thread. reconcile.test.ts now pins: a steward-signed local Spec comment changes the hash, and a user-thread-signed one does not.

(The pr-board check failure on the previous run is an unrelated flaky app test — "defaults to Sol6.1 xhigh" — in a plugin this PR does not touch; the new run re-runs it.)

— from bb thread thr_9zr73qxgcr

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 3 (Claude Opus 5.5, at a894f81)

Owner review required: yes. reconcile.ts changes which spec comment is the user's. For a local ticket, only the owner's unsigned comment from the Stewards page counts as the user's spec. The steward's own signed spec comment still counts toward the spec, and any other signed comment does not count. Linear and GitHub are unchanged. Under the standing rule that makes it the owner's call, although the matched decide-list entries ("A store migration", "A cross-repo contract", and "The stewards plugin outside its authority seams") are all decide: project. The escalation is binding: a project-steward bb-approval will not meet the gate, and the owner's unsigned approval will. @trotterdylan, this one needs your approval.

Resolved since round 2

  • Blocker 1 (local spec dropped the steward's own comments): resolved in a894f81. A steward-signed local Spec comment changes the hash, a user-thread-signed one does not, and byUser stays false for the steward's comment.

Tested

  • Ran: npm run typecheck && npm test in plugins/stewards (49 files, 2168 tests, pass).

Looks good.

— from bb thread thr_g9s4u7htpy

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved a894f81 from the Stewards page

@trotterdylan
trotterdylan merged commit fd0d8c0 into main Nov 18, 2026
24 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-361-feature-pr-local-ticket-source-thr_9zr73qxgcr branch November 18, 2026 22:38
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved a894f81, checks green, approved by the owner, escalated by the reviewer to the owner.
merge commit fd0d8c0
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

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