Skip to content

VM demo B: two users log in with mocactl against the P6 VM (device-flow acceptance, ownership checks) #367

Closed

Description

@pdettori

Part of the VM demo epic (#370). Item B: depends on A (#366, the control plane on deploy/vm).

Goal

Two distinct users, each on their own laptop, run mocactl login against the demo VM. Each creates and resumes sessions, and neither can see or reach the other's. This is also the first manual acceptance run of the real device-flow login, which is item 4 of #362.

Current state (verified on main @ 73f1bf4)

  • Identity: the only provider is GithubOAuthProvider, using the GitHub device flow (packages/control-plane/src/identity.ts:57-160, wired at main.ts:144).
  • Routes (packages/control-plane/src/routes.ts:33-132):
    • no auth: POST /v1/auth/device and /v1/auth/device/token;
    • api token: /v1/me, /v1/sessions* and /v1/credentials*.
  • Ownership: every session-scoped handler goes through one ownership choke point (handlers.ts:72-90), which returns 404, not 403, to a non-owner. listSessions is scoped by deps.index.listByOwner(p.sub), and ?owner= requires the admin role (handlers.ts:265-277). The worker allows a turn only when token.sid == body.sessionId (packages/knative-server/src/turn-auth.ts).
  • mocactl:
    • mocactl login polls the device flow (packages/mocactl/src/core/auth.ts:24-40, api/control-plane.ts:77-131);
    • it caches a 1-hour api token in $XDG_CONFIG_HOME/mocactl/auth.json, one identity per config dir, so two users on one machine need separate XDG_CONFIG_HOME values;
    • onboarding and doctor run seven checks.
  • Today's test stand-in for login: deploy/compose/smoke.sh:176-185 mints an api token for an arbitrary sub with the control plane's signing key. Use it for automated two-subject tests, but the demo itself uses real logins.
  • Session creation needs an inference credential: createSession fails if the user has none (handlers.ts:213-261). This issue touches that only enough to create sessions; item C (VM demo C: per-user inference credentials and a curl/git research turn in the P6 container sandbox #368) owns making credentials work for real.

Scope

  1. GitHub OAuth app setup on the VM path

    • Document it in deploy/vm/README.md: create the app, enable device flow, set SH_GITHUB_CLIENT_ID in control-plane.env.
    • The VM needs outbound access to github.com, and so do users' laptops for the verification URL.
    • Decide whether setup-vm.sh accepts SH_GITHUB_CLIENT_ID from its environment, as deploy/compose/install.sh:227-232 does.
  2. Two-user acceptance run on a VM built by item A (VM demo A: run the MU1 control plane on deploy/vm (systemd unit, generated secrets) #366), with two real GitHub accounts (write down the steps as a runbook):

    • mocactl login, then doctor (all seven checks), then run "hello" for each user;
    • user 1's /sessions never lists user 2's sessions;
    • GET/DELETE /v1/sessions/<other user's id> returns 404;
    • a turn posted with user 1's session token to user 2's session id is refused.
  3. Automated two-subject test, runnable without GitHub. Extend the control plane's vitest suite, or add a VM smoke, to cover:

    • two minted subjects;
    • disjoint session lists;
    • cross-owner 404s;
    • cross-session turn refusal at the harness.

    Tests of this kind may already exist in packages/control-plane and packages/knative-server. Check first, and add only what's missing.

  4. Record the fix list for anything the run finds, such as the mocactl UX when the control plane has no kubectl for /resources, or token expiry during a demo.

Explicitly not claimed (state this in the runbook)

Session ownership is enforced. Sandbox isolation between users is not.

  • On the container tier, every user's turns lease the same shared sandbox containers (harness/src/select-sandbox.ts:376-434 has no owner filter), and the container worker ignores workspace_key, so all users share /workspace, the Unix user and the process list (remote-worker/internal/exec/runner.go:98).
  • Fixing this is MI1 S5, owner binding (docs/specs/2026-09-28-moca-multi-user-isolation-design.md §9).
  • A cheap mitigation (a per-session working directory on the container worker) is listed as an optional follow-up on the epic.

Watch for: the MI1 S2 tenancy pin

MI1 §6.6 plans a first-subject pin under MOCA_TENANCY=single: the first subject to use a single-tenant deployment owns it, and later subjects get 403 single_tenant_deployment. It isn't implemented yet (MOCA_TENANCY is unset on the VM today). Once S2 lands, a two-user demo will need MOCA_TENANCY=multi, which in turn requires S5's sandbox owner binding. Make sure the demo runbook states which tenancy it runs under.

Optional, only if the owner chooses it: the dev identity provider

If a GitHub-free demo is wanted, #362 item 2 is the path. It needs an ADR before code, and it's loopback-only by design, so it only serves users who tunnel to the VM. Don't start it without the owner's decision.

Acceptance

  • Two real GitHub users complete login, doctor and run against the VM.
  • Their session lists are disjoint, and cross-owner access fails with 404 (or with the harness's refusal for turns).
  • The automated two-subject test passes.
  • The runbook is written, with the "not claimed" section.

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 Sep 30, 2026

    @pdettori
    MemberAuthor

    Automated two-subject test delivered in #371 (scope item 3). It covers: two minted subjects; disjoint session lists over HTTP; cross-owner 404s on GET/DELETE/token re-mint; cross-session turn refusal at the harness (400 session_mismatch, JSON and SSE branches, credential exchange never consulted). The audit that preceded it found no ownership bug — the handler-level properties were already covered by route-authz-enumeration, handlers-sessions and exchange tests; #371 adds the end-to-end shape with the smoke.sh minted-token stand-in.

    The two-user runbook steps and the fix-list candidates (mocactl /resources without kubectl, token expiry during a demo, one identity per XDG_CONFIG_HOME, the MI1 S2 tenancy-pin collision, shared /workspace on the container tier, device_flow_disabled as the likeliest first-run login failure) were drafted in the local plan (docs/plans/2026-09-30-vm-demo-b-two-subject-test.md, gitignored) and are ready to fold into the demo runbook slice.

    Remaining on this issue: items 1 and 2 (GitHub OAuth app docs in deploy/vm/, and the live two-account acceptance run).

  3. pdettori commented on Oct 1, 2026

    @pdettori
    MemberAuthor

    Two real GitHub accounts, live, on the shared KVM rig: 2026-10-01, at main @ 03d2ee8. This was the full VM demo (#370), recorded in docs/demos/vm-multi-user-demo.md (#412), whose Acts 1 and 3 overlap this issue's acceptance run.

    Setup:

    • one person (the rig owner), with two GitHub accounts on one laptop: two XDG_CONFIG_HOME directories, and user 2's device code approved in a private browser window;
    • the tunnel through an SSH account restricted to ports 8090/8080, as vm-two-user-acceptance.md 0a describes;
    • tenancy as deploy/vm ships it: MOCA_TENANCY unset, SH_REQUIRE_AUTH=true, operator fallback off.

    Against this issue's acceptance:

    Acceptance item Result
    Two real GitHub users complete login, doctor and run Yes. github:6678093 and github:228572680 (a second account), both through the real device flow. doctor passed all seven checks for both. Each ran research turns and a resume, on their own credential (anthropic, anthropic-dev). The control plane's audit stream shows each turn's own subject and credential name.
    Session lists are disjoint Yes. The owner index held one session per user and neither held the other's (checked in Redis). The TUI's Sessions view can't show this: both rows carry the same prompt as their title (#412's fix list, item 6).
    Cross-owner access fails with 404 Partly, live. User 2's mocactl run --session <user 1's id> and --session sess-does-not-exist both failed with that session no longer exists, or is not yours, exit 1. That path is the session-token re-mint (POST /v1/sessions/{id}/token) answering session_not_found 404. User 1 then resumed the same session normally. Not run live: the API-level GET and DELETE 404s (vm-two-user-acceptance.md 2b).
    Harness refuses a cross-session turn Not run live. The 400 session_mismatch (vm-two-user-acceptance.md 2c) is covered only by #371's automated test.
    Automated two-subject test passes Yes, #371.
    Runbook written, with "not claimed" vm-two-user-acceptance.md (#403), and the demo runbook (#412).

    Also confirmed on the run:

    Found by the run (filed or in #412's fix list):

    What would close the remaining gap: a pass through vm-two-user-acceptance.md Act 2 (2b and 2c) with the same two accounts. That is the curl checks only, about 10 minutes, and two people on two laptops if we want that case covered too. I'd leave this issue open until then, unless you consider #371 plus today's live run enough.

  4. pdettori commented on Oct 1, 2026

    @pdettori
    MemberAuthor

    Closing on the owner's call: the live two-account run on 2026-10-01 plus #371's automated two-subject test cover the acceptance. The API-level GET/DELETE 404s and the harness's session_mismatch were not run live; #371 covers them (see the comment above).

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