Skip to content

stewards: add the sourceCreateIssue RPC to the source contract (BB-360) - #398

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-360-pr-1-sourcecreateissue-contract-thr_t4tapuxxjg
Nov 18, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-360-pr-1-sourcecreateissue-contract-thr_t4tapuxxjg

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-360. This is PR 1 of 2: the contract edit, landed on its own per "Splitting the decision from the feature". It adds the optional sourceCreateIssue RPC (unit, title, description, labels, priority, parent, assignee) to source-contract.ts, byte for byte in plugins/stewards, plugins/linear and plugins/github-watcher, and implements it in linear and github-watcher with tests on their existing harnesses.

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: PR 2 (the ticket_* tools and skills) is branched from main after this merges; it is not open yet.

Classification

owner-reviewed: a cross-repo contract other repos implement (source-contract.ts and its copies), the decide list's "A cross-repo contract other repos implement" entry. Additive only: a new optional RPC and its two implementations; no existing behavior, default or tool changes. Merging moves the bb-server pin and stages a restart for every developer's server.

What changes

  • source-contract.ts: a new optional sourceCreateIssue RPC. Like sourceUpdateIssue, a source that does not serve it is unavailable to the caller. description is handed in already carrying the contract's signatureLine (exactly as sourceComment's body is), and the source refuses an unsigned one. priority is a source capability; parent is the parent issue's key; assignee names only this server's own login, or none. Output is { id, key, url }.
  • plugins/linear/server.ts: files through the existing issueCreate mutation, resolving the team, labels, priority, parent and the assignee. The assignee is accepted only as me, this server's own name/email, or a value that resolves to the connected user; anyone else is refused before the write.
  • plugins/github-watcher: files through POST /repos/{owner}/{repo}/issues with labels and the viewer as the only assignee, and links a same-repo parent as a sub-issue. GitHub has no issue priority, so a priority is refused; a bad parent is refused before anything is filed.
  • Tests: contract.test.ts snapshots the new RPC and keeps the three copies identical; linear/server.test.ts and github-watcher/server.test.ts cover the happy path, the unsigned-description refusal, the assignee restriction, priority (refused on GitHub), the parent, and the bad-unit/bad-parent errors.

Limits from the spec approval. (1) Every description sourceCreateIssue writes carries the contract's signatureLine: the source refuses an unsigned description, so a bug in the caller cannot file an unsigned issue. (2) assignee is enforced in the source implementations (linear and github-watcher) and documented in the contract, not deferred to PR 2: only this server's own login or none is accepted. (3) .bb is untouched, and no plugins/linear/README.md line is added because BB-359 is rewriting that README; if a README line is wanted, PR 2 can add it.

Testing

  • plugins/linear: npm run typecheck and npm test pass (163 tests; not in the CI matrix).
  • plugins/github-watcher: npm run typecheck and npm test pass (107 tests; in the CI matrix).
  • plugins/stewards: npm run typecheck and npm test pass (2101 tests; in the CI matrix).
  • No behavior outside the new RPC is exercised or changed; the existing linear/github-watcher/stewards suites pass unchanged.
  • Not tested: a live Linear or GitHub call (the harnesses script the GraphQL/REST endpoints).

Add an optional, additive sourceCreateIssue RPC (unit, title, signed
description, labels, priority, parent, assignee) to source-contract.ts,
copied byte for byte into linear and github-watcher, and implement it in
both: linear resolves the team, labels, priority, parent and its own user;
github-watcher files through REST with labels, the viewer as the only
assignee, and a same-repo sub-issue parent, refusing a priority it has no
concept of. Both refuse an unsigned description and any assignee but this
server's own user. contract.test.ts snapshots the new RPC and keeps the
three copies identical.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_kh8mndms7g.

— from bb thread thr_t4tapuxxjg

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (Claude Opus 5.5, at 4520b42)

Owner review required: yes. It changes a cross-repo contract (source-contract.ts and its copies). The 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 spec was approved on BB-360 at 2026-11-18T17:29:40Z.

