From 1d8b8675d79b4f6e077f72cbab76a17163b6556d Mon Sep 17 00:00:00 2001 From: Dylan Trotter Date: Sun, 18 Oct 2026 18:06:59 +0000 Subject: [PATCH 1/2] stewards: a page per project, and a record of questions put to the user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BB-1. The project steward's questions to the user are now rows in a new questions table (appended to MIGRATIONS), made by forwarding an escalation to the user and by steward_update { ask }, closed by steward_update { resolve: "", answer } or by the user on the page. A forwarded question and its escalation close together in one transaction. The nightly wake carries a record assembled from the tables: the previous digest with its date, what moved, what waits on the user, what is stuck or held. Every project steward wake lists the open questions. The Stewards page (a nav panel, a tab per project) shows waiting on you, in flight by stage, stuck or held, recently ended and the latest digest. DESIGN.md marks the Board phase built and describes the record in §12. Co-Authored-By: Claude Opus 5.5 --- plugins/stewards/DESIGN.md | 35 +- plugins/stewards/README.md | 13 + plugins/stewards/app.tsx | 369 +++++++++++++++++++++- plugins/stewards/server.test.ts | 141 +++++++++ plugins/stewards/server.ts | 262 +++++++++++++-- plugins/stewards/skills/stewards/SKILL.md | 16 +- plugins/stewards/store.test.ts | 51 +++ plugins/stewards/store.ts | 94 +++++- plugins/stewards/wake.test.ts | 80 +++++ plugins/stewards/wake.ts | 103 +++++- 10 files changed, 1117 insertions(+), 47 deletions(-) create mode 100644 plugins/stewards/store.test.ts create mode 100644 plugins/stewards/wake.test.ts diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md index c3d97782..511341fd 100644 --- a/plugins/stewards/DESIGN.md +++ b/plugins/stewards/DESIGN.md @@ -512,6 +512,31 @@ hard stop is the runaway guard (§12). you, and writes the morning digest as its reply to the nightly wake. - **Woken** at the end of the nightly pass, by escalations that reach it, and by your messages. +- **Questions to you are records.** Whatever the project steward asks you is + a row in the `questions` table, not just a sentence in its reply, so a + compaction cannot lose it and an answer given elsewhere cannot leave it + listed as open. A row is made two ways: when it forwards an escalation to + you (`steward_update { forward }` with the route reaching `me`), bound to + that escalation and its binding; and when it asks you something itself + with `steward_update { ask: { question, context } }`, bound to a binding + when it names one. It closes when the project steward records your answer + (`steward_update { resolve: "", answer }`) or when you close + it on the stewards page, with or without an answer. A question made by + forwarding and its escalation close together, in one transaction, from + either side: resolving the escalation (by decision, by the binding + ending) closes the question with the same text, and closing the question + resolves the escalation and tells the binding's steward. Every project + steward wake lists the open questions from the table, and tells it not + to ask one again. +- **The digest is written from the record.** The nightly wake carries a + section the plugin assembles from its tables: the previous digest with + its date; what moved since then (open bindings whose status record + advanced, bindings that ended, questions answered); what waits on you + (open questions, then open escalations with you that no question covers, + such as approval requests); and what is stuck or held (open `stuck` + escalations, bindings on hold). The project steward writes prose and + priorities on top, and is told the record wins where it disagrees with + its earlier digest. Only the latest digest is kept. - **Budget is advisory.** Status records report what each binding uses; the project steward keeps the total sensible through priority and holds. - **Runaway guard.** A hard cap on worker spawns per binding per hour: a @@ -617,7 +642,12 @@ follow-through: 6h # how long a terminal binding may be kept open the project's sidebar section. - **Agent tools:** `steward_report` and `steward_update`. - **CLI:** `bb stewards init | check | list | show | detach | pass | digest`. -- **UI:** a board of status records, later. +- **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. ### Changes to linear and github @@ -662,7 +692,8 @@ plugins' contract before stewards uses them, bb-plugins before bb-gate. 3. **Project steward.** Escalation routing and decisions, big decisions to you, priority and holds, the nightly pass, the morning digest. 4. **Reviews.** Review bindings, review workers. -5. **Board.** +5. **Board.** Built: the Stewards page, the question record (§12), and the + digest assembled from records. ## Known limits diff --git a/plugins/stewards/README.md b/plugins/stewards/README.md index 3ba02006..d563e072 100644 --- a/plugins/stewards/README.md +++ b/plugins/stewards/README.md @@ -96,6 +96,19 @@ bb. [DESIGN.md](DESIGN.md) is the design; this is how it is built and run. 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. +- **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: "", + answer }`) or you close it on the page. A forwarded escalation and its + question close together. The nightly wake lists them, with the previous + digest, what moved, what waits on you and what is stuck, all read from + the store, so the digest does not depend on the project steward's memory. - **The settings page** (Settings → Plugins → Stewards, [app.tsx](app.tsx)) shows each stewarded project's configuration, problems, project steward and nightly pass, runs `bb stewards check` on a button, and lists every diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx index 919e40c4..1f53d610 100644 --- a/plugins/stewards/app.tsx +++ b/plugins/stewards/app.tsx @@ -1,16 +1,24 @@ -// Settings → Plugins → Stewards: which projects are stewarded and whether -// their configuration is healthy, then every open steward and where it -// stands. Read-only; steering stays with the project steward and the CLI. +// Two surfaces. The Stewards page (a nav panel, one tab per stewarded +// project): what waits on you, what is in flight by stage, what is stuck or +// held, what ended lately, and the latest digest; the one write is closing a +// question put to you. Settings → Plugins → Stewards: which projects are +// stewarded and whether their configuration is healthy, then every open +// steward and where it stands. Steering stays with the project steward and +// the CLI. import { useCallback, useEffect, useRef, useState, type ReactNode } from "react"; -import { definePluginApp, experimental_Icon as Icon, useBbNavigate, useRpc } from "@get-bb/plugin-sdk/app"; +import { Markdown, definePluginApp, experimental_Icon as Icon, useBbNavigate, useRpc } from "@get-bb/plugin-sdk/app"; import type { rpcContract } from "./server"; type Client = ReturnType>; -type Overview = Awaited> extends infer R ? Extract : never; +type Overview = Awaited> extends infer R ? Extract : never; type Project = Overview["projects"][number]; type Steward = Project["stewards"][number]; +type BoardResult = Awaited> extends infer R ? Extract : never; +type Board = NonNullable; type CheckResult = { ok: boolean; lines: string[] }; +const BOARD_PATH = "board"; + const POLL_MS = 30_000; function message(error: unknown): string { @@ -26,24 +34,26 @@ function ago(at: number | null, now: number): string { return `${Math.round(s / 86_400)}d ago`; } -/** The overview, refetched every half minute while the page is visible. */ -function useOverview(): { overview: Overview | null; error: string | null } { - const rpc = useRpc(); - const [overview, setOverview] = useState(null); +/** What `load` returns, refetched every half minute while the page is visible, and on demand. */ +function usePolled(load: () => Promise): { data: T | null; error: string | null; refetch: () => void } { + const [data, setData] = useState(null); const [error, setError] = useState(null); const mounted = useRef(true); + // Only the latest call lands, so a slow answer for the last project does not replace this one's. + const latest = useRef(0); const refetch = useCallback(() => { - rpc.call("stewardsOverview", null).then( + const call = ++latest.current; + load().then( (o) => { - if (!mounted.current) return; - setOverview(o); + if (!mounted.current || call !== latest.current) return; + setData(o); setError(null); }, (e: unknown) => { - if (mounted.current) setError(message(e)); + if (mounted.current && call === latest.current) setError(message(e)); }, ); - }, [rpc]); + }, [load]); useEffect(() => { mounted.current = true; refetch(); @@ -60,13 +70,28 @@ function useOverview(): { overview: Overview | null; error: string | null } { document.removeEventListener("visibilitychange", onVisibility); }; }, [refetch]); - return { overview, error }; + return { data, error, refetch }; +} + +function useOverview(): { overview: Overview | null; error: string | null } { + const rpc = useRpc(); + const { data, error } = usePolled(useCallback(() => rpc.call("stewardsOverview", null), [rpc])); + return { overview: data, error }; } function Loading({ error }: { error: string | null }) { return

