Skip to content

VM demo C: per-user inference credentials and a curl/git research turn in the P6 container sandbox #368

Closed

Description

@pdettori

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:

  1. reaches a real model with that user's own inference credential (or a deliberately enabled operator fallback);
  2. runs curl and git in 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 sends PUT /v1/credentials/{name}.
    • Kinds are bearer, basic, api-key and oauth2-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.
  • At turn time the exchange (packages/control-plane/src/exchange.ts:115-150) resolves the endpoint: the credential's own, else SH_DEFAULT_INFERENCE_ENDPOINT, else it fails with endpoint_unresolved.
    • It picks mode = injectorConfigured ? 'placeholder' : 'direct'.
    • In direct mode (the VM today) it returns the user's real secret to the worker.
  • applyModelGateway (harness/src/run-turn.ts:504-560) always sends that secret as Authorization: Bearer, strips x-api-key, and applies only on the anthropic-messages path. A per-user credential on any other API fails the turn, by design (MI1 §5 R2).

What that means in practice

The sandbox side is ready

  • Image: remote-worker/Dockerfile (ubi9-minimal) installs git, bash, python3 and rg. curl and ca-certificates are expected from the base image but aren't installed explicitly, so confirm with podman run --rm ghcr.io/rossoctl/moca-remote-worker:latest curl --version, and add them explicitly if absent.
    • The image runs as USER 1001 with /workspace writable.
    • uid 1001 has no passwd entry, so HOME is probably /: git clone works, but git config --global fails unless HOME is set.
  • 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 to curl -o file and then grep or read the file.
  • Egress: deploy/vm's nftables table only filters the input hook. Forwarded traffic from moca-sandbox is 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-egress doesn't exist yet (MI1 S4/S5).
  • The worker's env filter is a denylist (remote-worker/internal/exec/sandboxenv.go:9-21), so PATH and HOME survive.
  • No existing smoke fetches from the internet. The closest, deploy/knative/leaf-smoke.sh:295, expects a 403.

Scope

  1. 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.com key. If it's broken, choose one:

    • (a) honour the credential's binding (header name and format) on the inference path, so an api-key kind is sent as x-api-key; or
    • (b) refuse the combination at PUT /v1/credentials with 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.

  2. mocactl onboarding: make sure the credential step tells users which endpoint and key shapes work, and doesn't silently accept one that will 401.

  3. Operator fallback on the VM: wire SH_ALLOW_OPERATOR_FALLBACK / SH_OPERATOR_INFERENCE_TOKEN / SH_DEFAULT_INFERENCE_ENDPOINT into 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.

  4. Sandbox tooling:

    • confirm curl and ca-certificates are in the image, and install them explicitly if not;
    • decide whether the image sets HOME=/workspace (or a passwd entry) so git config --global works;
    • keep the image's size and E8 rationale comments honest.
  5. Research smoke: a deploy/vm smoke 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 1 a small public repo and curl -o a 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.
  6. Docs: say in deploy/vm/README.md that 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: curl and git both ran in the sandbox, and the answer uses the fetched content.
  • curl, git and ca-certificates are guaranteed by the image, not assumed.

Out of scope

References

Working conventions (for a fresh session)

  • Workspace: git fetch, then create a worktree from rossoctl/main (never local main), under .worktrees/. Populate and build pi-fork (git submodule update --init --recursive && cd pi-fork && npm ci && npm run build), then pnpm install. A worktree without the pi-fork build does not typecheck.
  • Plans: write the plan with superpowers:writing-plans into docs/plans/<date>-<slug>.md. Plans are gitignored and never committed. Write it in chunks, one append per task. Use docs/plans/2026-09-28-mi1-s1-hardening.md as 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 for Errors. Redirect long output to /tmp/kagenti/.... make lint skips untracked files.
  • Commits: git commit -s with Assisted-By: Claude (Anthropic AI) <[email protected]>, never Co-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

  1. added
    enhancement
    on Sep 30, 2026
  2. pdettori commented on Oct 1, 2026

    @pdettori
    MemberAuthor

    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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions