Repository navigation
Closed
Labels
agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p1Scheduled into the current or next milestone.securityAuth, isolation, egress, secrets, or anything in the threat model.type: featA new capability or a change in user-visible behaviour.
Milestone
Description
Guardrail class: G1 (system integrity: resource exhaustion).
Context
Decision: docs/decisions/governed-writable-workers.md ("Resource limits (G1)"). In the maintainer's 2026-10-11 addition to #1636, resource exhaustion is part of system integrity. The /dev/shm budget from #1621 and #1625 is one instance of it.
The launcher sets namespaces and capabilities but no resource limits (export function workerCommand, packages/ui-sdk/src/server/worker-launcher.ts:105). The bootstrap validates descriptors before execve (export function workerBootstrap, worker-launcher.ts:146).
Scope
rlimits. The trusted bootstrap setsRLIMIT_AS,RLIMIT_NPROC,RLIMIT_FSIZEandRLIMIT_NOFILEbeforeexecve, with generous defaults recorded indocs/hosting/agent-workers.md. Measure them first: a Claude turn, a pi turn, abrain indexand a Chromium render must pass under them.- cgroups. When the server runs in a delegated cgroup v2 subtree, as under systemd user delegation or a container with cgroupns, it creates one child cgroup per worker with
memory.max,pids.maxandcpu.max. When it cannot, it records which limits are absent. - Status. The result goes into ui-server: learn at boot that the host cannot run agent workers and report it, instead of failing every turn #1632's host status and into the capabilities note.
- Roadblocks. A worker step that fails on a limit is recorded as a roadblock, with the limit named.
Out of scope
- Worker-state tmpfs sizing (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).
- Disk quotas on the brain filesystem. The free-space floor is part of the scope-cap sibling issue.
Acceptance criteria
- A fixture worker that forks without bound is stopped by
RLIMIT_NPROCorpids.max, and the host stays responsive. A test with a short timeout shows this. - A fixture that allocates past the memory limit fails inside the worker only.
- The four first-party workloads named above pass under the defaults. The test records their peak usage.
- Host status reports enforced and absent limits. A test runs it on a host without delegation.
- Mutation receipt: drop the
NPROClimit and the fork test fails.
Verification
ui-sdk tests on a supported Linux host and the integrated worker proof, then bun run check:pr --base origin/main.
Contract impact
Additive status fields. Minor changeset.
Metadata
Metadata
Assignees
Labels
agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.priority: p1Scheduled into the current or next milestone.securityAuth, isolation, egress, secrets, or anything in the threat model.type: featA new capability or a change in user-visible behaviour.
Activity
schlessera commentedon Oct 11, 2026
Claiming (claim token gov-1660-a04b). Branch:
feat/1660-worker-resource-limits. Plan: rlimits in the trusted worker bootstrap before execve, an optional per-worker cgroup v2 child when the server's cgroup is delegated, a namedworker_resource_limitfailure class, limits in the host status and the capabilities note, host-configurable generous defaults.CONTRACT: feat(ui-server): keep machine-readable governance events wi…
CONTRACT: feat(ui-server): keep machine-readable governance events wi…
CONTRACT: feat(ui-sdk): bound each agent worker's processes, memory, …
schlessera commentedon Oct 11, 2026
Coordination from #1654 (PR #1695): the capabilities note now has a seam for limits.
workerSandboxNote(sandbox, { limits })(packages/ui-sdk/src/server/worker-sandbox.ts) takesWorkerNoteLimitentries ({ name, value, onHit }), each rendered from the value that enforces it, as a closing "Limits in this turn:" list. Suggest #1692 passes its resolved limits there instead of appending a separate note, so both backends keep injecting one generated text.CONTRACT: feat(ui-server): keep machine-readable governance events wi…
CONTRACT: feat(ui-sdk): bound each agent worker's processes, memory, …
CONTRACT: feat(ui-sdk): bound each agent worker's processes, memory, …
CONTRACT: feat(ui-sdk): bound each agent worker's processes, memory, …
schlessera commentedon Oct 12, 2026
Merged in #1692 as 2b196b3. Its parent is 703a922, and its tree is the one CI tested on head 943f99a: all CI jobs and
contractpassed.prlimitis the first program inside the worker's namespaces and setsRLIMIT_NPROC,RLIMIT_DATA,RLIMIT_FSIZEandRLIMIT_NOFILEbefore the worker command runs. A host withoutprlimitrefuses turns and names the requirement.RLIMIT_NPROCis set inside the user namespace. Set outside, it counts every process of the uid and the namespace itself is refused (measured).RLIMIT_DATAinstead ofRLIMIT_AS. Chromium failed under everyRLIMIT_ASvalue that bounds anything. The decision record says so.memory.maxwith swap off,pids.max,cpu.maxand no descendant cgroups. This happens only when the server runs alone in a delegated cgroup v2 subtree mounted withnsdelegate. On Docker the status says why the cgroup limits are absent.runtime.workerHost.limitson/api/status.worker_resource_limit.resource_limitactivity events, recorded as ui-server: keep machine-readable governance events with the session history #1651 governance events.pids.max, fatal attribution and the governance writer.codex reviewpasses. Every finding was fixed.