Repository navigation
Description
Part of the VM demo epic (#370). Item C: depends on A (#366). It can be developed against minted tokens before B's (#367) real logins exist.
Goal
A logged-in user's turn on the P6 VM:
- reaches a real model with that user's own inference credential (or a deliberately enabled operator fallback);
- runs
curlandgitin the container sandbox to research live internet content, and answers from it.
This issue owns the "running commands on the sandbox like curl and git to research internet content" part of the demo, and item 3 of #362.
Current state (verified on main @ 73f1bf4)
How a per-user credential reaches the model
- A user stores a credential with mocactl's credentials overlay (
packages/mocactl/src/views/overlays/Credentials.tsx:79), which sendsPUT /v1/credentials/{name}.- Kinds are
bearer,basic,api-keyandoauth2-token(packages/control-plane/src/credential-store.ts:80-103). - An inference credential must be a single-field kind (
:176). - The descriptor carries a
binding(:28,:189) that nothing on the inference path uses.
- Kinds are
- At turn time the exchange (
packages/control-plane/src/exchange.ts:115-150) resolves the endpoint: the credential's own, elseSH_DEFAULT_INFERENCE_ENDPOINT, else it fails withendpoint_unresolved.- It picks
mode = injectorConfigured ? 'placeholder' : 'direct'. - In direct mode (the VM today) it returns the user's real secret to the worker.
- It picks
applyModelGateway(harness/src/run-turn.ts:504-560) always sends that secret asAuthorization: Bearer, stripsx-api-key, and applies only on theanthropic-messagespath. A per-user credential on any other API fails the turn, by design (MI1 §5 R2).
What that means in practice
- Works: a LiteLLM-style gateway token over Bearer. That's what the Compose deployment: add a control plane so mocactl works (credential store without Kubernetes, MU1 auth wiring) #348 live smoke used.
- Probably broken: a raw Anthropic API key (
sk-ant-api…) sent toapi.anthropic.com, which expectsx-api-key. The likely result is an opaque 401. Not verified yet: verify first. - Operator fallback:
SH_ALLOW_OPERATOR_FALLBACK=trueplusSH_OPERATOR_INFERENCE_TOKENon the control plane lets a user with no credential spend the operator's. It's audited asoperator_fallback_used.
The sandbox side is ready
- Image:
remote-worker/Dockerfile(ubi9-minimal) installsgit,bash,python3andrg.curland ca-certificates are expected from the base image but aren't installed explicitly, so confirm withpodman run --rm ghcr.io/rossoctl/moca-remote-worker:latest curl --version, and add them explicitly if absent.- The image runs as
USER 1001with/workspacewritable. - uid 1001 has no passwd entry, so
HOMEis probably/:git cloneworks, butgit config --globalfails unlessHOMEis set.
- The image runs as
- Tools: the agent's bash tool runs arbitrary commands (
packages/k8s-sandbox/src/extension.ts:71-72,operations.ts:103-105,remote-worker/internal/exec/runner.go:189), with no allowlist.- The seam caps output at 8 MiB (the command is killed with exit 137).
- Pi shows the model only the tail of output, 2000 lines or 50 KB (
pi-fork/packages/coding-agent/src/core/tools/truncate.ts:11-12), so prompts should steer the agent tocurl -o fileand then grep or read the file.
- Egress:
deploy/vm's nftables table only filters theinputhook. Forwarded traffic frommoca-sandboxis untouched, and the network isn't--internal, so the internet is reachable (deploy/vm/setup-vm.sh:367-425, README). No proxy env is expected.moca-egressdoesn't exist yet (MI1 S4/S5).- Cloud instance metadata is reachable too (deploy/vm: sandboxes can reach cloud instance metadata (169.254.169.254) #357). On the demo host, require IMDSv2 with hop limit 1 (the README gives the command).
- The worker's env filter is a denylist (
remote-worker/internal/exec/sandboxenv.go:9-21), soPATHandHOMEsurvive. - No existing smoke fetches from the internet. The closest,
deploy/knative/leaf-smoke.sh:295, expects a 403.
Scope
-
Verify the raw Anthropic key path (MU1 follow-ups from #348: VM control plane on Vault, dev identity provider, inference-credential binding #362 item 3) against a real
api.anthropic.comkey. If it's broken, choose one:- (a) honour the credential's
binding(header name and format) on the inference path, so anapi-keykind is sent asx-api-key; or - (b) refuse the combination at
PUT /v1/credentialswith a message naming it.
Keep the MI1 R2 rule: no caller credential ever becomes process-wide. Whatever lands must survive MI1 S2, where grants replace direct mode (spec §6). Note in the plan how S2 would absorb it.
- (a) honour the credential's
-
mocactl onboarding: make sure the credential step tells users which endpoint and key shapes work, and doesn't silently accept one that will 401.
-
Operator fallback on the VM: wire
SH_ALLOW_OPERATOR_FALLBACK/SH_OPERATOR_INFERENCE_TOKEN/SH_DEFAULT_INFERENCE_ENDPOINTinto item A's (VM demo A: run the MU1 control plane on deploy/vm (systemd unit, generated secrets) #366)control-plane.env.example, off by default and documented. The operator token is a secret, so treat it like A's other secrets. -
Sandbox tooling:
- confirm
curland ca-certificates are in the image, and install them explicitly if not; - decide whether the image sets
HOME=/workspace(or a passwd entry) sogit config --globalworks; - keep the image's size and E8 rationale comments honest.
- confirm
-
Research smoke: a
deploy/vmsmoke script (shellcheck-clean, gated by an env var like the other live smokes).- With one minted subject, create a session and run a turn whose prompt makes the agent
git clone --depth 1a small public repo andcurl -oa public page, then answer a question only that content can answer. Check the transcript for both commands and the answer. - Put the same prompt in the demo runbook.
- With one minted subject, create a session and run a turn whose prompt makes the agent
-
Docs: say in
deploy/vm/README.mdthat sandbox egress is open in this round, and warn about instance metadata.
Acceptance
- A user's turn completes on the VM with their own credential, for at least one working credential shape.
- The raw Anthropic key is either working or refused with a clear message. It never produces an opaque 401 mid-turn.
- The research smoke passes on a real VM with a real model:
curlandgitboth ran in the sandbox, and the answer uses the fetched content. curl,gitand ca-certificates are guaranteed by the image, not assumed.
Out of scope
- Grants and the
moca-egressinference listener (MI1 S2). - Egress allowlists and credential injection for
git/gh(MI1 S4/S5, Z5). - Internet access for P4 microVMs (P4.1: implement microVM egress transport (vsock → shared proxy) #277).
References
- MI1 spec
docs/specs/2026-09-28-moca-multi-user-isolation-design.md§5 (R2), §6 docs/specs/2026-09-08-multi-user-control-plane-design.md§3.6, §6.2- MU1 follow-ups from #348: VM control plane on Vault, dev identity provider, inference-credential binding #362, deploy/vm: sandboxes can reach cloud instance metadata (169.254.169.254) #357, Compose deployment: add a control plane so mocactl works (credential store without Kubernetes, MU1 auth wiring) #348 / 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.
Activity
fix(control-plane): refuse inference credentials that would 401 upstream
fix(harness): send an x-api-key caller credential as x-api-key
feat(control-plane): carry an inference credential's header to the da…
style: prettier on the rossoctl#368 control-plane and turn-auth changes
feat(mocactl): say which inference credential shapes work, refuse the…
fix(remote-worker): guarantee curl, CA certs and a writable HOME in t…
fix(control-plane): keep placeholder mode on Bearer; refuse misdirect…
fix(control-plane): send a misconfigured operator fallback to the ope…
Merge pull request #372 from pdettori/feat/368-inference-creds-sandbo…
feat(control-plane): refuse a misconfigured operator fallback at boot…
test(deploy/vm): a live smoke for a curl/git research turn in the con…
docs(deploy/vm): a research turn -- open egress, the demo prompt, the…
fix(mocactl): let the server resolve a missing inference credential (…
fix(deploy/compose): pass SH_OPERATOR_INFERENCE_HEADER to the control…
fix(control-plane): reserve 'operator-fallback'; a clear message for …
fix(deploy/vm): research smoke refuses a multi-line key file and retr…
Merge pull request #411 from pdettori/feat/368-phase2-vm-research
pdettori commentedon Oct 1, 2026
Closing: delivered in #372 and #411, and verified live on 2026-10-01. The research smoke passed 13/13 on a raw Anthropic key, and two users ran research turns on their own credentials (see #370).
feat(credentials): accept Anthropic OAuth tokens for inference
test(control-plane): pin the misdirection check on the dequeue path
fix(deploy/vm): load the oidc client secret by drop-in, not a fake op…