From ac1e7cf771f2ee8ff480d58a287a2970290fc5f5 Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Mon, 19 Oct 2026 23:32:36 +0000 Subject: [PATCH 1/2] stewards: typed needs-you items with links and one-click actions (BB-15) --- plugins/stewards/DESIGN.md | 63 +++- plugins/stewards/README.md | 34 +- plugins/stewards/app.tsx | 83 ++++- plugins/stewards/github.ts | 91 ++++++ plugins/stewards/reconcile.test.ts | 46 ++- plugins/stewards/reconcile.ts | 114 ++++++- plugins/stewards/server.test.ts | 245 +++++++++++++- plugins/stewards/server.ts | 371 +++++++++++++++++++++- plugins/stewards/skills/stewards/SKILL.md | 24 +- plugins/stewards/store.test.ts | 24 ++ plugins/stewards/store.ts | 116 +++++++ plugins/stewards/wake.ts | 30 +- 12 files changed, 1186 insertions(+), 55 deletions(-) create mode 100644 plugins/stewards/github.ts diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index 295d9354..69b7f069 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -661,13 +661,13 @@ follow-through: 6h # how long a terminal binding may be kept open - **Threads:** spawning stewards, recognizing workers, building wake messages, the project's sidebar section. - **Agent tools:** `steward_report` and `steward_update`. -- **CLI:** `bb stewards init | check | list | show | detach | pass | digest`. +- **CLI:** `bb stewards init | check | list | show | needs | done | detach | pass | digest`. - **UI:** the Stewards page, a nav panel with one tab per stewarded project: - waiting on you (open questions, which you can close there, forwarded - escalations and approval requests), in flight by stage (summary, next - action and actor, running workers), stuck or held, ended in the last two - weeks, and the latest digest with its date. Settings → Plugins → - Stewards keeps each project's configuration and health. + waiting on you (needs items with links and buttons, open questions, which you + can close there, forwarded escalations and approval requests), in flight by + stage (summary, next action and actor, running workers), stuck or held, ended + in the last two weeks, and the latest digest with its date. Settings → + Plugins → Stewards keeps each project's configuration and health. ### Changes to linear and github @@ -715,6 +715,57 @@ plugins' contract before stewards uses them, bb-plugins before bb-gate. 5. **Board.** Built: the Stewards page, the question record (§12), and the digest assembled from records. +## 18. Needs you items and one-click actions + +Everything a person had to do on a ticket used to exist only as prose, +repeated across Linear comments, the project steward's digest and the stewards' +replies. A **needs** record makes it structured: one row per thing the user +must do, with a link, one line of what, steps, and a close rule. It is filed by +the plugin from the snapshot or by a steward through `steward_report { needs }`, +listed under "Waiting on you" on the Stewards page, in the digest, and by +`bb stewards needs` and `bb stewards show`. + +| kind | filed by | link | done when | one-click action | +| -- | -- | -- | -- | -- | +| `approve-spec` | plugin, when the ready gate waits and the playbook's approver is `me` | the ticket | gate approval recorded | **Approve** / **Decline** (with an optional note); Approve records the approval on the gate, as BB-13 does from any surface | +| `approve-pr` | plugin, when a linked pull request is in the owner-reviewed lane, the reviewer's marker on the head is `approved`, checks are green, and no owner approval exists | the pull request | owner approval seen in the snapshot | **Approve**: posts the unsigned comment "Approved from the Stewards page" as the connected user | +| `merge` | plugin, when the lane gate is met and no worker is running, or by a steward whose worker reported a refused merge | the pull request | the pull request merged | **Merge**: the server re-checks the gate itself, squash-merges through the server's `gh` login, posts the "Merged: …" comment, and wakes the steward | +| `decide` | project steward (today's forwarded question) | the entity | answered | **Answer** (the question record's text box) | +| `provide-secret` | steward, with the variable name and purpose | the worker thread | the worker's `bb secret request` completes | **Provide**: opens the worker thread named in the item, or wakes the steward to start the worker that will request it | +| `configure` | steward, for a step outside the repos (install an app, grant a permission, enable an event, set a setting) | the external page where it happens | the user presses Done, or the steward observes it done | **Done** (with an optional note, saved as guidance) | + +The rules that hold: + +- **One gate function.** `prGate` in `reconcile.ts` is the build-tickets lane + gate: 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; a signed comment is a thread's, never the owner's. The merge + button, the item the plugin files and the wake's "Lane gate" line all read + it, so a steward is told whether a pull request's gate is met in the same + words the button acts on. +- **The buttons run on the server as the connected user, unsigned**, so they + count as human actions. Approve-PR is a comment, not a review, so GitHub is + the only thing that can refuse it (approving your own pull request); Merge + uses the server's `gh` token through the GitHub API. The server never signs + one with a thread id. +- **A button is offered only while the server can verify its preconditions.** + `syncNeeds` recomputes the plugin's items on every look and closes the ones + whose condition no longer holds; the page marks one whose condition has moved + since as not actionable and says why ("reviewer round 3 pending", "a worker + is still running"). The merge action re-checks `prGate` against a fresh + snapshot before it merges. +- **Every action wakes the steward with the item's closure** under "What + changed", and the wake lists the binding's open items and says not to ask the + user about them in prose. Closing an item from the page or with + `bb stewards done ` does the same. +- **Dedupe.** A need is keyed by (binding, kind, url) while open: a steward + that re-reports updates the wording rather than adding a row. The store + enforces it with a partial unique index. +- **`blockedOn` stays for third parties.** A `steward_report` whose `blockedOn` + names the user, the owner or a human with no open needs item is refused and + told to file one, so the ask reaches the page instead of only the prose. + ## Known limits - **Multi-repo projects only.** A bb project whose source is a single diff --git a/plugins/stewards/README.md b/plugins/stewards/README.md index e7ce8a62..18329b9d 100644 --- a/plugins/stewards/README.md +++ b/plugins/stewards/README.md @@ -87,9 +87,10 @@ bb. [DESIGN.md](DESIGN.md) is the design; this is how it is built and run. unless a playbook says `approval: me`. The plugin asks for that approval itself: whenever a ready gate's checklist is met, the ticket is substantial and the current spec has no approval, it files an `approval` - escalation with the approver (the project steward, or the user in the - steward's thread), whatever the steward's report says, and closes it once - approved or no longer needed. An approval is recorded from the approver's + escalation with the project steward, or an `approve-spec` item on the + Stewards page when the approver is the user (`approval: me`), whatever + the steward's report says, and closes it once approved or no longer + needed. An approval is recorded from the approver's words wherever they are: the project steward's guidance that resolves the request, the user's answer on the Stewards page, their message in the steward's thread, or their unsigned approving comment on the entity. A @@ -104,17 +105,32 @@ bb. [DESIGN.md](DESIGN.md) is the design; this is how it is built and run. escalations is with you, the project steward is woken with the change too, since you may have answered on the ticket rather than in its thread. A status blocked on the project steward or the user with no open - escalation is flagged in `bb stewards list` and the digest. + escalation or needs item is flagged in `bb stewards list` and the digest. +- **"Needs you" items** are the structured things only the user can do: an + `approve-spec`, an `approve-pr` or a `merge` the plugin files from the + snapshot, and a `configure`, `provide-secret` or `decide` a steward files + through `steward_report { needs }`. They are deduplicated by (binding, + kind, url) while open, listed under "Waiting on you" on the Stewards page + with a link and a button each, in the digest, and by `bb stewards needs`. + The buttons run on the server as the connected user, unsigned: Approve + posts the "Approved from the Stewards page" comment, Merge re-checks + the lane gate and squash-merges through the server's `gh` login, and every + action wakes the binding's steward with the closure under "What changed". + A button is shown only while the server can verify its preconditions; + otherwise the item says why not. `bb stewards done ` closes one from a + thread. A `blockedOn` naming the user, the owner or a human is refused + unless an open needs item says so. - **The nightly pass** (01:00 in the project's time zone by default, done by 02:45 so bb-gate's 03:00 restarts do not cut a turn) gives every open binding a turn, then wakes the project steward for the morning digest. A half-hourly mechanical sweep is the adoption and stuck backstop. - **The Stewards page** (a nav panel, [app.tsx](app.tsx)) has a tab per - stewarded project: what waits on you (questions the project steward put - to you, which you can answer and close there, forwarded escalations and - approval requests), what is in flight by stage with each status record - and running workers, what is stuck or held, what ended in the last two - weeks, and the latest digest with its date. + stewarded project: what waits on you (needs items with their links and + buttons, questions the project steward put to you, which you can answer + and close there, forwarded escalations and approval requests), what is in + flight by stage with each status record and running workers, what is stuck + or held, what ended in the last two weeks, and the latest digest with its + date. - **Questions to you** are kept in the store from the moment the project steward asks (`steward_update { ask }`, or forwarding an escalation) until it records your answer (`steward_update { resolve: "", diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index fbf45f24..273e1367 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -386,7 +386,7 @@ function BoardPage({ subPath }: { subPath: string }) { function ProjectBoard({ board: b, refetch }: { board: Board; refetch: () => void }) { const now = Date.now(); - const waiting = b.questions.length + b.withUser.length; + const waiting = b.questions.length + b.withUser.length + b.needs.length; return ( <>
@@ -438,6 +438,9 @@ function ProjectBoard({ board: b, refetch }: { board: Board; refetch: () => void

))} + {b.needs.map((n) => ( + + ))} )} @@ -522,6 +525,84 @@ function ProjectBoard({ board: b, refetch }: { board: Board; refetch: () => void ); } +/** + * One "needs you" item with its buttons. A button is offered only when the + * server can verify the item's preconditions now; otherwise the item says why + * it is not actionable yet. Every action runs on the server, as the user. + */ +function NeedRow({ need: n, now, onDone }: { need: Board["needs"][number]; now: number; onDone: () => void }) { + const rpc = useRpc(); + const navigate = useBbNavigate(); + const [note, setNote] = useState(""); + const [state, setState] = useState<"idle" | "running" | { error: string }>("idle"); + const act = (action: "approve" | "decline" | "done" | "merge" | "provide") => { + setState("running"); + rpc.call("stewardsNeedAction", { needId: n.id, action, note: note.trim() === "" ? null : note.trim() }).then( + (r) => { + if (!r.ok) return setState({ error: r.message }); + onDone(); + if (r.threadId !== null && r.threadId !== undefined) navigate.toThread(r.threadId); + }, + (e: unknown) => setState({ error: message(e) }), + ); + }; + const primary = "rounded-md border border-input bg-state-hover px-3 py-1 text-xs hover:bg-state-hover disabled:opacity-50"; + const secondary = "rounded-md border border-input px-3 py-1 text-xs hover:bg-state-hover disabled:opacity-50"; + const takesNote = n.kind === "approve-spec" || n.kind === "configure"; + return ( +
  • +

    + + {n.kind} + asked {ago(n.createdAt, now)} +

    +

    {n.what}

    + {n.how !== null ?
    : null} + {!n.actionable ?

    Not actionable yet: {n.why ?? "the server cannot verify it now"}.

    : null} + {takesNote ? ( +