Repository navigation
fix(sandbox): boot the guest server via a launcher, not a CLI - #200
Merged
Merged
Conversation
First real VM boot (via script/e2e-vz.ts on macOS/arm64) surfaced that the
guest never served: the mounted bundle dist/node/node.js is a library
module (exports Server/Config/bootstrap), not a CLI, so `node node.js
serve ...` executed nothing and init exited, panicking the kernel.
- image/guest/server-launch.mjs: import the bundle and call
Server.listen({...}) with env-provided credentials/hostname/port —
the same entry the desktop sidecar uses. Baked at
/opt/codev-guest/server-launch.mjs; both providers run it.
- image/Dockerfile: install the two externalized bundle deps
(jsonc-parser, @lydell/node-pty) into /opt/node_modules so ESM
resolution finds them without touching the host bundle; add
busybox-static for a clean poweroff.
- boot.ts: sandboxBootEnv now carries CODEV_SERVER_HOSTNAME/PORT and
drops sandboxServeArgs; export SANDBOX_GUEST_LAUNCHER. Both providers
and the vz boot.json updated.
- codev-init: run the launcher, seed /etc/skel into the home, poweroff
via busybox with a sysrq fallback.
- build-image.ts: clear only *.zip from the office staging dir so its
tracked .gitignore/.keep survive a build.
Verified end-to-end: create -> codev-vmm boot -> kernel -> virtio-fs ->
launcher -> Server.listen -> vsock bridge -> authenticated /global/health
returns OK. 60 tests pass, typecheck clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to the image pipeline (#199): the first real end-to-end VM boot on macOS/arm64 (via
script/e2e-vz.tsagainst a locally built image) revealed the guest never actually served, and fixes it. The whole stack now boots green.The bug
The providers assumed the mounted server bundle (
dist/node/node.js) was a CLI with aservesubcommand — that's how the WSL sidecar works, because it installs the fullopencodeCLI binary. But the desktop app's bundle is a library module (export { Server, Config, bootstrap }), which the desktop boots by callingServer.listen({...})directly (packages/desktop/src/main/sidecar.ts). Sonode node.js serve --hostname … --port …imported the module, executed nothing, and exited 0 → init exited →Kernel panic - Attempted to kill init.The fix
image/guest/server-launch.mjs— a tiny guest launcher that imports the bundle and callsServer.listen({ port, hostname, username, password, cors:["oc://renderer"] })with values from the boot env, mirroring the desktop sidecar. Baked at/opt/codev-guest/server-launch.mjs; both the vz and bwrap providers run it instead of a fictional CLI.image/Dockerfile— install the two externalized bundle deps (jsonc-parser,@lydell/node-pty) into/opt/node_modulesso ESM parent-dir resolution finds them without modifying the host bundle (and node-pty's arch-correct prebuild comes via its optionalDependencies); addbusybox-staticfor a cleanpoweroff.boot.ts—sandboxBootEnvnow carriesCODEV_SERVER_HOSTNAME/CODEV_SERVER_PORTandsandboxServeArgsis gone; newSANDBOX_GUEST_LAUNCHERconstant. The vzboot.jsonand both providers updated to match.image/guest/codev-init— run the launcher, seed/etc/skelinto the guest home, andbusybox poweroff -fwith a/proc/sysrq-triggerfallback so the helper'sguestDidStopfires cleanly.build-image.ts— clear only*.zipfrom the office staging dir so its tracked.gitignore/.keepsurvive (a prior run had deleted them).Verification
Real boot, not a fake helper:
Chain exercised: image download → SHA-256 verify → unpack → COW disk clone →
codev-vmmboot → custom 6.6 kernel → virtio-fs mounts → launcher →Server.listen→ vsock↔loopback bridge → authenticatedGET /global/healthfrom the host. Built image sizes (arm64, base toolchain, no office layer):vz-arm64235 MiB,bwrap-arm64222 MiB compressed.bun test60 pass / 2 skip,bun typecheckclean.Notes
🤖 Generated with Claude Code