Repository navigation
feat(microvm): P4 microVM worker on P6 — installer, rootfs recipe, first real turns (#369) - #376
Conversation
The 30-minute default reclaims an idle interactive session's workspace (rossoctl#338). Unset keeps the default; Normalize still enforces StandbyIdle < WorkspaceIdle. Refs rossoctl#369, rossoctl#338 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…n rootfs Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Reads P6's installed relay.env, generates a per-sandbox relay token once, and wires the relay and worker with drop-ins so no P6-owned file is edited. Refuses while container sandboxes are attached (P4-only host). Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
One always-on line per Exec, without the command text, so the journal shows which session's workspace each tool call used and which microVM ran it. The test binary defaults the line to a no-op: its volume starved a wall-clock socket-poll test. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…e run Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…recovers a failed worker - p4-turn-smoke.sh creates sessions by omitting sessionId (a made-up id is a 404), reads tool output from the response text, and makes every negative check depend on the turn's response being present. Failure path 2 kills the Running VM (Firecracker GET /), not the newest process. - mock-anthropic.mjs puts the tool results into its final text, the only part a non-streaming /turn returns. - setup-microvm.sh starts a stopped or failed worker on re-run, clears the worker's presence record before starting it, and counts stopped sandbox containers (podman-restart brings them back at boot). - p4-turn-smoke.test.sh runs the driver against a mock of the /turn contract. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…r host The shipped unit budgets 24 GiB and asserts >=23G, so it refuses on a 16 GiB host. The option writes a drop-in with a smaller SH_MAX_COMMITTED_MB and a matching AssertMemory (90% of the budget, the band the shipped unit is held to); unsetting it removes the drop-in. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Adds deploy/microvm/P4-ON-P6.md (P4-only host, snapshot recipe, installer, turns, automated check, workspace lifetime, verified/not verified from the 2026-09-30 KVM rig run, limits, uninstall) and the pointer to it from deploy/vm/README.md. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…e; runbook corrections - The AssertMemory= reset in 60-moca-memory.conf clears every Assert*= of the unit, the /dev/kvm guard included (checked on the rig). The drop-in now re-states the shipped unit's other assertions after the reset. - MICROVM_MAX_COMMITTED_MB refuses a leading zero, which bash would read as octal while Go reads decimal. - P4-ON-P6.md: an exposure warning where unauthenticated /turn is introduced, with the commands to turn auth off and back on; the control-plane note on the P4-only step; a sudo PATH note; corrected verified rows; the smoke settings via EnvironmentFile; an explicit rootfs --image; an uninstall that removes the key files and warns it deletes session data. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
…flags - setup-microvm.test.sh read modes with `stat -f %Lp || stat -c %a`. On GNU stat, -f is FILESYSTEM status and succeeds, so the fallback never ran and CI saw a filesystem report instead of 600. Try GNU stat first. - build-rootfs.sh: `[ ] && [ ] || usage` becomes an if (SC2015, flagged by CI's shellcheck; build-rootfs.test.sh runs shellcheck at every severity). - setup-microvm.test.sh: its assertion loop reads lines via process substitution (SC2013), keeping check()'s counter in the test's shell. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
0058a6c to
f471b1f
Compare
mrsabath
left a comment
There was a problem hiding this comment.
Reviewed the installer, the rootfs recipe, the turn driver, the vmpool/microvm-worker Go changes, the mock model and the runbook. All 13 CI checks green, including shellcheck, deploy-scripts, microvm-gates, CodeQL and Trivy.
No must-fix issues. Two non-blocking comments inline.
What I checked and found clean
- Secret handling in the installer. Token generated once from
/dev/urandomand length-validated; both env files land at0600;render_envstages underumask 077. The relay's file is rendered from scratch rather than merged, with the right reason stated — a changedMICROVM_SANDBOX_IDmust not leave the old id's token still valid at the relay. The tests assert the worker env carries neitherMOCA_RELAY_EXEC_TOKENnorSH_RELAY_TOKEN*, and that P6'srelay.envis untouched. - The "never logs the command" claim, which is the security assertion this PR rests on.
execLogomits the command andTestRunnerLogsTheWorkspaceKeyAndVMOfEveryExecpassesCommand: "echo SECRET-VALUE"then asserts the line does not contain it — a real guard, not a decorative one.WorkspaceKeygoes through%q, so a hostile session id cannot break journal parsing. The no-VM path is covered separately. poolConfig's newSH_WORKSPACE_IDLEblock. Traced all four branches against the first-error-wins idiom the five knobs above it use: consistent, and an invalid value cannot fall through to a zeroWorkspaceIdle.Normalizestill enforcesStandbyIdle < WorkspaceIdle, and the refusal cases (8,soon,0s,-1h) are each tested.- The
AssertMemory=reset. The empty-value reset clears every assertion, and the script re-states the others by reading them out of the shipped unit rather than hardcoding them — so the/dev/kvmguard survives, and a newly added assertion is carried too. mktempinrender_env. Checked whether the token could transit a default-umask temp file:mktempis 0600, andSANDBOX_TOKENuseskeepmode, whichcontinues before theawk/mktemppath is reached. No exposure.absent()in the smoke driver. Verified the proof string is not vacuous by tracing the mock'splan()/reply()state machine: on a failed tool call the harness still feeds atool_resultback,stepadvances, and the final text isdone-sleep\n<error>. So the proof holds andsleptis absent only when the sleep genuinely did not finish. The helper's doc comment explaining why the proof argument exists at all is the right instinct.start_workerordering. The presence record is cleared before the start, soverify_attachedcannot be satisfied by a stale record from a previous connection — exactly the token-mismatch silent failure the check exists for. The stop→HDEL→start ordering is pinned.- Idempotency.
install_if_changed/commit_envonly touch files whose content differs, andrender_envreplaces values in place rather than delete-and-append, so an unchanged re-run does not reorder the file. The suite asserts a byte-identical tree and zerodaemon-reload/restarton re-run. build-rootfs.shonly reads the image (podman create+export, container removed viatrap), refuses a non-empty--out, strips the inertremote-workerbinary from the guest tree, and records image + digest provenance.- Security sweep — no hardcoded secrets (the only literal is
mock-not-a-secret), nocurl | sh, noeval, no unpinned action refs. The runbook explicitly warns thatANTHROPIC_BASE_URLwould send the key to a third party and thatANTHROPIC_AUTH_TOKENstripsx-api-key; that hazard is usually left implicit. - Commits — 12, all signed off, conventional prefixes, every subject within 72 characters.
Notes
- I could not run the tests. No clone of this repo was available to me, so I reviewed the diff and fetched files at
f471b1fthrough the API but executed nothing — themake test/go test/ six-suite claims are unverified by me. CI's owncheck,lint,shellcheckanddeploy-scriptsjobs are green, which covers more ground than I could. - The P4-only guard is install-time only, and deliberately so:
preflightrefuses while anysh-sandbox-*container exists, but nothing stops a latersetup-vm.shrun orpodman-restart.servicefrom reattaching the container tier afterwards. The script comment and the runbook's "A P4-only host" section both say this, and the PR body discloses it as gap 4 / decision T1. Noted only so the deferral is visible in the review record, not as something to fix here. - The
MICROVM_MAX_COMMITTED_MB > SHIPPED_RESERVE_MBguard is a good catch: a budget at or below the reserve admits nothing, so refusing early beats a worker that starts and silently accepts no work. - Of the untested items you list, the reboot is the one I would most want covered before this is relied on, since
podman-restart.serviceinteracts with the tier-pinning gap above.
Bel lavoro — the runbook's split between verified and not verified is what made this reviewable at this size.
| for t in "$@"; do printf '#!/bin/sh\n' >"$FIXTURE/usr/bin/$t"; chmod +x "$FIXTURE/usr/bin/$t"; done | ||
| printf 'bin\n' >"$FIXTURE/usr/local/bin/remote-worker"; chmod +x "$FIXTURE/usr/local/bin/remote-worker" | ||
| } | ||
| ALL_TOOLS=(bash git rg python3 base64 file ls cat) |
There was a problem hiding this comment.
suggestion — this list can drift from the Go source, which is the failure build-snapshot.test.sh (in this same PR) goes out of its way to prevent.
That suite parses var probed = []string{…} straight out of remote-worker/cmd/worker/main.go and asserts the guest probe covers every entry, so adding a tool to the container tier turns the test red instead of drifting silently. That is the right pattern.
Here, ALL_TOOLS is a hand-copied duplicate of the script's own REQUIRED_TOOLS, pinned to nothing. Add a tool to probed in Go and build-snapshot.test.sh goes red while build-rootfs.sh keeps passing and keeps producing a rootfs that lacks it — surfacing later as a failed tool call, which is precisely the outcome REQUIRED_TOOLS' own comment says it exists to prevent.
Reusing the extraction already written next door would close it:
container_caps="$(sed -nE 's/^var probed = \[\]string\{(.*)\}$/\1/p' \
"$DIR/../../remote-worker/cmd/worker/main.go" | tr -d '"' | tr ',' ' ')"then assert REQUIRED_TOOLS ⊇ $container_caps. A subset assertion rather than equality, since ls and cat are a deliberate superset for the harness's own file ops.
There was a problem hiding this comment.
Done in b1de35c. ALL_TOOLS is now read from the script's own REQUIRED_TOOLS instead of a hand-kept copy. A new block asserts REQUIRED_TOOLS ⊇ the probed list from cmd/worker/main.go, using the same sed extraction as build-snapshot.test.sh. It checks a superset, as you suggested, since ls/cat are there for the harness's file ops.
To confirm it catches drift, I ran it against a copy of build-rootfs.sh with rg removed from REQUIRED_TOOLS. It fails with REQUIRED_TOOLS includes 'rg' (want 'yes', got 'no').
| # <name>.txt (the response text), and prints nothing. | ||
| turn() { | ||
| local body | ||
| if [ -n "$2" ]; then body="{\"sessionId\":\"$2\",\"prompt\":\"$3\"}"; else body="{\"prompt\":\"$3\"}"; fi |
There was a problem hiding this comment.
nit — the prompt is interpolated into JSON unescaped.
Nothing is broken today: all three call sites pass bare literals (P4-SMOKE-WRITE, P4-SMOKE-READ, P4-SMOKE-SLEEP), none of which contain a quote, backslash or newline. So this is purely about the next prompt someone adds — one with an apostrophe produces malformed JSON and a 400 that looks like a server problem rather than a quoting problem.
The script already depends on node for json_field, so building the body correctly costs nothing extra:
body="$(node -e 'const [s,p]=process.argv.slice(1);
process.stdout.write(JSON.stringify(s ? {sessionId:s, prompt:p} : {prompt:p}))' "$2" "$3")"Entirely defensive — take it or leave it.
There was a problem hiding this comment.
Taken, in b1de35c. turn() now builds the body with JSON.stringify through node, which the script already needs for json_field. A prompt with a quote now encodes as {"prompt":"it's a \"quoted\" line"}. p4-turn-smoke.test.sh covers both body shapes, with and without sessionId, because its curl mock parses every body with JSON.parse.
…ON-encode turn bodies Review follow-ups on rossoctl#376: - build-rootfs.test.sh reads REQUIRED_TOOLS from the script instead of a hand-kept copy, and asserts it covers cmd/worker's probed list, the way build-snapshot.test.sh pins the guest probe. - p4-turn-smoke.sh builds the /turn body with JSON.stringify, so a prompt with a quote, backslash or newline cannot produce malformed JSON. Refs rossoctl#369 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
Summary
VM demo D (#369, part of epic #370): the P4 Firecracker
microvm-workerinstalled next to a P6 host, attached to P6's relay under its own relay token, and serving real harness turns. Every tool call runs in a fresh microVM over a per-session workspace.Depends on #375. Without it, every tool call in a new session's first
/turnfails on this tier.What's in it
deploy/microvm/setup-microvm.sh: the sibling installer.relay.envand writes no P6-owned file. The relay gets the per-sandbox tokenSH_RELAY_TOKEN_<id>through a drop-in and a new env file.sh-sandbox-*container exists: the host is P4-only, see "Tier pinning".MICROVM_MAX_COMMITTED_MBsupports hosts smaller than the shipped 24 GiB budget. It re-states the unit's other assertions after resettingAssertMemory=.deploy/microvm/build-rootfs.sh: the rootfs recipe. It exports P6's own sandbox image as the golden rootfs, reading the image and never changing it.build-snapshot.sh's guest probe now checks the container tier's full capability set, pinned againstcmd/worker'sprobedlist.SH_WORKSPACE_IDLE, the P4 microVM tier: WorkspaceIdle=30min deletes a HITL session's workspace mid-session, silently #338 demo mitigation, onmicrovm-worker: unset keeps 30 minutes, and the installer writes8h.vmpool: exec req= workspace_key= vm= cold= exit= err=, never the command text. This is the acceptance evidence.mock-anthropic.mjs, a scripted loopback model, andp4-turn-smoke.sh, a turn driver with failure paths. The driver is tested against a mock of the real/turncontract.deploy/microvm/P4-ON-P6.md: the runbook, with verified and not verified from the rig run, the limits, and uninstall. A pointer is added fromdeploy/vm/README.md.Tier pinning (gap 4)
selectPoolSandboxleases the least-loaded of all presence records. It selects again every turn, and records carry no tier label, so with both tiers attached a session can hop tiers and lose its workspace.The decision was T1, a P4-only host. Per-session tier selection is a follow-up.
Verified on a KVM rig (2026-09-30)
m8i.xlargewith nested virtualisation, 16 GiB, Amazon Linux 2023, Firecracker v1.17.0. P6 came fromdeploy/vmbefore the control plane landed.nothing to change.base64 bash curl file git python3 rg.worker disconnected;vsock-short-response: vmpool: guest closed before End: EOF.workspace_key;uname -areadsLinux (none) 6.18.44+.Not verified:
mocactl run: it needs the control plane (VM demo A: run the MU1 control plane on deploy/vm (systemd unit, generated secrets) #366, now merged) on the rig.Limits, stated in the runbook:
Tests
make test,make typecheckandmake lintpass.go test ./...inremote-workerpasses.deploy/microvm/tests/*.test.shsuites pass: four new, two extended.Refs #369, #370, #338.
🤖 Generated with Claude Code