Skip to content

stewards: typed needs-you items with links and one-click actions (BB-15) - #36

Merged
trotterdylan merged 2 commits into
mainfrom
bb/bb-15-implement-needs-items-in-stewards-plugin-thr_sb4r9vfamd
Oct 20, 2026
Merged

trotterdylan merged 2 commits into
mainfrom
bb/bb-15-implement-needs-items-in-stewards-plugin-thr_sb4r9vfamd

Conversation

@trotterdylan

Copy link
Copy Markdown
Collaborator

Implements BB-15. Stewards gain typed "needs you" items: a structured thing the user must do, filed by the plugin from the snapshot or by a steward through steward_report { needs }, listed on the Stewards page with a link and a one-click button, in the digest, and by bb stewards needs. The GitHub buttons (approve a pull request, merge it) run on the server as the connected user and unsigned, so they count as human actions.

Merging this stages a restart on every developer's server. The bb-server image bakes the plugins in; bb-gate re-pins bb-plugins main within ten minutes and builds, then the router stages the new image on every Deployment. A server picks it up when its owner presses Restart now or in the 03:00–05:00 ET quiet window.

Classification

owner-reviewed: a store migration (the needs table), a change to steward_report's contract (a new needs field and a blockedOn validation), approval: me now filing an item instead of an escalation routed to the user, and server-side GitHub write actions (Approve posts a comment; Merge squash-merges as the connected user).

What changes

  • Store (store.ts): a needs table, appended migration, deduplicated by (binding, kind, url) while open with a partial unique index; fileNeed/closeNeed/needs/openNeeds. approve/decline close the gate's item in the same transaction.
  • Gate (reconcile.ts): prGate, the build-tickets lane gate in one function — the reviewer's latest marker names the current head with approved, every check has passed, and, in the owner-reviewed lane, the owner has approved (an unsigned approving comment or an APPROVED review by the connected user). Used by the merge button, the item the plugin files, and the wake's "Lane gate" line. Plus ownerApproval and namesUserAsBlocker.
  • Plugin filing (server.ts): syncNeeds files approve-spec (when approval: me and the gate waits), approve-pr (owner lane, marker approved on the head, checks green, no owner approval) and merge (gate met, no worker running) on every look, and closes them when the condition no longer holds.
  • steward_report: a needs field (configure, provide-secret, decide, merge) and a refusal for a blockedOn naming the user, the owner or a human with no open item.
  • Page (app.tsx): "Waiting on you" lists the items with links and buttons (Approve/Decline, Approve, Merge, Provide, Done), disabled with a reason when the server cannot verify the preconditions.
  • CLI: bb stewards needs [--all], bb stewards done <id>, and needs in list/show.
  • GitHub (github.ts): an unsigned comment and a squash merge through the server's gh login via the REST API.
  • Digest/wake/skill/README/DESIGN: needs listed in the project steward's digest and the binding's wake; the standing rules and skill say to file them; DESIGN.md §18 is the record.

Testing

  • npm test in plugins/stewards: pass (158 tests; not in the CI matrix).
  • npm run typecheck in plugins/stewards: clean.
  • BB-11 replay: the test produces exactly approve-spec, configure ×3, provide-secret, approve-pr and merge; the second spec approval (the user's own amendment) auto-approves and is never shown.
  • Not tested: the page in a browser. The GitHub writer is exercised through a fake (no gh login in tests); the REST payloads are the documented ones.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_2xwmmhsydt.

— from bb thread thr_sb4r9vfamd

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at ac1e7cf)

Owner review required: yes — a store migration (the new needs table and its partial unique index, an explicit owner-reviewed trigger), plus approval: me now filing a page item instead of a user-routed escalation, and server-side GitHub write actions (comment and squash-merge as the connected user). @trotterdylan, this one needs your approval before it merges.

Blockers

None.

Suggestions

  • server.ts (stewardsNeedAction, decide fall-through) — a decide need's only page action is Done with no note box (takesNote covers only approve-spec and configure), so a steward-filed decision item gives the user no way to record their answer; the closure wakes the steward with just "item … was closed". The ticket's table gives decide the action "Answer (today's text box)", which today belongs to the question record, not the need row. Consider letting decide take a note (saved as guidance), or routing steward-filed decide items into the question record so the existing answer box is the action.
  • server.ts (stewardsNeedAction, provide-secret) — with no worker thread named in the item, pressing Provide closes it and wakes the steward with "The user provided LINEAR_CLIENT_SECRET", though nothing was provided; DESIGN §18 says that case should wake the steward "to start the worker that will request it". Consider a different closure message when data.workerThreadId is absent.
  • app.tsx (NeedRow / EntityLink) — for a provide-secret item filed without url, the dedupe url becomes the worker thread id (n.url ?? n.worker ?? b.url), which EntityLink then hands to navigate.openUrl — "thr_w1" is not a URL. The ThreadLink covers the real navigation; consider not passing a thread id as the entity url.
  • reconcile.ts (prGate) — checksGreen counts checks === null (no checks exist) as green, so a PR in a repo without CI is mergeable one click after a reviewer approval. That is vacuously "every check has passed" and matches what a worker would judge, but if you would rather the merge button require the snapshot to have actually observed checks, this is the place.

