Model keys stay with osfd: a per-run gate, so a run's server holds no key #492

Closed
opened 2026-11-11 17:44:38 -05:00 by cmoriarty · 1 comment
Owner

What happens
A run's opencode serve reads its model key from a file its configuration names. The run fence (braid#203) lets the server read that one file, as it must, so the server's own process still holds a key. Nothing a step executes can reach it: sandboxes do not hold the file.

Fix
The design from the first draft of braid#203: providers point at a per-run gate in osfd, which adds the key and streams the answer back. The configuration then names no key file, and the fence's read list is empty.

Done when
No rendered opencode.json holds a {file: reference, a sim's fake model records its requests arriving through the gate, and the fence allows no key file.

Split from braid#203 by the owner's decision, 2026-11-11.

**What happens** A run's `opencode serve` reads its model key from a file its configuration names. The run fence (braid#203) lets the server read that one file, as it must, so the server's own process still holds a key. Nothing a step executes can reach it: sandboxes do not hold the file. **Fix** The design from the first draft of braid#203: providers point at a per-run gate in osfd, which adds the key and streams the answer back. The configuration then names no key file, and the fence's read list is empty. **Done when** No rendered `opencode.json` holds a `{file:` reference, a sim's fake model records its requests arriving through the gate, and the fence allows no key file. _Split from braid#203 by the owner's decision, 2026-11-11._
Author
Owner

Shipped in pull request 566 (change model-key-gate-492).

Every provider of a run's opencode.json (the backend, planning, Repair's, a Free run's router) now names /gate/<run>/<provider> on osfd and a token minted for the run. The gate checks the token, forwards to the provider with its key and an x-braid-gate mark, and streams the answer back. A request the server drops mid-answer closes the provider's request too. The look tool goes through the gate. The forgejo MCP server is refused with sandboxes on, since it would hand the forge token into a sandbox.

Done when, as asked: no rendered opencode.json holds a {file: reference (a test renders every kind, with planning, Repair and Free). Every simulated run now fails unless every request its fake model recorded carries the gate's mark: 7 of 7 on a laptop, 6 of 6 in the image. The fence's read list is empty, read from a configuration that names no file.

On production since 19a75bd: the gate answers 401 to a request without its run's token, and the deploy's self-check passed its 6 simulated runs, each now checking the gate's mark. Archived in pull request 568.

Shipped in pull request 566 (change `model-key-gate-492`). Every provider of a run's `opencode.json` (the backend, planning, Repair's, a Free run's router) now names `/gate/<run>/<provider>` on osfd and a token minted for the run. The gate checks the token, forwards to the provider with its key and an `x-braid-gate` mark, and streams the answer back. A request the server drops mid-answer closes the provider's request too. The `look` tool goes through the gate. The forgejo MCP server is refused with sandboxes on, since it would hand the forge token into a sandbox. **Done when, as asked:** no rendered `opencode.json` holds a `{file:` reference (a test renders every kind, with planning, Repair and Free). Every simulated run now fails unless every request its fake model recorded carries the gate's mark: 7 of 7 on a laptop, 6 of 6 in the image. The fence's read list is empty, read from a configuration that names no file. On production since 19a75bd: the gate answers 401 to a request without its run's token, and the deploy's self-check passed its 6 simulated runs, each now checking the gate's mark. Archived in pull request 568.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#492
No description provided.