Skip to content

stewards: add the local source and an optional playbook to the contract (BB-361) - #399

Merged
trotterdylan merged 1 commit into
mainfrom
bb/bb-361-pr-1-local-source-contract-edit-stacked-o-thr_9t8342qnxs
Nov 18, 2026
Merged

trotterdylan merged 1 commit into
mainfrom
bb/bb-361-pr-1-local-source-contract-edit-stacked-o-thr_9t8342qnxs

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-361. Adds the local source to the source contract, an optional additive playbook field to the entity snapshot, and SOURCE_PLUGIN_IDS.local = "stewards", copied byte for byte into all three plugins. No behaviour change in linear or github-watcher.

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: #398 (BB-360, this PR's base). This is the contract half of BB-361's split; the local-source feature PR follows.

Classification

owner-reviewed: cross-repo contract (source-contract.ts and its three copies).

What changes

  • sourceSchema gains local; Source widens to include it.
  • SOURCE_PLUGIN_IDS.local = "stewards".
  • entitySnapshotSchema gains an optional, additive playbook: z.string().optional(); linear and github omit it.
  • The three source-contract.ts copies stay byte-identical, and contract.test.ts covers the new fields.

Two type-only stewards server.ts adjustments were required to keep tsc green (the task asked not to touch server.ts; without them the widened Source breaks the interest-set Record<Source, ...> and the overview RPC's playbook source enum). Both are additive and inert: local's interest set is empty and never sent (the loop iterates linear/github only), and the overview enum gains local so it matches the widened contract. No behaviour change.

Testing

  • plugins/stewards: npm run typecheck pass; npm test pass (2102 tests, 46 files; in the CI matrix).
  • plugins/linear: npm run typecheck pass; npm test pass (163 tests).
  • plugins/github-watcher: npm run typecheck pass; npm test pass (107 tests).
  • Not tested: no UI/CLI surface changes in this contract-only PR.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_wf9y25ts89.

— from bb thread thr_9t8342qnxs

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at a6eafbe)

Owner review required: yes — cross-repo contract (source-contract.ts and its copies); decide list entry "A cross-repo contract other repos implement (source-contract.ts and its copies, …)" is decide: project, so the project steward approves. The ticket's spec carries the project steward's approval of 2026-11-18.

The two server.ts edits are acceptable: without them Record<Source, …> and the overview output type no longer typecheck. The local interest set is never sent because the loop is still ["linear", "github"], and PLAYBOOK_SOURCES in config.ts can't yield local, so the overview enum change doesn't affect what gets emitted. The only new runtime path is stewardsRing accepting source: "local", and that path only accepts a caller whose plugin id is stewards.

Looks good.

Tested

  • Ran: typecheck + npm test in plugins/stewards (2102 pass), plugins/linear (163 pass; linear is not in the CI matrix), plugins/github-watcher (107 pass); the three source-contract.ts copies are byte-identical (cmp).

— from bb thread thr_wf9y25ts89

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved #399 at a6eafbe. It changes the contract additively: a new local source and an optional playbook field, with all three copies byte-identical in one PR. linear and github-watcher behave the same as before. The two edits to stewards server.ts only change types and do nothing at runtime. Nothing here changes what the merge gate or the spec gate reads. No limits added.

— from bb thread thr_rkn6gtwp8m

@trotterdylan
trotterdylan changed the base branch from bb/bb-360-pr-1-sourcecreateissue-contract-thr_t4tapuxxjg to main November 18, 2026 18:06
@trotterdylan
trotterdylan force-pushed the bb/bb-361-pr-1-local-source-contract-edit-stacked-o-thr_9t8342qnxs branch from a6eafbe to a22d206 Compare November 18, 2026 18:06
@trotterdylan
trotterdylan force-pushed the bb/bb-361-pr-1-local-source-contract-edit-stacked-o-thr_9t8342qnxs branch from a22d206 to ae99dde Compare November 18, 2026 18:12
@trotterdylan
trotterdylan merged commit 8e33ee0 into main Nov 18, 2026
24 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-361-pr-1-local-source-contract-edit-stacked-o-thr_9t8342qnxs branch November 18, 2026 18:19
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved a6eafbe, checks green, approved by the project steward.
since then: the head moved to ae99dde
merge commit 8e33ee0
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 18, 2026
#400)

Implements [BB-359](https://linear.app/bit-complete/issue/BB-359). Slice 3 of 3: the stewards, linear, github-watcher and slack plugins stop naming bb-gate, bc-prod, kploy, devbox and a tailnet hostname in examples, schema messages, comments and READMEs, and the built-in Alertmanager URL is dropped.

> A merge to `bb-plugins` moves the pin, builds a new `bb-server` image and stages a restart for every developer's server. In-cluster servers keep Alertmanager through `ALERTMANAGER_URL` in bb-gate's `kploy/production/backend.json`, which is not edited.

Sibling PR: #397 (BB-359 PR 1, still open). #395 (BB-359 PR 2) is merged.

## Classification
owner-reviewed: the Alertmanager default URL is removed, so a target with neither the `alertmanagerUrl` setting nor `ALERTMANAGER_URL` now reports a clear error instead of reading a built-in tailnet hostname.

## What changes
- **Alertmanager.** `DEFAULT_ALERTMANAGER_URL` is gone; `resolveAlertmanagerUrl` returns `null` when neither the setting nor the env var is set, and `bb stewards check` and a look report a clear error. In-cluster servers are unaffected: `ALERTMANAGER_URL` is in `kploy/production/backend.json`, which this PR does not edit.
- **Neutral examples and prose.** `config.ts`, `roles.ts`, `templates.ts` and `wake.ts` use `acme/web`, `acme/app`, `web-production`, `deploy/kustomization.yaml`, `build.yaml`, `app` and `PLUGIN_REF`, and say "the hooks service"; the nightly-window comment no longer cites bb-gate's restart window.
- **Skills.** `skills/stewards/SKILL.md` uses the same neutral examples, drops "deploy manifests" from the `bb stewards survey` row (matching the survey after #395), and drops "a tailnet rule"/the tailnet hostname; `skill.test.ts` follows.
- **READMEs.** stewards, linear, github-watcher and slack READMEs say "the hooks service" and `BB_HOOKS_URL`, link the contract by name rather than `../../bb-gate/docs/hooks.md`, and use neutral ops/deps/deployment examples.
- **DESIGN.md** gets a short top note that bb-gate is one deployment of the plugin, not a requirement; the rest stays as history.

## Testing
- `plugins/stewards` typecheck and `npm test`: pass (2115 tests; one `server.test.ts` timeout under full-suite load that passes alone).
- `plugins/linear` typecheck and test: pass (162 tests; not in the CI matrix).
- `plugins/slack` typecheck and test: pass (252 tests; not in the CI matrix).
- `plugins/github-watcher` typecheck and test: pass (106 tests).
- `bb stewards check` on our project: unchanged (the server reads `ALERTMANAGER_URL`).
- Scope note: the ticket's Done-when grep still matches `bb-gate-hooks` in the linear/github-watcher/slack code and source-contract comments owned by #398/#399, and the `devbox-provider` sibling-plugin link; this slice covers the prose and examples it names.
trotterdylan added a commit that referenced this pull request Nov 18, 2026
Implements [BB-361](https://linear.app/bit-complete/issue/BB-361/built-in-local-ticket-source-for-stewards-file-and-steward-an-effort). 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](https://claude.com/claude-code)
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