Repository navigation
Description
Summary
P6 already has a production deployment story with no Kubernetes: deploy/vm/setup-vm.sh installs sh-supervisor and sh-relay as systemd units (bare node --import tsx processes) with Redis and the sandbox containers run via podman alongside them (deploy/vm/README.md:1-11). That path requires root, systemd, a harness system user, and a built checkout on the target machine — reasonable for a dedicated VM or bare metal, wrong for "let me try this on my laptop in five minutes."
This issue adds a second, additive deployment path — deploy/compose/ — that runs the same three long-running components (supervisor, relay, redis) via Docker Compose, fronted by a curl | sh-style bootstrap script, for the dev-machine trial case described in the RA1 rearchitecture design (docs/specs/2026-09-24-ra1-density-cutover-and-repo-rearchitecture-design.md). It does not replace or modify deploy/vm/, which remains the production path.
Compose is the right tool here specifically because P6 is already "no Kubernetes" and substrate-neutral below the process-manager line (P6 spec §2.1) — this issue containerizes processes that already run as bare processes (or podman, for Redis) in deploy/vm/, it does not re-architect anything.
The one hard constraint — read before writing the compose file
sh-supervisor spawns its worker pool with child_process.fork() (packages/supervisor/src/main.ts:58, packages/supervisor/src/pool.ts:145,327). fork() creates a child of the calling process, in the same PID namespace — it cannot create a process in a different container. This is also why ADR-0034 describes accepted-socket handoff as IPC between supervisor and worker, not a network call.
Consequence: the supervisor and its entire worker pool (SH_WORKERS processes) must run inside one container. Do not attempt "one worker per container," a sidecar-per-worker pattern, or anything that tries to scale W by adding containers — W is scaled via SH_WORKERS inside the single supervisor container, exactly as it is today on the VM path. If more throughput is wanted than one container's CPU allocation supports, scale by running additional replicas of the whole supervisor container (each an independent supervisor with its own worker pool, its own port, behind whatever fronts them), not by decomposing one supervisor's pool.
This depends softly on #341 (fixing SH_WORKERS's cgroup-blind default) — until that lands, operators must set SH_WORKERS explicitly in the compose file rather than relying on the auto-detected default to respect deploy.resources.limits.cpus. Not a hard blocker; just don't assume the default is container-aware yet.
Deliverables
deploy/compose/docker-compose.ymlwith three services:redis(official image, matching whateverdeploy/vm/setup-vm.sh'sstart_redis()pins)sandbox-relay(frompackages/sandbox-relay), env mirroringdeploy/vm/env/relay.env.example(SH_RELAY_PORT,REDIS_URL,SH_RELAY_TOKEN)supervisor(frompackages/supervisor), env mirroringdeploy/vm/env/supervisor.env.example(SH_WORKERS,SH_TURNS_PER_WORKER,SH_ROUTING_POLICY,SH_SANDBOX_DISCOVERY=records,SH_REMOTE_SANDBOX=1,SH_RELAY_ADDR,REDIS_URL,KAGENTI_SANDBOX_POOL_SELECTOR,KAGENTI_SANDBOX_CAP) — noteSH_RELAY_ADDRmust point at thesandbox-relayservice name, not127.0.0.1, since these are now separate containers on a compose networkSH_RELAY_PORT(relay's bind port) and the supervisor'sSH_RELAY_ADDRport must still agree, same footgun therelay.env.examplecomment already flags for the VM path
- A Dockerfile (or a multi-stage Dockerfile with per-package targets) building
packages/sandbox-relayandpackages/supervisor— needspi-forkbuilt first per the existing prerequisite (deploy/vm/README.md's "Prerequisites"); decide at implementation time whether the image build does this or requires a pre-built context deploy/compose/install.sh: acurl -fsSL .../install.sh | sh-style bootstrap that fetches the compose file + a generated.env(prompting for/generatingSH_RELAY_TOKEN, since relay token validation is fail-closed perrelay.env.example) and runsdocker compose up -ddeploy/compose/README.mddocumenting the trial flow, explicitly cross-linking todeploy/vm/README.mdas "the production path" so the two don't get confused
Test plan (write these first, mirroring deploy/vm/tests/setup-vm.test.sh's approach)
- A mocked test for
install.shin the same style assetup-vm.test.sh: mockdocker/docker composeontoPATH, source or run the script, assert on recorded argv and generated.env/compose file content — in particular assertSH_RELAY_TOKENis passed by env/file, never appears in argv (same secret-handling checksetup-vm.test.shdoes forSANDBOX_TOKENviaMOCK_ENV_LOG) - A static check on
docker-compose.ymlthat there is exactly one service definition owning the supervisor's worker pool (i.e., the compose file itself can't regress into a per-worker-container topology) — e.g. assert there's onesupervisorservice and no per-worker replica count applied to it that the fork()-based pool doesn't itself manage - If Docker is available in CI/dev sandbox: an end-to-end smoke test —
docker compose up -d, poll the supervisor's health/admin port, confirm it reportsworkers > 0, confirm a trivial turn reaches the relay and Redis,docker compose down. Gate this behind an env var the wayM3_LIVE_SMOKEgates other live tests (per this repo's Testing conventions), since it needs Docker on the runner.
Acceptance
-
deploy/vm/is untouched -
deploy/compose/docker-compose.ymlruns supervisor+worker-pool as one service/container; no per-worker container scheme - Env surface mirrors
deploy/vm/env/*.env.examplevar-for-var, with only the addressing changed (service names instead of127.0.0.1) -
install.shnever putsSH_RELAY_TOKENon a process argv; mocked test proves it -
deploy/compose/README.mdcross-linksdeploy/vm/README.mdand states which path is for production vs. trial - A real
docker compose up(manual or gated smoke test) reaches a working/turnagainst a stub sandbox
Out of scope
- The P4 (Firecracker/KVM) tier — stays bare-metal/systemd-only; not part of this issue
- Any change to
SH_WORKERS's default-detection behavior — tracked in supervisor: SH_WORKERS default reads host CPU count via cpus().length, blind to container/cgroup CPU limits #341 - Kubernetes/Knative deprecation — unrelated, tracked in the RA1 plan
Related: P6 spec (docs/specs/2026-09-08-p6-vm-process-manager-design.md), ADR-0034, deploy/vm/README.md, RA1 design (docs/specs/2026-09-24-ra1-density-cutover-and-repo-rearchitecture-design.md), #341.
Activity
test(compose): keep install.test.sh off the host's real docker (#342)
Merge pull request #345 from rossoctl/feat/342-compose-trial
feat(deploy): add a Docker Compose trial path for the P6 runtime (ros…