Skip to content

stewards: Provide spawns a fixed-prompt requester that opens bb's secure form (BB-22) - #50

Merged
trotterdylan merged 3 commits into
mainfrom
bb/bb-22-provide-secret-form
Oct 20, 2026
Merged

trotterdylan merged 3 commits into
mainfrom
bb/bb-22-provide-secret-form

Conversation

@trotterdylan

@trotterdylan trotterdylan commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Implements BB-22. Provide on a provide-secret item now spawns a fixed-prompt requester thread (same provider/model/machine the binding's workers use), navigates the user to it, and bb's secure form appears in its first turn. Case A writes a worker dotenv; case B imports into a stewards secret setting through the new bb stewards secret import, which only the spawned requester may run, only while its need is open, and only for that need's own setting. The need closes when the requester finishes and the steward is told. setting is validated against the plugin's declared secret: true settings, and the wake, skill and page say where the value goes.

Merging this rebuilds the bb-server image and stages a restart for every developer's server (AGENTS.md, "Shipping a plugin change"). Do not press Restart now from a thread you still need.

Classification

owner-reviewed: it changes what Provide does for an existing item, and adds a secret-handling CLI command.

What changes

  • Provide spawns the requester. The server spawns a requester thread on the project's machine with the binding's worker model, returns its id (the page navigates to it), and leaves the need open until the requester finishes; the requester is recorded as a worker so its idle/failed turn closes the need and wakes the steward. A second Provide reuses the live requester; an archived or deleted one is dropped and respawned.
  • New need fields. steward_report { needs } gains writeEnv (case A dotenv path; defaults to the named worker's thread storage) and setting (case B stewards secret setting, validated against the declared secret: true settings). A provide-secret need must name a variable or a setting; the env var is derived from the setting name when variable is omitted. A named worker on another host than the requester falls back to the requester's own storage.
  • New bb stewards secret import --from <dotenv> --setting <name>. It reads the file through bb.sdk.files on the invoking thread's host, writes the value with settings.experimental_set, and deletes the file. The value never appears in argv, logs, messages or output.
  • Security limit. A new secret_requesters table binds the requester's thread id to its need. The command refuses any other thread, any other setting, a setting that is not secret: true, a file that is not on the invoking thread's host, and any import once the need has closed.
  • Page. The item text names the destination, the button reads Provide, the row says the form opens in a thread, and Done remains the manual escape hatch.
  • Wording. The wake's standing rules, the stewards skill, the default playbook and DESIGN.md describe setting/writeEnv and stop pointing items at code-writing workers.

Testing

  • npm run typecheck and npm test in plugins/stewards: pass (305 tests). The stewards suite is in the plugins CI matrix and ran green on this PR.
  • New tests cover: the spawn with the expected prompt/model/machine and the need closing when the requester reports; a need without worker; steward_report validation of setting and of a need that names neither variable nor setting; case B import setting the value, deleting the file and leaking nothing into messages, results or the store; refusal of an unrelated thread, the wrong setting, a non-secret setting, a file on another host, and an import after the need closed; a requester archived mid-form being respawned; the cross-host storage fallback; and the dotenv parser (quotes, export, trailing comments).
  • Not tested live: experimental_set with a secret field on a running server, and the requester running bb there. Confirmed from the server source that experimental_set persists secret descriptors to a 0600 file, and the requester runs on the same host as workers, which already run bb thread spawn and gh.

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Independent review running in bb thread @thread:thr_9rxzed53gj.

— from bb thread thr_9uhbkvxye2

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 1 (GLM 5.3, at f6865c7)

Owner review required: yes — it changes what the existing Provide button on a provide-secret item does (it used to open the named worker / wake the steward; it now spawns a requester thread), and it adds a new secret-handling CLI surface (bb stewards secret import writes a plugin secret setting). @trotterdylan, this one needs your approval.

Blockers

None.

Suggestions

  • server.ts (thread.archived / thread.deleted / stopWorkers) — a requester that is archived, deleted or stopped mid-form leaves its need open, and the thread.archived/thread.deleted/stopWorkers paths set the worker to stopped without closing or clearing the requester binding. For a deleted requester the next Provide respawns (good), but for an archived one deletedAt === null, so Provide answers "The form is already open" and navigates to an archived thread where no form is waiting. Consider closing the need (or clearing the binding so Provide respawns) when the requester's worker goes stopped, or treating archivedAt !== null like deleted in the Provide path.
  • requesterWriteEnv (case A with a named worker) — the requester writes the dotenv at the worker's storageRootPath, an absolute path on the requester's own machine. If the worker runs on a different host than the project machine the value lands on the wrong machine, and the write to another thread's storage directory may be refused by the secrets plugin's path rules (the PR body flags this as not tested live). Consider comparing the worker's storageLocation().hostId with the requester's host and falling back to the requester's own storage (the worker then needs to be told where to read it), or at least noting the assumption in DESIGN.md.
  • secretVariable fallback — when a need has neither variable nor setting, the variable becomes need.what verbatim, which can contain spaces and produces bb secret request "Sentry token" .... Consider requiring one of the two in steward_report for provide-secret, or sanitising the fallback.
  • Identity is an env var — ctx.threadId for a plugin CLI command is the BB_THREAD_ID the client posts (verified in the bb 0.46 CLI bundle), so the "only the requester thread" limit holds for threads that report themselves honestly; any shell could spoof the env var. This matches how the plugin already trusts ctx.threadId (bb stewards init writes on "the thread's" machine) and the ticket prescribes exactly this binding, so it is not a blocker — but the residual assumption (the limit also confines the write to the need's own declared secret setting, and the value is not readable back through the plugin) is worth a line in DESIGN.md so the owner approves it knowingly.
  • PR body — it says the stewards suite is "not in the CI matrix", but quality_checks (stewards) is in the plugins workflow matrix and ran green on this PR. Worth correcting in the body.

Checked

  • Ran: npm run typecheck and npm test in plugins/stewards at f6865c7 — typecheck clean, 290/290 tests pass. The stewards suite is in the CI matrix, so nothing the diff touches was skipped by CI; I ran it anyway.
  • Verified against ticket:
    • Provide spawns a requester with the fixed prompt (model/machine from the binding's worker spec), the page navigates to it (app.tsx line 554), and the need closes when the requester finishes — met, covered in server.test.ts.
    • Case B: import sets the setting, deletes the dotenv, and the value appears in no message, result, store row, stdout/stderr or argv; non-secret setting names, files on another host, and imports after the need closed are all refused — met, covered.
    • setting validated against declared secret: true settings at steward_report time; wake standing rules, the stewards skill, DESIGN.md and the default playbook all describe setting/writeEnv — met.
    • Needs without worker still spawn a requester (own storage default) — met.
    • Required security limit: secret_requesters binds requester threadId → need; tests cover unrelated thread, right thread + wrong setting, non-secret setting, other-host file, and import after close — met.
  • Store: the migration is append-only (CREATE TABLE IF NOT EXISTS secret_requesters), state survives the server restart that shipping this triggers.
  • Contracts: source-contract.ts and its copies are untouched; no cross-repo surface changes.

— from bb thread thr_9rxzed53gj

…et-form

# Conflicts:
#	plugins/stewards/server.test.ts
#	plugins/stewards/server.ts
#	plugins/stewards/store.ts
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Round 1 addressed at 9e64c17 (also merged main, which brought BB-3 in). Thanks — all five suggestions taken or noted:

  • Archived/deleted/stopped requester. Fixed. stewardsNeedAction now treats an archived requester like a deleted one (drops the binding and spawns a fresh thread), and thread.archived clears the requester binding so a later Provide respawns. New test: "respawns the requester when the first one was archived".
  • requesterWriteEnv cross-host. Fixed. spawnRequester resolves the requester's host once and requesterWriteEnv only uses the worker's storage when storageLocation().hostId matches it; otherwise it falls back to the requester's own $BB_THREAD_STORAGE and logs the mismatch. New test: "falls back to the requester's own storage when the named worker is on another machine".
  • secretVariable fallback. Fixed at the source: steward_report now refuses a provide-secret need that names neither variable nor setting, and secretVariable still derives the env var from the setting name (sentryToken → SENTRY_TOKEN). Test extended.
  • Identity is an env var. Accepted as a documented residual, not a blocker. Added a DESIGN.md bullet stating the ctx.threadId assumption and that the import is additionally confined to a plugin-declared secret: true setting and its value is never readable back through the plugin.
  • PR body. Corrected: the stewards suite is in the plugins CI matrix and ran green; the body now says so.

Re-ran npm run typecheck and npm test in plugins/stewards at 9e64c17: clean, 305/305.

— from bb thread thr_9uhbkvxye2

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Review round 2 (GLM 5.3, at 9e64c17)

Owner review required: yes — same trigger as round 1 (changes what the existing Provide button does for a provide-secret item, and adds the bb stewards secret import secret-writing command). @trotterdylan, this one needs your approval; the round-1 verdict stands for the suggested fixes and the merge of main, so this marker repeats it on the new head.

Blockers

None.

Resolved since round 1

  • Archived requester pointed at a dead form: resolved — thread.archived now clears the requester binding, and Provide treats archivedAt !== null like deleted, so it respawns; covered by the new "respawns the requester when the first one was archived" test.
  • Cross-host worker storage path: resolved — requesterWriteEnv compares the worker's storageLocation().hostId with the requester's machine and falls back to the requester's own storage (with a warn); covered by the new other-host test.
  • secretVariable falling back to need.what: resolved — steward_report now refuses a provide-secret need that names neither variable nor setting; covered by test.
  • ctx.threadId env-var assumption: resolved — documented in DESIGN.md §needs ("the limit rests on ctx.threadId … a shell could spoof it, so the import is also confined to a setting the plugin itself declared secret: true").
  • PR body CI-matrix claim: resolved — now says the stewards suite is in the matrix and ran green.

Checked

  • The merge of main (BB-3 lessons, stewards: record general judgements as lessons and land them in .bb (BB-3) #49) conflicted in server.ts, server.test.ts and store.ts; the resolution keeps both features side by side (the combined diff against each parent is exactly the other feature's changes) and nothing of BB-22's was dropped.
  • Ran: npm run typecheck and npm test in plugins/stewards at 9e64c17 — typecheck clean, 305/305 pass (15 new tests since round 1: the three fix tests above plus BB-3's, which arrived via main). CI's quality_checks (stewards) is green on this head.
  • Acceptance criteria and the required security limit: all still met at this head, unchanged from round 1's findings.

— from bb thread thr_9rxzed53gj

@trotterdylan

Copy link
Copy Markdown
Collaborator Author

LGTM

@trotterdylan
trotterdylan merged commit 7cf9846 into main Oct 20, 2026
18 checks passed
@trotterdylan
trotterdylan deleted the bb/bb-22-provide-secret-form branch October 20, 2026 17:29
@trotterdylan

Copy link
Copy Markdown
Collaborator Author

Merged: owner-reviewed, approved by trotterdylan on 9e64c17 (comment LGTM, 2026-10-20T17:28:41Z); reviewer approved 9e64c17; checks green. No commits landed after the approval.

Merging moves the bb-plugins pin, rebuilds the bb-server image and stages a restart for every developer's server (AGENTS.md, "Shipping a plugin change"). Do not press Restart now from a thread you still need.

— from bb thread thr_9uhbkvxye2

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