Repository navigation
feat(sbx): lease mode level 2 — tracked processes (plan 5) - #814
Conversation
…s lists (additive) Exec gains kind (field 11, ExecKind) and process (field 12, ProcessArgs). ExecKind's zero value is EXEC_KIND_COMMAND, so an Exec from an older client is a plain command. The process kinds are only sent once the far end is known to understand them (the worker's lease-processes-v1 capability). TrackedProcess describes one tracked process (state running | exited | killed, code is the exit code or the signal number). LeaseEvent gains tracked (field 9); processes (field 7) keeps the display strings. LeaseStatus gains processes (field 7) and stopped (field 8). The LeaseEvent state comment lists processes_stopped, emitted when a set_mode downgrade stops processes. Everything is additive; buf breaking against upstream/main passes. Fixtures that compare decoded lease messages exactly now expect the new empty lists. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…sistent reaper registrations Level 2's guest foundation (plan 5 Task 2). Request gains kind, process and max_processes, End gains tracked; all omitempty, so an old host's request and a per-Exec End are byte-identical. tracked.go holds the 4 MiB ring log, the tracked table (running-name uniqueness, exited entries replaced by name, limit counts running only) and the uid allocator (20000+, skips populated uids, rotates). The reaper gains track(pid, onExit), which expect and cancel never clear. The shim takes the identity's user name (sbx, or sbxp<n>) as an argument, and the agent gains --lease-tracked-uid-base and --lease-tracked-uids. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Ruling P5-R5: every lease End carries the whole tracked table in one 32 KiB frame, and each ring lives in agent memory. The table now keeps at most trackedExitedKeep (8) exited entries, evicting the oldest exited first, ring included; running entries are never evicted. At exit, markExit trims the process's ring to its last trackedExitedLogCap (64 KiB), and later writes stay within it. The End at the cap (4 running + 8 exited, 255-byte worst-case-escaped names) encodes to 20406 bytes. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ries Review round 1 of plan 5 Task 2. - ring.Write read max before taking the lock while shrink lowered it under the lock: a data race once a tracked process's leftovers write after its exit. Write now takes the lock first; concurrent Write/shrink/Tail test. - Ruling P5-R9: markExit returns the entries its eviction drops, so the caller can keep their cgroups (and uids) until empty; the allocator's populated is documented as answered from real cgroups, never the table. - max_processes 0 (an old host, omitempty) means the default 4. - track's doc requires expect before the fork; the flags and options say 0 means the default; newReaper shares the map setup with the tests. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ps under their own uids
Level 2's handlers (spec §7), dispatched from runLease on Request.Kind:
process_start, process_list, process_logs, process_stop and the host-only
process_stop_all. Each tracked process runs in CgroupRoot/tracked/p<id>
(root-owned, Exec caps written first, CLONE_INTO_CGROUP), through the shim
under its own tracked uid in sbx-ws, umask 0002, HOME /tmp/sbx-proc-<uid>
(0700, made afresh), its own session, stdin /dev/null, stdout+stderr in its
ring. The end-of-Exec kill still touches only e<seq>.
- Every lease End carries End.Tracked, the command kind's included.
- An unknown kind is refused with lease_unsupported and never runs (P5-R6);
a process kind outside a lease is refused too.
- Names per P5-R8 (process_name_invalid); unnamed shows as p<id>; cwd must
resolve inside the workspace (process_cwd); the uid allocator's refusal is
process_limit.
- Ruling P5-R9: a uid -> tracked/p<id> map of every uid handed out answers
populated(); a cgroup dir is removed only once empty; an entry the table
drops (eviction, name replacement) has its leftovers killed.
- process_stop: the signal to every process in the cgroup, 10 s grace, then
cgroup.kill and waitCgroupEmpty; a cgroup that will not empty answers
End{TeardownFailed} and the agent is dead, as for an Exec.
- The shim resets inherited SIG_IGN to SIG_DFL before its exec (the agent
ignores TERM/INT/HUP, so the command would too), and marks fd 3 close-on-
exec: process_start waits on that exec barrier, so a stop right after a
start reaches the command rather than a shim with TERM ignored.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
…nux_test.go A pure move, no test changed (task 3 review, minor 9). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…vilege drop; bounded errors and logs Task 3 review, fix round 1. - I1: ForkExec's Dir chdir'd as root into a path a running tracked process could swap for a symlink after the check. The agent now opens the checked cwd with openat2(RESOLVE_BENEATH|NO_SYMLINKS|NO_MAGICLINKS|NO_XDEV) beneath the workspace and passes the O_PATH fd to the shim (fd 4); the shim fchdir's into it after setresuid and closes it. No root chdir is left. The shim argv gains <cwd>: `-` (inherited, lease Execs) or `fd`. - P5-R12: HOME is <parent>/<uid> under a root-owned 0711 /tmp/sbx-proc, made at lease prepare and re-checked (fail closed) at each start. - P5-R13: an unknown stop signal is `process_signal: unknown signal <s>`; an exited entry with children stays exited (documented). - process_logs keeps the newest lines within CapBytes, counted as dropped. - cwd errors carry the clipped cwd, not the PathError's full path. - The recycled-pid race in signalCgroup is documented (pidfd would cover only the main pid). - The start-then-stop test runs through a wrapper shim that ignores the signals instead of ignoring them in the test binary. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… feature build-snapshot.sh bakes the tracked-process users sbxp0..sbxp3 (uids 20000..20003, group sbx-ws 7000, HOME /tmp/sbx-proc/<uid>, ruling P5-R12) beside sbx, refusing a tree that already uses one of those names or uids (compared as numbers) for another account. The init passes --lease-tracked-uid-base 20000 --lease-tracked-uids 4 to the agent. check_lease_support also proves in the guest that a child cgroup has cgroup.kill (a probe cgroup it removes again), that the tracked uid range is held by exactly the sbxp lines, and that gid 7000 is sbx-ws alone. The Firecracker manifest lists lease-processes-v1 beside lease-v1; Cloud Hypervisor lists neither. vmpool gains FeatureLeaseProcessesV1 = "lease-processes-v1". Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…lds only Level 2 (lease-processes-v1) is Firecracker-only, so a Cloud Hypervisor build must gain no new failure mode (ruling P5-R15): add_sbx_identity adds the sbxp0..sbxp3 lines and refuses a tracked-range clash only when VMM=firecracker, and check_lease_support sends the cgroup.kill, tracked range and gid-7000 probes only then; a CH guest is asked the four questions of before. The gid compares, at build and in the guest, are numeric like the uid ones (07000 is caught), and the guest's tracked lines are compared in sorted order, so an image with the exact lines out of order passes as add_sbx_identity accepts it. A test now runs the real guest command under /bin/sh against a fake guest tree. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…ease events and status Exec and Command gain Kind and Process, forwarded to the guest's Request (with SH_LEASE_MAX_PROCESSES on process_start). A process kind is refused lease_unsupported on a snapshot without lease-processes-v1 and processes_not_enabled below lease+processes (also under the gate, after the relevel); list/logs/stop with no live lease answer [] or process_not_found without starting one. Guest process refusals keep the lease and reach the client as their bare wire strings; process kinds get a 30 s timeout floor. Each lease keeps a mirror of the guest's tracked table, refreshed from every lease End and persisted with the open lease. Lease ends (worker_restart included) list the running processes as "<name> (pid <n>)" and in structured form; LeaseStatus carries them; lease_process audit records cover start, stop and exit; execLog gains kind. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…inds keep the lease - LeaseStatus.processes carries the live lease's whole tracked table, exited entries with their state and code included (P5-R16), so a client can read why a process died. Lease-end events still list the running entries only. The proto, Go and TS comments say so (comment-only regeneration). - A guest refusal keeps the lease only for a process kind: a command whose guest error starts with a refusal prefix ends the lease agent_dead. - Test the per-exec refusal of a process kind on a same-epoch downgrade with a live lease (routeExec's endFirst case): its pin is released and the refusal ends nothing. - Note that a stop answered before the process dies is followed by an exit record. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
A pure move, no change in behaviour: TrackedProcess and its methods, runningTracked and displays (from lease_mode.go), and refreshTrackedLocked, auditTracked, findTracked and trackedAuditField (from lease.go). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…esses, under the gate A lease leaving level 2 is marked (stopTracked) and the next holder of the run's gate sends the host-only process_stop_all before anything else runs: - set_mode lease+processes -> lease waits for the gate like endLeaseWaiting (shared loop: waitLeaseGate, starting case included, cut mode_change at LeaseGraceLimit), keeps the lease, and returns the stopped list, which LeaseControl puts in that answer's LeaseStatus.stopped only (P5-R19); - an Exec carrying the downgrade's epoch (ruling R18), or one that beats the set_mode wait to the gate, stops them before its Run and carries a processes_stopped LeaseEvent (reason mode_change), never acknowledged nor stored (P5-R19); - a teardown_failed End or a failed guest call ends the lease teardown_failed, listing the mirror's running entries; a guest refusal ends it mode_change; - each stopped process gets a lease_process stop record at lease+processes. The stop-all is sent even with nothing running, and only on a snapshot with lease-processes-v1. SetMode now returns ([]TrackedProcess, error). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
waitLeaseGate takes an owed predicate, checked under p.mu at the grace point: when it no longer holds, the waiter returns without cutting. stopTrackedWaiting's predicate is "the lease still has its stop to take, or is a level-2 lease a starting Exec installed after the downgrade"; endLeaseWaiting's is always true. A lease Exec at the new epoch that did the stop under its own gate is no longer cut lease_ended(mode_change) at the set_mode's grace limit, and the lease is kept (review Important 1). Tests: TestDowngradeGraceDoesNotCutAfterAnExecStopped (the review probe), TestDowngradeStopIsBoundedByTheGraceLimit, and Exec-path subtests of TestExecRelevelStopsTrackedAndNotifies for a failing stop-all (fresh lease, teardown_failed end on the response) and nothing running (no processes_stopped). pool.go names stopTrackedUnderGate. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Per ruling P5-R19 the list is never stored nor acknowledged; drop "reported until acknowledged". Regenerated gen/go and both TS copies (comment-only diffs). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
wexec.Spec gains Kind (the guest protocol's spelling, "" for a command) and Process, mapped from pb.Exec by the session. A kind the worker does not know travels as "unknown(<n>)", and both tiers refuse it, and any name that maps to no kind, as "lease_unsupported: unknown exec kind <n>" before any VM or lease work (ruling P5-R22). The container tier (BashRunner, and WorkspaceRunner ahead of the workspace mkdir) refuses every non-command kind with "lease_unsupported: this worker has no lease mode" and never runs the command. vmpool.Runner maps the kinds and the process args into vmpool.Exec; no Spec kind maps to the host-only process_stop_all. The dedup fingerprint hashes the kind and the process args for a process kind only, so a command Exec's fingerprint stays byte-identical across the upgrade (pinned against the pre-change value). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…d detail Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
On the sandbox path Exec.kind and Exec.process pass through to the worker, but a process kind is forwarded only on a token whose mode claim is lease+processes. Below that (lease, per-exec, or a token minted before the mode claims) it is refused FAILED_PRECONDITION with "processes_not_enabled: this sandbox's mode is <mode>", before any slot or worker call. A kind outside 0..4 is refused INVALID_ARGUMENT "unknown exec kind <n>". Both are audited as refused. The harness path forces kind = EXEC_KIND_COMMAND and an empty process, whatever the client sent. The sandbox_exec audit line gains kind (unknown(<n>) for an unknown one) and, for a process kind, process: p<id> when an id is given, else the name, cut to 128 bytes, never the command. A process_start's command is logged only as cmd under SH_SANDBOX_AUDIT_COMMANDS, like any Exec's. @moca/k8s-sandbox now exports ExecKind and ProcessArgs. Three test fixtures that hand-built partial Execs use Exec.fromPartial, as a decoded request always carries a kind. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…follow the mode, level-2 texts - SandboxExecConn.process(op, args, opts): an Exec of a process kind under exec's retries (token refusal, stale_mode re-mint), parsing the guest's JSON; process wire refusals become a ProcessError carrying its events. - MCP process_start/list/logs/stop, listed only while the current token's mode is lease+processes; a call below it answers the exact spec §7 refusal and sends nothing (P5-R27). - The server declares tools.listChanged; tokenMinted() sends list_changed when a mint changes the mode, on the first mint only if the tools were listed under another mode. Descriptions are rebuilt per mode. - Level-2 bash description and rules carry the §7 sentence; sandbox_info lists the tracked processes from LeaseStatus.processes. - leaseNotice renders processes_stopped (Global Constraints copy). - A stale_mode first attempt's events now survive a retry refused as ExecRefusedError (PERMISSION_DENIED), the M3 follow-up gap. - mocactl sbx mcp wires the process calls, the sandbox id and tokenMinted. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The Go copy of leaseNotice renders processes_stopped exactly as the TS one (P5-R26), with the same fixture strings in TestNoticeCopyMatchesTS. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…view minors - P5-R29: a process tool called below lease+processes forces one fresh mint (refreshMode; mocactl's re-mint, or the connection's first mint) and refuses unsent only if the fresh token is still below. The relay's processes_not_enabled refusal is re-minted and retried once, like stale_mode, carrying the first attempt's events. - list_changed compares a mint's mode against the last listed mode, once until the client lists again (Minor 4). - A failed re-mint keeps the first attempt's acked events on the token source's error (leaseEventsOf; Minor 1). - Level 2 uses LEASE_PROCESSES_RULE: only `&`, `nohup` and `setsid` processes do not survive a call (Minor 2); the CLI refusal is tested (Minor 3); the `process` locals are renamed (Minor 6). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…and plan-4 carry-overs - `mocactl sbx proc start|ls|logs|stop` (spec §7, P5-R31): the sandbox ID is optional (the bound one, or --sandbox); logs/stop take the process first (p<n> or a decimal id, else a name); start's command is everything after `--`, quoted as `run` quotes it; ls --json prints the TrackedProcessView[] array; exit 0, 1 on a refusal or failure, 130 on Ctrl-C. Below lease+processes the token's mode refuses it unsent with the CLI §7 text. - `mode` lease+processes → lease prints `stopped <n> tracked processes: …` from LeaseStatus.stopped, only when non-empty (P5-R30); `get` lists the tracked processes; the help no longer says every downgrade ends the lease. - sandbox-client: LeaseStatusView.stopped; CLI wording of process_not_found and process_limit names the sbx proc commands. - M2: put, push, pull, up, --seed and doctor say the lease events their Execs carried (noticingExec). - Tests for the plan-4 gaps: a lease create's ApiError and --json failure paths, mode with a failing openExec, doctor's level-2 stale rules block. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…shaped names refused Task 10 fix round 1. - P5-R6: processRow and process_start render ids as p<id>, so process_list, process_stop, sandbox_info and mocactl show the same ids. The MCP tools' selector and `mocactl sbx proc` share processSelector (sandbox-client): a p<n> or n reaches the guest as the id, a named process included. - P5-R33: a name shaped like an id (^p?[0-9]+$) is refused process_name_invalid in the guest's validateProcessName, and before sending in MCP process_start and `sbx proc start --name`, with the same text (processNameProblem). - proc: a Ctrl-C before the Exec went out says nothing was sent; one row and display helper in proc.ts, used by get and mode; `stopped 1 tracked process: …` for one. - Tests: ls --json stays pure JSON with a lease event; Ctrl-C on ls, logs and stop. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Level-2 halves of TestGateLeaseExecKillsProcesses (process_start survivors), TestGateLeasePrivilege (the tracked half, Review Focus 2), TestGateLeaseStaleEpoch (a downgrade stops tracked processes and keeps the lease) and TestGateLeaseNotice (every end lists what it stopped), and the new TestGateLeaseProcessLifecycle. Each level-2 half skips, NOT RUN, unless the snapshot advertises lease-processes-v1; the level-1 half still runs on a lease-v1-only snapshot. The inventory lists them with their prerequisites. Carry-overs: the expiring event's age_ms is asserted exactly, with a lease+processes variant; relay tests that the keepalive coalescing map prunes and that a failed write opens no window; setup.sh warns, and names the hosts to reinstall, after an idle-ceiling change. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
On the AWS rig a tracked process's exit (SIGCHLD to PID 1) interrupted the vsock accept; Serve returned the EINTR, main's log.Fatalf exited init, and the guest kernel panicked (Task 11 fix round 1, item 1). The vsock accept retries EINTR and ECONNABORTED at once (acceptRetryable), Serve backs off and retries every accept error but a closed listener, as EgressForwarder.Serve does, and a closed vsock listener's Accept reports net.ErrClosed. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… end syncs first Ruling P5-R34 (Task 11 fix round 1, item 2): both launchers wrapped process_start's command in the per-Exec template, so the reported pid was the wrapper's, an OOM read exited(137), and the wrapper's cd /workspace overrode the requested cwd. A process kind is now sent exactly as given (wrapForGuest); a command keeps its wrapper. Durability: only an Exec's wrapper synced, and a tracked process writes between Execs, so a lease end destroyed its writes with the guest's page cache. An end of a lease at level 2, or with tracked processes, now runs a bounded sync (LeaseEndSyncTimeout) before the destroy, the closed pool's detach included; agent_dead and teardown_failed ends skip it. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
… level apart TestGateLeaseProcessLifecycle asserts process_start's cwd (sub, and /workspace by default) and that a stop kills the command itself; the grace_limit driver's grace is 10 s so level 2's extra steps fit; each gate's level-1 and level-2 halves are subtests of their own (Task 11 fix round 1, items 2-4). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review at 84e241c
Plan 5 (level 2, lease+processes) is carefully built. The relay gate (token mode and worker capability, with a backstop at the write), the container-tier refusal, the uid-reuse rule, cgroup.kill teardown, the shim's privilege-drop order, the exec barrier and the PID-1 accept fix all check out. Level 2 stays off by default (SH_SANDBOX_MODES_ALLOWED=per-exec).
One must-fix (inline, tracked.go:309): exited entries are evicted in start order, so a long-lived process that exits after 8 short jobs is evicted the moment it exits, and process_stop then reports a killed process as running.
Suggestions: the 30 s process-kind floor is counted from arrival, so a gate wait can end the lease agent_dead (pool.go:399). Lease-end syncs run serially in Close and in the reclaim batch (pool.go:1034, lease.go:1030). fchdir doesn't enforce search on the cwd's parents (lease_shim_linux.go:106). proc logs writes to the terminal unsanitized (proc.ts:236). The audit line can name a caller-supplied id on process_start (sandbox-caller.ts:198). The rest are nits.
Checked and found correct:
- Process kinds can't reach level 1, a per-exec route, Cloud Hypervisor or the container tier. Unknown kinds are refused.
- The harness path zeroes kind/process.
- The command's dedup fingerprint is byte-identical, and the kind encoding is injective.
- Proto changes are additive (Exec 11/12, LeaseEvent 9, LeaseStatus 7/8), and
ExecKind0 is COMMAND. - The tracked mirror's bounds and fail-closed load are right.
- The downgrade stop runs under the gate, with no
p.muheld across Run. - The client re-mint and held-event paths are right, and so are the
list_changeddedupe and the id/name rules matching the guest. - Docs constants match the code (uids 20000–20003, 4 MiB ring, 10 s TERM→kill, tail 200, 4 processes).
- Both merges of main keep both sides (remerge-diff), with no conflict markers.
The live SBX0 smoke (step 9) hasn't run yet, and the KVM rig run predates the merges, as the PR says. The security-review §7 draft still needs the security owner's sign-off.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: Go (guest agent, vmpool, session, exec, worker cmds), proto, TypeScript (sandbox-relay, sandbox-client/MCP, mocactl), Shell (setup.sh, smoke.sh, build-snapshot.sh), Docs (spec, direct-client API, security review, RUNBOOK/README)
Agent/IDE config (.claude/.vscode): none
Commits: 42 commits, all signed off: yes
CI status: passing (17/17)
|
|
||
| // evictExited drops the oldest exited entries past trackedExitedKeep and returns copies | ||
| // of them. The caller holds mu. | ||
| func (t *trackedTable) evictExited() []trackedEntry { |
There was a problem hiding this comment.
must-fix: evictExited drops the first exited entries in t.entries, which is kept in start order, so it drops the oldest-started exited entries, not the oldest-exited. markExit calls it right after marking the entry, so the entry that just exited can be the one dropped.
Scenario: start a long-lived server p1, then start and finish 8 short jobs p2..p9 (8 exited entries kept). Now p1 crashes: markExit(p1) sees 9 exited entries, and the first exited one in slice order is p1, so p1 is evicted in the same call. Its exit code and log tail are gone immediately, and it never shows as exited in a process_list or End.Tracked. That contradicts spec §7 ("an exited process stays … so the agent can read why it died", "dropping the oldest first").
The same path makes process_stop p1 answer wrongly. awaitFinal (tracked_linux.go:424) wakes on the exit signal, lookup(p.ID) fails because the entry was just evicted, and it returns the row it took before the stop: state: running, code 0. processStopAll goes through awaitFinal too.
TestTrackedNinthExitEvictsTheOldestExited only exits entries in start order, so it doesn't catch this.
Fix: record an exit sequence (or exit time) in markExit and evict by smallest exit sequence, never the entry being marked in the same call. Also have awaitFinal fall back to the final row the reaper recorded (e.g. carry it on the exits signal) rather than the pre-stop row. Add a test that exits entries out of start order.
| @@ -330,6 +396,9 @@ func (p *pool) ExecPhased(ctx context.Context, key string, e Exec, out Sink, ph | |||
| // timeout_s is a plain proto3 field, so an Exec that simply omitted it was | |||
| // bounded by nothing on either side — see clampTimeoutS. | |||
| timeoutS, clamped := clampTimeoutS(e.TimeoutS) | |||
| if e.Kind.isProcess() && timeoutS < ProcessKindMinTimeoutS { | |||
There was a problem hiding this comment.
suggestion: ProcessKindMinTimeoutS is applied to the budget at arrival, but the guest-side work it protects starts only once Run starts under the gate (lease.go:737, leaseGuestTimeoutS(deadline, t0)). On the guest, processStop ignores req.TimeoutS and takes ~10 s (TERM grace), then cgroup.kill, up to 5 s for the cgroup to empty, and up to 5 s in awaitFinal.
Scenario: a tracked process ignores SIGTERM, and its process_stop queues 20–29 s behind another lease Exec (a downgrade's stop counts). The not-run check passes because the deadline hasn't passed, so Run starts with a few seconds left. The host timer fires at deadline + LeaseTimeoutSlack (8 s) before the guest's 10 s grace is up, and timedOut ends the lease agent_dead. The VM is destroyed with every tracked process in it, and the client sees a timeout.
Fix: for a process kind, give Run at least the floor from t0 (deadline = max(deadline, t0+ProcessKindMinTimeoutS)), or treat "less than the floor left at Run" as not run, which keeps the lease.
| @@ -955,7 +1032,7 @@ func (p *pool) Close() error { | |||
| } | |||
| } | |||
| for _, v := range leases { | |||
There was a problem hiding this comment.
suggestion: Close now calls destroyLeaseVictim once per lease in turn, and for a detached level-2 lease (worker_restart, sync on) each one can block for up to LeaseEndSyncTimeout (30 s). microvm-worker.service has TimeoutStopSec=30 and KillMode=control-group.
Scenario: one wedged level-2 guest, or several healthy ones each taking a second or more to sync, pushes Close past 30 s. systemd SIGKILLs the group, and the leases later in the loop are never synced, which loses exactly the tracked-process writes this step exists to keep. Before this PR, Close didn't wait on guests.
Fix: sync the victims concurrently under one overall deadline well below TimeoutStopSec, then destroy them. Alternatively, raise TimeoutStopSec to cover the bound and document it.
| func (p *pool) destroySweptLeases(vs []*leaseVictim) { | ||
| for _, v := range vs { | ||
| p.destroyLeaseVM(v.key, v.vm) | ||
| p.destroyLeaseVictim(v) |
There was a problem hiding this comment.
suggestion: destroySweptLeases (and memory_reclaim victims through the same path) syncs each victim in turn on the single reclaim goroutine. Each victim already holds its run's gate, and endLeaseLocked has already removed the lease's charge from committedLocked. memory_reclaim deliberately keeps sync on (lease.go:875).
Scenario: N level-2 leases end on one tick (idle or memory_reclaim), and the first guest is wedged. Execs for the other N−1 keys wait on their gates for ~30 s before they can start fresh leases, and every queued reclaim batch waits too. Meanwhile admission counts the still-running VMs' memory as free, so a memory_reclaim can over-commit the host for up to 30 s per wedged victim, one after another.
Fix: sync a batch's victims in parallel, each releasing its gate when done. Also consider keeping a victim's charge counted until its VM is destroyed, at least for memory_reclaim.
| } | ||
| // After the drop: the kernel checks the directory against the dropped identity, | ||
| // and the descriptor, not a path, names it. | ||
| if sa.cwdFromFD { |
There was a problem hiding this comment.
suggestion: the comment says the kernel checks the directory against the dropped identity. That's true for the target, but the cwd was opened by root with openat2 (tracked_linux.go:145), so the parents' search permission was checked as root. fchdir then checks only MAY_EXEC|MAY_CHDIR on the final directory.
Scenario: a tracked uid (sbxpN, group sbx-ws) can be started in /workspace/private/sub when private is 0700 and owned by the exec uid, as long as sub is group-searchable. It couldn't reach that path itself. The impact stays inside the workspace, but it's wider than spec §7 / P5-R14 ("a cwd the tracked uid cannot search fails"). Related: resolveProcessCwd's root-side EvalSymlinks/Stat errors reveal which paths exist.
Fix: after the drop, have the shim re-resolve the relative path from a workspace-root descriptor as the dropped uid (openat2 with RESOLVE_BENEATH|RESOLVE_NO_SYMLINKS|RESOLVE_NO_XDEV) and fchdir to that. Or document that parent permissions are not enforced.
| func (a *Agent) launchTracked(id string, log *ring, command string, cwdDir *os.File, maxRunning int, r *reaper, shim string) (int, int, error) { | ||
| l := &a.lease | ||
| lo := a.opts.Lease | ||
| uid, err := l.uids.take(l.cgroups.populated) |
There was a problem hiding this comment.
nit: this refusal also fires when uids are held by leftover children of exited or evicted entries, so a user with 1 running process and 3 uids still populated is told "4 running". Say so, e.g. "N running, M uids held by leftover children of exited processes; process_stop them".
| } | ||
| let tail: number | undefined; | ||
| if (v.tail !== undefined) { | ||
| tail = /^\d+$/.test(v.tail.trim()) ? Number(v.tail.trim()) : Number.NaN; |
There was a problem hiding this comment.
nit: the check only requires Number.isSafeInteger(tail) && tail >= 1, but ProcessArgs.tail is uint32, and the writer does >>> 0. --tail 4294967296 is sent as 0 (the guest's default 200), and 4294967297 as 1. Also require tail <= 0xffffffff, or clamp to it.
| "The last lines of a tracked process's combined stdout and stderr, by its id or name. tail " + | ||
| `is the number of lines (default 200); output is truncated to the last ${MAX_LINES} lines or ` + | ||
| `${MAX_BYTES / 1024}KB.`, | ||
| inputSchema: { |
There was a problem hiding this comment.
nit: tail has no upper bound here. BinaryWriter.uint32 throws above 2^32−1, so process_logs {tail: 5e9} surfaces as an INTERNAL serialization failure rather than invalid input. Cap it and throw ToolInputError above the cap.
| } | ||
| parts := make([]string, len(ps)) | ||
| for i, tp := range ps { | ||
| parts[i] = tp.ID + ":" + tp.DisplayName() + ":" + tp.stateText() |
There was a problem hiding this comment.
nit: the host takes ids and names from the guest's End without checking them (trackedFromGuest) and logs them with %s (here and id=%s at :131). A compromised guest agent could put newlines into the host's lease end / lease_process audit lines. Use %q, or validate them against the guest's own [A-Za-z0-9._-] / p[0-9]+ rules in trackedFromGuest.
| * A fresh token's mode, for the process tools' gate (P5-R29): the connection's first mint if it | ||
| * is not open yet, else one forced re-mint. `onToken` sees it, so the list follows it too. | ||
| */ | ||
| const refreshMode = async () => { |
There was a problem hiding this comment.
nit: refreshMode ignores the AbortSignal the MCP server passes it (mcp-server.ts:532), so a cancelled process tool call can't stop its forced re-mint. The server still maps the cancel correctly afterwards. Thread the signal into open() / remint().
markExit evicted the first exited entry in start order, so a long-lived process that exited after eight short jobs evicted itself in the same call: its exit code and log were gone at once, and process_stop answered the row it took before the stop (state running). The table now records an exit sequence and evicts the entry that exited first, never the one being marked. The reaper's final row rides on the exit signal, and awaitFinal (process_stop, process_stop_all) falls back to it when the table has evicted the entry, never to the pre-stop row. PR rossoctl#814 review #4574559333. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
process_start's uid refusal said "N running" even when most uids were held by leftover children of exited processes, so a user with one running process was told "4 running". The allocator now counts what holds each uid, and the refusal reads `process_limit: N running, M uids held by leftover children of exited processes (process_stop them)` in that case, keeping the process_limit: prefix. PR rossoctl#814 review #4574559359. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The tracked process's cwd was opened by root with openat2, so its parents' search permission was checked as root; the shim's fchdir then checked only the final directory. A tracked uid could be started in /workspace/private/sub under a 0700 private it could not reach itself. The agent now hands the shim an O_PATH descriptor of the workspace root and the cwd relative to it (`fd:<rel>`). After the privilege drop the shim resolves the path with openat2 (RESOLVE_BENEATH, NO_SYMLINKS, NO_MAGICLINKS, NO_XDEV) and fchdirs into the result, so every directory on the way is searched as the tracked uid. A cwd it cannot reach still shows exited(127) with `cwd: permission denied` (P5-R14). The root-side checks keep their up-front refusals, now with one text (`process_cwd: <cwd>: not a directory inside the workspace`), so they no longer reveal which paths exist. PR rossoctl#814 review #4574559347. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ProcessKindMinTimeoutS was applied to the budget at arrival, but the guest work it protects (process_stop's TERM grace, cgroup.kill, the teardown bound) starts only at Run. A process_stop that queued 25 s behind another Exec ran with ~5 s left; the host gave up at deadline + LeaseTimeoutSlack under a guest still doing its job and ended the lease agent_dead, destroying every tracked process. runLease now computes the run's deadline as max(budget end, Run + ProcessKindMinTimeoutS) for a process kind; the guest's timeout_s and the host timer (extend) both follow it. The not-run check still uses the budget, so a spent budget is still not run and keeps the lease. PR rossoctl#814 review #4574559337. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Close synced each detached level-2 lease in turn, each up to LeaseEndSyncTimeout (30 s); one wedged guest pushed Close past the units' TimeoutStopSec=30, and systemd's SIGKILL then lost the later leases' tracked-process writes. Close now syncs its victims concurrently under one overall bound, LeaseCloseSyncTimeout (20 s), then destroys them all. The reclaim path (destroySweptLeases: idle, max_duration, keepalive_lost, memory_reclaim) synced a batch's victims one after another on the reclaim goroutine, each holding its gate. They now sync and destroy in parallel, each releasing its gate (and pin) once its own VM is gone, so a wedged guest delays only its own key. The charge stays removed at the end, as before: with parallel syncs the over-commit window is one sync bound per batch, not one per victim. PR rossoctl#814 review #4574559340, #4574559342. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
The host took ids, names and states from the guest's End unchecked and logged the id with %s, so a compromised guest agent could put newlines into the host's lease_process and lease end audit lines. trackedFromGuest now keeps only rows within the guest's own rules (id of decimal digits, name of 1-64 [A-Za-z0-9._-] or empty, state running, exited or killed); any other row is dropped and flagged in a quoted `guest tracked row refused` line. The lease_process line quotes the id too (id=%q). PR rossoctl#814 review #4574559366. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…nds' command auditProcess preferred p<id> whenever ProcessArgs.id was set, so a process_start with a caller-supplied id (which the guest ignores and replaces with its own) was audited as `p1`, hiding the real name. A process_start's audit line now names only its name. process_list, process_logs and process_stop carry no command (the guest ignores one), but a caller-sent command was forwarded and, under SH_SANDBOX_AUDIT_COMMANDS=1, audited as cmd. The relay now clears it before forwarding and never audits it for those kinds. The security review's audit row also records the worker's validation of the guest's tracked rows (previous commit). PR rossoctl#814 review #4574559352. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ProcessArgs.tail is a uint32 and BinaryWriter.uint32 throws above
2^32-1, so `process_logs {tail: 5e9}` surfaced as an internal
serialization failure. The tool now refuses a tail above 4294967295
with a ToolInputError, and its input schema says the maximum.
PR rossoctl#814 review #4574559362.
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
`proc logs` wrote the ring log straight to stdout. Unlike `run`, it replays later, out of band, output of a process the agent started, so an OSC 52 clipboard write, OSC 8 link or title sequence could reach the user's terminal. On a TTY the output is now sanitized (newlines and tabs kept); piped, or with the new `--raw`, it is passed through as written. The help text, spec §8.2 and the security review's name-safety row say so. `--tail` accepted any safe integer, but ProcessArgs.tail is a uint32 and the writer wraps (4294967296 went out as 0, the guest's default 200). A tail above 4294967295 is now a usage error. PR rossoctl#814 review #4574559350, #4574559360. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
refreshMode ignored the AbortSignal the MCP server passes it, so a cancelled process tool call could not stop its forced re-mint. The signal now reaches open() (the connection's first mint) and remint(); the token function's forced mint aborts its request when it started it, and stops waiting when it joined another caller's mint. PR rossoctl#814 review #4574559371. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
TestSweptLeasesSyncInParallel read the run pins as soon as the VMs were destroyed, but a victim releases its gate and pin just after its destroy, so the check could see every key still held. It now waits for the two released keys as well. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up review at 9fbce48
The 11 new commits (2e14696..9fbce48) address all 12 items from our 84e241c review. I checked each one against the code:
- must-fix,
tracked.goeviction: fixed.markExitstamps anexitSeq, andevictExited(keep)sorts the exited entries by it and never drops the entry it just marked.awaitFinal→finalRowfalls back to the row the reaper recorded on the exit signal, so it no longer returns the pre-stoprunningrow. A test exits entries out of start order. - pool.go:399 floor: fixed.
runLeasesetsrunDeadline = max(deadline, gate + ProcessKindMinTimeoutS)for a process kind.extendmoves the host timer there, and the guest'sTimeoutSfollows it. Client side, the 60 sPROCESS_TIMEOUT_Splus the 90 s backstop still covers a full gate wait plus the floor. - Close / reclaim serial sync: fixed.
Closesyncs concurrently underLeaseCloseSyncTimeout(20 s), destroys, then waits for the syncs. Swept/reclaimed victims each run in their own goroutine, and each gate is released after its own VM. Keeping the charge until destroy was declined, with the reason documented. That's acceptable now that a batch takes at most one sync bound. - shim cwd: fixed. The shim gets a workspace-root
O_PATHfd plus a local relative path, and re-resolves it withopenat2(BENEATH|NO_SYMLINKS|NO_MAGICLINKS|NO_XDEV) aftersetresuid, so the parents are searched as the tracked uid.parseShimArgsrequiresfilepath.IsLocal. The root-side refusals now share one text, so they no longer reveal which paths exist. proc logs: sanitized on a TTY, with--rawor piped output passing through, and documented in the help text.- relay audit:
process_startis audited by name only. list/logs/stop havecommandcleared before forwarding and never put it incmd. - nits: the leftover-uid wording (
uidsExhausted/processLimitError, plus the direct-client doc row).--tailand MCPtailare capped at 2^32−1, and MCP returns aToolInputError.trackedFromGuestdrops rows that break the guest's id/name/state rules, logs them quoted and clipped, andid=%q. The tool call's signal is threaded throughopen()andremint(), anduntilAbortedlets a joined mint keep running for the others.
One new suggestion (inline): LeaseCloseSyncTimeout's comment says Close finishes within the unit's stop timeout, but lease batches already on reclaimQ still drain afterwards with their own 30 s sync bound each.
Every new commit is signed off, and CI is green on 9fbce48 (17/17). This clears our CHANGES_REQUESTED.
Author: pdettori (MEMBER — maintainer)
Areas reviewed: Go (guestagent tracked table/shim, vmpool lease/pool/guestconn), TypeScript (mocactl proc/mcp/exec, sandbox-client tools, sandbox-relay caller), Docs (spec, security review, direct-client API). Incremental diff 84e241c..9fbce48 only.
Agent/IDE config (.claude/.vscode): none
Commits: 11 new (53 total), all signed-off: yes
CI status: passing (17/17)
| // that: it syncs its victims concurrently, waits at most this long for all of them, then | ||
| // destroys them all. A guest that has not answered by then loses its unsynced writes, | ||
| // rather than every lease after it in a loop losing theirs to systemd's SIGKILL. | ||
| const LeaseCloseSyncTimeout = 20 * time.Second |
There was a problem hiding this comment.
suggestion: the comment says Close "must sync and destroy within" the units' TimeoutStopSec=30, and that is now true for the leases Close detaches itself. But after this loop Close still runs close(p.reclaimQ); p.reclaimDone.Wait() (pool.go:1059). That drains every reclaim batch already queued, and each lease victim in it still syncs with its own LeaseEndSyncTimeout (30 s), in parallel within a batch but one batch after another.
Scenario: the lease ticker queues an idle or memory_reclaim batch with a wedged level-2 guest just before shutdown. Close spends up to 20 s on its own syncs, then waits up to 30 s more on the queued batch, so systemd SIGKILLs the group partway through. In the worst case the queued victim's VM is left to the next start's sweep.
Fix: have doReclaim use a closing context once p.closed is set (for example, share Close's bound, or cancel queued victims' syncs when Close starts). At minimum, say in the comment that queued sweep batches are outside the bound.
There was a problem hiding this comment.
Fixed in 3f5c495. Every lease-end sync now runs under a pool-wide syncCtx, and Close cancels it when closeSyncBound (20 s) has passed since it began. So a sweep or memory_reclaim batch already on reclaimQ shares Close's bound: its wedged sync is cancelled at the bound and reclaimDone.Wait() returns right after, instead of adding a further LeaseEndSyncTimeout. The comment on LeaseCloseSyncTimeout now says so. Pinned by TestCloseBoundsAQueuedSweepBatchsSync, which failed before the change (Close took 30 s) and passes now.
Every lease-end sync now runs under the pool's syncCtx, which Close cancels when its bound passes, so a queued reclaim batch with a wedged guest no longer adds a further LeaseEndSyncTimeout after Close's own syncs. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
Thanks for the follow-up and the approval. The one new suggestion (queued sweep batches outside One status note: the guest-agent root tests and the KVM gates have not been re-run since the review fixes. The rig was unreachable from this network when I tried. The changes that need a real guest are the eviction order, Assisted-By: Claude Code |
Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
|
Rig results for the review fixes (tree 8b78725, which is 3f5c495 plus a gate-test text update). Run on a KVM host with Firecracker, on a freshly built snapshot with
Two things came up on the way, neither a regression:
The live SBX0 smoke (step 9) still has not run. It waits on access to the SBX0 host. Assisted-By: Claude Code |
…te lifecycle stack Upstream main 0dc3d01 (API 1.21.0) carries the reviewed, final form of the features this branch held in early, integrated versions, through the PRs filed from this fork (rossoctl#755-rossoctl#776, rossoctl#781, rossoctl#782, rossoctl#784-rossoctl#786, rossoctl#789-rossoctl#794, rossoctl#798-rossoctl#800) and the maintainer's lease mode, grants and lease clients (rossoctl#763, rossoctl#802, rossoctl#807, rossoctl#808, rossoctl#810, rossoctl#812, rossoctl#814). Where upstream has a feature, upstream's version wins: its code, tests, openapi, CHANGELOG (byte identical), docs and specs. The fork was 736 commits behind and 390 ahead (merge base dd0ce71). Conflict resolution (148 files, 82 both-modified, 66 both-added): every conflicted file is upstream's side as is (byte identical to 0dc3d01). No conflicted file differs from 0dc3d01 in this commit. One file merged without a conflict and was set back to upstream's: - packages/mocactl/src/sbx/push.ts: the auto-merge added the fork's baselineAtHead a second time beside upstream's own (fb28e06's function, already upstream); upstream's file as is. With that, this commit's tree is 0dc3d01's plus the 18 files only the fork has (below). Every other file the fork changed is upstream's. Conflicted files, all resolved to upstream's side (0dc3d01): - deploy/k8s/overlays/ocp-combined/kustomization.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-addressing.yaml (AA) - deploy/k8s/overlays/ocp-combined/patch-relay.yaml (AA) - deploy/microvm/P4-ON-P6.md (UU) - deploy/microvm/build-rootfs.sh (UU) - deploy/microvm/build-snapshot.sh (UU) - deploy/microvm/setup-microvm.sh (UU) - deploy/microvm/tests/build-rootfs.test.sh (UU) - deploy/microvm/tests/build-snapshot.test.sh (UU) - deploy/microvm/tests/setup-microvm.test.sh (UU) - deploy/sbx/README.md (UU) - deploy/sbx/RUNBOOK.md (UU) - deploy/sbx/host-agent.sh (AA) - deploy/sbx/install-host.sh (UU) - deploy/sbx/sbx-host-agent-wanted.service (AA) - deploy/sbx/sbx-host-agent-wanted.timer (AA) - deploy/sbx/sbx-host-agent.service (AA) - deploy/sbx/[email protected] (UU) - deploy/sbx/setup.sh (UU) - deploy/sbx/template-onboarding/GUIDE.md (AA) - deploy/sbx/template-onboarding/ONBOARDING.md (AA) - deploy/sbx/template-onboarding/README.md (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.gate-record.json (AA) - deploy/sbx/template-onboarding/examples/django__django-11133.json (AA) - deploy/sbx/template-onboarding/governance/GATING-RULES.md (AA) - deploy/sbx/template-onboarding/governance/PROCESS.md (AA) - deploy/sbx/template-onboarding/governance/README.md (AA) - deploy/sbx/template-onboarding/template-build.sh (AA) - deploy/sbx/template-onboarding/template-register.sh (AA) - deploy/sbx/template-onboarding/tests/examples.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-build.test.sh (AA) - deploy/sbx/template-onboarding/tests/template-register.test.sh (AA) - deploy/sbx/template-onboarding/verify-provenance.py (AA) - deploy/sbx/templates-check.sh (AA) - deploy/sbx/tests/host-agent.test.sh (AA) - deploy/sbx/tests/install-host.test.sh (UU) - deploy/sbx/tests/overlay-combined.test.sh (AA) - deploy/sbx/tests/setup.test.sh (UU) - deploy/sbx/tests/templates-check.test.sh (AA) - deploy/vm/tests/setup-vm.test.sh (UU) - docs/api/CHANGELOG.md (UU) - docs/api/harness-openapi.yaml (UU) - docs/api/openapi.yaml (UU) - docs/concepts/sandboxes-and-tiers.md (UU) - docs/reference/change-policy.md (UU) - docs/reference/cli-mocactl.md (UU) - docs/reference/configuration.md (UU) - docs/reference/http-api.md (UU) - docs/sbx/user-guide.md (UU) - docs/specs/2026-10-15-sbx0-internal-sandbox-service-design.md (UU) - docs/specs/2026-10-30-session-sandbox-templates-design.md (AA) - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md (AA) - docs/specs/2026-11-05-combined-control-plane-design.md (AA) - docs/specs/2026-11-08-enrollment-and-roles-api-design.md (AA) - docs/specs/2026-11-08-sandbox-egress-records-design.md (AA) - docs/specs/2026-11-08-subject-trust-gate-records-design.md (AA) - docs/specs/README.md (UU) - harness/src/run-turn.ts (UU) - harness/src/sandbox-affinity.ts (UU) - harness/src/select-sandbox.ts (UU) - harness/test/select-sandbox-templates.test.ts (AA) - harness/test/turn-seed.test.ts (AA) - harness/test/turn-stream.test.ts (UU) - packages/control-plane/src/activation-lock.ts (AA) - packages/control-plane/src/activation.ts (AA) - packages/control-plane/src/egress-handlers.ts (UU) - packages/control-plane/src/egress-log.ts (AA) - packages/control-plane/src/errors.ts (UU) - packages/control-plane/src/exchange.ts (UU) - packages/control-plane/src/handler-util.ts (UU) - packages/control-plane/src/handlers.ts (UU) - packages/control-plane/src/host-handlers.ts (AA) - packages/control-plane/src/identity.ts (UU) - packages/control-plane/src/index.ts (UU) - packages/control-plane/src/main.ts (UU) - packages/control-plane/src/member-handlers.ts (AA) - packages/control-plane/src/members.ts (AA) - packages/control-plane/src/ownership.ts (UU) - packages/control-plane/src/provenance.ts (AA) - packages/control-plane/src/routes.ts (UU) - packages/control-plane/src/sandbox-config.ts (UU) - packages/control-plane/src/sandbox-handlers.ts (UU) - packages/control-plane/src/server.ts (UU) - packages/control-plane/src/template-catalog.ts (AA) - packages/control-plane/src/template-policy.ts (AA) - packages/control-plane/src/token.ts (UU) - packages/control-plane/test/activation.test.ts (AA) - packages/control-plane/test/egress-redis.test.ts (AA) - packages/control-plane/test/errors.test.ts (UU) - packages/control-plane/test/host-flow.test.ts (AA) - packages/control-plane/test/members.test.ts (AA) - packages/control-plane/test/openapi-contract.test.ts (UU) - packages/control-plane/test/provenance.test.ts (AA) - packages/control-plane/test/repository-allowlist.test.ts (AA) - packages/control-plane/test/route-authz-enumeration.test.ts (UU) - packages/control-plane/test/route-profile.test.ts (UU) - packages/control-plane/test/routes.test.ts (UU) - packages/control-plane/test/sandbox-egress.test.ts (AA) - packages/control-plane/test/sandbox-handlers.test.ts (UU) - packages/control-plane/test/session-templates.test.ts (AA) - packages/control-plane/test/subject-trust.test.ts (AA) - packages/control-plane/test/template-admin.test.ts (AA) - packages/control-plane/test/template-catalog.test.ts (AA) - packages/control-plane/test/template-create.test.ts (AA) - packages/knative-server/src/server.ts (UU) - packages/knative-server/src/turn-auth.ts (UU) - packages/knative-server/test/turn-auth.test.ts (UU) - packages/mocactl/src/api/errors.ts (UU) - packages/mocactl/src/api/frames.ts (UU) - packages/mocactl/src/cli.ts (UU) - packages/mocactl/src/core/session-manager.ts (UU) - packages/mocactl/src/core/session-options.ts (UU) - packages/mocactl/src/headless.ts (UU) - packages/mocactl/src/sbx/api.ts (UU) - packages/mocactl/src/sbx/call-record.ts (AA) - packages/mocactl/src/sbx/cli.ts (UU) - packages/mocactl/src/sbx/commands.ts (UU) - packages/mocactl/src/sbx/dry-run.ts (AA) - packages/mocactl/src/sbx/exec.ts (UU) - packages/mocactl/src/sbx/run.ts (UU) - packages/mocactl/src/sbx/templates.ts (AA) - packages/mocactl/test/contract.test.ts (UU) - packages/mocactl/test/harness.test.ts (UU) - packages/mocactl/test/headless.test.ts (UU) - packages/mocactl/test/helpers/sbx.ts (UU) - packages/mocactl/test/run-record.test.ts (AA) - packages/mocactl/test/sbx-admin-subjects.test.ts (AA) - packages/mocactl/test/sbx-cli.test.ts (UU) - packages/mocactl/test/sbx-egress.test.ts (AA) - packages/mocactl/test/sbx-exec.test.ts (UU) - packages/mocactl/test/sbx-templates.test.ts (AA) - packages/mocactl/test/session-manager.test.ts (UU) - packages/mocactl/test/session-options.test.ts (UU) - remote-worker/cmd/microvm-worker/main.go (UU) - remote-worker/cmd/microvm-worker/template_record.go (AA) - remote-worker/cmd/microvm-worker/template_record_test.go (AA) - remote-worker/cmd/microvm-worker/verify_cache.go (AA) - remote-worker/cmd/microvm-worker/verify_cache_test.go (AA) - remote-worker/internal/egress/audit_test.go (UU) - remote-worker/internal/session/labels.go (UU) - remote-worker/internal/vmpool/errors.go (UU) - remote-worker/internal/vmpool/guestconn.go (UU) - remote-worker/internal/vmpool/guestconn_test.go (UU) - remote-worker/internal/vmpool/launcher_firecracker.go (UU) - remote-worker/internal/vmpool/launcher_firecracker_egress_unix_test.go (UU) - remote-worker/internal/vmpool/snapshot.go (UU) - remote-worker/internal/vmpool/snapshot_test.go (UU) - remote-worker/internal/vmpool/verifycache.go (AA) Fork-only files, kept as they are (upstream has no such file): - deploy/sbx/mint-login.sh, deploy/sbx/tests/mint-login.test.sh: a test login minted with the deployment's signing key. Checked against upstream: makeSigner/mint, SANDBOX_API_ISSUER, the moca-mu1 Secret and its label, the env keys it reads and mocactl's sbx-auth.json shape are all still upstream's. - deploy/sbx/template-onboarding/deck/ (README, requirements, the two generators, deck_kit.py, the two PDFs, .gitignore): the fork's decks. - deploy/sbx/template-onboarding/GUIDE.pdf: regenerated from upstream's GUIDE.md in a later commit. - deploy/sbx/template-onboarding/governance/GAPS-AND-ASSUMPTIONS.md and INVENTORY-2026-11-02.md: the fork's register and inventory. - docs/specs/2026-11-09-cold-start-pacing-design.md, 2026-11-09-memory-aware-placement-design.md and 2026-11-10-mocactl-template-commands-design.md: the fork's design notes; upstream folded their content into its lifecycle spec (§6.4 memory, §6.5 pacing) and the user guide (mocactl). - docs/tools/gen_pdf.py, docs/tools/gen_toc.py: the PDF and TOC tools. Fork-only behaviour, decided one by one (from git log 0dc3d01..f125c02 --no-merges, checked against 0dc3d01): Ported onto upstream's code, each in its own commit after this one: - The pinned-session retire guard (c571226): a retire is refused (409 build_in_use) while an active Moca Pi session is pinned to the build. Upstream's buildsInUse checks live sandboxes only and its comment says pinned sessions are still to be checked. - Reuse only while a host holds the snapshot (G29, 521efe5): upstream reuses any registered build with the same inputs; its own lifecycle spec (§4, Reuse) says a registered build is reused only while a host reports holding its snapshot. - install-host.sh --uninstall-shared and the mounted legacy jail guard (5e66397): upstream has neither. - GUIDE §4b.4's base example without skip_git_identity_check (f125c02): upstream applies X12 under every profile, so its example create would be refused. - Links from upstream's READMEs to the fork-only files above. Dropped, because upstream's design replaces them on purpose: - Removal of admin-rejected builds: upstream stops them and never removes them (the user's decision in rossoctl#786). - The harness-profile catalog's fallback to SH_SESSION_TEMPLATES (902255b): upstream serves the harness profile the store's templates only (its test was renamed so); a combined plane is unaffected. - The fork's register ids (G-numbers), window dates and results pointers inside the documents upstream now has (RUNBOOK, README, GUIDE, ONBOARDING, PROCESS, GATING-RULES, P4-ON-P6, the specs): upstream's text wins; the fork's own documents above keep them. - The fork's image-builder-specific wording in GATING-RULES.md: upstream's generic wording (the image builder) is taken as is. Dropped, could be re-proposed (no upstream equivalent, but the port is an API change or its intent upstream is unclear): - TurnPlacement.template, a turn result naming the session's sandbox template (9d6004d): a harness API field; upstream's CHANGELOG is kept byte identical. - An imported build's catalog entry and create record carrying the declared seed (20d0995): sessions are seeded the same (upstream falls back to the declared seed); only the field in the catalog API goes. - mocactl: sbx create --seed checking the seeded HEAD against the spec's baseline_commit; activate --wait stopping at once on not_held or memfile_mismatch; ApiError's readiness, readinessReason and queuePosition in refusals; an admin write refused when the control plane URL came only from the login; the admin-write issuer check for the combined profile; the dry run's X1.offline check and its guest_mb and git-less advice; the quota, policy and build lines' extra fields (quotaSource, selfAttest, allowedRepositories, heldBy, attestation). Upstream's reviewed client (rossoctl#767, rossoctl#768) left them out; the server still enforces every rule. Already upstream (not lost): build reuse (G21), the verify cache, the host agent's --keep-shared removals, read-ahead, the hash_version 2 check in the microVM worker, M7, G39, G42, G43, G48, G49, G50, mocactl --record, --version, the minted login's own control plane, activate --wait sizing, and every other fork feature listed in the task. The relay's per-client tokens: not on this branch (the fork's sandbox-relay main.ts is older upstream code), so nothing to resolve. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Sixteen ADRs still said Proposed although their decisions are in code on main. Each status line now names the merged PRs that implemented it and the date the core landed (format of ADR-0042), and notes what is still owed where only part is built: - 0028 (rossoctl#170, rossoctl#201, rossoctl#340; its KEDA transport removed by ADR-0041) - 0029 (rossoctl#171), 0030 (rossoctl#214), 0031 (rossoctl#214, rossoctl#225) - 0032 (rossoctl#249, rossoctl#350, as amended by MI1) - 0035 (rossoctl#251; ADR-0048 adds lease mode beside it) - 0036 (rossoctl#347), 0038 (rossoctl#458), 0039 (rossoctl#467), 0040 (rossoctl#481) - 0043 (rossoctl#560, rossoctl#588, rossoctl#600, rossoctl#615), 0044 (rossoctl#563), 0045 (rossoctl#620) - 0046 (phase 1: rossoctl#630, rossoctl#641, rossoctl#646; phase 2 owed) - 0047 (M1 and M3: rossoctl#704, rossoctl#713, rossoctl#717, rossoctl#765; M2 owed) - 0048 (rossoctl#706, rossoctl#763, rossoctl#802, rossoctl#808, rossoctl#814; off by default until the security review's lease sections are signed off) The README index follows, and its 0033 row, which still said Proposed after rossoctl#249 accepted the ADR, is corrected. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Summary
This is plan 5 of SBX lease mode: level 2,
lease+processes, the tracked processes of spec §7. Aprocess_startsurvives between Execs. Background processes started any other way (&,nohup,setsid) still die at the end of their Exec, as at level 1. Spec:docs/specs/2026-11-08-sbx-lease-mode-design.md. It is built on plans 2–4 (#763, #802, #808).Level 2 stays off.
SH_SANDBOX_MODES_ALLOWEDdefaults toper-exec, and no default changes here.docs/sbx/security-review.md§7, "Lease mode, level 2", is a DRAFT that needs the security owner's sign-off beforelease+processescan be allowed.What it adds
ExecKind(COMMANDis 0 and stays the default);process_start,process_list,process_logsandprocess_stop;Exec.kindandExec.process(ProcessArgs);TrackedProcess;LeaseEvent.tracked, and theprocesses_stoppedstate;LeaseStatus.processes(the full table) andLeaseStatus.stopped.tracked/p<id>cgroup, under a fresh uid from 20000–20003 in groupsbx-ws, with HOME/tmp/sbx-proc/<uid>and a 4 MiB ring log.openat2 RESOLVE_BENEATH, and the shim changes into it withfchdirafter the privilege drop.process_stopsends TERM, then runscgroup.killafter 10 s.process_stop_allis host-only.lease-processes-v1feature, sbxp0..3 identities, and a cgroup.kill probe, all on Firecracker only.worker_restart, and refreshed from the lease end's guest sync;cd/synctemplate;teardown_failedandsandbox_deleted.sbx:lease-processes-v1in Hello.lease+processestoken, and only to a worker that advertises the capability. That makes "compat first" hold under worker version skew;kindandprocess, with no command text.SandboxExecConn.process();lease+processes, withtools/list_changedwhen the mode changes;processes_stoppednotice. The static Go client has an identical copy of it;sbx proc start|ls|logs|stop;modeprints the level 2→1stopped …line;getlists the processes;TrackedProcessand a mixed-version note;Testing
go test ./...(15 packages);-raceon vmpool, session and guestagent; vet on darwin and linux.make typecheck;setup.test.sh,smoke.test.shandinstall-host.test.shunder bash 5 and 3.2;make check-links; pre-commit.-run TestGate), the new level-2 halves andTestGateLeaseProcessLifecycleincluded: 76 PASS, 0 FAIL, 0 SKIP, on a snapshot withlease-v1andlease-processes-v1.process_start, which reported the wrong pid, showedexited(137)for an OOM, and ignored the cwd. Both are fixed and pinned.Merge note
upstream/mainis merged in twice: d227d41, then 906482c. Three conflicts were resolved:deploy/sbx/setup.sh: the combined-profile variables from main, plus this branch'sREINSTALL_SETTINGS;remote-worker/cmd/microvm-worker/main.go: main'sWithBuild(Labels(...)), plus this branch's P5-R37 comment;packages/mocactl/src/sbx/cli.ts: main's templates comment, plus this branch's proc-flag check.The affected suites were re-run on each merge (Go, relay, sandbox-client, k8s-sandbox, control-plane, the touched mocactl files, typecheck, and the setup, install-host and smoke shell tests). The KVM rig run predates the merges. Main changed nothing in the guest agent or vmpool.
Review notes
The decisions taken during the build (rulings P5-R1..P5-R40) are reflected in the spec's "as built" text. The ones that change visible behaviour:
p<id>;set_modeanswer only;processes_stoppednotice instead.Assisted-By: Claude Code