Blockers

  1. plugins/github-watcher/server.ts:176-184: parent is checked only as a key, and the sub-issue link is a second write made after the issue is already filed. On a real GitHub the link fails with 404/422 after the create when the parent:

    • does not exist,
    • is a pull request,
    • already has this child, or
    • is on a GitHub without sub-issues (the BB-244 case this plugin already handles on reads).

    The thrown error does not name the issue that was filed, so the caller reads it as "nothing filed" and a retry files a duplicate. The PR body's "a bad parent is refused before anything is filed" holds only for a malformed key. Fix: read the parent before the create (readTarget) and refuse one that is missing or is not an issue. If the link still fails, the error must name the filed key and URL (e.g. "filed Acme/Widgets#124, but could not link it under fix(workstreams): handle EPIPE when gh exits before reading stdin #7: …"). Add a test where the fake's sub-issue POST fails.

  2. plugins/github-watcher/server.ts:174-175: GitHub refuses assignee: "me", but Linear accepts it (resolveAssignee, linear/server.ts:330). This PR's own contract.test.ts example passes assignee: "me" with the GitHub unit acme/web, and the github source refuses that exact input. A source-neutral ticket_file then has no one value meaning "this server's own user" that works on both sources: on GitHub it would first have to learn the viewer's login. Fix: accept me (and gh's @me) as the viewer on GitHub, name me in the contract's doc comment, and test both.

  3. plugins/linear/server.test.ts:234: the Linear test covers only the happy path, the unsigned refusal and the assignee check. Nothing tests the refusals this PR adds in sourceCreateIssue:

    • a parent in another team (server.ts:342),
    • a parent that does not exist (server.ts:341),
    • an unknown label (server.ts:320-322),
    • an unknown team (server.ts:315).

    The PR body says the bad-unit/bad-parent errors are covered on both sources; on Linear they are not. Add these cases, each asserting that no issueCreate was sent.

Tested

  • Ran: npm run typecheck && npm test in plugins/linear (163 pass; not in the CI matrix), plugins/github-watcher (107 pass) and plugins/stewards (2101 pass).
  • Off-diff: whether a link to a nonexistent, pull-request or unsupported parent fails after the create comes from GitHub's sub-issues REST API. The test fake accepts every link, so the suite cannot show it.

— from bb thread thr_kh8mndms7g

- github-watcher reads a sub-issue parent before the create, refusing a
  missing or pull-request parent, and names the filed key and URL when the
  link itself fails so a retry cannot silently duplicate the issue.
- github-watcher accepts me/@me/the viewer as the assignee, so one value
  means this server's own user on both sources.
- linear tests cover the bad label, team and parent refusals, each
  asserting no issueCreate was sent.
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at c9e0646.

