Repository navigation
Description
Summary
mocactl (PR #347) cannot be used with the Docker Compose trial deployment (deploy/compose/). The compose stack runs only the harness side: supervisor and workers, relay, Redis and one sandbox. It has no control plane, and mocactl needs one for login, sessions, credentials and session tokens.
Adding a control plane is more than one extra service. This issue lists every gap, most blocking first.
Gaps
1. No control-plane service in compose (blocking, small)
The harness image already contains packages/control-plane, so this is one service:
- on the shared Redis
- published on loopback only (e.g.
127.0.0.1:${SH_CP_PORT:-8090}), like the supervisor
2. The control plane can only store credentials in Kubernetes (blocking, the one real code change)
depsFromEnvwiresK8sSecretStore, which writes Kubernetes Secrets throughkubectl. The only otherCredentialStoreisInMemoryCredentialStore, for tests. Compose has neither Kubernetes norkubectl.- Needed: a
CredentialStorethat doesn't need Kubernetes, selected by configuration. It should reuse the existing envelope encryption (envelope.ts,SH_CREDENTIAL_KEK).- File store on a named volume (recommended): credentials survive
docker compose down. - Redis store: simpler, but compose's Redis has no volume, so a
downwipes every user's credentials.
- File store on a named volume (recommended): credentials survive
- It must keep the store's invariants: exact-name lookup only, and a list that decrypts nothing (
credential-store.ts, spec §6.5). - Not blocking: the
/v1/sessions/{id}/resourcessandbox lookup also useskubectl, but it degrades gracefully andmocactlnever calls it.
3. The supervisor lacks the MU1 auth settings, so every mocactl turn fails (blocking)
- Settings to add:
SH_SESSION_TOKEN_PUBLIC_KEYS,SH_CONTROL_PLANE_URL=http://control-plane:8080,SH_EXCHANGE_TOKEN,SH_REQUIRE_AUTH. - Why turns fail rather than degrade:
resolveTurnAuth(packages/knative-server/src/turn-auth.ts) rejects a present-but-invalid token even withSH_REQUIRE_AUTH=false.mocactlalways sends a session token, so turns fail withtoken_invalidrather than falling back to the operator's key.mocactl doctorcheck 7 reports exactly this. - Fix the VM env too: the compose environment mirrors
deploy/vm/env/*.env.examplesetting for setting, anddeploy/compose/tests/compose.test.shenforces that. So the fix belongs indeploy/vm/env/supervisor.env.exampleas well. The P6/VM path has this same gap today.
4. install.sh must generate the new secrets (blocking)
It already generates SH_RELAY_TOKEN into .env (mode 0600, written once). It would also need to write:
- an ed25519 signing key (
SH_SESSION_TOKEN_PRIVATE_KEY), with its public half published to the supervisor asSH_SESSION_TOKEN_PUBLIC_KEYS(kid:base64-DER) SH_CREDENTIAL_KEK(32 random bytes, base64)SH_EXCHANGE_TOKEN
It shouldn't assume openssl exists on the host; node inside the image can generate all three. tests/install.test.sh must cover them, including the rule that a re-run never overwrites them.
5. Addressing: set the advertised harness URL
Discovery (GET /v1/discovery, PR #347) makes this one setting on the control plane:
SH_PUBLIC_HARNESS_URL=http://127.0.0.1:${SH_PORT:-8080}
That is the harness as the user reaches it. The supervisor reaches the control plane by service name (item 3). The user then gives mocactl a single URL, http://127.0.0.1:8090.
6. Login requires a GitHub OAuth app (needs a decision)
Device-flow login needs SH_GITHUB_CLIENT_ID, from an OAuth app with device flow enabled (it is off by default), plus internet access. That is real friction for a "five-minute trial". The options:
- (a) Document the one-time app registration and pass the client ID through
install.sh. - (b) Add an opt-in, loopback-only, single-user development identity provider for trials.
(b) is security-sensitive. It must never be the default, it must refuse to start on a non-loopback bind, and it needs its own ADR.
7. Model credentials change hands
- Today: compose passes the operator's
ANTHROPIC_API_KEYstraight to the workers. - Under MU1: each user stores their own inference credential, which
mocactlonboarding prompts for. - To keep a one-key trial: compose can set
SH_ALLOW_OPERATOR_FALLBACK=true,SH_OPERATOR_INFERENCE_TOKENandSH_DEFAULT_INFERENCE_ENDPOINTon the control plane. The README must say what that fallback means: every user spends the operator's key.
Already fine
- Streaming: SSE through the supervisor's socket handoff is integration-tested (
packages/supervisor/test/handoff.integration.test.ts). - Same handler: the supervisor serves
POST /v1/turnandGET /healthwith the same handler as the Knative path. - Not yet exercised:
deploy/compose/smoke.shonly calls plain/turn. The acceptance criteria below add/v1/turnstreaming.
Acceptance criteria
-
install.shbrings up the stack with a control plane, andmocactl --control-plane-url http://127.0.0.1:8090needs no other URL. Doctor reports "harness located — http://127.0.0.1:8080 (advertised by the control plane)". -
mocactl login→mocactl doctorpasses all 7 checks →mocactl run "hello"streams a reply. - A stored credential survives
docker compose down && up(if the file store is chosen). -
compose.test.shandinstall.test.shcover the new service, settings and generated secrets.deploy/vm/env/*.env.examplecarries the MU1 settings. -
smoke.shexercises an authenticatedPOST /v1/turnwithAccept: text/event-stream.
Related: #347 (mocactl, GET /v1/discovery).
Activity
pdettori commentedon Sep 29, 2026
The multi-user isolation design (MI1) is now public in #350:
docs/specs/2026-09-28-moca-multi-user-isolation-design.md. Its §10.3 covers this issue.This issue's goal and most of its items stand. Four things change:
moca-brainnetwork only, never the sandbox network. fix: MI1 S1 — multi-user isolation hardening (R1–R8) #350 already splits compose intomoca-brain(Redis, supervisor) andmoca-sandbox(sandboxes), with only the relay on both.install.shshould write the session-token signing key, the KEK and the exchange token to files mounted as composesecrets:(mode 0600), not into.env. It should be structured so the later slices' keys can slot in next to them: the grant key ring,moca-egress's client credential, and per-sandbox tokens. The relay exec token that fix: MI1 S1 — multi-user isolation hardening (R1–R8) #350 adds (MOCA_RELAY_EXEC_TOKEN) is an environment variable for now and moves to a file with MI1's slice S2.MOCA_TENANCY=single. Item 7 (users' own inference credentials in direct mode, plus the operator fallback) is safe there because the control plane pins the first subject that creates a session and refuses any other with403 single_tenant_deployment. Multi-user compose arrives with MI1's slices S2 and S5.SH_EXCHANGE_TOKENto the worker environment, so it should land with or after fix: MI1 S1 — multi-user isolation hardening (R1–R8) #350, never before: fix: MI1 S1 — multi-user isolation hardening (R1–R8) #350 makes sandbox commands receive an explicit environment allowlist instead of the worker's environment.Two more points:
MOCA_TENANCY=multi.CredentialStore, is what MI1's slice S2 (grants and the token endpoint) builds on, so it is on MI1's critical path.fix(turn-stream): a turn that stops with pi's 'stop' or 'length' ends…
feat(control-plane): file and Vault credential stores, selected by SH…
feat(deploy/compose): add the MU1 control plane so mocactl works (#348)
Merge pull request #364 from pdettori/fix/348-compose-control-plane