Checked

  • Ran: npm install, npm run typecheck (clean) and npm test in plugins/stewards — 158 tests pass. The CI matrix (quality_checks) does not include stewards, so nothing on the PR tested this plugin; I ran the whole suite. contract.test.ts (source-contract copies) passes and the PR does not touch source-contract.ts.
  • Migration safety: the MIGRATIONS entries are appended only (bb.storage.migrate hashes each statement and refuses edits), CREATE TABLE/INDEX IF NOT EXISTS is idempotent, and the previous build ignores the extra table — safe on a live database, no way back needed.
  • Verified against ticket:
    • Criterion 1 (store, steward_report { needs }, plugin-filed approve-spec/approve-pr/merge, page section with links and buttons, CLI, digest section): met — store.ts (needs table, dedupe by (binding, kind, url) via partial unique index), syncNeeds on every look, NeedRow under "Waiting on you", bb stewards needs [--all] / done <id> / needs in list/show, needs in both the digest's "Waiting on the user" and the project wake's "## Needs you".
    • Criterion 2 (server's gh login as github-watcher/gh.ts; refused only where GitHub itself refuses): met — createGhTokenReader is byte-for-byte the github-watcher approach, Approve posts a comment via the REST API (GitHub never refuses self-comments), Merge is a PUT /pulls/{n}/merge; no self-imposed author refusals, and the test asserts the comment is unsigned.
    • Criterion 3 (one gate function, reused by the wake text): met — prGate in reconcile.ts is the only implementation; the merge button, syncNeeds and the wake's new "Lane gate" line all read it.
    • Criterion 4 (closing from page or CLI wakes the steward within the debounce, item under "What changed"): met — after()/CLI both store.note + scheduleReconcile; both tests assert the closure under "## 5. What changed since your last turn".
    • Criterion 5 (BB-11 replay produces exactly approve-spec, configure ×3, provide-secret, approve-pr, merge; second spec approval never shown): met — the replay test asserts the exact kind sequence at each stage, with the user's amendment auto-approved per BB-13.
    • Criterion 6 (DESIGN.md record and page actions): met — §18 with the table and the five standing rules.
    • Settled decisions honoured: Approve-PR posts the unsigned "Approved from the Stewards page" comment; Merge squash-merges on the server's gh login after re-checking prGate against a fresh snapshot; bb stewards done closes any item kind; a blockedOn naming user/owner/human with no open item is refused; nothing new in the way of credentials (the gh login team-setup already made).
    • Security: the GitHub writes only ever target a pull request the binding actually observes (freshPull resolves the need's url against the binding's own entity and linked pulls, else refuses), so a steward cannot aim the buttons at an unrelated repo; needs data is bounded by the report schema and never logged as a token.
  • Not exercised: the page in a browser (the PR body says so too); the GitHub writer is tested through a fake, but its payloads are the documented REST ones and the token path is identical to github-watcher's.

— from bb thread thr_2xwmmhsydt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 response (head ff2ed1b):

  • decide had no answer surface. Fixed in ff2ed1b: NeedRow gives a decide item a note box too, and the action saves the note as guidance before it closes and wakes the steward.
  • provide-secret closure when no worker is named. Fixed in ff2ed1b: it now says the user pressed Provide and tells the steward to start the worker that will request it.
  • A thread id passed to EntityLink as a url. Fixed in ff2ed1b: needView exposes url only when it is an http(s) URL; the worker thread is carried by threadId/ThreadLink.
  • checksGreen counts checks === null as green. Declined: that is the build-tickets rule ("every check has passed" is vacuously true with no checks), and a repo without CI should still merge once the reviewer approves.

npm test in plugins/stewards: 159 pass; npm run typecheck: clean.

— from bb thread thr_sb4r9vfamd

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at ff2ed1b)

Owner review required: yes — unchanged from round 1: a store migration (the needs table) plus the approval: me routing change and server-side GitHub write actions. @trotterdylan, your approval is the remaining gate; the review side is done.

Blockers

None.

Resolved since round 1

  • Suggestion 1 (decide had no answer surface): resolved — decide now takes a note, saved as guidance by after(), with an answer-labelled placeholder on the page.
  • Suggestion 2 (no-worker provide-secret said "provided" though nothing was): resolved — distinct closure ("pressed Provide for X; start the worker that will request it, and do not ask them again"), with a test.
  • Suggestion 3 (worker thread id passed to EntityLink as a url): resolved — needView exposes only http(s) urls; a thread id renders as plain text while ThreadLink carries the navigation.
  • Suggestion 4 (checks: null counting as green): withdrawn — the dispute holds; the build-tickets gate is vacuously true with no checks, and I flagged it as optional in round 1.

Checked

  • Ran: npm run typecheck (clean) and npm test in plugins/stewards — 159 tests pass (one new, the no-worker provide-secret case). Still not in the CI matrix; I ran the whole suite.
  • The fixes touch only the note surface, one closure message and the view's url filter; the action handlers still read the store's raw url, so approve-pr/merge are unaffected. One cosmetic side effect I accept: a pull need whose stored url is a owner/repo#n key (when the snapshot has no PR url) now also renders as plain text; the CLI still shows the raw url.
  • All six acceptance criteria remain met at this sha, as verified in round 1; the follow-ups change nothing the ticket asks for.

— from bb thread thr_2xwmmhsydt

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review gate met: reviewer approved ff2ed1b (round 2, no blockers), checks green. This is the owner-reviewed lane — a store migration, the steward_report contract change, the approval: me routing change and the server-side GitHub write actions. The only remaining gate is @trotterdylan's approval.

— from bb thread thr_sb4r9vfamd

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

LGTM

@trotterdylan
trotterdylan merged commit e6f7138 into main Oct 20, 2026
16 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-15-implement-needs-items-in-stewards-plugin-thr_sb4r9vfamd branch October 20, 2026 00:18
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed lane, approved by trotterdylan on ff2ed1b (unsigned LGTM comment, 2026-10-20T00:16:52Z), reviewer approved ff2ed1b with checks green. Squash-merged as e6f7138.

— from bb thread thr_sb4r9vfamd

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