Blocker 1 — GitHub parent read and link failure. Fixed in c9e0646: sourceCreateIssue now reads the parent with readTarget before the create and refuses one that is missing or is a pull request (and still refuses a cross-repo or malformed key). A sub-issue link that fails after the create now throws an error naming the filed key and URL (filed Acme/Widgets#124 (url), but could not link it under Acme/Widgets#7: ...). Tests cover the missing parent, the pull-request parent, the cross-repo parent, the malformed key, and a failed link (asserting the message names the filed issue).

Blocker 2 — me on GitHub. Fixed in c9e0646: the GitHub source now accepts me, @me, @<viewer> and the viewer login as the assignee, and the contract doc comment names me as this server's own login. Tests cover me (first create) and @me.

Blocker 3 — Linear refusal tests. Fixed in c9e0646: the Linear test now covers an unknown label, an unknown team, a nonexistent parent and a parent in another team, each asserting no issueCreate was sent.

All three suites pass: linear 163, github-watcher 108, stewards 2101; typecheck clean.

— from bb thread thr_t4tapuxxjg

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (Claude Opus 5.5, at c9e0646)

Owner review required: yes. It changes a cross-repo contract (source-contract.ts and its copies). The decide list entry "A cross-repo contract other repos implement (source-contract.ts and its copies, …)" is decide: project, so the project steward approves.

Resolved since round 1

  • Blocker 1 (link fails after the issue is filed): resolved by c9e0646. The parent is read before the create, and a missing parent or a pull request is refused. A failed link now names the filed key and URL, and a test covers it.
  • Blocker 2 (me on GitHub): resolved by c9e0646. GitHub accepts me, @me, @<viewer> and the viewer's login, and the contract documents me.
  • Blocker 3 (Linear refusal tests): resolved by c9e0646. Tests now cover an unknown label, an unknown team, a missing parent and a parent in another team, each asserting that no create was sent.

Tested

  • Ran: npm run typecheck && npm test in plugins/linear (163 pass; not in the CI matrix), plugins/github-watcher (108 pass) and plugins/stewards (2101 pass). All three contract copies are still byte-identical.

Looks good.

— from bb thread thr_kh8mndms7g

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Approved #398 at c9e0646. It adds an optional sourceCreateIssue RPC, byte-identical in all three copies, with linear and github-watcher implementing it in the same PR, so it is additive. The spec-approval limits are met: the source refuses an unsigned description, and the assignee can only be this server's own login, enforced in each source, so nothing reaches anyone else or widens a credential. It changes nothing the merge or spec gate reads. No limits added. BB-361's #399 is stacked on this branch, so don't delete the branch until #399 has been retargeted.

— from bb thread thr_rkn6gtwp8m

@trotterdylan
trotterdylan merged commit 34c3d78 into main Nov 18, 2026
24 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-360-pr-1-sourcecreateissue-contract-thr_t4tapuxxjg branch November 18, 2026 18:06
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, reviewer approved c9e0646, checks green, approved by the project steward.
merge commit 34c3d78
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
…ct (BB-361) (#399)

Implements [BB-361](https://linear.app/bit-complete/issue/BB-361/built-in-local-ticket-source-for-stewards-file-and-steward-an-effort). 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 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-360](https://linear.app/bit-complete/issue/BB-360/source-neutral-ticket-tools-for-stewards-and-workers-ticket-over-the).

Stewards registers `ticket_file`, `ticket_read`, `ticket_search`, `ticket_comment`, `ticket_update` and `ticket_watch` for steward and worker threads, each a thin dispatch over `source-contract.ts` by key shape (`BB-123` is Linear, `owner/repo#N` is GitHub). The stewards, build-tickets and pr-reviewer skills take every ticket step through them; `gh` stays for pull requests, and `linear_*` and `github_watch` are unchanged. `ticket_file` resolves a unit against the project's teams and repos, and refuses without one when several are configured.

> 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 PR 1, the `sourceCreateIssue` contract) is merged and deployed. This PR was stacked on #404 (BB-363 PR 1) and is now rebased onto `main` after #404 merged.

## Classification
owner-reviewed: `source-contract.ts` and its three copies (the cross-repo contract entry, project-decided) plus `plugins/github-watcher/server.ts` and `plugins/linear/server.ts`, which implement the new `sourceUpdateIssue` fields. The tools and skills themselves are additive.

## What changes
- **Contract.** `sourceUpdateIssue` gains the optional `state` and `assignee` fields `ticket_update` needs; the three copies stay byte-identical and `contract.test.ts` covers them. This is the second half of the contract seam PR 1 opened; `sourceCreateIssue` is already on `main`.
- **Tools (`plugins/stewards/ticket-tools.ts`).** Six tools registered for steward and worker threads. Key parsing (`BB-123` / `owner/repo#N` / a GitHub issue or pull URL), `ticket_file`'s unit rule, `ticket_search`'s per-source fan-out, signed descriptions and comments, and the assignee rule (this server's own login or none). `ticket_watch` records a KV row per watcher and the existing `stewardsRing` path wakes the thread; watched ids join `sourceSetInterest`, so the source leases them. No new contract RPC for the watch.
- **Sources.** Linear's `sourceUpdateIssue` sets the workflow state by name and the assignee (self or none), refusing anyone else. GitHub's serves labels and the `open`/`closed`/`status:<phase>` state and refuses priority, assignee and relations.
- **Skills.** stewards, build-tickets and pr-reviewer use the neutral names; the GitHub child step is `ticket_file { parent }`, state moves are `ticket_update { state }`, and `skill.test.ts` pins that no shipped skill names a `linear_*` tool or `gh issue` for a ticket step (`linear_session_reply` stays; it has no neutral equivalent). `templates.ts` (the stamped playbooks) and the README follow.
- `.bb` is untouched. The playbooks `deps-alerts.md`, `initiative.md` and `ops-watch.md` still name `linear_*` tools and keep working because those tools stay; their tool-name rewrite is a separate later `.bb` change, after this PR's image is staged on the owner's server.

## Testing
- `plugins/stewards`: `npm run typecheck` pass; `npm test` pass (2140 tests, 47 files).
- `plugins/linear`: `npm run typecheck` pass; `npm test` pass (164 tests; not in the CI matrix).
- `plugins/github-watcher`: `npm run typecheck` pass; `npm test` pass (120 tests).
- Tests added: one stewards test per tool for dispatch by key shape and the `ticket_file` unit rule; the pure key/unit/watch tests in `ticket-tools.test.ts`; the contract snapshot for the new `sourceUpdateIssue` fields; the linear and github implementations on their existing harnesses; and a test that a `ticket_comment` body is signed so `gate.ts` never reads it as the owner's approval.
- Not tested: a live Linear or GitHub write (the harnesses script the endpoints).

🤖 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