Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Part of the VM demo epic (#370). Item A: the other items depend on it.
Goal
sudo ./deploy/vm/setup-vm.sh should also install and start the MU1 control plane next to sh-supervisor and sh-relay, so that mocactl can log in and create sessions against a single P6 VM. Today that can't happen: deploy/vm has no control plane at all.
This is item 1 of #362, narrowed for the demo: the file credential store is the default, and Vault is an option documented as a follow-up.
Current state (verified on main @ 73f1bf4)
deploy/vm/systemd/holds onlysh-supervisor.service,sh-relay.serviceandmoca-sandbox-firewall.service, andsetup-vm.shinstalls only those.deploy/vm/env/supervisor.env.example:30-40carries the MU1 settings commented out:SH_SESSION_TOKEN_PUBLIC_KEYSSH_CONTROL_PLANE_URL=http://127.0.0.1:8090SH_EXCHANGE_TOKENSH_REQUIRE_AUTH=false
- The control plane is
packages/control-plane/src/main.ts, run asnode --import tsx src/main.ts.- It listens on
SH_CONTROL_PLANE_PORT(default 8080, which collides with the supervisor, so use 8090 as compose does). - It refuses to start without
SH_SESSION_TOKEN_PRIVATE_KEY,SH_GITHUB_CLIENT_ID,SH_CREDENTIAL_KEKandSH_EXCHANGE_TOKEN(main.ts:58-65). - Optional settings:
SH_PUBLIC_HARNESS_URL,SH_DEFAULT_INFERENCE_ENDPOINT,SH_ALLOW_OPERATOR_FALLBACKwithSH_OPERATOR_INFERENCE_TOKEN,REDIS_URL,SH_ADMIN_SUBJECTS, andSH_CREDENTIAL_STORE=kubernetes|file|vault(main.ts:88-132).
- It listens on
- Key generation:
packages/control-plane/src/genkeys.tsprints the four MU1 secrets on stdout. The private key and KEK go to the control plane, the public keyset to the supervisor, and the exchange token to both. - The model to copy is compose (feat: MU1 control plane in the compose trial, with file and Vault credential stores (#348) #364):
deploy/compose/install.sh:170-243generates the keys once and turns the profile on only whenSH_GITHUB_CLIENT_IDis set;deploy/compose/docker-compose.yml:113-156holds the control-plane service;deploy/compose/tests/compose.test.shhas the var-for-var mirror check.
- Precedent for secrets that are generated once and never rotated:
setup-vm.sh's handling ofMOCA_RELAY_EXEC_TOKEN(README "Bring it up", step 3). - Precedent for the Redis dependency: Redis already runs as a podman container published on
127.0.0.1:6379. - Session-scoped discovery:
/v1/sessions/{id}/resourcesshells out tokubectl(handlers.ts:389). On a VM it answers with an error shape. It must not crash anything, and mocactl should degrade gracefully. Check this.
Scope
deploy/vm/systemd/sh-control-plane.service, hardened like the others (User=harness,ProtectSystem=strict,NoNewPrivileges, …).WorkingDirectoryis the checkout'spackages/control-plane.StateDirectory=holds the file credential store (SH_CREDENTIAL_DIR).- The supervisor is ordered only
After=network-online.targettoday. Decide whether the control plane also needs Redis ordering (for exampleAfter=podman-restart.service), since it cannot serve without Redis.
deploy/vm/env/control-plane.env.example, with every setting documented.SH_CONTROL_PLANE_PORT=8090SH_CREDENTIAL_STORE=fileREDIS_URLSH_PUBLIC_HARNESS_URL: must be the harness URL as clients reach it, so the default is empty and required.SH_GITHUB_CLIENT_ID: its value is item B's concern, but the slot is here.
setup-vm.sh- Install the new unit and env file. Like the existing env files, an operator-edited file is never clobbered.
- Generate the MU1 secrets once, with
genkeys.tsrun by the checkout's own node. Write each half into the file that needs it: control plane orsupervisor.env. - A re-run never rotates them. A half-migrated pair of files stops with a message naming both.
- Uncomment and set the supervisor's MU1 lines and
SH_REQUIRE_AUTH=true. - Restart what it owns, using the same restart and try-restart rules as today.
- Decide and document: is the control plane opt-in (
SH_GITHUB_CLIENT_IDpresent, like compose), or always installed?
- Secrets custody: follow MI1 §6.7 ("secrets are files, never env vars") where it's cheap, meaning
LoadCredential=for the private key, KEK and exchange token. If the control plane can't read secrets from files yet, record that as a follow-up rather than blocking the demo, and say so in the README. - Network exposure: the supervisor (
0.0.0.0:8080) and the control plane speak plain HTTP.- Document the supported demo topology: an SSH tunnel from each user's laptop, or a cloud firewall allowlist.
- Say which ports clients need: the control plane, plus the harness via
SH_PUBLIC_HARNESS_URL. - TLS termination is out of scope, but state it as a limit.
- Tests: extend
deploy/vm/tests/setup-vm.test.sh:- the unit is installed;
- secrets are generated once and survive a re-run unrotated;
- both halves agree (the kid in the public keyset matches the private key);
- the migration path from an existing VM without a control plane works.
- Docs: add a
deploy/vm/README.mdsection, a "Upgrading an existing VM" note, and fixpackages/mocactl/README.md's troubleshooting text, which says the example does not include the MU1 vars.
Acceptance
- On a fresh VM, following the README's first-run flow (two invocations), all three units are active and
curl -s 127.0.0.1:8090/readyzsucceeds. mocactl --control-plane-url http://<vm-or-tunnel>:8090 doctorreports "harness located" and "harness trusts this control plane". It needs a token from item B, or the api token minted as indeploy/compose/smoke.sh:176-185, which is acceptable at this stage.- A re-run of
setup-vm.shleaves every secret unchanged. - An existing VM without a control plane upgrades by re-running
setup-vm.sh.
Out of scope
- Vault wiring (the rest of MU1 follow-ups from #348: VM control plane on Vault, dev identity provider, inference-credential binding #362 item 1).
- The dev identity provider (MU1 follow-ups from #348: VM control plane on Vault, dev identity provider, inference-credential binding #362 item 2).
- Grants and
MOCA_TENANCY(MI1 S2). - TLS.
References
docs/specs/2026-09-08-multi-user-control-plane-design.md(MU1)docs/specs/2026-09-28-moca-multi-user-isolation-design.md§6.6–6.7, §10.3, §15- MU1 follow-ups from #348: VM control plane on Vault, dev identity provider, inference-credential binding #362, feat: MU1 control plane in the compose trial, with file and Vault credential stores (#348) #364
Working conventions (for a fresh session)
- Workspace:
git fetch, then create a worktree fromrossoctl/main(never localmain), under.worktrees/. Populate and buildpi-fork(git submodule update --init --recursive && cd pi-fork && npm ci && npm run build), thenpnpm install. A worktree without the pi-fork build does not typecheck. - Plans: write the plan with
superpowers:writing-plansintodocs/plans/<date>-<slug>.md. Plans are gitignored and never committed. Write it in chunks, one append per task. Usedocs/plans/2026-09-28-mi1-s1-hardening.mdas the model for style and granularity, if you have it locally. - Pre-flight table: list every process entrypoint, systemd unit, env example and shell/Go launcher whose boot contract changes, not only TypeScript call sites.
- Tests: Redis on 6379 must be up. Use each package's own
node_modules/.bin/vitest. vitest can exit non-zero with every test green, so grep the log forErrors. Redirect long output to/tmp/kagenti/....make lintskips untracked files. - Commits:
git commit -swithAssisted-By: Claude (Anthropic AI) <[email protected]>, neverCo-Authored-By. - Shared KVM rig (
[email protected]): the owner runs tutorials on it. Alert the owner before using it, record a manifest of what you install, and verify cleanup. The rig's podman is a static build (Amazon Linux 2023 packages none). - Don't push or open PRs without the owner's go-ahead.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
fix(deploy/vm): name off-PATH tools; closing message follows the supe…
Merge pull request #374 from pdettori/feat/vm-control-plane