From f6865c74abf65eb5bdeffea0341d6a18806ff544 Mon Sep 17 00:00:00 2001
From: Dylan Trotter
Date: Tue, 20 Oct 2026 17:09:36 +0000
Subject: [PATCH 1/2] stewards: Provide spawns a fixed-prompt requester that
opens bb's secure form (BB-22)
---
plugins/stewards/DESIGN.md | 8 +-
plugins/stewards/app.tsx | 14 +-
plugins/stewards/config.test.ts | 5 +-
plugins/stewards/server.test.ts | 166 ++++++++++-
plugins/stewards/server.ts | 338 +++++++++++++++++++---
plugins/stewards/skills/stewards/SKILL.md | 21 +-
plugins/stewards/store.ts | 39 ++-
plugins/stewards/templates.ts | 2 +-
plugins/stewards/wake.test.ts | 8 +-
plugins/stewards/wake.ts | 4 +-
10 files changed, 526 insertions(+), 79 deletions(-)
diff --git a/plugins/stewards/DESIGN.md b/plugins/stewards/DESIGN.md
index bd11429c..6f814a94 100644
--- a/plugins/stewards/DESIGN.md
+++ b/plugins/stewards/DESIGN.md
@@ -846,9 +846,9 @@ what a wake carries.
from the wake's evidence and the code in its workspace. **Until a token
is set, the look fails with "no Sentry token is configured"; that one
failure wakes the steward**, which files the `provide-secret` need naming
- the setting (variable `sentryToken`, the Sentry auth-tokens page, the
- scopes) and does nothing else; later looks are quiet until the token
- appears. Any other read failure (403, a wrong URL) is logged and shown by
+ the setting (variable `SENTRY_TOKEN`, setting `sentryToken`, the Sentry
+ auth-tokens page, the scopes) and does nothing else; later looks are quiet
+ until the token appears. Any other read failure (403, a wrong URL) is logged and shown by
`bb stewards check`, and wakes nobody, as a namespace kubectl cannot read
does not.
- **Doorbells come from bb-gate-hooks directly** (`hooks-client.ts`, a copy
@@ -916,7 +916,7 @@ listed under "Waiting on you" on the Stewards page, in the digest, and by
| `approve-pr` | plugin, when a linked pull request is in the owner-reviewed lane, the reviewer's latest marker 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 text box), or one button per `choices` label and **Other…** |
-| `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 |
+| `provide-secret` | steward, with the variable name and purpose, and either the `writeEnv` dotenv path (or `worker`) or the `setting` of one of the plugin's secret settings | the dotenv, or the stewards secret setting | the requester's `bb secret request` (and `bb stewards secret import` for a setting) completes | **Provide**: the server spawns a fixed-prompt requester thread, opens bb's secure form in its first turn, and navigates to it; **Done** is the manual escape hatch |
| `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:
diff --git a/plugins/stewards/app.tsx b/plugins/stewards/app.tsx
index 2d272887..d9b7b278 100644
--- a/plugins/stewards/app.tsx
+++ b/plugins/stewards/app.tsx
@@ -569,6 +569,7 @@ function NeedRow({ need: n, now, onDone }: { need: Board["needs"][number]; now:
asked {ago(n.createdAt, now)}
{n.what}
+ {n.kind === "provide-secret" ?
The form opens in a thread; the value goes to {n.destination ?? "the destination the item names"}.
: null}
{n.how !== null ?
: null}
{!n.actionable ?
Not actionable yet: {n.why ?? "the server cannot verify it now"}.
: null}
{takesNote ? (
@@ -600,9 +601,14 @@ function NeedRow({ need: n, now, onDone }: { need: Board["needs"][number]; now:
Merge
) : n.kind === "provide-secret" ? (
-
+ <>
+
+
+ >
) : n.kind === "configure" ? (
)}
- {n.threadId !== null ? Open the worker : null}
+ {n.threadId !== null ? {n.kind === "provide-secret" ? "Open the requester" : "Open the worker"} : null}
{typeof state === "object" ? {state.error} : null}
diff --git a/plugins/stewards/config.test.ts b/plugins/stewards/config.test.ts
index 1fa69a03..1ca0bbab 100644
--- a/plugins/stewards/config.test.ts
+++ b/plugins/stewards/config.test.ts
@@ -117,10 +117,11 @@ describe("playbooks", () => {
}
});
- it("tells the default playbooks to get credentials through bb secret request and to escalate build-time blockers", () => {
+ it("tells the default playbooks to file credentials as provide-secret needs and to escalate build-time blockers", () => {
const linear = parsePlaybook(LINEAR_TICKETS, "linear-tickets");
if (!linear.ok) throw new Error(linear.error);
- expect(phaseInstructions(linear.value, "In Progress")).toMatch(/bb secret request/u);
+ expect(phaseInstructions(linear.value, "In Progress")).toMatch(/provide-secret/u);
+ expect(phaseInstructions(linear.value, "In Progress")).toMatch(/writeEnv/u);
expect(phaseInstructions(linear.value, "In Progress")).toMatch(/changes what the ticket needs/u);
expect(phaseInstructions(linear.value, "In Progress")).toMatch(/escalated as a `decision`/u);
expect(phaseInstructions(linear.value, "In Review")).toMatch(/escalated as a `decision`/u);
diff --git a/plugins/stewards/server.test.ts b/plugins/stewards/server.test.ts
index 21582506..a407af07 100644
--- a/plugins/stewards/server.test.ts
+++ b/plugins/stewards/server.test.ts
@@ -4,7 +4,7 @@ import { describe, expect, it } from "vitest";
import { PROJECT_FILE, playbookPath } from "./config.js";
import { comment, crashingPod, issue, pull, warningEvent } from "./fixtures.js";
import { kubectlRefusal, type KubectlResult } from "./kubectl.js";
-import { createStewardsPlugin, testHooks, type StewardsDeps } from "./server.js";
+import { createStewardsPlugin, parseDotenvValue, secretVariable, testHooks, type StewardsDeps } from "./server.js";
import { SOURCE_PLUGIN_IDS, type EntitySnapshot } from "./source-contract.js";
import { MIGRATIONS } from "./store.js";
import { GITHUB_PRS, GITHUB_REVIEWS, LINEAR_TICKETS, OPS_WATCH, DEPS_ALERTS, DEPS_PRS, projectFileTemplate } from "./templates.js";
@@ -27,6 +27,9 @@ function world() {
const rpcCalls: Call[] = [];
const threads = new Map();
const writes: Array<{ path: string; hostId?: string }> = [];
+ /** Dotenv files by `${hostId}:${path}`, for `bb stewards secret import`. */
+ const fileContents = new Map();
+ const fileKey = (hostId: string | undefined, path: string) => `${hostId ?? ""}:${path}`;
const sections: Array<{ id: string; name: string }> = [];
/** Each thread's latest context window reading, as bb reports it. */
const usage = new Map();
@@ -93,6 +96,16 @@ function world() {
writes.push({ path: args.path, hostId: args.hostId });
return { outcome: "written" };
},
+ read: async (args: { path: string; hostId?: string }) => {
+ const key = fileKey(args.hostId, args.path);
+ if (!fileContents.has(key)) throw Object.assign(new Error("no such file"), { status: 404 });
+ const content = fileContents.get(key)!;
+ return { path: args.path, content, contentEncoding: "utf8" as const, sizeBytes: content.length, sha256: "sha" };
+ },
+ remove: async (args: { path: string; hostId?: string }) => {
+ fileContents.delete(fileKey(args.hostId, args.path));
+ return {};
+ },
},
hosts: { list: async () => [{ id: "host_off", status: "disconnected" }, { id: "host_on", status: "connected" }] },
threadSections: {
@@ -111,7 +124,8 @@ function world() {
threads: {
spawn: async (args: Record) => {
const id = `thr_${++n}`;
- threads.set(id, { status: "idle", archivedAt: null, title: (args.title as string | undefined) ?? null, sectionId: (args.sectionId as string | undefined) ?? null });
+ const environment = args.environment as { machine?: { hostId?: string } } | undefined;
+ threads.set(id, { status: "idle", archivedAt: null, title: (args.title as string | undefined) ?? null, sectionId: (args.sectionId as string | undefined) ?? null, ...(environment?.machine?.hostId === undefined ? {} : { hostId: environment.machine.hostId }) });
metadata.set(id, { ...((args.pluginMetadata as Record | undefined) ?? {}) });
spawns.push({ ...args, id });
return makeThreadResponse({ id });
@@ -154,6 +168,7 @@ function world() {
return {};
},
compact: async () => ({ ok: true }),
+ storageLocation: async ({ threadId }: { threadId: string }) => ({ hostId: "host_on", storageRootPath: `/storage/${threadId}` }),
updatePluginMetadata: async (args: { threadId: string; set?: Record }) => {
const next = { ...(metadata.get(args.threadId) ?? {}), ...(args.set ?? {}) };
metadata.set(args.threadId, next);
@@ -170,7 +185,7 @@ function world() {
},
};
let now = Date.parse("2026-10-14T15:00:00Z");
- return { files, writes, repos, entities, dependabotAlerts, rpcCalls, threads, sections, usage, metadata, spawns, sends, userTurns, githubComments, githubMerges, github, sdk, now: () => now, advance: (ms: number) => (now += ms) };
+ return { files, writes, fileContents, repos, entities, dependabotAlerts, rpcCalls, threads, sections, usage, metadata, spawns, sends, userTurns, githubComments, githubMerges, github, sdk, now: () => now, advance: (ms: number) => (now += ms) };
}
async function setup(extra: Partial = {}, settings: Record = {}) {
@@ -2279,18 +2294,136 @@ describe("needs you items", () => {
expect(t.sends.filter((s) => s.threadId === steward).at(-1)!.text).toMatch(/## 5\. What changed since your last turn[\s\S]*configure item .* closed from a thread/u);
});
- it("says so when a provide-secret item has no worker to open", async () => {
+ it("Provide spawns a requester thread with the fixed prompt, navigates to it, and closes the need when it finishes", async () => {
const t = await setup();
t.entities.set("uuid-12", issue());
await t.ring("linear", "uuid-12");
const steward = t.spawns[1]!.id;
- await t.tool("steward_report", { ...base, actor: "me", needs: [{ kind: "provide-secret", what: "LINEAR_CLIENT_SECRET", variable: "LINEAR_CLIENT_SECRET", purpose: "Token exchange" }] }, steward);
+ await t.tool("steward_report", { ...base, actor: "me", needs: [{ kind: "provide-secret", what: "LINEAR_CLIENT_SECRET", variable: "LINEAR_CLIENT_SECRET", purpose: "Token exchange", worker: "thr_w1" }] }, steward);
const b = t.hooks.store.find("ENG-12")!;
const need = t.hooks.store.openNeeds(b.id).find((n) => n.kind === "provide-secret")!;
- const res = await t.harness.callRpc("stewardsNeedAction", { needId: need.id, action: "provide" }, client);
- expect(res).toMatchObject({ ok: true, threadId: null });
+ const spawned = t.spawns.length;
+ const res = (await t.harness.callRpc("stewardsNeedAction", { needId: need.id, action: "provide" }, client)) as { ok: boolean; threadId: string };
+ expect(res).toMatchObject({ ok: true, threadId: expect.stringMatching(/^thr_/u) });
+ expect(t.spawns.length).toBe(spawned + 1);
+ const requester = t.spawns.at(-1)!;
+ expect(requester.id).toBe(res.threadId);
+ // Same machine and model the binding's workers use.
+ expect(requester).toMatchObject({
+ title: "Provide LINEAR_CLIENT_SECRET for ENG-12",
+ providerId: "claude-code",
+ model: "claude-opus-5-5",
+ reasoningLevel: "high",
+ environment: { type: "provider", environmentProviderId: "multi-repo-workspace", machine: { type: "existing", hostId: "host_on" } },
+ });
+ const prompt = String(requester.prompt);
+ expect(prompt).toContain('bb secret request LINEAR_CLIENT_SECRET --purpose "Token exchange" --write-env "/storage/thr_w1/.secrets.env"');
+ expect(prompt).toMatch(/If the request fails or is cancelled/u);
+ expect(prompt).not.toMatch(/bb stewards secret import/u);
+ // The need stays open while the requester runs, so the import is accepted.
+ expect(t.hooks.store.need(need.id)!.status).toBe("open");
+ // The requester is a worker: when it finishes, the need closes and the steward is told.
+ await t.idle(res.threadId, "Provided LINEAR_CLIENT_SECRET.");
await t.flush();
- expect(t.sends.filter((s) => s.threadId === steward).at(-1)!.text).toMatch(/start the worker that will request it/u);
+ expect(t.hooks.store.need(need.id)!.status).toBe("done");
+ expect(t.sends.filter((s) => s.threadId === steward).at(-1)!.text).toMatch(/Worker "Provide LINEAR_CLIENT_SECRET for ENG-12" finished its turn/u);
+ });
+
+ it("Provide works with no worker named, using the requester's own storage", async () => {
+ const t = await setup();
+ t.entities.set("uuid-12", issue());
+ await t.ring("linear", "uuid-12");
+ const steward = t.spawns[1]!.id;
+ await t.tool("steward_report", { ...base, actor: "me", needs: [{ kind: "provide-secret", what: "SOME_TOKEN", variable: "SOME_TOKEN", purpose: "Auth" }] }, steward);
+ const b = t.hooks.store.find("ENG-12")!;
+ const need = t.hooks.store.openNeeds(b.id).find((n) => n.kind === "provide-secret")!;
+ const res = (await t.harness.callRpc("stewardsNeedAction", { needId: need.id, action: "provide" }, client)) as { ok: boolean; threadId: string };
+ expect(res.ok).toBe(true);
+ const requester = t.spawns.at(-1)!;
+ expect(String(requester.prompt)).toContain('--write-env "$BB_THREAD_STORAGE/.secrets.env"');
+ });
+
+ it("refuses a provide-secret setting that is not a declared secret setting", async () => {
+ const t = await setup();
+ t.entities.set("uuid-12", issue());
+ await t.ring("linear", "uuid-12");
+ const steward = t.spawns[1]!.id;
+ const bad = await t.tool("steward_report", { ...base, actor: "me", needs: [{ kind: "provide-secret", what: "Bad", variable: "X", purpose: "Y", setting: "paused" }] }, steward);
+ expect(bad.error).toBe(false);
+ expect(bad.text).toMatch(/is not a secret setting/u);
+ const good = await t.tool("steward_report", { ...base, actor: "me", needs: [{ kind: "provide-secret", what: "Good", variable: "SENTRY_TOKEN", purpose: "Y", setting: "sentryToken" }] }, steward);
+ expect(good.error).toBe(false);
+ const b = t.hooks.store.find("ENG-12")!;
+ expect(t.hooks.store.openNeeds(b.id).some((n) => n.data.setting === "sentryToken")).toBe(true);
+ });
+
+ it("Case B: a requester imports a dotenv into a declared secret setting, deletes the file, and leaks nothing", async () => {
+ const t = await setup();
+ t.entities.set("uuid-12", issue());
+ await t.ring("linear", "uuid-12");
+ const steward = t.spawns[1]!.id;
+ await t.tool("steward_report", { ...base, actor: "me", needs: [{ kind: "provide-secret", what: "Enter the Sentry token", variable: "SENTRY_TOKEN", purpose: "Read Sentry", setting: "sentryToken" }] }, steward);
+ const b = t.hooks.store.find("ENG-12")!;
+ const need = t.hooks.store.openNeeds(b.id).find((n) => n.kind === "provide-secret")!;
+ const res = (await t.harness.callRpc("stewardsNeedAction", { needId: need.id, action: "provide" }, client)) as { ok: boolean; threadId: string };
+ expect(res.ok).toBe(true);
+ const requester = t.spawns.at(-1)!;
+ expect(String(requester.prompt)).toContain('bb stewards secret import --from "$BB_THREAD_STORAGE/.secrets.env" --setting sentryToken');
+ // The requester writes the dotenv; the import reads it, sets the setting, and deletes the file.
+ t.fileContents.set("host_on:/tmp/.secrets.env", "SENTRY_TOKEN='s3cr3t-value'\n");
+ const out = await t.harness.behavior.runCli(["secret", "import", "--from", "/tmp/.secrets.env", "--setting", "sentryToken"], { threadId: res.threadId, projectId: "p1" });
+ expect(out.exitCode).toBe(0);
+ expect(out.stdout).toContain("Imported sentryToken");
+ expect(out.stdout).not.toContain("s3cr3t-value");
+ expect(out.stderr).not.toContain("s3cr3t-value");
+ expect((await t.hooks.settings.get()).sentryToken).toBe("s3cr3t-value");
+ expect(t.fileContents.has("host_on:/tmp/.secrets.env")).toBe(false);
+ // The value appears in no message, worker result or need record either.
+ const transcript = JSON.stringify([...t.sends, ...t.userTurns, t.hooks.store.needs(b.id, true), t.hooks.store.workers(b.id)]);
+ expect(transcript).not.toContain("s3cr3t-value");
+ });
+
+ it("Case B: secret import refuses an unrelated thread, the wrong setting, a non-secret setting, a file on another host, and an import after the need closed", async () => {
+ const t = await setup();
+ t.entities.set("uuid-12", issue());
+ await t.ring("linear", "uuid-12");
+ const steward = t.spawns[1]!.id;
+ await t.tool("steward_report", { ...base, actor: "me", needs: [{ kind: "provide-secret", what: "Enter the Sentry token", variable: "SENTRY_TOKEN", purpose: "Read Sentry", setting: "sentryToken" }] }, steward);
+ const b = t.hooks.store.find("ENG-12")!;
+ const need = t.hooks.store.openNeeds(b.id).find((n) => n.kind === "provide-secret")!;
+ const res = (await t.harness.callRpc("stewardsNeedAction", { needId: need.id, action: "provide" }, client)) as { ok: boolean; threadId: string };
+ const requester = res.threadId;
+ t.fileContents.set("host_on:/tmp/.secrets.env", "SENTRY_TOKEN='s3cr3t-value'\n");
+ const importFrom = (threadId: string, setting: string, from = "/tmp/.secrets.env") =>
+ t.harness.behavior.runCli(["secret", "import", "--from", from, "--setting", setting], { threadId, projectId: "p1" });
+
+ // (a) An unrelated thread is refused.
+ const other = await importFrom("thr_other", "sentryToken");
+ expect(other.exitCode).toBe(1);
+ expect(other.stderr).toMatch(/not a provide-secret requester thread/u);
+ // (b) The right thread naming a different setting is refused.
+ const wrong = await importFrom(requester, "sentryApiUrl");
+ expect(wrong.exitCode).toBe(1);
+ expect(wrong.stderr).toMatch(/goes to/u);
+ // A non-secret setting is refused even if a need somehow names it.
+ const sneaky = t.hooks.store.fileNeed({ bindingId: b.id, kind: "provide-secret", url: "sneaky", what: "Sneaky", how: null, data: { variable: "SENTRY_TOKEN", setting: "sentryApiUrl" }, filedBy: "steward" });
+ t.hooks.store.setSecretRequester("thr_sneaky", sneaky.id);
+ const notSecret = await importFrom("thr_sneaky", "sentryApiUrl");
+ expect(notSecret.exitCode).toBe(1);
+ expect(notSecret.stderr).toMatch(/not a secret setting/u);
+ // A file that exists only on another host is not read from the invoking thread's.
+ t.fileContents.set("host_off:/tmp/elsewhere.env", "SENTRY_TOKEN='x'\n");
+ const otherHost = await importFrom(requester, "sentryToken", "/tmp/elsewhere.env");
+ expect(otherHost.exitCode).toBe(1);
+ expect(otherHost.stderr).toMatch(/Could not read/u);
+ // (c) After the need closes, the import is refused.
+ await t.idle(requester, "Provided.");
+ await t.flush();
+ expect(t.hooks.store.need(need.id)!.status).toBe("done");
+ const closed = await importFrom(requester, "sentryToken");
+ expect(closed.exitCode).toBe(1);
+ expect(closed.stderr).toMatch(/closed/u);
+ expect((await t.hooks.settings.get()).sentryToken).toBeUndefined();
});
it("refuses a blockedOn naming the user with no item, and accepts one with an item", async () => {
@@ -3464,7 +3597,7 @@ describe("Sentry stewards", () => {
expect(steward()).toBeDefined();
const first = wakes()[0]!;
expect(first).toMatch(/The plugin has no Sentry token, so it cannot read this project/u);
- expect(first).toMatch(/File one provide-secret need for it with steward_report: variable `sentryToken`, url https:\/\/sentry\.io\/settings\/account\/api\/auth-tokens\//u);
+ expect(first).toMatch(/File one provide-secret need for it with steward_report: variable `SENTRY_TOKEN`, setting `sentryToken`, url https:\/\/sentry\.io\/settings\/account\/api\/auth-tokens\//u);
expect(first).toMatch(/project:read and event:read/u);
expect(first).toMatch(/Cannot read sentry-project\/acme\/web: no Sentry token is configured/u);
// Said once: the next looks are quiet until a token appears.
@@ -3494,3 +3627,18 @@ describe("Sentry stewards", () => {
expect(sentry.calls.every((c) => c.startsWith("/api/0/"))).toBe(true);
});
});
+
+describe("the dotenv a requester imports", () => {
+ it("reads the named variable, quoted or not, and strips a trailing comment", () => {
+ expect(parseDotenvValue("OTHER='x'\nSENTRY_TOKEN='s3cr3t'\n", "SENTRY_TOKEN")).toBe("s3cr3t");
+ expect(parseDotenvValue('export SENTRY_TOKEN="s3cr3t"\n', "SENTRY_TOKEN")).toBe("s3cr3t");
+ expect(parseDotenvValue("SENTRY_TOKEN=s3cr3t # the token\n", "SENTRY_TOKEN")).toBe("s3cr3t");
+ expect(parseDotenvValue("SENTRY_TOKEN='has # hash'\n", "SENTRY_TOKEN")).toBe("has # hash");
+ expect(parseDotenvValue("OTHER='x'\n", "SENTRY_TOKEN")).toBeNull();
+ });
+
+ it("derives the env var from a setting name when the need names no variable", () => {
+ expect(secretVariable({ what: "Enter it", data: { setting: "sentryToken" } })).toBe("SENTRY_TOKEN");
+ expect(secretVariable({ what: "Enter it", data: { variable: "LINEAR_CLIENT_SECRET", setting: "sentryToken" } })).toBe("LINEAR_CLIENT_SECRET");
+ });
+});
diff --git a/plugins/stewards/server.ts b/plugins/stewards/server.ts
index fc2a7c1b..92e946cc 100644
--- a/plugins/stewards/server.ts
+++ b/plugins/stewards/server.ts
@@ -263,6 +263,8 @@ export const rpcContract = defineRpcContract({
choices: z.array(z.string()),
what: z.string(),
how: z.string().nullable(),
+ /** For a provide-secret item: where the value goes, in words. */
+ destination: z.string().nullable(),
threadId: z.string().nullable(),
createdAt: z.number(),
/** Whether the server can verify the preconditions now; when false, `why` says what is missing. */
@@ -350,43 +352,146 @@ export const choicesSchema = z
.max(6)
.refine((labels) => new Set(labels).size === labels.length, "choices must be distinct");
+/**
+ * The dotenv value `bb secret request` wrote for one variable, or null. The
+ * file is read on the invoking thread's host through `bb.sdk.files`; only the
+ * named variable's value is returned, and the value is never logged.
+ */
+export function parseDotenvValue(content: string, name: string): string | null {
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
+ const pattern = new RegExp(`^\\s*(?:export\\s+)?${escaped}\\s*=\\s*(.*)$`, "u");
+ for (const line of content.split(/\r?\n/u)) {
+ const match = pattern.exec(line);
+ if (match === null) continue;
+ return unquoteDotenvValue(stripDotenvComment((match[1] ?? "").trim()));
+ }
+ return null;
+}
+
+function stripDotenvComment(raw: string): string {
+ let quote: "'" | '"' | null = null;
+ let escaped = false;
+ for (let i = 0; i < raw.length; i += 1) {
+ const ch = raw[i]!;
+ if (escaped) {
+ escaped = false;
+ continue;
+ }
+ if (quote === '"' && ch === "\\") {
+ escaped = true;
+ continue;
+ }
+ if (ch === "'" || ch === '"') {
+ quote = quote === ch ? null : (quote ?? ch);
+ continue;
+ }
+ if (ch === "#" && quote === null && i > 0 && /\s/u.test(raw[i - 1] ?? "")) return raw.slice(0, i).trimEnd();
+ }
+ return raw;
+}
+
+function unquoteDotenvValue(raw: string): string {
+ if (raw.length >= 2 && raw.startsWith("'") && raw.endsWith("'")) return raw.slice(1, -1);
+ if (raw.length >= 2 && raw.startsWith('"') && raw.endsWith('"')) {
+ return raw
+ .slice(1, -1)
+ .replace(/\\n/gu, "\n")
+ .replace(/\\r/gu, "\r")
+ .replace(/\\"/gu, '"')
+ .replace(/\\\\/gu, "\\");
+ }
+ return raw;
+}
+
+/** Where a provide-secret item's value goes, for the page and the requester prompt. */
+export function secretDestination(need: Pick): string | null {
+ const setting = typeof need.data.setting === "string" && need.data.setting.trim() !== "" ? need.data.setting.trim() : null;
+ if (setting !== null) return `the stewards setting ${setting}`;
+ const writeEnv = typeof need.data.writeEnv === "string" && need.data.writeEnv.trim() !== "" ? need.data.writeEnv.trim() : null;
+ if (writeEnv !== null) return `the dotenv ${writeEnv}`;
+ return "a dotenv on this machine";
+}
+
+/** The env var a provide-secret item's dotenv holds: `variable`, else the setting name in SCREAMING_SNAKE_CASE. */
+export function secretVariable(need: Pick): string {
+ const variable = typeof need.data.variable === "string" && need.data.variable.trim() !== "" ? need.data.variable.trim() : null;
+ if (variable !== null) return variable;
+ const setting = typeof need.data.setting === "string" && need.data.setting.trim() !== "" ? need.data.setting.trim() : null;
+ if (setting !== null) return setting.replace(/([a-z0-9])([A-Z])/gu, "$1_$2").replace(/[^A-Za-z0-9_]/gu, "_").toUpperCase();
+ return need.what.trim();
+}
+
+/**
+ * The fixed prompt the plugin gives the requester thread it spawns for a
+ * provide-secret need. The form opens in that thread's first turn; the value
+ * never reaches the agent, argv, logs or the timeline. The prompt says what to
+ * report when the request fails, so the steward is told.
+ */
+export function requesterPrompt(b: Pick, need: Pick, writeEnv: string): string {
+ const variable = secretVariable(need);
+ const rawPurpose = typeof need.data.purpose === "string" && need.data.purpose.trim() !== "" ? need.data.purpose.trim() : `the value ${b.entityKey} needs`;
+ const purpose = rawPurpose.replace(/\s+/gu, " ");
+ const setting = typeof need.data.setting === "string" && need.data.setting.trim() !== "" ? need.data.setting.trim() : null;
+ const lines = [
+ `You are a one-task requester thread started by the stewards plugin for ${b.entityKey}. The user is waiting to enter a secret through bb's secure form. Do only this; do not explore the workspace or do anything else.`,
+ "",
+ "Run this command and wait for the user to submit the form in this thread:",
+ "",
+ ` bb secret request ${variable} --purpose ${JSON.stringify(purpose)} --write-env ${JSON.stringify(writeEnv)}`,
+ ];
+ if (setting !== null) {
+ lines.push("", "Then, once it succeeds, run:", "", ` bb stewards secret import --from ${JSON.stringify(writeEnv)} --setting ${setting}`);
+ }
+ lines.push(
+ "",
+ "The form is masked; the value never reaches you, argv, logs or the timeline. Never read, echo or cat the dotenv file. When it succeeds, reply with one short line saying the secret was provided.",
+ "If the request fails or is cancelled, reply with one line saying what failed (the error code or message). Do not retry more than once, and never paste any value.",
+ );
+ return lines.join("\n");
+}
+
+export const STEWARDS_SETTINGS = {
+ paused: {
+ type: "boolean",
+ label: "Pause stewards",
+ description: "No steward is woken and nothing new is adopted while this is on. Changes still queue up and are delivered when it is turned off.",
+ default: false,
+ },
+ workerSpawnsPerHour: {
+ type: "number",
+ label: "Worker spawns per binding per hour",
+ description: "The runaway guard: a steward that tries to start more workers than this in an hour is refused. Not a budget.",
+ default: 6,
+ },
+ compactAboveTokens: {
+ type: "number",
+ label: "Compact a steward above this many context tokens",
+ description: "After a steward's or the project steward's turn, and before a wake that would push it over, its context is compacted when it holds more than this. Every wake is self-contained, so little is lost. 0 leaves compaction to the provider.",
+ default: 120_000,
+ },
+ sentryToken: {
+ type: "string",
+ secret: true,
+ label: "Sentry token",
+ description: `A Sentry user auth token with the scopes ${TOKEN_SCOPES.join(" and ")}, for the ops stewards of sentry-project targets: the plugin reads each project's issues with it and proves its bb-gate-hooks leases with it. Created at Settings → Account → API → Auth Tokens in Sentry.`,
+ },
+ sentryApiUrl: {
+ type: "string",
+ label: "Sentry API",
+ description: "Where Sentry is read; change it for a self-hosted Sentry.",
+ default: SENTRY_API_URL,
+ },
+} as const;
+
+/** The declared settings a provide-secret need may name: only `secret: true` fields are accepted. */
+export const SECRET_SETTING_NAMES = new Set(Object.entries(STEWARDS_SETTINGS).filter(([, descriptor]) => "secret" in descriptor && descriptor.secret === true).map(([name]) => name));
+
export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => Promise {
return async (bb) => {
const timing: Timing = { ...DEFAULT_TIMING, ...deps.timing };
const now = deps.now;
const github = deps.github ?? createGhWriter();
- const settings = bb.settings.define({
- paused: {
- type: "boolean",
- label: "Pause stewards",
- description: "No steward is woken and nothing new is adopted while this is on. Changes still queue up and are delivered when it is turned off.",
- default: false,
- },
- workerSpawnsPerHour: {
- type: "number",
- label: "Worker spawns per binding per hour",
- description: "The runaway guard: a steward that tries to start more workers than this in an hour is refused. Not a budget.",
- default: 6,
- },
- compactAboveTokens: {
- type: "number",
- label: "Compact a steward above this many context tokens",
- description: "After a steward's or the project steward's turn, and before a wake that would push it over, its context is compacted when it holds more than this. Every wake is self-contained, so little is lost. 0 leaves compaction to the provider.",
- default: 120_000,
- },
- sentryToken: {
- type: "string",
- secret: true,
- label: "Sentry token",
- description: `A Sentry user auth token with the scopes ${TOKEN_SCOPES.join(" and ")}, for the ops stewards of sentry-project targets: the plugin reads each project's issues with it and proves its bb-gate-hooks leases with it. Created at Settings → Account → API → Auth Tokens in Sentry.`,
- },
- sentryApiUrl: {
- type: "string",
- label: "Sentry API",
- description: "Where Sentry is read; change it for a self-hosted Sentry.",
- default: SENTRY_API_URL,
- },
- });
+ const settings = bb.settings.define(STEWARDS_SETTINGS);
const fetchImpl = deps.fetch ?? globalThis.fetch;
const env = deps.env ?? process.env;
@@ -982,6 +1087,66 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
return thread.id;
}
+ /**
+ * The dotenv the requester writes for a provide-secret need. The need's
+ * own `writeEnv` wins; a stewards setting always uses the requester's
+ * temporary storage; otherwise the named worker's thread storage, so the
+ * value lands where the worker reads it.
+ */
+ async function requesterWriteEnv(need: Need): Promise {
+ const named = typeof need.data.writeEnv === "string" && need.data.writeEnv.trim() !== "" ? need.data.writeEnv.trim() : null;
+ if (named !== null) return named;
+ if (typeof need.data.setting === "string" && need.data.setting.trim() !== "") return "$BB_THREAD_STORAGE/.secrets.env";
+ const workerThreadId = typeof need.data.workerThreadId === "string" ? need.data.workerThreadId : null;
+ if (workerThreadId !== null) {
+ try {
+ const location = await bb.sdk.threads.storageLocation({ threadId: workerThreadId });
+ if (typeof location.storageRootPath === "string" && location.storageRootPath !== "") return `${location.storageRootPath.replace(/\/$/u, "")}/.secrets.env`;
+ } catch (error) {
+ bb.log.warn(`stewards: could not resolve worker ${workerThreadId}'s storage (${errorMessage(error)}); using the requester's own`);
+ }
+ }
+ return "$BB_THREAD_STORAGE/.secrets.env";
+ }
+
+ /**
+ * Spawn the fixed-prompt requester thread for an open provide-secret need,
+ * on the same machine and with the same model the binding's workers use. It
+ * is recorded as a worker so the steward is told when it finishes, and
+ * bound to the need so `bb stewards secret import` accepts only it.
+ */
+ async function spawnRequester(b: Binding, need: Need): Promise {
+ const config = await loadConfig(b.projectId);
+ const playbook = config === null ? null : bindingPlaybook(config, b);
+ const model = playbook === null ? parseModel(b.modelWorker) : workerModel(b, playbook);
+ const writeEnv = await requesterWriteEnv(need);
+ const variable = secretVariable(need);
+ const title = `Provide ${variable} for ${b.entityKey}`;
+ const sectionId = await projectSection(b.projectId);
+ const thread = await bb.sdk.threads.spawn({
+ projectId: b.projectId,
+ environment: freshEnvironment(await projectHost(b.projectId)),
+ prompt: requesterPrompt(b, need, writeEnv),
+ title,
+ ...modelArgs(model),
+ ...(sectionId === null ? {} : { sectionId }),
+ pluginMetadata: { role: "requester", bindingId: b.id, needId: need.id },
+ });
+ store.setSecretRequester(thread.id, need.id);
+ store.addWorker(thread.id, b.id, title);
+ bb.log.info(`stewards: started a requester thread for ${b.entityKey}'s ${variable} (${thread.id})`);
+ return thread.id;
+ }
+
+ /** Close the provide-secret need a requester was spawned for, once it has finished. */
+ function closeRequesterNeed(threadId: string): void {
+ const requester = store.secretRequester(threadId);
+ if (requester === null) return;
+ const need = store.need(requester.needId);
+ if (need === null || need.status !== "open") return;
+ store.closeNeed(need.id, "The requester thread finished; the secret was provided through bb's secure form.");
+ }
+
// ---- the reconcile loop ------------------------------------------------------------------
/**
@@ -2426,6 +2591,7 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
if (worker !== null) {
if (worker.status === "stopped") return;
store.setWorker(thread.id, "finished", lastAssistantText === null ? null : clip(lastAssistantText, 4000));
+ closeRequesterNeed(thread.id);
const b = store.binding(worker.bindingId);
if (b === null || b.endedAt !== null) return;
store.note(b.id, `Worker "${worker.title}" finished its turn.`);
@@ -2645,6 +2811,7 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
const worker = store.worker(thread.id);
if (worker === null || !workerInFlight(worker)) return;
store.setWorker(thread.id, "failed", error);
+ closeRequesterNeed(thread.id);
store.note(worker.bindingId, `Worker "${worker.title}" failed: ${error ?? "no detail"}`);
scheduleReconcile(worker.bindingId);
});
@@ -3032,12 +3199,31 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
if (need.kind === "provide-secret") {
if (action !== "provide" && action !== "done") return { ok: false, message: "Provide the secret, or mark it done." };
- const threadId = typeof need.data.workerThreadId === "string" ? need.data.workerThreadId : null;
- const named = typeof need.data.variable === "string" ? need.data.variable : need.what;
- store.closeNeedByKey(b.id, "provide-secret", need.url, text === null ? "Provided on the Stewards page." : `Provided on the Stewards page: ${text}`);
- if (threadId === null) after(`The user pressed Provide for ${named} on the Stewards page; start the worker that will request it, and do not ask them again.`);
- else after(`The user provided ${named}${text === null ? "" : `: ${text}`}.`);
- return { ok: true, message: `Recorded; ${b.entityKey}'s steward has been told.`, threadId };
+ const named = typeof need.data.variable === "string" && need.data.variable.trim() !== "" ? need.data.variable.trim() : need.what;
+ // Done is the manual escape hatch: the value was entered another way.
+ if (action === "done") {
+ store.closeNeedByKey(b.id, "provide-secret", need.url, text === null ? "Marked done on the Stewards page." : `Marked done on the Stewards page: ${text}`);
+ after(`The user marked ${named} done on the Stewards page${text === null ? "" : `: ${text}`}; the value was entered another way.`);
+ return { ok: true, message: `Recorded; ${b.entityKey}'s steward has been told.`, threadId: null };
+ }
+ // Provide opens bb's secure form in a requester thread the plugin
+ // spawns, so the user never has to prompt one. The need stays open
+ // until the requester finishes, so `bb stewards secret import`
+ // (case B) is accepted while it runs.
+ const existing = store.secretRequesterForNeed(need.id);
+ if (existing !== null) {
+ const info = await threadInfo(existing.threadId).catch(() => null);
+ if (info !== null && info.deletedAt === null) return { ok: true, message: `The form is already open for ${named}.`, threadId: existing.threadId };
+ store.clearSecretRequester(existing.threadId);
+ }
+ let requesterId: string;
+ try {
+ requesterId = await spawnRequester(b, need);
+ } catch (error) {
+ return { ok: false, message: `Could not start the requester thread: ${errorMessage(error)}` };
+ }
+ store.note(b.id, `Started a requester thread for ${named}; the user is entering it there.`);
+ return { ok: true, message: `Opening the secure form for ${named} in a new thread.`, threadId: requesterId };
}
if (need.kind === "decide" && action === "choose") {
@@ -3236,6 +3422,8 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
variable: z.string().trim().max(200).optional().describe("provide-secret: the variable name."),
purpose: z.string().trim().max(500).optional().describe("provide-secret: what the value is for."),
worker: z.string().trim().max(200).optional().describe("provide-secret: the worker thread that will request it; its link is used when url is left out."),
+ writeEnv: z.string().trim().max(500).optional().describe("provide-secret: the dotenv path the requester writes (case A); defaults to the named worker's thread storage."),
+ setting: z.string().trim().max(200).optional().describe("provide-secret: the stewards plugin secret setting the value goes to (case B); only a declared secret setting is accepted."),
page: z.string().trim().max(500).optional().describe("configure: the external page where the step happens."),
choices: choicesSchema.optional().describe('decide only: 2-6 short labels the user picks between (["Merge", "Close", "Verify first"]); the page shows one button each, so do not write "reply with your choice" in prose.'),
}),
@@ -3393,6 +3581,16 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
refused.push(`${n.kind} for ${n.url ?? "the item"} not filed: choices are for a decide item.`);
continue;
}
+ if (n.setting !== undefined) {
+ if (n.kind !== "provide-secret") {
+ refused.push(`${n.kind} for ${n.url ?? "the item"} not filed: setting is for a provide-secret item.`);
+ continue;
+ }
+ if (!SECRET_SETTING_NAMES.has(n.setting)) {
+ refused.push(`provide-secret for ${n.variable ?? n.what} not filed: ${JSON.stringify(n.setting)} is not a secret setting of the stewards plugin (secret settings: ${[...SECRET_SETTING_NAMES].join(", ") || "none"}).`);
+ continue;
+ }
+ }
store.fileNeed({
bindingId: b.id,
kind: n.kind,
@@ -3403,6 +3601,8 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
...(n.variable === undefined ? {} : { variable: n.variable }),
...(n.purpose === undefined ? {} : { purpose: n.purpose }),
...(n.worker === undefined ? {} : { workerThreadId: n.worker }),
+ ...(n.writeEnv === undefined ? {} : { writeEnv: n.writeEnv }),
+ ...(n.setting === undefined ? {} : { setting: n.setting }),
...(n.page === undefined ? {} : { page: n.page }),
...(n.choices === undefined ? {} : { choices: n.choices }),
},
@@ -3738,7 +3938,7 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
});
/** One open "needs you" item, with whether its button can act now and why not when it cannot. */
- function needView(n: Need, b: Binding): { id: string; bindingId: string; key: string; kind: string; url: string | null; escalationId: string | null; choices: string[]; what: string; how: string | null; threadId: string | null; createdAt: number; actionable: boolean; why: string | null } {
+ function needView(n: Need, b: Binding): { id: string; bindingId: string; key: string; kind: string; url: string | null; escalationId: string | null; choices: string[]; what: string; how: string | null; destination: string | null; threadId: string | null; createdAt: number; actionable: boolean; why: string | null } {
let actionable = true;
let why: string | null = null;
let threadId: string | null = null;
@@ -3755,11 +3955,11 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
why = actionable ? null : working ? "a worker is still running" : (gate?.missing ?? "the pull request has not been observed yet");
}
} else if (n.kind === "provide-secret") {
- // Always actionable: with a worker named, the page opens it; without,
- // the action tells the steward to start the worker that requests it.
- threadId = typeof n.data.workerThreadId === "string" ? n.data.workerThreadId : null;
+ // Always actionable: the page opens a requester thread and the form
+ // appears in its first turn. Link the thread once one has been spawned.
+ threadId = store.secretRequesterForNeed(n.id)?.threadId ?? null;
}
- return { id: n.id, bindingId: b.id, key: b.entityKey, kind: n.kind, url: /^https?:\/\//iu.test(n.url) ? n.url : null, escalationId: typeof n.data.escalationId === "string" ? n.data.escalationId : null, choices: needChoices(n), what: n.what, how: n.how, threadId, createdAt: n.createdAt, actionable, why };
+ return { id: n.id, bindingId: b.id, key: b.entityKey, kind: n.kind, url: /^https?:\/\//iu.test(n.url) ? n.url : null, escalationId: typeof n.data.escalationId === "string" ? n.data.escalationId : null, choices: needChoices(n), what: n.what, how: n.how, destination: n.kind === "provide-secret" ? secretDestination(n) : null, threadId, createdAt: n.createdAt, actionable, why };
}
function formatBindings(rows: Binding[]): string {
@@ -4257,6 +4457,54 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
return { exitCode: 0, stdout: row.digest === null ? "No digest yet." : `${iso(row.digestAt ?? 0)}\n\n${row.digest}` };
},
}),
+
+ // Case B of a provide-secret need: a stewards secret setting cannot
+ // be reached by `bb secret request` (which writes a dotenv on the
+ // worker's machine), so the requester thread the plugin spawned
+ // reads that dotenv here and writes the setting. Only that thread,
+ // only while its need is open, and only for the need's own setting.
+ "secret import": cliCommand({
+ summary: "Write a secret from a dotenv into a declared secret setting (requester threads only)",
+ description:
+ "Only the requester thread the plugin spawned for an open provide-secret need may run this, and only for that need's own setting. The dotenv is read through bb.sdk.files on the invoking thread's host, the value is written with the plugin's settings, and the file is deleted. The value never appears in argv, logs, messages or output.",
+ options: {
+ from: { type: "string", required: true, description: "The dotenv file to read, on the invoking thread's host." },
+ setting: { type: "string", required: true, description: "The declared secret setting to write." },
+ },
+ async run(input, ctx) {
+ const from = input.options.from;
+ const setting = input.options.setting;
+ if (ctx.threadId === undefined) throw new PluginCliError("bb stewards secret import must run from a bb thread.", { code: "missing_thread" });
+ const requester = store.secretRequester(ctx.threadId);
+ if (requester === null) throw new PluginCliError("This thread is not a provide-secret requester thread.", { code: "not_requester", hint: "Press Provide on the Stewards page to open one." });
+ const need = store.need(requester.needId);
+ if (need === null || need.kind !== "provide-secret" || need.status !== "open") throw new PluginCliError("That provide-secret item is closed.", { code: "need_closed" });
+ const expected = typeof need.data.setting === "string" && need.data.setting.trim() !== "" ? need.data.setting.trim() : null;
+ if (expected !== setting) throw new PluginCliError(`This item's secret goes to ${JSON.stringify(expected ?? "no setting")}, not ${JSON.stringify(setting)}.`, { code: "wrong_setting" });
+ if (!SECRET_SETTING_NAMES.has(setting)) throw new PluginCliError(`${JSON.stringify(setting)} is not a secret setting of the stewards plugin.`, { code: "not_secret_setting", hint: `Secret settings: ${[...SECRET_SETTING_NAMES].join(", ") || "none"}.` });
+ const variable = secretVariable(need);
+ const info = await threadInfo(ctx.threadId);
+ const hostId = info?.environmentHostId ?? null;
+ if (hostId === null) throw new PluginCliError("The requester thread has no machine to read the file from.", { code: "no_host" });
+ let content: string;
+ try {
+ const result = await bb.sdk.files.read({ hostId, path: from });
+ if (result.contentEncoding !== "utf8") throw new Error("the file is not UTF-8 text");
+ content = result.content;
+ } catch (error) {
+ throw new PluginCliError(`Could not read ${from} on the thread's machine: ${errorMessage(error)}`, { code: "read_failed" });
+ }
+ const value = parseDotenvValue(content, variable);
+ if (value === null || value === "") throw new PluginCliError(`${variable} is not set in ${from}.`, { code: "missing_value" });
+ try {
+ await settings.experimental_set({ [setting]: value } as unknown as Parameters[0]);
+ } catch {
+ throw new PluginCliError(`Could not write the ${setting} setting; the value was not saved.`, { code: "write_failed" });
+ }
+ await bb.sdk.files.remove({ hostId, path: from }).catch(() => undefined);
+ return { exitCode: 0, stdout: `Imported ${setting}; the dotenv is gone.` };
+ },
+ }),
},
}),
);
@@ -4266,12 +4514,12 @@ export function createStewardsPlugin(deps: StewardsDeps): (bb: BbPluginApi) => P
tagged.clear();
kept.clear();
};
- testHooks.set(bb.pluginId, { sweep, store, db, forgetTags, nightlyPass: (projectId: string, night: string) => loadConfig(projectId, true).then((c) => (c === null ? undefined : nightlyPass(c, night, true))), settle: () => Promise.all([...chains.values()]).then(() => undefined), sentryDoorbell: onSentryDoorbell, sentryLeases });
+ testHooks.set(bb.pluginId, { sweep, store, db, settings, forgetTags, nightlyPass: (projectId: string, night: string) => loadConfig(projectId, true).then((c) => (c === null ? undefined : nightlyPass(c, night, true))), settle: () => Promise.all([...chains.values()]).then(() => undefined), sentryDoorbell: onSentryDoorbell, sentryLeases });
};
}
/** Test seams, keyed by plugin id. Not part of any contract. */
-export const testHooks = new Map; store: Store; db: { prepare(sql: string): { run(...args: unknown[]): unknown } }; forgetTags(): void; nightlyPass(projectId: string, night: string): Promise; settle(): Promise; sentryDoorbell(id: string, unit: string | null): void; sentryLeases(): Lease[] }>();
+export const testHooks = new Map; store: Store; db: { prepare(sql: string): { run(...args: unknown[]): unknown } }; settings: { get(): Promise> }; forgetTags(): void; nightlyPass(projectId: string, night: string): Promise; settle(): Promise; sentryDoorbell(id: string, unit: string | null): void; sentryLeases(): Lease[] }>();
export { DEFAULT_PLAYBOOKS, STEWARDS_PLUGIN_ID };
diff --git a/plugins/stewards/skills/stewards/SKILL.md b/plugins/stewards/skills/stewards/SKILL.md
index ec38522d..e0a73845 100644
--- a/plugins/stewards/skills/stewards/SKILL.md
+++ b/plugins/stewards/skills/stewards/SKILL.md
@@ -37,7 +37,10 @@ Two tools are yours; everything else you do with the tools every thread has.
button, deduplicated by (binding, kind, url). A `decide` item that is a
pick between fixed options carries `choices` — two to six short labels,
such as `choices: ["Merge", "Close", "Verify first"]` — and the page
- shows a button each; never write "reply with your choice" in prose.
+ shows a button each; never write "reply with your choice" in prose. A
+ `provide-secret` item carries the `variable` and `purpose`, and either
+ the `writeEnv` dotenv path (or `worker` thread) or the `setting` of one
+ of the stewards plugin's own `secret: true` settings.
- **Decide what the project's guidance settles.** AGENTS.md, architecture
and design docs, and the playbook are your guidance. Escalate only what
they do not settle, with `steward_report { escalate: { kind, question,
@@ -52,12 +55,15 @@ Two tools are yours; everything else you do with the tools every thread has.
ask them. An escalation or approval request that is already open is on the
Stewards page: do not ask for it again, and a reply that does counts like a
missed report toward `stuck`.
-- **A credential is a worker's, through `bb secret request`.** When the work
- needs a secret, the worker obtains it with `bb secret request` (the
- `secrets` skill): never paste one into a thread, and never route the user
- to a script to run. You file the user-facing item for it — a
- `provide-secret` need with the variable name and purpose — and the worker
- takes the value.
+- **A credential is a `provide-secret` need, not a code-writing worker's
+ job to prompt.** File the user-facing item with
+ `steward_report { needs: [{ kind: "provide-secret", url, what, how,
+ variable, purpose }] }`; the plugin spawns a requester thread and opens
+ bb's secure form in its first turn. For a dotenv on a worker's machine
+ name the `writeEnv` path (or the `worker`); for one of the stewards
+ plugin's own settings name `setting` — only a declared `secret: true`
+ setting is accepted. Never paste a secret, and never route the user to a
+ script to run.
- **A build-time blocker is a `decision` the same turn.** A worker's finding
that would stop the feature working once it ships, or that changes what the
ticket needs (a credential, an access, a contract), is escalated as a
@@ -279,6 +285,7 @@ project.
| `bb stewards needs [--all] [--json]` | What waits on the user, with links and the action each supports |
| `bb stewards done [--choice