Repository navigation
Description
Context
0.41.0 ordinary hosted workers expose a read-only brain and no persistent writable utility area. workerCommand mounts the brain read-only at packages/ui-sdk/src/server/worker-launcher.ts:135, creates per-turn scratch at :137 and mounts the host read-only at :132. Reported failures include .brain/scratch writes/prune, workspace clone/fetch, binary outputs and Chromium HOME/XDG caches. Redirecting caches to /tmp allowed a reported render, while persistent scratch still refused. These are reported Docker observations, not a fresh render receipt from triage.
Scope
Deliver the D1–D6 named writable utility areas, hardlink/alias guard, HOME overlay/XDG fallback, clear scratch-command errors and generated capability-note mechanism specified below. This is the strict-profile utility baseline and an input to #1649's later governed profile. It does not implement promotion, pinning or expired-link UI.
Out of scope
- Governed canonical-brain writes/profile (ui-sdk: run interactive and voice turns in a governed writable worker with read-only protected paths #1649), policy changes, journaling or widening autonomous access.
- Turn-temp link promotion (ui-server: at turn end, promote files the answer links in turn temp into persistent scratch and rewrite the links #1655), retained-conversation scratch pins (core: scratch prune never deletes a file that a retained conversation still links #1656), expired artifact presentation (ui-react: a link to a scratch file that no longer exists renders as expired, not a 404 #1657) and profile-specific note additions (backends: the sandbox-capabilities note states the three write areas, which one to link, and the turn's profile #1654). Their own prerequisites and design do not block this baseline mechanism.
- A validated scratch-to-canonical promotion tool: D7 explicitly stops it pending strict-profile work.
- A second memory or transcript persistence mechanism: backends: each Claude turn copies the brain's whole transcript history into a 64 MiB tmpfs #1621/backends: concurrent turns share one host /dev/shm, so a second parallel session fails with ENOSPC #1625 owns the parent-validated bounded memory path and runtime capacity. Accept their dynamic facts through the existing note generator when available; do not duplicate constants or claim unimplemented capacity guarantees.
- Operator deployment details, live providers, additional configuration seams or release publication.
Decision (maintainer, 2026-10-11): designed writable areas in the worker
The read-only brain stays for interactive and voice turns, with designed writable areas beside it:
- D1. Scratch.
<brain>/.brain/scratchis bound read-write into the worker as its own mount, created when missing. It must be a real directory inside the brain, never a symlink or redirect. Hard links into the rest of the brain fail across the mount, and the server never follows a symlink when it serves, previews or prunes scratch. The existing flow (brain render --scratch,brain image --scratch,brain scratch prune, a link for the reader) works unchanged. The per-turnBRAIN_WORKER_SCRATCHtmpfs stays as it is. - D2. Workspaces. The index-excluded workspace directory is bound read-write, only when it exists, and never the brain root, an ancestor of it or anything holding authoritative documents. Core has no workspace setting, only the always-excluded name
workspaces(DEFAULT_EXCLUDE,packages/core/src/lib/config.ts:475-488), so the name is fixed and the directory's existence is the opt-in. A brain-config key is rejected (an agent in a terminal could widen its own future mount); an operator-owned override is a possible later addition. - D3. Pre-existing hard links. Before each turn, each area is walked with
lstat, counting the names each file's inode has inside it. A file is offending only when its link count exceeds the names found inside, so links wholly within the area (local clones, package stores) are fine. An offending scratch name is unlinked; an offending workspace file, or a walk past the entry cap, leavesworkspaces/read-only for that turn, named in the agent's note and the server log. - D4. A writable
$HOMEfor the turn. A per-turnbwrap --tmp-overlayover$HOME: existing configuration still reads, writes are discarded at turn end. The probe verifies it on each turn; where the overlay is unavailable (bubblewrap before 0.11.0, setuid bubblewrap, or a kernel refusing overlayfs in a user namespace) the fallback isXDG_CONFIG_HOME,XDG_CACHE_HOMEandXDG_DATA_HOMEon per-turn directories under/tmp. Not for the restricted (autonomous) envelope, which is unchanged. - D5. Clear errors. An
EROFSon a known read-only path names the sandbox rule and the allowed alternative where the product can intercept it (thebrainCLI's scratch-capable commands and the agent's instructions). Arbitrary tools are not wrapped. - D6. The agent knows its limits up front. A note generated from the same resolved layout that builds the mounts is injected into every turn's agent context, for both backends, and is tested to match the mounts. It names three places: turn temp (
$BRAIN_WORKER_SCRATCH,/tmp,$HOMEwrites), deleted at turn end and never to be linked in a response; persistent scratch (.brain/scratch/, plusworkspaces/for clones), kept across turns and the only non-brain place to link, where anything linked in a response goes; and the brain, canonical. - D7. Promote from scratch (a validated server tool copying a scratch file to a named brain path) is stopped: it only matters for the strict profile below and waits for that work.
A separate "governed writable" epic will revise the default for interactive and voice turns (brain writable inside the worker, policy-protected paths read-only, per-turn journals with revert, auditing), with the 0.41 read-only brain as an opt-in strict profile. D1–D6 remain what the strict profile gets; the launcher takes the list of areas as an input so a profile can choose it. Memory persistence (the first comment's point 2) is owned by #1621/#1625. Release: 0.42.0.
Acceptance criteria for the decision
- D1/D2: from inside a real worker, files written in
.brain/scratch/and an existingworkspaces/persist on the host; write, create, mkdir, rename, hard-link and symlink-write attempts into the rest of the brain fail, observed from outside. A symlinked.brain,.brain/scratchorworkspacesis never created through or bound. The integrated proof (tests/policy-write-boundary.test.ts) attacks from inside both areas for both adapters. - D3: a hard link wholly inside
workspaces/keeps it writable; one to a file outside makes it read-only, named in the note and server log; a scratch alias of an outside file is unlinked. - D4: the overlay discards host-home writes while reads still work; without the overlay the XDG directories are writable and
$HOMEis read-only. The tests follow the host's bubblewrap version. - D5:
brain render --scratchandbrain scratch prunerun on a writable scratch mount;brain renderinto the read-only brain names--scratch; the file routes refuse a scratch symlink. - D6: the note matches the mounts for every layout tested, including the link rule.
- Each guard has a mutation receipt; selected hosted proof passes.
Verification and contract handoff — 2026-10-11
Source inspected at main 02d4eb0ce37f621764a80636e8ac95b9b4d19d3c. The current workerCommand still ro-binds the brain at packages/ui-sdk/src/server/worker-launcher.ts:135; DEFAULT_EXCLUDE really names workspaces at packages/core/src/lib/config.ts:475-488. The local installed bubblewrap 0.12.0 advertises --tmp-overlay; that help check is not a successful overlay/worker render proof. The older-version/setuid/kernel fallback requirements are supplied by D4 and still need the stated actual-host tests. Read the worker boundary record and preserve the real two-adapter integrated attacks, scratch route/prune alias checks and meaningful mutations. No fresh render or protected-write proof is claimed here.
The approved D1–D6 criteria are complete. Remove needs: design: artifact UI and broader profile/limits interactions now live in the named sibling tasks/epics, not this mechanism. Native parent #1644 is preserved after the maintainer's hierarchy update. Preserve p1 and the recorded 0.42.0 release target; do not assign a milestone or publish from triage. Both governed and strict will consume the named-mount/note mechanism, but this issue alone does not change the default brain profile. Internal layout/context changes need no new consumer schema by implication; assess actual public representations under the contract/version agreement if implementation changes them. Run required local preflight and selected hosted proof for the implementation.
Activity
schlessera commentedon Oct 11, 2026
Two more findings from hosted turns on 0.41.0.
1.
brain render --scratchfails in two layers$HOME, Chromium doesn't start:mkdir: cannot create directory '/root/.local/share/applications': Read-only file system(thenchrome_crashpad_handler: --database is required).HOME/XDG_CONFIG_HOME/XDG_CACHE_HOMEpointed at/tmp, Chromium renders the PDF, but saving it fails:EROFS: read-only file system, open '<brain>/.brain/scratch/.<name>-<timestamp>.pdf.<id>.tmp'.So the renderer itself works inside the sandbox. Only a writable
$HOMEand a writable, persistent scratch location are missing. Generating a PDF, image or other file for the user is currently impossible in a hosted turn.2. Agent memory written during a turn is silently discarded
The Claude runtime keeps its auto-memory under the project directory of the config dir (
projects/<project>/memory/*.md). That directory is copied into the worker state at turn start, so memory is readable. Butpersist()only writes back.jsonltranscripts (if (!file.endsWith(".jsonl")) continue;,packages/ui-backend-claude/src/worker-state.ts:79). Any memory file the agent creates or edits during a turn is dropped when the state dir is cleaned up.Reproduced: in one turn the agent wrote
memory/<name>.mdand appended a line tomemory/MEMORY.md, and both writes succeeded inside the worker. In every later session, neither the file nor the index line exists. Nothing reports the loss, so the agent believes it saved something.Expected: either persist the memory directory (with the same alias/size checks as transcripts), or keep it out of the writable state and tell the agent that memory is read-only in hosted turns. This may deserve its own issue; it sits on the same persist path as #1621 D1, so the design there should decide which non-transcript files under the project directory are carried back.
schlessera commentedon Oct 11, 2026
2026-10-11 triage: folded the later two-layer render failure and silently discarded auto-memory report into the active handoff. A bounded real-state fixture reproduced memory loss. Added explicit artifact/workspace authority and memory persistence/read-only choices; preserved the read-only brain, server-owned writes and autonomous isolation instead of selecting writable mounts by implication.
schlessera commentedon Oct 11, 2026
Coordination note: finding 2 above (agent memory written during a turn is discarded) is being fixed together with #1621/#1625, because it sits on the same copy/persist path in
packages/ui-backend-claude/src/worker-state.ts. That PR copies the project'smemory/folder into the worker state and persists changedmemory/*.mdnotes back with the same alias, byte-bound and concurrent-change checks as transcripts (a note another turn changed meanwhile is refused alone and named). Work on this issue does not need to touch the memory path; finding 1 (writable$HOMEand scratch forbrain render --scratch) stays here.schlessera commentedon Oct 11, 2026
Request for the generated sandbox-capabilities note in the turn's agent context (maintainer addition, 2026-10-11: the agent should know its limits rather than run into errors). The #1621/#1625 PR implements memory option M2 (parent-validated bounded persistence) per the maintainer's batch instruction. Please include these facts for interactive Claude turns in that note, or expose an input the #1621 PR can feed, rather than a second mechanism:
memory/*.mdfile directly in the project memory folder is saved after the turn. Subfolders and other file types are not saved, and nothing is deleted. A note another conversation changed during this turn is not overwritten; the turn reports it./dev/shm. A conversation whose history no longer fits refuses withsession_too_largeand is continued in a new conversation.Autonomous (restricted) turns keep no memory, settings or transcript, so none of this applies to them. I will rebase onto your mechanism if it lands first; if mine lands first, the constants live in
packages/ui-backend-claude/src/worker-state-budget.ts.schlessera commentedon Oct 11, 2026
2026-10-11 triage: Folded #1636’s approved governed/strict and utility-lifetime rulings into the active brief, and separated the coordinated memory fix. Replaced the settled authority decision with the precise remaining artifact/limits design need; native attachment to #1636 reflects the full deliverable.
41 remaining items
fix(ui-server): never follow a link under the agent-writable scratch …
test: attack from inside the writable areas in the integrated boundar…
docs: record the worker's writable areas and where a turn's outputs go
chore(ui-sdk): record the internal worker-sandbox exports in the API …
CONTRACT: fix(backends): give hosted workers persistent writable scra…
schlessera commentedon Oct 11, 2026
Outcome: merged in #1641 as squash
b8862b31ba7ab852e3c8ce1b81eed59e74ca7b3con main. Its parent is998810973c, and its tree equals the merge of that base with the tested head784b4d90. Release: 0.42.0..brain/scratch/is a writable bind, and an existingworkspaces/is too, each guarded against symlinks, nested mounts and outside hard links.--tmp-overlay$HOMEwhere the host supports it, with the XDG fallback elsewhere.brainCLI name--scratch.a5a8899e(treed9044879). feat(ui-react): show a link to a cleared scratch file as expired (#1657) #1688 landed on main between that run and the merge. It shares no files with this PR, and its tests pass on the combined tree locally. The failing-first and mutation receipts are in the PR body.CONTRACT: fix(backends): give each Claude worker a private, size-limi…
CONTRACT: fix(backends): give each Claude worker a private, size-limi…
CONTRACT: fix(backends): give each Claude worker a private, size-limi…
CONTRACT: fix(backends): give each Claude worker a private, size-limi…
CONTRACT: fix(backends): give each Claude worker a private, size-limi…
CONTRACT: fix(backends): give each Claude worker a private, size-limi…
CONTRACT: fix(backends): give each Claude worker a private, size-limi…
CONTRACT: fix(backends): give each Claude worker a private, size-limi…