Repository navigation
Description
Guardrail class: G1 (system integrity). This must land before governed can become the default.
Context
Decision: docs/decisions/governed-writable-workers.md ("The host execution boundary"). The independent review (findings) reproduced four ways read-only mounts alone leave host execution open once the brain is writable:
- Config dependencies. The host imports
brain.config.tsand its local imports (export async function loadUserConfig,packages/core/src/lib/config.ts:590). - Bun startup. A new
bunfig.tomlpreload or.envruns in any host Bun process started with the brain as its working directory. - Git includes and filters.
- Symlinked refs that make a host commit write outside the brain.
Host-side evaluation today:
- The application route calls
core.initContextandcore.indexAllin-process (export function createBrainApplication,packages/ui-server/src/brain/application.ts:113). - The server spawns the
brainCLI (async sync(),packages/ui-server/src/brain/client.ts:363). - Cron runs
brain sync --json && brain index(SYNC_JOB_COMMAND,packages/ui-server/src/cron/emit.ts:76).
Scope
-
Maintenance worker. A maintenance-worker launch form of the existing launcher, built on backends: the worker sandbox leaves no persistent writable place for scratch, workspaces or file outputs #1626's mount list: the brain is writable, the host read-only with runtime and home directories masked, network only when the command needs it, and only explicitly passed credentials.
-
What moves into it under
governed(and whenever agovernedturn has run on this brain since boot):- the application route's planning (
initContext,prepareIngest); - its indexing;
- every server-spawned
braincommand; - cron's emitted commands, through a wrapper the server installs;
- every git invocation.
The host keeps the descriptor-anchored Markdown commit it does today and receives plans as validated data.
- the application route's planning (
-
Working directory. At boot, the server refuses
governed(it usesstrict, with a named status) when its own working directory is inside the brain. -
Durable manifest. The protected-path manifest is written to
brain-ui.dbbefore every governed launch. At boot, every turn with a manifest but no end record is reconciled (quarantine of unexpected protected files) before any maintenance worker or turn starts. -
Writer gate. Turns and uncredentialed maintenance workers hold the brain's writer gate shared. A credentialed maintenance worker (sync, or an interim keyed reindex) holds it exclusively, from validation through reconciliation. A running turn never awaits a credentialed worker, because that would deadlock. Maintenance that a turn waits for, such as the synchronous index after a curated application, is credential-free. Credentialed work is queued until no shared holder remains.
Out of scope
- The governed profile's mounts (sibling issue).
- The journal, which runs no git (sibling issue).
- Metered provider relays (sibling issue).
Acceptance criteria
- With a fixture
brain.config.tsimporting./helper.tsthat writes a host sentinel when evaluated, abrain_addapplication, an index refresh and a sync never create the host sentinel. The helper's effect appears only inside the worker. Tests cover each path. - A fixture
bunfig.tomlpreload and a.envcreated by a turn never run in a host process. A test checks for a host sentinel after a server-spawnedbraincommand. - A fixture
.git/refs/headssymlinked outside the brain cannot make a sync or commit create a file outside the brain. A test checks the outside directory. - A server started with its working directory inside the brain reports
governedunavailable and runsstrict. - After a simulated crash mid-turn with an attacker-created
brain.config.ts, boot quarantines it before anything evaluates it. A test covers this. - Mutation receipts: run indexing in-process and the config-helper test fails; skip boot reconciliation and the crash test fails.
Verification
ui-server, ui-sdk and core tests on a supported Linux host, then the integrated boundary proof, then bun run check:pr --base origin/main. Update docs/hosting/agent-workers.md.
Contract impact
The cron command shape changes: emitted commands go through the wrapper. Assess this against the integration contract's cron section, and add a CONTRACT: commit if it is documented there. Minor changeset.
Blocked by #1626
Activity
schlessera commentedon Oct 11, 2026
Claimed (claim token
gov1648-a1e5). Branchfeat/1648-host-execution-boundary, stacked on #1641's branch (fix/1626-worker-writable-areas) as a draft until #1641 merges, then retargeted to main before any force-push.schlessera commentedon Oct 11, 2026
Unblocked: #1626 is closed, so
scripts/sync-project.tsis removing theblockedlabel.CONTRACT: feat(ui-server): run the brain's own code only in maintenan…
5 remaining items
CONTRACT: feat(ui-server): run the brain's own code only in maintenan…
CONTRACT: feat(ui-server): run the brain's own code only in maintenan…
test: temporary CI diagnostic for maintenance workers (#1648)
test: temporary maintenance trace (#1648)
test: temporary maintenance trace (#1648)
test: temporary maintenance trace (#1648)
CONTRACT: feat(ui-server): run the brain's own code only in maintenan…
test: temporary CI diagnostic for maintenance workers (#1648)
test: temporary maintenance trace (#1648)
test: temporary lock repro (#1648)
test: deeper maintenance trace (#1648)
fix(ui-sdk): read worker pipes without holding a thread (#1648)
fix(ui-sdk): await a maintenance worker's input write before ending it (
CONTRACT: feat(ui-server): run the brain's own code only in maintenan…