A fence for each run and a sandbox for each step; Midway, the standard test run (#203, #489) #490

Merged
cmoriarty merged 15 commits from step-sandboxes into main 2026-11-11 17:38:00 -05:00
Owner

Two changes, one after the other on this branch: agents-reach-only-their-run (braid#203) and standard-test-run (braid#489).

A fence for each run, a sandbox for each step (braid#203)

  • Run fence (Landlock). A run's opencode serve starts through a launcher that lets it open the run's folder, the image and its own key files, and nothing else, and signal only its own processes. This covers the file tools, which run inside the server.
  • Step sandbox (namespaces, bubblewrap). osfd makes one for each worktree in use: the run's when its server starts, a group's when the group starts. Inside: its own process list, its own localhost, its own /tmp, its worktree and the run's shared folders at the paths they have outside, the image read-only. Not inside: other worktrees, other runs, osf.db, keys, the token.
  • How commands get there. The server's SHELL is a client that hands each command, with its directory, environment and output, to a spawner inside the sandbox. The Playwright server, the app tool, installs, lanes, apply's suites, services and a project's own scripted steps go the same way.
  • Network. pasta gives a sandbox the internet with no proxy. nftables rules refuse loopback, link-local, the private ranges and the container's own addresses, except entries of OSF_EGRESS_ALLOW. The guard refuses a webfetch to the same addresses.
  • Fails closed. OSF_SANDBOX=step is the image's mode. osfd probes both layers at start; if the probe fails no run starts, and /api/status and doctor say why.
  • Deploy. osfd only: a seccomp profile (Docker's default plus one rule), systempaths=unconfined, no-new-privileges, /dev/net/tun. The image gains bubblewrap, passt, nftables. The deploy job's self-check runs under the same options.

Left for follow-up issues, by the owner's decision: model keys behind a gate, the forge token's split with osfd's git inside the sandbox, a console setting for the allowlist.

Midway, the standard test run (braid#489)

  • docs/test-briefs/midway.md: one project of eight parts that do not depend on each other, one for each kind of software Braid is judged on.
  • tools/standard-run.sh <server> <n> starts it with the standard settings.
  • docs/testing.md: the three briefs, and the rows recorded for each standard run.

Evidence

  • ./tools/test.sh on the laptop: backend 776 passed and 2 skipped (the two tests that need Linux), 52 browser tests, 47 s in all.
  • This branch's image, built on the production host and self-checked there with OSF_SANDBOX=step under the stack's own options: the fence line and the five sandbox lines ok, and the six simulated runs pass with a real opencode serve under the fence, agent-leaves-its-step among them.
  • Portainer reads the profile by the compose file's path: a throwaway stack from this branch came up with the profile's contents as its seccomp option, and was removed.
  • Measurements, and four things learned about bubblewrap, pasta and Landlock, are in the change's design.md.

🤖 Generated with Claude Code

Two changes, one after the other on this branch: `agents-reach-only-their-run` (braid#203) and `standard-test-run` (braid#489). ## A fence for each run, a sandbox for each step (braid#203) - **Run fence (Landlock).** A run's `opencode serve` starts through a launcher that lets it open the run's folder, the image and its own key files, and nothing else, and signal only its own processes. This covers the file tools, which run inside the server. - **Step sandbox (namespaces, bubblewrap).** osfd makes one for each worktree in use: the run's when its server starts, a group's when the group starts. Inside: its own process list, its own `localhost`, its own `/tmp`, its worktree and the run's shared folders at the paths they have outside, the image read-only. Not inside: other worktrees, other runs, `osf.db`, keys, the token. - **How commands get there.** The server's `SHELL` is a client that hands each command, with its directory, environment and output, to a spawner inside the sandbox. The Playwright server, the `app` tool, installs, lanes, apply's suites, services and a project's own scripted steps go the same way. - **Network.** `pasta` gives a sandbox the internet with no proxy. `nftables` rules refuse loopback, link-local, the private ranges and the container's own addresses, except entries of `OSF_EGRESS_ALLOW`. The guard refuses a `webfetch` to the same addresses. - **Fails closed.** `OSF_SANDBOX=step` is the image's mode. osfd probes both layers at start; if the probe fails no run starts, and `/api/status` and doctor say why. - **Deploy.** `osfd` only: a seccomp profile (Docker's default plus one rule), `systempaths=unconfined`, `no-new-privileges`, `/dev/net/tun`. The image gains `bubblewrap`, `passt`, `nftables`. The deploy job's self-check runs under the same options. Left for follow-up issues, by the owner's decision: model keys behind a gate, the forge token's split with osfd's git inside the sandbox, a console setting for the allowlist. ## Midway, the standard test run (braid#489) - `docs/test-briefs/midway.md`: one project of eight parts that do not depend on each other, one for each kind of software Braid is judged on. - `tools/standard-run.sh <server> <n>` starts it with the standard settings. - `docs/testing.md`: the three briefs, and the rows recorded for each standard run. ## Evidence - `./tools/test.sh` on the laptop: backend 776 passed and 2 skipped (the two tests that need Linux), 52 browser tests, 47 s in all. - This branch's image, built on the production host and self-checked there with `OSF_SANDBOX=step` under the stack's own options: the fence line and the five sandbox lines `ok`, and the six simulated runs pass with a real `opencode serve` under the fence, `agent-leaves-its-step` among them. - Portainer reads the profile by the compose file's path: a throwaway stack from this branch came up with the profile's contents as its seccomp option, and was removed. - Measurements, and four things learned about bubblewrap, `pasta` and Landlock, are in the change's `design.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Measured in a Linux container with bubblewrap 0.12, pasta and nftables: a sandbox comes up in
about 30 ms, holds only its worktree and the run's shared folders, reaches the internet, is
refused the container's addresses, loopback and private ranges, and two serve on one port.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A run's server gets SHELL and the browser server's command pointing at the client; groups get a
sandbox with their worktree; Braid's own steps hand project commands over; the app tool starts
and probes its app inside. A scenario for an agent that tries to leave its step, and a
scenario's needs: sandbox with a reported skip.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
One project of eight parts that do not depend on each other, one for each kind of software Braid
is judged on; the standard settings in tools/standard-run.sh; the record each run leaves.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
feat(sandbox): an agent step makes sure of its worktree's sandbox before its first command (#203)
All checks were successful
test / suite (pull_request) Successful in 1m13s
7918b3fc35
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
docs(openspec): keep the changed requirements within the main specs' 500 characters (#203)
All checks were successful
test / suite (pull_request) Successful in 1m10s
9d9f3a278d
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
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!490
No description provided.