{error === null ? "Loading…" : {error}}

; } +function PageLink({ projectId, children }: { projectId: string; children: ReactNode }) { + const navigate = useBbNavigate(); + return ( + + ); +} + function ThreadLink({ threadId, children }: { threadId: string; children: ReactNode }) { const navigate = useBbNavigate(); return ( @@ -82,6 +107,16 @@ function Badge({ children, tone = "muted" }: { children: ReactNode; tone?: "mute return {children}; } +function EntityLink({ entityKey, url }: { entityKey: string; url: string | null }) { + const navigate = useBbNavigate(); + if (url === null) return {entityKey}; + return ( + + ); +} + function Row({ label, children }: { label: string; children: ReactNode }) { return (
@@ -168,6 +203,9 @@ function ProjectStatus({ project: p, now }: { project: Project; now: number }) { {p.projectStewardThreadId === null ? not started yet; it starts with the first steward : Open thread} + + Open the stewards page + {p.nightly === null ? "—" : `${p.nightly.at} ${p.nightly.timezone}`} · last ran {p.lastNight ?? "never"} · digest {ago(p.digestAt, now)} @@ -273,7 +311,308 @@ function StewardRow({ steward: s, now }: { steward: Steward; now: number }) { ); } +// ---- The stewards page ------------------------------------------------------------------------- + +const STAGES: Array<{ stage: string | null; title: string }> = [ + { stage: "spec", title: "Spec" }, + { stage: "build", title: "Build" }, + { stage: "review", title: "Review" }, + { stage: null, title: "No stage" }, +]; + +function Section({ title, count, children }: { title: string; count?: number; children: ReactNode }) { + return ( +
+

+ {title} + {count === undefined ? null : {count}} +

+ {children} +
+ ); +} + +function List({ children }: { children: ReactNode }) { + return
    {children}
; +} + +function None({ children }: { children: ReactNode }) { + return

{children}

; +} + +function BoardPage({ subPath }: { subPath: string }) { + const rpc = useRpc(); + const navigate = useBbNavigate(); + const first = subPath.split("/")[0] ?? ""; + const wanted = first === "" ? null : decodeURIComponent(first); + const { data, error, refetch } = usePolled(useCallback(() => rpc.call("stewardsBoard", { projectId: wanted }), [rpc, wanted])); + return ( +
+
+ {data === null ? ( + + ) : data.projects.length === 0 ? ( + + No project is stewarded. Run bb stewards init from a thread in a multi-repo project, commit and publish it, and merge the guidance branch. + + ) : ( + <> + {data.projects.length > 1 ? ( + + ) : null} + {data.board === null ? That project is not stewarded. : } + {error !== null ?

Refresh failed: {error}

: null} + + )} +
+
+ ); +} + +function ProjectBoard({ board: b, refetch }: { board: Board; refetch: () => void }) { + const now = Date.now(); + const waiting = b.questions.length + b.withUser.length; + return ( + <> +
+

{b.name}

+ {b.projectStewardThreadId === null ? ( + No project steward yet; it starts with the first steward. + ) : ( + Open the project steward + )} +
+ {b.paused ? ( +

+ + Stewards are paused: nothing is woken or adopted. +

+ ) : null} + +
+ {waiting === 0 ? ( + Nothing is waiting on you. + ) : ( + + {b.questions.map((q) => ( + + ))} + {b.withUser.map((x) => ( +
  • +

    + + {x.kind === "approval" ? "approval request" : `${x.kind} escalation`} + {ago(x.createdAt, now)} +

    +

    {x.question}

    + {x.recommendation !== null ?

    Recommendation: {x.recommendation}

    : null} +

    + {x.kind === "approval" ? "Approve or decline in its steward's thread." : "Answer in the project steward's thread."} + {x.kind === "approval" && x.threadId !== null ? ( + <> + {" "} + Open steward + + ) : null} + {x.kind !== "approval" && b.projectStewardThreadId !== null ? ( + <> + {" "} + Open the project steward + + ) : null} +

    +
  • + ))} +
    + )} +
    + +
    + {b.stewards.length === 0 ? ( + No open stewards. Label a Linear ticket or pull request to adopt it. + ) : ( + STAGES.map(({ stage, title }) => { + const rows = b.stewards.filter((s) => (s.stage ?? null) === stage); + if (rows.length === 0) return null; + return ( +
    +

    + {title} · {rows.length} +

    + + {rows.map((s) => ( + + ))} + +
    + ); + }) + )} +
    + +
    + {b.stuck.length === 0 ? ( + Nothing is stuck or held. + ) : ( + + {b.stuck.map((x, i) => ( +
  • +

    + + {x.since !== null ? {ago(x.since, now)} : null} +

    +

    {x.why}

    + {x.threadId !== null ? ( +

    + Open steward +

    + ) : null} +
  • + ))} +
    + )} +
    + +
    + {b.ended.length === 0 ? ( + Nothing ended in the last two weeks. + ) : ( + + {b.ended.map((x) => ( +
  • + + {x.title} + {x.kind} + {x.endReason !== null ? {x.endReason} : null} + {ago(x.endedAt, now)} +
  • + ))} +
    + )} +
    + +
    + {b.digest === null ? ( + No digest yet; the project steward writes one at the end of each nightly pass. + ) : ( +
    +

    + {new Date(b.digest.at).toLocaleString()} ({ago(b.digest.at, now)}) +

    + +
    + )} +
    + + ); +} + +function QuestionRow({ question: q, now, onClosed }: { question: Board["questions"][number]; now: number; onClosed: () => void }) { + const rpc = useRpc(); + const [answer, setAnswer] = useState(""); + const [state, setState] = useState<"idle" | "closing" | { error: string }>("idle"); + const close = () => { + setState("closing"); + rpc.call("stewardsAnswerQuestion", { questionId: q.id, answer: answer.trim() === "" ? null : answer.trim() }).then( + (r) => { + if (r.ok) onClosed(); + else setState({ error: r.message }); + }, + (e: unknown) => setState({ error: message(e) }), + ); + }; + return ( +
  • +

    + {q.key !== null ? : null} + {q.escalationId === null ? "question" : "forwarded escalation"} + asked {ago(q.createdAt, now)} +

    +

    {q.question}

    + {q.context !== null ?

    {q.context}

    : null} +
    +