Skip to content

ui-server: never run repository code, git or the brain CLI on the host against a brain that governed turns can write #1648

Closed

Description

@schlessera

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.ts and its local imports (export async function loadUserConfig, packages/core/src/lib/config.ts:590).
  • Bun startup. A new bunfig.toml preload or .env runs 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.initContext and core.indexAll in-process (export function createBrainApplication, packages/ui-server/src/brain/application.ts:113).
  • The server spawns the brain CLI (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 a governed turn has run on this brain since boot):

    • the application route's planning (initContext, prepareIngest);
    • its indexing;
    • every server-spawned brain command;
    • 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.

  • Working directory. At boot, the server refuses governed (it uses strict, with a named status) when its own working directory is inside the brain.

  • Durable manifest. The protected-path manifest is written to brain-ui.db before 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.ts importing ./helper.ts that writes a host sentinel when evaluated, a brain_add application, 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.toml preload and a .env created by a turn never run in a host process. A test checks for a host sentinel after a server-spawned brain command.
  • A fixture .git/refs/heads symlinked 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 governed unavailable and runs strict.
  • 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

  1. added this to the 0.42.0 milestone on Oct 11, 2026
  2. added
    type: feat
    area: core
    area: ui-sdk
    area: ui-server
    priority: p0
    agent-ready
    blocked
    security
    on Oct 11, 2026
  3. self-assigned this
    on Oct 11, 2026
  4. schlessera commented on Oct 11, 2026

    @schlessera
    OwnerAuthor

    Claimed (claim token gov1648-a1e5). Branch feat/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.

  5. schlessera commented on Oct 11, 2026

    @schlessera
    OwnerAuthor

    Unblocked: #1626 is closed, so scripts/sync-project.ts is removing the blocked label.

  6. removed
    blocked
    on Oct 11, 2026
  7. 5 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-readyarea: corearea: ui-sdkarea: ui-serverpriority: p0securitytype: feat

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions