diff --git a/.overdeck/context/codebase/concerns.md b/.overdeck/context/codebase/concerns.md index a5af992ae29..06a4d453669 100644 --- a/.overdeck/context/codebase/concerns.md +++ b/.overdeck/context/codebase/concerns.md @@ -983,9 +983,31 @@ Live landmines a change in this repo can step on. Verified 2026-09-26 (Fly, link description, the `pan --help` `--yolo` text and `docs/CONFIGURATION.md` still say it blocks destructive commands (#5566). The real guardrails are the agent `git`/`gh` PATH shims (`launcher-git-guard.ts`), the workspace deny rules (`claude-settings-overlay.ts`), the - tmux-send-keys guard and the primary-checkout `--cwd` refusals; none is a sandbox. A project's + tmux-send-keys guard and the primary-checkout `--cwd` refusals; none is a sandbox. Since PAN-5754 an + isolated Claude Code agent (any token role but `conversation`/`flywheel`) runs Bash in Claude Code's + sandbox with `allowUnsandboxedCommands: false`, and its `--settings` deny rules hold even when this hook + answers allow (`agent-isolation/claude-settings.ts`); operator conversations and the Flywheel keep the + old behaviour. A project's `.pan.yaml` can also set `claude.permissionMode` / `codex.permissionMode` (`stripProjectSecurity` - keeps them), resolved from the launching process's cwd. + keeps them), resolved from the launching process's cwd. `stripProjectSecurity` + (`config-yaml/load.ts`) strips only `security`, `harnesses`, `computer_use` and `mcp.public`, + so a committed `.pan.yaml` can set any `agents.*` key (PAN-5754 adds `agents.isolation` to it). +- **Any local process is the operator on the dashboard** (verified 2026-12-03, PAN-5754 planning) — + an uncredentialed loopback peer passes gate rule 4 and always mints the root session + (`isTrustedLocalCaller`), so an agent needs no token file: `curl -X POST + 127.0.0.1:3011/api/dashboard/session` is enough. Claude Code's Bash sandbox does not close + this: its proxy forwards to host loopback when `NO_PROXY` is cleared, `deniedDomains` ignores + CIDR (`127.0.0.0/8` blocks nothing), and Traefik is reachable through a Docker bridge gateway + the dashboard trusts as a local client. Name entries (`127.0.0.1`, `localhost`, `*.localhost`) + are checked after DNS resolution. Other sandbox facts from the same probes: permission rules + need `Read(//abs/path)` (a single `/` is relative to the settings file and silently matches + nothing); `denyWrite` on a directory does not stop `connect()` to a Unix socket inside it, but + `denyRead` masks it; `allowUnixSockets` path lists do nothing on Linux; hooks and stdio MCP + servers run outside the sandbox; sandboxed commands get their own PID namespace. +- **Gate admission misreads pids from a PID namespace** (found planning PAN-5754) — + `quality-gate-admission.ts` `processIsAlive` uses `process.kill(pid, 0)`. A gate run inside a + sandbox (own PID namespace) sees every outside holder as dead and clears live slots; its own + pids are namespace-local. Records need the PID namespace before liveness can be trusted. - **Codex app-server threads ignore `codex.permissionMode`** (verified 2026-11-18, #5567) — `codex/app-server-host.ts` `threadOptions` always passes `runtimeMode: 'default'`, which `app-server-manager.ts` `mapRuntimeMode` turns into on-request approval and `workspace-write`; diff --git a/.pan/continues/PAN-5754.xbrief.json b/.pan/continues/PAN-5754.xbrief.json new file mode 100644 index 00000000000..f2735594eb8 --- /dev/null +++ b/.pan/continues/PAN-5754.xbrief.json @@ -0,0 +1,640 @@ +{ + "version": "1", + "issueId": "PAN-5754", + "created": "2026-12-03T21:28:28.525Z", + "updated": "2026-12-04T15:12:44.078Z", + "gitState": {}, + "decisions": [], + "hazards": [], + "resumePoint": null, + "sessionHistory": [ + { + "reason": "feedback", + "note": "[2026-12-04T01:05Z] ci-monitor → FAILED — seq 1", + "timestamp": "2026-12-04T01:05:26.233Z" + }, + { + "reason": "resume", + "agentModel": "claude-opus-5-5", + "timestamp": "2026-12-04T01:15:40.134Z" + }, + { + "reason": "feedback", + "note": "[2026-12-04T01:17Z] review-agent → CHANGES-REQUESTED — seq 2", + "timestamp": "2026-12-04T01:17:01.458Z" + }, + { + "reason": "feedback", + "note": "[2026-12-04T02:28Z] ci-monitor → FAILED — seq 3", + "timestamp": "2026-12-04T02:28:05.190Z" + }, + { + "reason": "resume", + "agentModel": "claude-opus-5-5", + "timestamp": "2026-12-04T03:04:40.533Z" + }, + { + "reason": "resume", + "agentModel": "claude-opus-5-5", + "timestamp": "2026-12-04T03:57:13.546Z" + }, + { + "reason": "resume", + "agentModel": "claude-opus-5-5", + "timestamp": "2026-12-04T14:53:43.625Z" + }, + { + "reason": "resume", + "agentModel": "claude-opus-5-5", + "timestamp": "2026-12-04T15:12:44.077Z" + } + ], + "items": { + "iso-config": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T21:28:28.525Z", + "doneAt": "2026-12-03T21:36:05.380Z" + }, + "iso-config.ac1": { + "status": "completed", + "doneAt": "2026-12-03T21:36:05.380Z" + }, + "iso-config.ac2": { + "status": "completed", + "doneAt": "2026-12-03T21:36:05.380Z" + }, + "iso-config.ac3": { + "status": "completed", + "doneAt": "2026-12-03T21:36:05.380Z" + }, + "iso-config.ac4": { + "status": "completed", + "doneAt": "2026-12-03T21:36:05.380Z" + }, + "iso-config.ac5": { + "status": "completed", + "doneAt": "2026-12-03T21:36:05.380Z" + }, + "token-location": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T21:36:26.224Z", + "doneAt": "2026-12-03T21:49:04.899Z" + }, + "token-location.ac1": { + "status": "completed", + "doneAt": "2026-12-03T21:49:04.899Z" + }, + "token-location.ac2": { + "status": "completed", + "doneAt": "2026-12-03T21:49:04.899Z" + }, + "token-location.ac3": { + "status": "completed", + "doneAt": "2026-12-03T21:49:04.899Z" + }, + "iso-policy": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T21:49:07.518Z", + "doneAt": "2026-12-03T21:53:07.731Z" + }, + "iso-policy.ac1": { + "status": "completed", + "doneAt": "2026-12-03T21:53:07.731Z" + }, + "iso-policy.ac2": { + "status": "completed", + "doneAt": "2026-12-03T21:53:07.731Z" + }, + "iso-policy.ac3": { + "status": "completed", + "doneAt": "2026-12-03T21:53:07.731Z" + }, + "iso-policy.ac4": { + "status": "completed", + "doneAt": "2026-12-03T21:53:07.731Z" + }, + "iso-policy.ac5": { + "status": "completed", + "doneAt": "2026-12-03T21:53:07.731Z" + }, + "claude-settings": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T21:53:09.165Z", + "doneAt": "2026-12-03T21:54:15.430Z" + }, + "claude-settings.ac1": { + "status": "completed", + "doneAt": "2026-12-03T21:54:15.430Z" + }, + "claude-settings.ac2": { + "status": "completed", + "doneAt": "2026-12-03T21:54:15.430Z" + }, + "claude-settings.ac3": { + "status": "completed", + "doneAt": "2026-12-03T21:54:15.430Z" + }, + "write-guard-hook": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T21:54:16.764Z", + "doneAt": "2026-12-03T21:54:59.963Z" + }, + "write-guard-hook.ac1": { + "status": "completed", + "doneAt": "2026-12-03T21:54:59.963Z" + }, + "write-guard-hook.ac2": { + "status": "completed", + "doneAt": "2026-12-03T21:54:59.963Z" + }, + "write-guard-hook.ac3": { + "status": "completed", + "doneAt": "2026-12-03T21:54:59.963Z" + }, + "launch-isolation": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T21:55:02.104Z", + "doneAt": "2026-12-03T22:06:44.505Z" + }, + "launch-isolation.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:06:44.505Z" + }, + "launch-isolation.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:06:44.505Z" + }, + "launch-isolation.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:06:44.505Z" + }, + "launch-isolation.ac4": { + "status": "completed", + "doneAt": "2026-12-03T22:06:44.505Z" + }, + "launch-isolation.ac5": { + "status": "completed", + "doneAt": "2026-12-03T22:06:44.505Z" + }, + "codex-clamp": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:08:53.441Z", + "doneAt": "2026-12-03T22:12:55.288Z" + }, + "codex-clamp.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:12:55.288Z" + }, + "codex-clamp.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:12:55.288Z" + }, + "launch-sites-agents": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:12:57.127Z", + "doneAt": "2026-12-03T22:18:17.798Z" + }, + "launch-sites-planning-conv": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:15:55.429Z", + "doneAt": "2026-12-03T22:20:20.918Z" + }, + "launch-sites-agents.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:18:17.798Z" + }, + "launch-sites-agents.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:18:17.798Z" + }, + "launch-sites-agents.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:18:17.798Z" + }, + "launch-sites-planning-conv.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:20:20.918Z" + }, + "launch-sites-planning-conv.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:20:20.918Z" + }, + "launch-sites-planning-conv.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:20:20.918Z" + }, + "agent-socket": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:20:22.611Z", + "doneAt": "2026-12-03T22:21:44.107Z" + }, + "agent-socket.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:21:44.107Z" + }, + "agent-socket.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:21:44.107Z" + }, + "agent-socket.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:21:44.107Z" + }, + "cli-credential": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:21:45.732Z", + "doneAt": "2026-12-03T22:23:28.777Z" + }, + "cli-credential.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:23:28.777Z" + }, + "cli-credential.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:23:28.777Z" + }, + "cli-credential.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:23:28.777Z" + }, + "cli-callers": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:23:38.426Z", + "doneAt": "2026-12-03T22:29:38.175Z" + }, + "cli-callers.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:29:38.175Z" + }, + "cli-callers.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:29:38.175Z" + }, + "cli-callers.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:29:38.175Z" + }, + "hooks-token": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:29:39.381Z", + "doneAt": "2026-12-03T22:32:10.535Z" + }, + "hooks-token.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:32:10.535Z" + }, + "hooks-token.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:32:10.535Z" + }, + "hooks-token.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:32:10.535Z" + }, + "in-pane-callers": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:32:16.444Z", + "doneAt": "2026-12-03T22:34:52.764Z" + }, + "in-pane-callers.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:34:52.764Z" + }, + "in-pane-callers.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:34:52.764Z" + }, + "self-auth-routes": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:34:54.245Z", + "doneAt": "2026-12-03T22:41:36.098Z" + }, + "self-auth-routes.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:41:36.098Z" + }, + "self-auth-routes.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:41:36.098Z" + }, + "self-auth-routes.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:41:36.098Z" + }, + "self-auth-routes.ac4": { + "status": "completed", + "doneAt": "2026-12-03T22:41:36.098Z" + }, + "route-scope-rows": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:41:37.692Z", + "doneAt": "2026-12-03T22:44:29.515Z" + }, + "route-scope-rows.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:44:29.515Z" + }, + "route-scope-rows.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:44:29.515Z" + }, + "route-scope-rows.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:44:29.515Z" + }, + "pi-routes-self-auth": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:44:41.717Z", + "doneAt": "2026-12-03T22:46:58.295Z" + }, + "pi-routes-self-auth.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:46:58.295Z" + }, + "pi-routes-self-auth.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:46:58.295Z" + }, + "pi-routes-self-auth.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:46:58.295Z" + }, + "pi-extension-token": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:46:59.733Z", + "doneAt": "2026-12-03T22:48:17.742Z" + }, + "pi-extension-token.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:48:17.742Z" + }, + "pi-extension-token.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:48:17.742Z" + }, + "admission-pidns": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:48:19.149Z", + "doneAt": "2026-12-03T22:55:35.478Z" + }, + "admission-pidns.ac1": { + "status": "completed", + "doneAt": "2026-12-03T22:55:35.478Z" + }, + "admission-pidns.ac2": { + "status": "completed", + "doneAt": "2026-12-03T22:55:35.478Z" + }, + "admission-pidns.ac3": { + "status": "completed", + "doneAt": "2026-12-03T22:55:35.478Z" + }, + "peer-rule": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T22:55:43.287Z", + "doneAt": "2026-12-03T23:08:40.296Z" + }, + "peer-rule.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:08:40.296Z" + }, + "peer-rule.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:08:40.296Z" + }, + "peer-rule.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:08:40.296Z" + }, + "peer-rule.ac4": { + "status": "completed", + "doneAt": "2026-12-03T23:08:40.296Z" + }, + "peer-rule.ac5": { + "status": "completed", + "doneAt": "2026-12-03T23:08:40.296Z" + }, + "traefik-trust": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:08:42.091Z", + "doneAt": "2026-12-03T23:13:34.557Z" + }, + "traefik-trust.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:13:34.557Z" + }, + "traefik-trust.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:13:34.557Z" + }, + "traefik-trust.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:13:34.557Z" + }, + "launch-sites-runtimes": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:13:46.175Z", + "doneAt": "2026-12-03T23:26:00.562Z" + }, + "launch-sites-runtimes.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:26:00.562Z" + }, + "launch-sites-runtimes.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:26:00.562Z" + }, + "launch-sites-runtimes.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:26:00.562Z" + }, + "capability-doctor": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:26:02.217Z", + "doneAt": "2026-12-03T23:31:05.720Z" + }, + "capability-doctor.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:31:05.720Z" + }, + "capability-doctor.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:31:05.720Z" + }, + "capability-doctor.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:31:05.720Z" + }, + "capability-doctor.ac4": { + "status": "completed", + "doneAt": "2026-12-03T23:31:05.720Z" + }, + "self-cli-route": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:31:07.160Z", + "doneAt": "2026-12-03T23:41:22.467Z" + }, + "self-cli-route.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:41:22.467Z" + }, + "self-cli-route.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:41:22.467Z" + }, + "self-cli-route.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:41:22.467Z" + }, + "self-cli-route.ac4": { + "status": "completed", + "doneAt": "2026-12-03T23:41:22.467Z" + }, + "self-cli-route.ac5": { + "status": "completed", + "doneAt": "2026-12-03T23:41:22.467Z" + }, + "forward-messaging": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:41:33.033Z", + "doneAt": "2026-12-03T23:43:13.187Z" + }, + "forward-messaging.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:43:13.187Z" + }, + "forward-messaging.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:43:13.187Z" + }, + "forward-messaging.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:43:13.187Z" + }, + "forward-planning-review": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:43:15.154Z", + "doneAt": "2026-12-03T23:46:04.485Z" + }, + "forward-planning-review.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:46:04.485Z" + }, + "forward-planning-review.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:46:04.485Z" + }, + "forward-planning-review.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:46:04.485Z" + }, + "forward-swarm-misc": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:46:05.977Z", + "doneAt": "2026-12-03T23:49:18.971Z" + }, + "forward-swarm-misc.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:49:18.971Z" + }, + "forward-swarm-misc.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:49:18.971Z" + }, + "forward-swarm-misc.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:49:18.971Z" + }, + "forward-swarm-misc.ac4": { + "status": "completed", + "doneAt": "2026-12-03T23:49:18.971Z" + }, + "verb-coverage": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:49:21.009Z", + "doneAt": "2026-12-03T23:53:19.545Z" + }, + "verb-coverage.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:53:19.545Z" + }, + "verb-coverage.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:53:19.545Z" + }, + "docs": { + "status": "completed", + "claimedBy": "agent-pan-5754", + "claimedAt": "2026-12-03T23:53:21.386Z", + "doneAt": "2026-12-03T23:57:16.185Z" + }, + "docs.ac1": { + "status": "completed", + "doneAt": "2026-12-03T23:57:16.185Z" + }, + "docs.ac2": { + "status": "completed", + "doneAt": "2026-12-03T23:57:16.185Z" + }, + "docs.ac3": { + "status": "completed", + "doneAt": "2026-12-03T23:57:16.185Z" + }, + "docs.ac4": { + "status": "completed", + "doneAt": "2026-12-03T23:57:16.185Z" + } + }, + "feedback": [ + { + "seq": 1, + "specialist": "ci-monitor", + "outcome": "failed", + "timestamp": "2026-12-04T01:05:26Z", + "markdownBody": "# CI Failure Feedback for PAN-5754\n\nPull request: https://github.com/eltmon/overdeck/pull/5993 (head `0c125bcc`)\n\nSource: check_run:test-shard (2/4)\n\nFailed check: test — this project runs its tests on CI (`verification.tests: ci`), so the CI test job is the verification test gate. Reproduce with the project's test runner scoped to the failing test files; do not run the full suite locally.\n\n## Failing checks (1)\n\n### test-shard (2/4)\n\nJob log: `gh api repos/eltmon/overdeck/actions/jobs/144728134786/logs` \nCheck: https://github.com/eltmon/overdeck/actions/runs/47239796267/job/144728134786 \n```\n\u001b[41m\u001b[1m FAIL \u001b[22m\u001b[49m \u001b[30m\u001b[42m root \u001b[49m\u001b[39m tests/unit/telemetry-docs.test.ts\u001b[2m > \u001b[22mtelemetry documentation\u001b[2m > \u001b[22mkeeps every event, property, and allowed value domain in exact contract sync\n\u001b[41m\u001b[1m FAIL \u001b[22m\u001b[49m \u001b[30m\u001b[42m root \u001b[49m\u001b[39m tests/unit/telemetry-docs.test.ts\u001b[2m > \u001b[22mtelemetry documentation\u001b[2m > \u001b[22mkeeps every event, property, and allowed value domain in exact contract sync\n\u001b[31m\u001b[1mAssertionError\u001b[22m: expected { events: { …(29) }, …(1) } to deeply equal { events: { …(29) }, …(1) }\u001b[39m\n\n\u001b[32m- Expected\u001b[39m\n\u001b[31m+ Received\u001b[39m\n\n\u001b[33m@@ -104,22 +104,15 @@\u001b[39m\n\u001b[2m \"/api/activity\",\u001b[22m\n\u001b[2m \"/api/agent-directory\",\u001b[22m\n\u001b[2m \"/api/agent-requests\",\u001b[22m\n\u001b[2m \"/api/agents\",\u001b[22m\n\u001b[2m \"/api/agents/:id/answer-question\",\u001b[22m\n\u001b[32m- \"/api/agents/:id/classify-completion\",\u001b[39m\n\u001b[32m- \"/api/agents/:id/conversation\",\u001b[39m\n\u001b[32m- \"/api/agents/:id/heartbeat\",\u001b[39m\n\u001b[2m \"/api/agents/:id/message\",\u001b[22m\n\u001b[2m \"/api/agents/:id/permissions/:requestId/respond\",\u001b[22m\n\u001b[2m \"/api/agents/:id/plan-action\",\u001b[22m\n\u001b[32m- \"/api/agents/:id/plan-checklist\",\u001b[39m\n\u001b[32m- \"/api/agents/:id/runtime\",\u001b[39m\n\u001b[2m \"/api/agents/:id/send-now\",\u001b[22m\n\u001b[32m- \"/api/agents/:id/stuck\",\u001b[39m\n\u001b[2m \"/api/agents/:id/tell\",\u001b[22m\n\u001b[32m- \"/api/agents/:id/work-complete\",\u001b[39m\n\u001b[2m \"/api/backend-restart-recovery\",\u001b[22m\n\u001b[2m \"/api/backend-restart-recovery/dismiss\",\u001b[22m\n\u001b[2m \"/api/backend-restart-recovery/resume-all\",\u001b[22m\n\u001b[2m \"/api/backend-restart-recovery/stop\",\u001b[22m\n\u001b[2m \"/api/connectors/self\",\u001b[22m\n\u001b[33m@@ -135,11 +128,10 @@\u001b[39m\n\u001b[2m \"/api/conversations/:name/attachments/:file\",\u001b[22m\n\u001b[2m \"/api/conversations/:name/bookmarks\",\u001b[22m\n\u001b[2m \"/api/conversations/:name/cha\n…\n\u001b[2m Test Files \u001b[22m \u001b[1m\u001b[31m1 failed\u001b[39m\u001b[22m\u001b[2m | \u001b[22m\u001b[1m\u001b[32m776 passed\u001b[39m\u001b[22m\u001b[2m | \u001b[22m\u001b[33m1 skipped\u001b[39m\u001b[90m (778)\u001b[39m\n```\n\n## Required action\n\nFix the failing checks, commit the fixes, and push an update. If a failure is marked [INHERITED FROM MAIN], it is not caused by your PR and does not need to be fixed in this branch.\n" + }, + { + "seq": 2, + "specialist": "review-agent", + "outcome": "changes-requested", + "timestamp": "2026-12-04T01:17:01Z", + "markdownBody": "# Review CHANGES REQUESTED for PAN-5754\n\n# Review — PAN-5754\n## Verdict: CHANGES REQUESTED — an isolated agent's own token still drives unisolated operator sessions (`/ws/terminal` on any pane, `POST /api/conversations`, `POST /api/self/handoff`)\n\n## Context\n- Run ID: agent-pan-5754-review-183ed25f\n- Manifest: /home/eltmon/Projects/overdeck/workspaces/feature-pan-5754/.pan/review/agent-pan-5754-review-183ed25f/context.json\n- Branch / workspace: feature/pan-5754 / /home/eltmon/Projects/overdeck/workspaces/feature-pan-5754\n- HEAD reviewed: 183ed25feb6272ace351df1294a666bc3e4fa9c4 (pushed). The code was read at 0c125bcce2c (prior dispatch, agent-pan-5754-review-0c125bcc, which never signalled); `git diff 0c125bcc 183ed25 -- . ':!.pan'` changes only `docs/TELEMETRY.md` (the shard-2 CI fix), so the code reviewed is the code at this head.\n- Base: origin/main e87739cc252; PR #5993. No prior completed review cycle.\n\n## Blocking Findings\n\n### [security] An isolated agent's token reaches unisolated operator sessions — `src/dashboard/server/ws-terminal.ts:263`, `src/dashboard/server/routes/conversations.ts:311`, `src/dashboard/server/routes/self-workflow.ts:180`\n- Severity: ! MUST\n- Classification / requirement scope: specification defect (in_pr_scope). The PRD's threat model claims an isolated Claude Code agent \"cannot, from any tool: … 3. connect to the Herdr, tmux, PTY-supervisor or ACP-host sockets, **so it cannot type into another pane**\" and \"2. get a dashboard credential with `admin` scope or a root session\". No work item restricts what the agent's **own** token can do. Before this PR the token's reach did not matter, because every agent could read `internal-token`. This PR makes the agent token the boundary, so its reach is now in scope.\n- Trigger and changed-code connection: the isolated agent can read its own token (`allowRead` on its `agent-tokens//`, `OVERDECK_AGENT_TOKEN_FILE`). It reaches the dashboard over the agent socket this PR adds (`agent-api-socket.ts`, which feeds `deliverHttpSocket`, so HTTP and WebSocket upgrades reach the same server; `allowAllUnixSockets: true`, and `agent-api/` is not masked) or through the sandbox proxy with the Bearer token. Work, worker, plan, strike, sequencer and knowledge tokens hold `operate` (`AGENT_TOKEN_SCOPES`, `src/lib/mcp/agent-token.ts`). Three paths follow:\n 1. **`/ws/terminal?session=`.** `authorizeDashboardUpgrade(headers, 'GET', WS_TERMINAL_SCOPE='operate')` (`ws-auth.ts`) checks only origin (a GET with no Origin passes), credential and scope. `linkActorFence` (`link-fence.ts:89`) fences only `kind: 'machine'` credentials. Nothing checks that the session belongs to the token's owner. So a work agent can attach to the Flywheel's or an operator conversation's pane and type into it, which contradicts threat claim 3 word for word.\n 2. **`POST /api/conversations`** (`operate` row, `route-scopes.ts:99`). `validateOrigin` accepts a Bearer `odk_` request with no Origin (`origin-validation.ts:144`). `handleConversationCreate` records `startOrigin` (`startedBy: 'agent'`) only for display. The new row has `laneRole: null`, so `conversationTokenRole` returns `conversation` (`agent-injection.ts:72`). `prepareAgentLaunchAccess` therefore applies no isolation (FR-11): no sandbox, `internal-token` readable. The request's message becomes that conversation's first prompt.\n 3. **`POST /api/self/handoff`** (`tell` row, the MCP `handoff` tool). `handleSelfHandoff` runs `pan handoff self --title … -- ` as a self job with no role check in `prelude` and no `--role`/`--issue` pin. With no `role` in the body, `conversation-forks.ts:778` defaults `paneRole` to `'conversation'`, and the fork's `createConversation` sets no `laneRole`. So an isolated lane/worker conversation's handoff successor is an unisolated operator conversation. The forwarded CLI row pins `--role=work` for exactly this reason (`self-cli-verbs/core.ts`, comment on the `handoff` row), but the MCP route bypasses the pin.\n- Expected / observed / impact: Expected: an isolated agent cannot act with operator rights or drive another pane. Observed (static trace): one HTTP request or WebSocket upgrade with its own token starts, or types into, an unsandboxed session that holds `internal-token`. That is a full escalation to the operator credential. None of the three paths appears in the residual list in `configuration/agent-isolation.mdx` or `docs/AGENT-ISOLATION.md`; the docs say the opposite.\n- Evidence: static trace of the files and lines above. The gate path is `remote-request-gate.ts` → `resolveDashboardCredential` → `scopeSatisfies(credentialScopes, requiredScopeFor(...))`. Limits: no live isolated agent was run (CP-1 is unverified on this host because `socat` is missing), and no exploit was attempted. Accepted residual R-1 (the verification gate runs workspace `npm` scripts unsandboxed) already offers a slower path to the same rights. The operator may weigh that, but R-1 is disclosed and these paths are not.\n- Fix: choose per path, then update the threat model and docs to match.\n - `/ws/terminal`: refuse agent-kind tokens of isolated roles, or allow only the token's own session.\n - `POST /api/conversations` (and the sibling create routes `POST /api/fleet/conversations` and `/api/machines/work/conversations`, which take the same `operate` row): refuse isolated agent tokens, or start the new conversation isolated (for example as token role `worker`).\n - `POST /api/self/handoff`: apply the same role/issue pin as the forwarded CLI row, or refuse isolated callers.\n - If any path is kept on purpose, list it as a residual risk on the user page and in `pan doctor`.\n\n## Non-blocking Findings\n\n1. **[security, ~ SHOULD, specification defect] `~/.cache` is writable and holds code that runs outside the sandbox.** D-8 makes the whole cache dir writable and denies only `~/.cache/ms-playwright` (`policy.ts` `CACHE_EXECUTABLE_DIRS`). On this host, `pnpm` resolves to corepack (`…/corepack/dist/pnpm.js`), which runs the package manager it keeps under `~/.cache/node/corepack`. Any operator or gate `pnpm` call would run code an isolated agent wrote, which contradicts threat claim 4. Unverified candidates seen in `~/.cache`: `opencode/`, `codex-runtimes/codex-primary-runtime/{dependencies,plugins}`, `uv/` (uvx tools), plus `~/.bun/install/cache` (bunx). Fix: allowlist specific cache subdirs, or extend the deny list, and disclose the remainder.\n2. **[security, ~ SHOULD] The forwarded `memory add|edit --user|--machine` (all isolated roles) writes operator- and machine-level memory.** That memory is rendered into every managed launch, including the Flywheel, so it is a persistent prompt-injection channel into unisolated sessions. `--project ` also writes another project's plan home through a self job. The design keeps `tell` to unisolated conversations (roles need `pan tell conv-flywheel`), so disclose this class, or drop `--user`/`--machine` from the forwarded rows.\n3. **[performance, ? MAY] The peer rule's cost per new uncredentialed loopback connection is unmeasured.** `resolveIsolatedPeer` reads `/proc/net/tcp{,6}`, walks every live root's tree and awaits one `readlink` per fd, serially (`roots.ts` `pidsHoldSocket`), ahead of the gate, with no time bound. It runs only for uncredentialed literal-loopback requests when roots exist, and caches per socket. Health polls and first browser connections before the session cookie qualify. With about 13 agents of tens of processes and hundreds of fds each, this could be thousands of serial syscalls per new connection. Measure it, or parallelize and bound it.\n4. **[correctness, ? MAY] The first hooks of a fresh session may be refused.** `user-prompt-submit`, `turn-complete` and `permission-event` pass `bodyNamesAgent=false`, so a session not yet indexed is refused for agent tokens (`authorizeInternalOrSessionOwner`). The first turn's events could be dropped. Not observed; a live run would settle it.\n5. **[validation gap, ~] `packages/contracts/src/harness-behavior.test.ts` is outside the root vitest include.** The root config includes `packages/**/src/__tests__/**`. The contracts package has its own `vitest` script; confirm CI runs it.\n\n## Coverage\nChanged-file ledger (code at 0c125bcc == 183ed25 except `docs/TELEMETRY.md`):\n- Auth and gate: `routes/dashboard-auth.ts`, `isolated-peer.ts`, `agent-isolation/roots.ts`, `public-ingress.ts`, `remote-request-gate.ts` (unchanged; traced), `ws-auth.ts`/`ws-terminal.ts` (unchanged; traced → blocker), `routes/workspace-wake.ts`, `server.ts`, `agent-api-socket.ts`, `boot-gates.ts` `hostsMachineLinks` (true on the primary dashboard, so FR-6 holds by default) — reviewed.\n- Self routes: `routes/self-or-internal.ts`, `agents/shared.ts`, `agents/permissions.ts`, `agents/runtime-events.ts`, `hooks.ts`, `conversations.ts` (control-ack), `issues.ts` (complete-planning), `specialists/legacy-routes.ts`, `route-scopes.ts` — reviewed.\n- Forwarding: `routes/self-cli.ts`, `services/self-cli-argv.ts`, `self-cli-verbs/*` (all 7), `self-job-argv.ts`, `self-jobs.ts` (job env built from the dashboard's env, so no re-forwarding), `cli/isolated-forward.ts`, `cli/index.ts`, `dashboard-call.ts` — reviewed.\n- Tokens and launch: `mcp/agent-token.ts` (re-mint revokes all prior records, so a legacy `mcp-token` is dead), `mcp/agent-injection.ts`, `agent-isolation/{config,paths,policy,policy-input,claude-settings,launch,launcher-lines,runtime-launch,codex,prerequisites}.ts`, `launcher-generator.ts` (skill-settings lines run before the isolation merge, and the merge clears `PAN_SKILL_SETTINGS`, so there is one `--settings`), `agents/{spawn,spawn-prep,recovery,messaging,runtime-command}.ts`, `planning/spawn-planning-session.ts`, `misc/planning.ts`, `overdeck/conversation-runtime.ts`, `runtimes/{acp,codex,kimi-code,muse,ohmypi,prime-agent}.ts` (`claude-code` delegates to `spawn.ts`), `config-yaml/{load,schema,schema-agent-isolation}.ts`, `host-tools.ts` (misses rechecked after 60 s) — reviewed.\n- Clients: `dashboard-client/agent-credential.ts`, `agent-runtime.ts`, `caveman/workspace.ts`, `channels/overdeck-bridge.ts`, `codex/prompt-memory.ts`, `cloister/deacon-event-client.ts`, `pipeline-notifier.ts`, `packages/pi-extension/src/index.ts`, `cli/commands/{plan,start,install,sync,doctor,doctor-agent-isolation}.ts` — reviewed.\n- Gate admission: `quality-gate-admission{,-pidns}.ts` — reviewed.\n- Hooks: `agent-isolation-guard` (fails closed; canonical path), `pan-hook-lib.sh`, `permission-event-hook`, `session-start-hook`, `stop-hook`, `user-prompt-submit-hook`; the other hooks use `pan_emit_event` and `statusline.sh` uses its own Bearer — reviewed.\n- Contracts: `harness-capabilities.ts`, `telemetry.ts`, `docs/TELEMETRY.md` — reviewed.\n- Docs: `configuration/agent-isolation.mdx`, `docs/AGENT-ISOLATION.md`, `docs/DASHBOARD-AUTH.md` (skimmed), `SECURITY-AUDIT` (skimmed), `CLAUDE.md`, `changelog.d`, `docs.json`, `harnesses.mdx` — reviewed for residual disclosure.\n- Tests (~35 files): sampled. NFR-4 grep over every added or modified test found no `skipIf`, no `.only` and no source-file reads. `tests/scripts/**` is in the default include.\n- `.pan/*`, `.overdeck/context/codebase/concerns.md`: planning artifacts, not applicable.\n\nDimensions: correctness ✓, security (one blocker, two advisories), performance (one advisory, unmeasured), requirements/UX (below).\n\nAC matrix (PRD \"Acceptance criteria\"):\n- WI-1 to WI-6, WI-9 to WI-16, WI-20 to WI-23, WI-26 to WI-28, WI-29, D-12: **met** by code trace and the focused tests (232 passed).\n- WI-7/8: met (`prepareAgentLaunchAccess` at every site; plain conversations unisolated).\n- WI-17 to WI-19: met (rows and roles as stated).\n- WI-24: met (doctor error row for missing socat; warn row per `none`-class harness).\n- WI-25: met. `npm run lint:docs` was not run here; CI lint passed at 0c125bcc.\n- Threat-model claims 2 and 3 (the PR's stated security property): **unmet** — see the blocker.\n- Live verification (CP-1): **unverified** (no `socat` on this host; disclosed in the PR).\n\n## Verification\n- Focused vitest, run on the working tree at 183ed25 (same code): 20 files, 232 tests passed — isolated-peer, agent-api-socket, self-cli-route, self-cli-coverage, self-or-internal, dashboard-auth-forwarded, `agent-isolation/__tests__/*`, agent-isolation-guard, hooks-agent-token, isolation-runtime-launch, `dashboard-client/__tests__/*`, isolated-forward, spawn-isolation, agent-token.\n- CI at 0c125bcc: lint, build, integrations and test shards 1, 3 and 4 passed. Shard 2 failed on `tests/unit/telemetry-docs.test.ts`: the new `client_route` values were missing from `docs/TELEMETRY.md`. That failure is caused by this PR and fixed by docs-only commit 492624a, which is in this head.\n- CI at 183ed25: test jobs not started yet, so the suite is **unverified**, not green. `overdeck/test` (the verification gate: typecheck and lint) passed at 0c125bcc.\n- `npm run lint:effect-diagnostics`: not run; this head has no successful result. Unverified.\n- Live sandbox probes: not run (CP-1; no `socat`).\n\n## Scope Note\n- **Rollout hazard (operator):** this host still lacks `socat` (`command -v socat` finds nothing; `bwrap` is present). `agents.isolation.enabled` defaults to true, so merging and deploying this refuses every isolated Claude Code launch (work, review, test, plan) until `sudo apt-get install socat` runs. The PR body says this; the Flywheel must not auto-merge before it is done.\n- This dispatch supersedes run agent-pan-5754-review-0c125bcc, which was interrupted before signalling.\n\nSource: /home/eltmon/Projects/overdeck/workspaces/feature-pan-5754/.pan/review/agent-pan-5754-review-183ed25f/review.md\n\n## Required action\n\nFix every blocking review finding, commit the fixes, then re-request review with:\n\n`pan review request PAN-5754 -m \"Fixed review issues\"`" + }, + { + "seq": 3, + "specialist": "ci-monitor", + "outcome": "failed", + "timestamp": "2026-12-04T02:28:05Z", + "markdownBody": "# CI Failure Feedback for PAN-5754\n\nPull request: https://github.com/eltmon/overdeck/pull/5993 (head `70693776`)\n\nSource: check_run:test-shard (1/4)\n\nFailed check: test — this project runs its tests on CI (`verification.tests: ci`), so the CI test job is the verification test gate. Reproduce with the project's test runner scoped to the failing test files; do not run the full suite locally.\n\n## Failing checks (1)\n\n### test-shard (1/4)\n\nJob log: `gh api repos/eltmon/overdeck/actions/jobs/144765484862/logs` \nCheck: https://github.com/eltmon/overdeck/actions/runs/47250728297/job/144765484862 \n```\n\u001b[41m\u001b[1m FAIL \u001b[22m\u001b[49m \u001b[30m\u001b[42m root \u001b[49m\u001b[39m tests/unit/cli/memory-self-roundtrip.test.ts\u001b[2m > \u001b[22mself-memory routes through the real pan memory program (PAN-4940 WI-4, issue AC-11)\u001b[2m > \u001b[22ma type user fact lands in the operator store\n\u001b[41m\u001b[1m FAIL \u001b[22m\u001b[49m \u001b[30m\u001b[42m root \u001b[49m\u001b[39m tests/unit/cli/memory-self-roundtrip.test.ts\u001b[2m > \u001b[22mself-memory routes through the real pan memory program (PAN-4940 WI-4, issue AC-11)\u001b[2m > \u001b[22ma type user fact lands in the operator store\n\u001b[31m\u001b[1mAssertionError\u001b[22m: expected undefined to be 'done' // Object.is equality\u001b[39m\n\n\u001b[32m- Expected:\u001b[39m\n\"done\"\n\n\u001b[31m+ Received:\u001b[39m\nundefined\n\n\u001b[36m \u001b[2m❯\u001b[22m tests/unit/cli/memory-self-roundtrip.test.ts:\u001b[2m163:28\u001b[22m\u001b[39m\n \u001b[90m161|\u001b[39m )\u001b[33m;\u001b[39m\n \u001b[90m162|\u001b[39m const addBody = addResult.body as { status: string; stdout: string…\n \u001b[90m163|\u001b[39m \u001b[34mexpect\u001b[39m(addBody\u001b[33m.\u001b[39mstatus)\u001b[33m.\u001b[39m\u001b[34mtoBe\u001b[39m(\u001b[32m'done'\u001b[39m)\u001b[33m;\u001b[39m\n \u001b[90m |\u001b[39m \u001b[31m^\u001b[39m\n \u001b[90m164|\u001b[39m \u001b[35mconst\u001b[39m addStdout \u001b[33m=\u001b[39m \u001b[33mJSON\u001b[39m\u001b[33m.\u001b[39m\u001b[34mparse\u001b[39m(addBody\u001b[33m.\u001b[39mstdout) \u001b[35mas\u001b[39m { file\u001b[33m:\u001b[39m string }\u001b[33m;\u001b[39m\n \u001b[90m165|\u001b[39m expect(addStdout.file).toBe(join(process.env.OVERDECK_HOME as stri…\n\n\u001b[31m\u001b[2m⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯\u001b[22m\u001b[39m\n\n\n\u001b[2m Test Files \u001b[22m \u001b[1m\u001b[31m1 failed\u001b[39m\u001b[22m\u001b[2m | \u001b[22m\u001b[1m\u001b[32m777 passed\u001b[39m\u001b[22m\u001b[2m | \u001b[22m\u001b[33m2 skipped\u001b[39m\u001b[90m (780)\u001b[39m\n```\n\n## Required action\n\nFix the failing checks, commit the fixes, and push an update. If a failure is marked [INHERITED FROM MAIN], it is not caused by your PR and does not need to be fixed in this branch.\n" + } + ], + "agentModel": "claude-opus-5-5" +} diff --git a/.pan/drafts/PAN-5754-critique-2.md b/.pan/drafts/PAN-5754-critique-2.md new file mode 100644 index 00000000000..054688f974e --- /dev/null +++ b/.pan/drafts/PAN-5754-critique-2.md @@ -0,0 +1,13 @@ +plan-digest: cd5f51cba77f8b6ffaf5d13a700be55daf5b16acaec452804b4f409af3b43cfc + +## blocks-the-design: forwarded handoff can create an operator conversation + +The draft grants a work token the `handoff` self-job verb without binding its source conversation (`.pan/drafts/PAN-5754.md`, lines 280–294). The existing CLI accepts an explicit conversation name or ID and sends the caller's focus to the fork route (`src/cli/commands/handoff.ts`, lines 100–107, 200–218). The fork handler defaults an omitted role to `conversation` (`src/lib/overdeck/conversation-forks.ts`, lines 774–778). Under FR-11, that successor has the operator credential and no sandbox. Thus an isolated work agent can forward `pan handoff ` and cause a privileged successor to run. Remove `handoff` from the generic forwarded table, or replace it with a self-only action that binds the source and successor to the caller's issue and isolated token role. Add a test that an agent cannot hand off an operator conversation or create a `conversation`-role successor. + +## blocks-the-design: root registration fails open + +The peer rule trusts loopback whenever the root registry is empty (`.pan/drafts/PAN-5754.md`, lines 111–113, 313–319), and the existing mint accepts an uncredentialed trusted loopback peer (`src/dashboard/server/routes/dashboard-auth.ts`, lines 454, 476–482, 509–519). The launcher plan creates only the policy's masked directories before writing `/isolation/roots/.json`; it never creates `isolation/roots` or requires that write to succeed (`.pan/drafts/PAN-5754.md`, lines 204–213, 309–312). The first launch therefore has no registry entry if that directory is absent, and a later write failure has the same effect. Probe P10 already establishes that sandboxed Bash can reach host loopback through its proxy. Create the roots directory before launch, require an atomic registration and verified readback, and refuse the launch on any failure. Test a fresh home and an unwritable roots directory. + +## blocks-the-design: validated file flags can be swapped before the self job reads them + +D-7 validates a `workspacePath` flag with `realpath`, then passes the path to a self job outside the sandbox (`.pan/drafts/PAN-5754.md`, line 103). WI-19 explicitly enables `worker run --brief` this way (line 306). The existing worker command reads `options.brief` when the child runs (`src/cli/commands/worker.ts`, lines 228–235). An agent can replace a validated workspace file with a symlink to `internal-token` between the check and that read, causing the operator-rights child to consume the secret as a worker prompt. Exclude file-reading flags from self jobs. For `--brief`, have the isolated CLI read the file inside its sandbox and forward bounded prompt text; apply the same rule to any later file flag. Add a symlink-swap regression test. diff --git a/.pan/drafts/PAN-5754-critique.md b/.pan/drafts/PAN-5754-critique.md new file mode 100644 index 00000000000..4b8e7957421 --- /dev/null +++ b/.pan/drafts/PAN-5754-critique.md @@ -0,0 +1,25 @@ +plan-digest: 9b53f7de14313c03619205faff1f5a4e187f464173d900216017977417463c02 + +## blocks-the-design: fail-open leaves the credential readable on this host + +The PRD's probe notes say `socat` is absent here and Claude Code runs commands unsandboxed without it (`.pan/drafts/PAN-5754.md`, lines 35 and 64). D-12 and WI-4 deliberately set `failIfUnavailable: false` (lines 117 and 182-190). In that state, D-8's read deny and socket masks never apply, so a newly launched Claude agent can read `~/.overdeck/internal-token` and connect to the terminal sockets. A doctor error after launch does not enforce isolation. Make the isolated launch fail when the sandbox is unavailable, or make the switch explicitly opt-in until the prerequisites are present; require a launch test with `socat` missing. + +## blocks-the-design: forwarded file flags read operator secrets + +D-7 says each forwarded row allows the command's Commander flags except a list that omits file inputs (`.pan/drafts/PAN-5754.md`, line 103); WI-16 forwards `worker report` and WI-19 forwards `worker run` (lines 291 and 304). `worker report --file ` reads that path through `deps.readFile` (`src/cli/commands/worker.ts`, lines 366-399), and `worker run --brief ` does the same (lines 225-233). Self jobs run outside the sandbox with the dashboard user's filesystem rights (`src/dashboard/server/services/self-jobs.ts`, lines 125-133, 231-239). A worker can therefore forward `worker report --file ~/.overdeck/internal-token`, then retrieve the report, bypassing D-8. Exclude file-reading flags from these rows, use the bounded stdin path for reports, and validate any indispensable path against the caller's workspace with realpath before starting a job. Test the protected-file case. + +## blocks-the-design: hook payloads have no subject agent ID + +WI-14 says the five hook routes can compare the token with “the body's agent id field each handler already parses” (`.pan/drafts/PAN-5754.md`, lines 263-274). The actual `user-prompt-submit` payload contains only `session_id` and `prompt` (`sync-sources/hooks/user-prompt-submit-hook`, lines 43-45); `turn-complete` contains only `session_id` (`sync-sources/hooks/stop-hook`, lines 85-92); and `permission-event` posts Claude's raw payload (`sync-sources/hooks/permission-event-hook`, lines 12-21). Their handlers resolve a conversation from `session_id` (`src/dashboard/server/routes/hooks.ts`, lines 617-627, 669-681, 572-585). As written, the new equality check either rejects legitimate isolated hooks or accepts a caller-supplied ID unrelated to the session being mutated. Resolve the session's owner on the server and compare it with the token before handling each route; specify what to do when a session has no owner. Test a token for A with B's `session_id`. + +## blocks-the-design: alternate runtime launches bypass isolation + +WI-7 and WI-8 list only the agent spawn, recovery, messaging, planning and conversation launch sites (`.pan/drafts/PAN-5754.md`, lines 217-230). The runtime registry also launches agents directly: crash recovery calls `runtime.spawnAgent` (`src/lib/cloister/service-crash.ts`, lines 429-441) and session rotation does likewise (`src/lib/cloister/session-rotation.ts`, lines 245-257). The Codex runtime builds its own tmux command and environment, without `generateLauncherScript` (`src/lib/runtimes/codex.ts`, lines 674-699); Muse, Kimi, Prime Agent and ohmypi each call `generateLauncherScript` in their own runtime modules. Those paths will not receive `prepareAgentIsolation`, the token env, root registration or the Codex clamp. Inventory every production `spawnAgent`/`generateLauncherScript` path and make the runtime entry points prepare isolation too; test a crash restart and a rotation through a direct runtime. + +## blocks-the-design: worker run cannot pass its required issue + +D-7 excludes `--issue` from every forwarded row, and WI-19 forwards `worker run` without specifying a server-injected replacement (`.pan/drafts/PAN-5754.md`, lines 103 and 304). But `worker run` takes the issue only through `--issue` (`src/cli/commands/worker.ts`, lines 514-519) and returns a usage error when it is absent (lines 196-203). This breaks the planned delegated worker flow. For this row, validate any supplied `--issue` against `caller.issueId`, remove it from caller argv, and inject the caller's issue on the server; test the normal `pan worker run --issue ` command. + +## blocks-the-design: generic self jobs truncate and time out long commands + +WI-16 promises that forwarded verbs print their stdout/stderr and exit with their code (`.pan/drafts/PAN-5754.md`, lines 282-292). Existing self jobs keep only the last 16 KiB of stdout except for `task-done` and kill a command after 15 minutes (`src/dashboard/server/services/self-jobs.ts`, lines 29-36, 125-143, 231-239). `worker run` and `worker wait` can wait without a deadline (`src/cli/commands/worker.ts`, lines 215-216 and 267-272), while a valid worker report can be 1 MiB (`src/lib/agents/worker/report.ts`, lines 22-23). Forwarding these commands through the current runner silently cuts a valid report and kills a still-waiting command. Give long waits a bounded, resumable job protocol and preserve the full result for report-producing verbs; test a report over 16 KiB and a wait that exceeds the job timeout. diff --git a/.pan/drafts/PAN-5754.md b/.pan/drafts/PAN-5754.md new file mode 100644 index 00000000000..348fa173512 --- /dev/null +++ b/.pan/drafts/PAN-5754.md @@ -0,0 +1,501 @@ +# PAN-5754 — Isolate agents from the operator credential + +**Issue:** [PAN-5754](https://github.com/eltmon/overdeck/issues/5754) (follow-up to the PAN-5687 audit, findings F-4 and F-9; tracks #5699, relates to #5696). +**Operator direction (issue comment, 2026-12-03):** use the harness sandbox and per-agent tokens, not a separate uid. Hooks and the CLI inside an agent use the agent's per-agent token, never `~/.overdeck/internal-token`. Claude Code agents get deny-read on the operator credential files and deny-write on the terminal-backend socket directories. Every other harness gets the closest equivalent its sandbox offers; where a harness has no sandbox, the docs and `pan doctor` say so. Operator conversations keep the operator credential. Plan and implement it as one issue. + +## Summary + +Today every managed agent runs as the operator's user and can act as the operator on the dashboard in one command. It can `cat ~/.overdeck/internal-token`, or `curl -X POST http://127.0.0.1:3011/api/dashboard/session` to mint a root session cookie (a loopback caller always mints), or drive another agent's pane through the Herdr or tmux socket. This plan closes those paths for pipeline agents: + +1. Isolated agents authenticate to the dashboard only with their own agent token, from hooks and from the CLI. +2. Claude Code agents run every Bash command inside Claude Code's OS sandbox, under an Overdeck-generated policy. The policy hides the operator's secret files, masks the terminal-backend socket directories, limits writes, and blocks the files Claude Code or Overdeck later execute outside the sandbox. +3. The dashboard stops treating connections from an isolated agent's process tree as a trusted local caller, and stops trusting uncredentialed Traefik-forwarded requests while isolation is on. +4. CLI verbs that need the operator's rights or a terminal socket run as dashboard self jobs, bound to the calling agent's identity and role. +5. Codex gets the closest equivalent (its write sandbox). Every harness without a sandbox is named in the docs and in `pan doctor`. + +## Glossary + +- **Operator credential.** The dashboard root secret `~/.overdeck/internal-token` (`src/lib/internal-token.ts`), the session cookie derived from it, and the Overdeck-held secrets that mint or impersonate dashboard access. The full list is the **operator secret set** in D-8. +- **Agent token.** A managed agent's or conversation's own `odk_<64 hex>` access token (PAN-4927, `src/lib/mcp/agent-token.ts`). Its scopes come from `AGENT_TOKEN_SCOPES` and never include `admin`. +- **Token role.** The `AgentTokenRole` an owner's token carries: `work`, `worker`, `plan`, `strike`, `sequencer`, `knowledge`, `flywheel`, `review`, `test`, `ship`, or `conversation` (`agent-token.ts` `AGENT_TOKEN_SCOPES`; conversations get theirs from `conversationTokenRole`, `src/lib/mcp/agent-injection.ts`). +- **Isolated agent.** A launch whose token role is neither `conversation` nor `flywheel` (D-1). +- **Isolated context.** A process whose environment has `OVERDECK_AGENT_TOKEN_FILE` set. The launcher sets it only for isolated agents. +- **Isolation policy.** The pure data structure (D-8) that lists the paths an isolated agent may read and write, and the socket directories it may not reach. One policy feeds the Claude Code settings file, the write guard hook and `pan doctor`. +- **Isolation settings file.** The Claude Code settings JSON rendered from the isolation policy and passed with `--settings `. +- **Write guard hook.** `sync-sources/hooks/agent-isolation-guard`, a PreToolUse hook that denies Edit, Write, MultiEdit and NotebookEdit calls outside the policy's writable paths. The sandbox covers Bash only; this hook covers the file tools. +- **Sandbox proxy.** The HTTP and SOCKS proxy Claude Code runs for sandboxed commands. On Linux a sandboxed command has its own network namespace and reaches the network only through it. +- **Isolated process tree.** Every process descended from an isolated agent's launcher root pid, recorded in the root registry (D-10). +- **Trusted local caller.** Rule 4 of the remote request gate: `isTrustedLocalCaller` in `src/dashboard/server/routes/dashboard-auth.ts`. A trusted local caller passes the gate with no credential and mints the root session. +- **Agent socket.** A new Unix socket, `/agent-api/dashboard.sock`. The dashboard serves its normal HTTP app on it, and a request on it is never a trusted local caller (D-6). +- **Self job / self route.** A `pan` verb the dashboard runs for the calling agent with its own rights, in the agent's workspace and with the agent's identity variables (`src/dashboard/server/services/self-jobs.ts`, closed verb table in `services/self-job-argv.ts`). +- **Forwarded verb.** A `pan` verb that an isolated-context CLI sends to `POST /api/self/cli` instead of running locally (D-7). + +## Verified facts (probes run during planning, 2026-12-03) + +All probes ran Claude Code 2.1.335 on this Linux host (bubblewrap 0.9.0), in scratch directories, with `--settings `. `socat` is **not installed** on this host, so the probes put a copy from `apt-get download socat` on `PATH` for the probe process only. Every row below is an observed result. + +| # | Setting under test | Observed | +|---|---|---| +| P1 | `sandbox.filesystem.denyRead` on a directory | `cat` and Python `open()` get `ENOENT`: the directory is masked | +| P2 | `denyWrite` on a path inside an `allowWrite` path | `Read-only file system`: deny inside allow holds | +| P3 | Default write policy | Writes outside the cwd and `$TMPDIR` fail (`Read-only file system`) | +| P4 | Default Unix sockets | Every `connect()` fails `EPERM`: the Herdr socket, a test socket, `/var/run/docker.sock` | +| P5 | `sandbox.network.allowUnixSockets: [path]` on Linux | No effect: still `EPERM` | +| P6 | `allowAllUnixSockets: true` + `denyWrite` on the socket's directory | `connect()` **succeeds**. Deny-write does not stop a socket connect | +| P7 | `allowAllUnixSockets: true` + `denyRead` on the socket's directory (or file) | `ENOENT` (directory) or `ECONNREFUSED` (file masked with `/dev/null`): blocked | +| P8 | `allowRead` on a subdirectory of a `denyRead` directory | The subdirectory is readable; its siblings stay hidden | +| P9 | Direct TCP to `127.0.0.1:3011` from the sandbox | Fails: default `NO_PROXY` sends it direct, and the namespace has no route | +| P10 | `curl --noproxy '' --proxy "$HTTP_PROXY" http://127.0.0.1:3011/api/health` | **HTTP 200**: the sandbox proxy forwards to host loopback | +| P11 | `deniedDomains: ["127.0.0.1","localhost","*.localhost","::1"]` | Refused, including `127.0.0.1.nip.io` ("resolved to a deny-listed address") and `127.1` | +| P12 | `deniedDomains` with CIDR (`127.0.0.0/8`, `172.16.0.0/12`, …) | **Ignored**: `127.0.0.1`, `172.17.0.1:3011`, `172.31.0.1:80` (Traefik via a bridge gateway) and the LAN address all answered | +| P13 | Process view | 5 processes visible: the sandbox has its own PID namespace | +| P14 | Node `fetch` to the internet | `ENOTFOUND`; with `NODE_USE_ENV_PROXY=1` (Node 22.22) it returns 200 and prints an `EnvHttpProxyAgent is experimental` warning | +| P15 | git in a worktree with `allowWrite: []`, `denyWrite: [/hooks, /config]` | `git commit` works; `.git/hooks` write fails; `git config --local` fails (`could not lock config file`) | +| P16 | `git ls-remote` over https and ssh, `gh api` | All work through the proxy | +| P17 | `permissions.deny` with `Read(/abs/path)` | Does **not** match: a single leading `/` is relative to the settings file | +| P18 | `permissions.deny` with `Read(//abs/path)` and `Edit(//abs/dir/**)` | Blocks the Read and Write tools in `bypassPermissions` mode, **and** when a PreToolUse hook answers `allow` | +| P19 | A PreToolUse hook answering `deny` for `Write|Edit` | Blocks the Write tool in `bypassPermissions` mode | +| P20 | Sandbox `denyRead` vs the Read tool | The Read tool still reads a sandbox-`denyRead` file: the file tools need their own rules | +| P21 | A project `.claude/settings.local.json` adding `allowRead`, `excludedCommands: ["cat"]`, `allowAllUnixSockets` | None of them widened the `--settings` sandbox | +| P22 | `sandbox.network.allowedDomains: ["*"]` in `default` permission mode | Internet hosts reachable with no prompt | +| P23 | Codex 0.173 `codex sandbox -c sandbox_mode=workspace-write` | Reads the secret file; HOME write blocked; cwd write allowed; reaches `127.0.0.1:3011` directly | +| P24 | The composed D-8 profile (`allowAllUnixSockets`, `allowedDomains: ["*"]`; `denyRead` on a sockets dir, the Herdr sessions dir, `/tmp/tmux-`, `/run/user/`, `/tmp/.X11-unix`, `docker.sock`) | Internet and git over https work. A socket in a non-masked directory (the agent-socket stand-in) connects. The PTY-style socket, Herdr, D-Bus (`/run/user//bus`) and Docker are all blocked. `/tmp/.X11-unix` lists empty. Masking `XDG_RUNTIME_DIR` does not break Claude Code's own proxy bridge (its temp dir is `/tmp/claude-`) | + +Docs facts (code.claude.com, read 2026-12-03): hooks, stdio MCP servers and the status line run **outside** the sandbox. Without bubblewrap or socat, Claude Code runs commands **unsandboxed** unless `sandbox.failIfUnavailable: true`. Settings arrays merge across scopes, and a deny at any scope wins. + +Harness sandbox matrix, from the installed binaries' `--help` (2026-12-03): + +| Harness | Sandbox offered | Class | +|---|---|---| +| claude-code | OS sandbox (bubblewrap/Seatbelt), read deny, write allowlist, socket block, network namespace | `os-sandbox` | +| codex 0.173 | `workspace-write` OS sandbox (writes only); `--permission-profile` exists | `write-sandbox` | +| muse | Own OS sandbox, on by default (`muse sandbox`, `--permission-profile`) | `harness-default` | +| grok, opencode | Tool permission rules only (`--deny`, permission config) | `none` | +| pi, ohmypi (omp), kimi-code, prime-agent, antigravity, acp | None | `none` | + +## Threat model + +**Claim.** An isolated agent whose harness is Claude Code with a working sandbox cannot, from any tool: +1. read the operator secret set or another owner's agent token; +2. get a dashboard credential with `admin` scope or a root session, whether by an uncredentialed loopback request, the session mint, or the managed Traefik; +3. connect to the Herdr, tmux, PTY-supervisor or ACP-host sockets, so it cannot type into another pane; +4. write the files that Claude Code or Overdeck later run outside the sandbox with the operator's rights (D-8 lists them). + +**Residual risks** (stated in the docs, `pan doctor` and NonGoals; each needs its own issue): +- R-1. The verification gate and the post-merge deploy run workspace code (`npm run …`) outside any sandbox. An agent that edits `package.json` scripts reaches the operator's rights there. +- R-2. A harness with no sandbox (class `none`) can still read the secret files. It can also reach the dashboard as a trusted local caller by detaching from its process tree (`setsid`). For those harnesses the token change alone holds. +- R-3. `agents.isolation.allow_docker: true` gives the agent the Docker socket, which is root-equivalent. +- R-4. Isolated agents can still write `~/.overdeck/overdeck.db` and other non-secret Overdeck state (pipeline integrity, not the credential). +- R-5. Non-Bash tools that run outside the sandbox: an operator- or project-configured MCP server (for example Playwright) does whatever the agent asks of it. +- R-6. On macOS the peer rule (D-10) is off, and `pan doctor` says so. +- R-7. Other harness credentials the agent needs, such as `~/.claude/.credentials.json` and the `gh` token, stay readable. +- R-8. `~/.overdeck/config.yaml` stays readable, because the CLI reads it on every call. Audit F-5 notes it holds provider API keys and tracker tokens. +- R-9. Per-agent files under `~/.overdeck/agents//` (the PTY supervisor token, delivered `secrets/`) of *other* agents stay readable. An agent could forge another agent's lifecycle events or read its delivered secrets (lateral, not the operator credential). + +## Decisions + +- **D-1 Who is isolated.** An isolated agent is a launch whose token role is not `conversation` and not `flywheel`. Operator conversations (token role `conversation`) and the Flywheel (token role `flywheel`, whether an agent or the Flywheel conversation) keep the operator credential and get no sandbox. Lane and worker conversations (`laneRole !== null` → token role `worker`) are isolated. `isIsolatedTokenRole(role)` in `src/lib/agent-isolation/config.ts` is the one predicate. +- **D-2 Master switch.** `agents.isolation.enabled` (global `config.yaml` only, default `true`, secure by default). `false` restores today's behaviour for every launch. `.pan.yaml` cannot set it. Today `stripProjectSecurity` (`src/lib/config-yaml/load.ts`) does **not** strip `agents`, and an agent can commit a `.pan.yaml`, so WI-1 adds `agents.isolation` to the stripped keys. +- **D-3 Credential selection.** In an isolated context, hooks and the CLI read only `OVERDECK_AGENT_TOKEN_FILE` and send `Authorization: Bearer `. They never call `getInternalToken`, `ensureInternalToken` or read the internal-token file, and never fall back to them. The launcher unsets `OVERDECK_INTERNAL_TOKEN` for isolated launches (a long-lived Herdr or tmux server may carry a stale one, PAN-4628). +- **D-4 Token location.** Agent tokens move from `/mcp-token` to `/agent-tokens/agent//mcp-token` and `/agent-tokens/conversation//mcp-token`. The sandbox then denies `agent-tokens/` and re-allows the owner's own directory (P8). A per-file list would go stale as other agents launch. Revoke removes both the new file and any legacy `/mcp-token`. +- **D-5 Mint for isolation.** An isolated launch mints its token with `ensureAgentMcpToken` whatever `overdeckMcpEnabledFor(harness)` says. If the mint fails, the launch fails with an error naming the agent (fail closed). The MCP injection keeps its own fail-open behaviour. +- **D-6 CLI transport: the agent socket.** In the sandbox, loopback TCP needs the proxy and a future Claude Code could block it, while `allowAllUnixSockets` is documented. So the dashboard listens on `/agent-api/dashboard.sock` (directory 0700, socket 0600) and hands each connection to the HTTP server with the existing `deliverHttpSocket` (`src/dashboard/server/channel-listener.ts`). A Unix-socket request has no peer address, so `localPeerKind` returns `null` and only a credential passes the gate. The isolated CLI connects with `node:http` `socketPath`. It falls back to TCP only when the socket fails with `ENOENT`, `ECONNREFUSED` or `EPERM`, which is the Codex case. It never falls back to the internal token. +- **D-7 Forwarded verbs.** Verbs that need `admin` routes or terminal sockets run as self jobs. One route, `POST /api/self/cli` with body `{ "argv": string[] }`, matches argv against a closed table of forwarded verbs. Each row declares: the argv prefix, the token roles allowed, which positional (if any) is the issue (it must equal the caller's issue, case-insensitive), and the allowed flags. The flags are exactly the verb's commander options, minus any flag that selects another agent, issue, session, model or harness, or that forces (`--agent`, `--issue`, `--session`, `--model`, `--harness`, `--force`, `--yes` and any flag whose name ends in `-agent` or `-issue`). The server builds argv only through the existing `buildSelfJobArgv` piece types. The isolated CLI forwards a verb that matches a row, prints the job's stdout and stderr, and exits with the job's exit code. A row may also declare a **text tail**: trailing free-text positionals (a message), passed as one `rest` piece after `--`, so spaces and any text survive. A `ref` piece cannot carry spaces (`SELF_JOB_REF_PATTERN`). A row may declare **stdin**: the body's `stdin` string (at most 1 MiB) is written to the job's stdin, for `worker report` and `lane report`. **Path and issue flags.** A flag whose value the verb reads as a file (`--file`, `--brief`, any `--*-file`, `--path`, `--from`) is excluded unless the row marks it `workspacePath`. Then the server resolves it with `realpath` and requires it to lie inside the caller's workspace and outside the D-8 read-deny set; anything else gets 400 `path-outside-workspace`. A self job runs outside the sandbox, so a forwarded file flag would otherwise read operator secrets (critique round 1). `worker report` takes its report only on stdin. A row may name an **issue flag** (`issueFlag: 'issue'`): a supplied value must equal the caller's issue, the server strips it and injects `--issue=`. That is how `worker run`, which requires `--issue`, is forwarded. **Long and large jobs.** Self-cli jobs keep their whole stdout and stderr up to `SELF_JOB_MAX_BUFFER` (4 MiB), not the 16 KiB tail. A row marked `longRunning` gets a job timeout of `SELF_CLI_LONG_JOB_TIMEOUT_MS` (24 h) instead of 15 min. The CLI forwarder follows `next` wait chunks until the job ends. If the job is gone (404 `unknown-job`, for example after a dashboard restart), it exits 75 with `forwarded job lost (dashboard restarted?); re-run the command`. A verb that matches no row runs locally with the agent token. +- **D-8 The isolation policy (Claude Code).** + - **Read deny (sandbox `denyRead` + `Read(//…)` deny rules).** Inside ``: `internal-token`, `access-tokens.json`, `account.json`, `machine-key.json`, `machine-links.json`, `ssh-machines.json`, `credentials/`, `github-app/`, `cliproxy/`, `kimi-cliproxy-home/`, `secrets/`, `vault/`, `certs/`, `browser-profiles/` (browser profiles can hold a signed-in dashboard session cookie) and `agent-tokens/`, with `allowRead` for the owner's own token directory. + - **Socket masks (sandbox `denyRead` + `denyWrite`).** The Herdr sessions directory (`dirname(dirname(herdrSocketPath()))`), the tmux socket directory for the operator's uid (`$TMUX_TMPDIR` or `/tmp`, then `tmux-`), `/sockets`, `$XDG_RUNTIME_DIR` (or `/run/user/`), `/tmp/.X11-unix`, and `/var/run/docker.sock` plus `/run/docker.sock` unless `allow_docker`. With `allowAllUnixSockets: true` these masks are what blocks the sockets (P6, P7). The launcher creates each masked directory that is missing (`mkdir -p`, mode 0700) before launch, so a server that starts later still lands under the mask. + - **Write allow (sandbox `allowWrite`).** The default cwd and `$TMPDIR`. Also `/tmp`, the git common directory of the workspace and of each child repo in a polyrepo workspace (`git rev-parse --git-common-dir`), inside `` **only** `overdeck.db`, `panopticon.db` and `cache.db` with their `-wal`/`-shm` files, `logs/`, `tmp/` and `verification-workers/admission/` (an allowlist: every other entry in ``, classified or not, stays read-only; mutating verbs are forwarded, D-7), the package caches that exist at launch (`~/.npm`, `~/.bun`, `~/.cache`, `~/.local/share/pnpm`, `~/.yarn`, `~/.gradle`, `~/.m2`, `~/.cargo`, `~/go`, `~/.pub-cache`), and `agents.isolation.allow_write`. + - **Write deny (sandbox `denyWrite` + write guard hook + `Edit(//…)` deny rules).** In the workspace: `.git` (the file), `.claude/` and `.mcp.json`. For each git common dir: `hooks/` and `config`. `` needs no deny list beyond the read-deny set, because only the allowlisted entries are writable. `agent-api/` must stay out of the allowlist: an agent that could write it could unlink and rebind the socket and capture other agents' tokens. In the caches: `~/.bun/bin`, `~/.cargo/bin`, `~/go/bin`, `~/.npm/_npx` and `~/.cache/ms-playwright`, because MCP servers and browsers run from them outside the sandbox. Writes anywhere else in the home directory (rc files, `~/.claude`, `~/.config`, `~/.local/bin`) fall outside the allowlist and fail. + - **Sandbox switches.** `enabled: true`, `failIfUnavailable: true` (D-12), `allowUnsandboxedCommands: false` (no retry outside the sandbox, which also narrows F-4's auto-approval), `autoAllowBashIfSandboxed: true`, `network.allowAllUnixSockets: true`, `network.allowedDomains: ["*"]` (no network prompt in any permission mode, P22). +- **D-9 Socket wording.** The issue says "deny-write on the terminal-backend socket directories". P6 shows deny-write does not stop `connect()`, so the policy applies both `denyRead` (which blocks) and `denyWrite` (as worded) to those directories. This deviation is recorded in `autoDecisions`. +- **D-10 Peer rule.** The sandbox proxy forwards to host loopback (P10), and CIDR denies do not work (P12), so the network layer cannot keep an agent off the dashboard port. On Linux, the dashboard decides whether a loopback request's TCP connection is owned by a process in an isolated process tree. If it is, `localPeerKind` returns `null` for that request: no trusted local caller, no session mint, and a credential is required. The decision is made once per connection and cached on the socket. It runs only for a loopback peer that sent no credential, and only when the root registry is non-empty. + - **Root registry.** Before it starts the harness, each isolated launcher writes `/isolation/roots/.json` holding `{ "pid": $$, "startTime": }`. That directory is write-denied to the agent (D-8). The dashboard ignores and deletes an entry whose pid is gone or whose start time differs. + - **Lookup.** Read `/proc/net/tcp` and `/proc/net/tcp6` for the row whose local address is the client's address and port and whose remote address is the server's: that gives the inode. Collect the descendants of each live root through `/proc//task//children`. Then test whether any descendant's `/proc//fd` links to `socket:[]`. + - **Other platforms.** When `/proc/net/tcp` is absent (macOS), the rule is off and `pan doctor` warns (R-6). + - **Self-authenticated routes.** The rule does not apply to `POST /api/agents/:id/lifecycle` when the request carries `x-overdeck-pty-token`. The PTY supervisor runs inside the isolated tree, posts there with its own per-session token (not a dashboard credential), and today passes the gate only as an uncredentialed loopback caller. Its handler verifies that token. This exception list, `ISOLATED_PEER_SELF_AUTH_ROUTES` in `isolated-peer.ts`, holds only routes whose handler checks a non-dashboard secret. +- **D-11 Traefik.** A sandboxed process reaches the managed Traefik through the proxy at a bridge gateway (P12), and an in-tree browser reaches it directly. Traefik then forwards with a gateway client address, which `peerIsManagedTraefikForLocalClient` trusts. So while `agents.isolation.enabled` is true, a Traefik-forwarded request without a credential is **not** a trusted local caller. Browsers that already hold the 30-day `overdeck_session` cookie are unaffected. A new browser profile on `overdeck.localhost` signs in through the existing `#overdeck_token=` link or uses `http://localhost:`. The 401 body for that case names both. +- **D-12 Missing sandbox prerequisites: fail closed.** On Linux, an isolated Claude Code launch first checks that `bwrap` and `socat` are on `PATH`. If either is missing, the launch is **refused** before any pane starts, with the error `agent isolation: Claude Code sandbox unavailable (missing: socat). Install with: sudo apt-get install bubblewrap socat, or set agents.isolation.enabled: false to run agents unisolated`. The settings file also sets `failIfUnavailable: true`, so Claude Code itself refuses to run unsandboxed if the check is ever bypassed. `pan doctor` reports the same condition as an **error**. Overdeck never installs system packages. A fail-open launch would leave the credential readable with only a doctor message (critique round 1), so a missing prerequisite stops the launch instead. **Rollout hazard:** this host lacks `socat` today, so the work agent must state in the PR description, and in a `pan tell conv-flywheel` before `pan done`, that `sudo apt-get install socat` is required before this merges. +- **D-13 Codex.** An isolated Codex launch clamps `codex.permissionMode: full-access` to `workspace` (`workspace-write`). Conversations keep the configured mode. Reads of the secret set stay possible (P23); that is checkpoint CP-5. +- **D-14 Other harnesses.** Muse keeps its own default sandbox. Overdeck does not configure it beyond the token change, and the docs and doctor class it `harness-default`. grok, opencode, pi, ohmypi, kimi-code, prime-agent, antigravity and acp are class `none`, and `pan doctor` prints a warn row per configured harness of that class: `: no sandbox — the agent token is used, but the agent can read operator secrets`. +- **D-15 Launcher's own calls.** Commands the launcher script runs after the harness exits (review sub-role `pan tell`, `pan admin agents exited`) are Overdeck code the agent cannot change (`launcher.sh` sits under `agents/`, which is write-denied). They run with `env -u OVERDECK_AGENT_TOKEN_FILE`, so they keep the operator credential. +- **D-16 Hook routes.** Routes that only hooks and in-pane helpers call accept either the internal token or an agent token whose `agentId` equals the route's subject agent. The subject is the path `:id` where the route has one. For the session-keyed hook routes (`user-prompt-submit`, `turn-complete`, `permission-event`, the memory routes), the payload carries only `session_id` (`sync-sources/hooks/user-prompt-submit-hook` lines ~43-45, `stop-hook` ~85-92, `permission-event-hook` ~12-21). There the server resolves the session's owner (the agent or conversation whose recorded Claude session id is `session_id`, through the same lookup the handlers already use, `routes/hooks.ts` lines ~572-585, ~617-627, ~669-681) and compares that owner with the token's `agentId`. A session with no owner is refused for agent tokens (403 `not-self`); the internal token still passes. A mismatch gets 403 `{ "code": "not-self" }`. These routes get the `tell` scope row, which every agent role holds. +- **D-17 Admission queue.** Gate admission records stamp each pid with its PID namespace (`readlink /proc/self/ns/pid`). An owner from another namespace counts as alive until `staleMs`, because a sandboxed gate run sees every outside pid as dead (P13). Today that would steal live slots. +- **D-19 pi extension.** `packages/pi-extension/src/index.ts` reads `/internal-token` and posts heartbeat, work-complete, stuck, plan-checklist, classify-completion, conversation control-ack and specialists auto-complete. With `OVERDECK_AGENT_TOKEN_FILE` set, it sends the agent token instead. Those routes accept a self agent token (D-16). +- **D-18 F-4 narrowing.** The auto-approve hook is unchanged. For isolated Claude Code agents the boundary is the sandbox with `allowUnsandboxedCommands: false`, plus the deny rules, which hold even when the hook answers allow (P18). + +## Requirements + +- **FR-1** `isIsolatedTokenRole` returns true for `work`, `worker`, `plan`, `strike`, `sequencer`, `knowledge`, `review`, `test` and `ship`, and false for `conversation` and `flywheel`. Isolation applies only when `agents.isolation.enabled` is not `false`. +- **FR-2** In an isolated context the CLI and every hook authenticate with the agent token from `OVERDECK_AGENT_TOKEN_FILE`. They never read, create or send the internal token. +- **FR-3** Agent tokens live under `/agent-tokens/{agent,conversation}//mcp-token`. An isolated Claude Code sandbox can read only its own. +- **FR-4** An isolated Claude Code launch passes `--settings `. The file holds the D-8 sandbox, the deny rules and the write guard hook. +- **FR-5** From an isolated Claude Code sandbox, the Herdr, tmux, `~/.overdeck/sockets` and Docker sockets cannot be connected to (Docker only when `allow_docker` is false). +- **FR-6** The dashboard serves its HTTP app on the agent socket. A request there passes the gate only with a credential. +- **FR-7** `POST /api/self/cli` runs a forwarded verb as a self job for an agent token whose role the verb's row allows. It refuses any other issue, any disallowed flag, and any token role the row does not list. +- **FR-8** The hook and self-report routes (heartbeat, the hooks routes, the memory hook routes, the permission request, permission-event) accept an agent token that speaks only for itself (D-16). +- **FR-9** On Linux, a loopback connection owned by an isolated process tree is never a trusted local caller and never mints a session. +- **FR-10** While isolation is enabled, an uncredentialed Traefik-forwarded request is not a trusted local caller. +- **FR-11** Operator conversations and the Flywheel launch exactly as before: no `--settings` isolation file, no agent-token env, and the internal token available. +- **FR-12** An isolated Codex launch never runs `danger-full-access`. +- **FR-13** `pan doctor` reports the isolation state: the switch, the Claude Code sandbox prerequisites, and one row per configured harness class. +- **FR-14** `agents.isolation.{enabled, allow_docker, allow_write}` are parsed and validated (`enabled` and `allow_docker` booleans; `allow_write` absolute or `~`-prefixed paths). +- **FR-15** Gate admission does not reap a live owner from another PID namespace. +- **FR-17** In-pane processes keep working under the peer rule: the PTY supervisor's lifecycle post (own token) passes, and the pi extension authenticates with the agent token. +- **FR-16** The user and developer docs describe the model, the per-harness matrix, the residual risks and the config keys. +- **NFR-1** The peer rule does async file I/O only, runs only for uncredentialed loopback requests, and caches its answer per connection. No `execSync` and no blocking calls in server code. +- **NFR-2** An isolated launch whose token mint fails does not start. +- **NFR-3** No item raises a `scripts/file-size-allowlist.txt` cap. A growing god file gets an extraction instead. +- **NFR-4** New tests never read source files to assert content (the lint gate rejects source-grep tests) and add no `skipIf` or `.only`. + +## Work items + +Each item lands as its own commit with an `Item: ` trailer. File references were verified on `36e20af8c66`; search for the quoted anchor if a line has moved. + +### WI-1 `iso-config` — isolation config and paths (FR-1, FR-14) +- **New** `src/lib/config-yaml/schema-agent-isolation.ts`: `export interface AgentIsolationConfig { enabled?: boolean; allow_docker?: boolean; allow_write?: string[] }`. +- `src/lib/config-yaml/schema.ts`: inside `agents?: {` (anchor `/** RTK Bash output compression configuration */`) add one line, `isolation?: import('./schema-agent-isolation.js').AgentIsolationConfig;`. +- **New** `src/lib/agent-isolation/config.ts`: + - `readAgentIsolationConfig(config = loadYamlConfig().config): { enabled: boolean; allowDocker: boolean; allowWrite: string[] }`, defaulting to `{ enabled: true, allowDocker: false, allowWrite: [] }`, expanding `~`, and dropping relative paths with one warning each. + - `isIsolatedTokenRole(role: AgentTokenRole): boolean`. + - `isAgentIsolationActive(role)`, which is the config switch AND the role check. +- **New** `src/lib/agent-isolation/paths.ts` (no imports beyond `node:path` and `../paths.js`): `agentTokensDir()`, `agentTokenDir(kind, id)`, `isolationDir()`, `isolationOwnerDir(kind, id)`, `isolationRootsDir()`, `agentApiSocketPath()` (`/agent-api/dashboard.sock`), and the env var names `OVERDECK_AGENT_TOKEN_FILE`, `OVERDECK_DASHBOARD_SOCKET`, `OVERDECK_ISOLATED`. +- `src/lib/config-yaml/load.ts` `stripProjectSecurity` (anchor `const { security: _security, harnesses: _harnesses, computer_use: _computerUse, ...rest } = config;`): also drop `agents.isolation`, keeping the other `agents` keys (`caveman`, `rtk`). +- Tests: `src/lib/agent-isolation/__tests__/config.test.ts` covers each role, the switch off, `~` expansion, a relative path being dropped, and `stripProjectSecurity` removing `agents.isolation` while keeping `agents.rtk`. + +### WI-2 `token-location` — move agent tokens and decouple the mint (FR-3, NFR-2) +- `src/lib/mcp/agent-token.ts`: `agentMcpTokenPath(dir)` (anchor `export function agentMcpTokenPath`) becomes `agentMcpTokenPathFor(owner: { agentId; agentKind })`, which returns `agentTokenDir(kind, normalizedId)/mcp-token`. `ensureAgentMcpToken` writes there, creating the directory 0700. `revokeAgentMcpTokens` unlinks the new path and also the legacy `/mcp-token` when `dir` is known. +- `src/lib/mcp/agent-injection.ts`: `mintOverdeckTokenFile` uses the new path. The written `overdeck-mcp.json` keeps its location. +- **New** export `ensureIsolationToken(owner)` in `agent-token.ts`. It calls `ensureAgentMcpToken` without the `overdeckMcpEnabledFor` gate and rethrows any failure as `Error('agent isolation: token mint failed for : ')`. +- Tests: extend `tests/unit/lib/mcp/agent-token.test.ts` for the new path, legacy unlink, and `ensureIsolationToken` throwing. + +### WI-3 `iso-policy` — the pure isolation policy (FR-4, FR-5) — requiresInspection +- **New** `src/lib/agent-isolation/policy.ts`: + - `buildIsolationPolicy(input: IsolationPolicyInput): IsolationPolicy`, pure. The input is `{ overdeckHome, homeDir, workspace, gitCommonDirs, owner: { kind, id }, uid, herdrSessionsDir, tmuxSocketDir, xdgRuntimeDir, allowDocker, extraAllowWrite, existingCacheDirs }`. + - The output is `{ denyRead, allowRead, allowWrite, denyWrite, maskedSocketDirs, mkdirBeforeLaunch }`: arrays of absolute paths exactly as D-8 lists them. + - `serializePolicy(policy)` returns the JSON the guard hook reads (`{ version: 1, allowWrite, denyWrite }`). +- **New** `src/lib/agent-isolation/policy-input.ts`: `resolveIsolationPolicyInput(owner, workspace)` gathers the real values asynchronously (`execFile('git', ['rev-parse','--git-common-dir'])` for the workspace and each child directory holding a `.git` file; `herdrSocketPath()`; `process.getuid()`; `existsSync` checks for caches). +- Tests: `src/lib/agent-isolation/__tests__/policy.test.ts`. Assert every D-8 path class: the internal token is in `denyRead` and `denyWrite`; the own token dir is in `allowRead`; another owner's is covered only by `agent-tokens/`; `.git/hooks` and `.git/config` are in `denyWrite`; docker.sock is masked unless `allowDocker`; `extraAllowWrite` lands in `allowWrite`. + +### WI-4 `claude-settings` — render the isolation settings file (FR-4) +- **New** `src/lib/agent-isolation/claude-settings.ts`: + - `renderIsolationClaudeSettings(policy, guardHookPath, policyFile): object` returns: + ```json + { "sandbox": { "enabled": true, "failIfUnavailable": true, "allowUnsandboxedCommands": false, + "autoAllowBashIfSandboxed": true, + "network": { "allowAllUnixSockets": true, "allowedDomains": ["*"] }, + "filesystem": { "denyRead": [...], "allowRead": [...], "allowWrite": [...], "denyWrite": [...] } }, + "permissions": { "deny": ["Read(//)", "Read(///**)", "Edit(//)", "Edit(///**)"] }, + "hooks": { "PreToolUse": [{ "matcher": "Edit|Write|MultiEdit|NotebookEdit", + "hooks": [{ "type": "command", "command": "OVERDECK_ISOLATION_POLICY= " }] }] } } + ``` + - Permission paths use the `//` absolute form (P17). A directory gets `/**`; a file gets the bare path. + - `writeIsolationFiles(owner, policy)` writes `isolationOwnerDir(kind,id)/claude-settings.json` and `policy.json` (0600, directory 0700, temp file then rename) and returns both paths. +- Tests: `src/lib/agent-isolation/__tests__/claude-settings.test.ts`. Every `denyRead` path appears as a `Read(//…)` rule; no rule starts with a single `/`; the hook command names the policy file. + +### WI-5 `write-guard-hook` — the PreToolUse write guard (FR-4) +- **New** `sync-sources/hooks/agent-isolation-guard` (bash, `set -u`, needs `jq`, mode 0755). It reads the hook JSON from stdin and takes the target from `.tool_input.file_path` (Edit, Write, MultiEdit) or `.tool_input.notebook_path` (NotebookEdit). + - It resolves the target with `realpath -m`, or, when the target exists and is a symlink, with `realpath` so the link's destination is judged. + - It allows when the resolved path is under an `allowWrite` root and under no `denyWrite` root, and prints nothing (exit 0). + - Otherwise it prints `{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny","permissionDecisionReason":"agent isolation: is outside this agent's writable paths"}}`. + - It denies when the policy file is missing or unreadable (fail closed). +- `pan sync` already ships it: `src/lib/sync-hooks.ts` copies every file in `sync-sources/hooks/` to `~/.overdeck/bin/` (`readdirSync`), so there is no list to edit. The settings file names it as `join(BIN_DIR, 'agent-isolation-guard')`. `bin/` is write-denied to isolated agents (D-8), so an agent cannot replace it. +- Tests: `tests/scripts/agent-isolation-guard.test.ts` runs the script with `spawnSync` against a fixture policy. Cases: allowed path; denied path; a symlink in the cwd pointing to a denied file; a missing policy denies. + +### WI-6 `launch-isolation` — launcher wiring (FR-2, FR-4, FR-11, NFR-2) +- **New** `src/lib/agent-isolation/launch.ts`: `prepareAgentIsolation(owner: OverdeckMcpLaunchOwner): Promise<{ isolation?: LaunchIsolation }>`. It returns `{}` when `isAgentIsolationActive(owner.role)` is false. Otherwise it: + 1. for a claude-code launch on Linux, checks `bwrap` and `socat` on `PATH` and throws the D-12 error when either is missing (the check is an injected dependency so tests run without them); + 2. calls `ensureIsolationToken` (throws, so the launch fails, NFR-2); + 2. resolves the policy input and builds the policy; + 3. when the harness's `launchCommandKind` is `claude-code`, writes the settings and policy files; + 4. returns `LaunchIsolation = { settingsFile?: string; env: Record; unsetEnv: string[]; mkdirs: string[]; rootFile: string }`. `env` is `OVERDECK_AGENT_TOKEN_FILE`, `OVERDECK_DASHBOARD_SOCKET` (`agentApiSocketPath()`), `OVERDECK_ISOLATED=1` and `NODE_USE_ENV_PROXY=1`. `unsetEnv` is `['OVERDECK_INTERNAL_TOKEN']`. +- `src/lib/launcher-generator.ts`. Keep the file at or below its `origin/main` count plus its allowlist cap (938); put any helper in `src/lib/agent-isolation/launcher-lines.ts`. + - Add `isolation?: LaunchIsolation` to `LauncherConfig`. + - In `generateLauncherScript`, emit `mkdir -p -m 700 `, the `export` lines, the `unset` line, and the root-registry line from WI-13's `rootRegistrationLauncherLine(rootFile)`, after the env block and before `cd`. + - In `buildCommand`'s conversation branch and in `buildNonConversationCommand`, append ` --settings ` for the claude-code command when `settingsFile` is set. + - In `buildReviewSubRoleCommand`, prefix the post-exit `pan tell` and `pan admin agents exited` lines with `env -u OVERDECK_AGENT_TOKEN_FILE` (D-15). +- Tests: extend `src/lib/__tests__/launcher-generator*.test.ts`. An isolated claude-code launch contains `--settings`, the exports and the `unset`; a launch with `isolation` undefined is byte-identical to today; the review sub-role post-exit lines carry `env -u OVERDECK_AGENT_TOKEN_FILE`. + +### WI-7 `launch-sites-agents` — wire agent launch sites (FR-1, FR-4, FR-11) +Spread `...(await prepareAgentIsolation({...same owner as the MCP call...}))` next to each `prepareClaudeOverdeckMcp` / `prepareCodexOverdeckMcp` call: +- `src/lib/agents/spawn.ts` (anchors `await prepareClaudeOverdeckMcp({ agentId, agentKind: 'agent', role, harness: resolvedHarness` and the codex call above it); +- `src/lib/agents/spawn-prep.ts` (`const overdeckMcp = await prepareClaudeOverdeckMcp(`); +- `src/lib/agents/recovery.ts` (`...(await prepareClaudeOverdeckMcp({ agentId: normalizedId`); +- `src/lib/agents/messaging.ts` (`...(await prepareClaudeOverdeckMcp({ agentId: normalizedId, agentKind: 'agent', role: resumeRole`). + +A thrown isolation error must fail the spawn the same way a missing binary does. Tests: one spawn test per file asserts that the launcher config carries `isolation` for role `work` and no `isolation` for role `flywheel`. + +### WI-8 `launch-sites-planning-conv` — wire planning and conversation launch sites (FR-1, FR-11) +- `src/lib/planning/spawn-planning-session.ts` (`...(await prepareClaudeOverdeckMcp({ agentId: sessionName`) and `src/dashboard/server/routes/misc/planning.ts` (same anchor): role `plan` is isolated. +- `src/lib/overdeck/conversation-runtime.ts` (anchors `? await prepareClaudeOverdeckMcp({ agentId: tokenRow.name` and the codex call): pass `role: conversationTokenRole(tokenRow, role, tmuxSession)`. A plain conversation resolves to `conversation`, so it is not isolated (FR-11); a lane conversation resolves to `worker`, so it is. +- Tests: a conversation launch test asserts that no `--settings` appears for a plain conversation and that it does appear for a lane conversation. + +### WI-9 `agent-socket` — the agent socket listener (FR-6) +- **New** `src/dashboard/server/agent-api-socket.ts`: `installAgentApiSocket(): Promise<() => Promise>`. + - Create the directory 0700 and unlink a stale socket. + - `net.createServer((socket) => { if (!deliverHttpSocket(socket)) socket.destroy(); })`, then `listen(agentApiSocketPath())` and `chmod 0600`. + - Return a closer that closes the server and unlinks the socket. +- `src/dashboard/server/server.ts`: right after `installChannelListener(nodeServer, {` (primary dashboard only), call it and register the closer with the server's shutdown. +- Tests: `src/dashboard/server/__tests__/agent-api-socket.test.ts` drives a real request over the socket against a test server. Without a credential, `GET /api/agents` gets 401; with an agent token it gets 200; the socket file mode is 0600. + +### WI-10 `cli-credential` — CLI credential and transport helper (FR-2) +- **New** `src/lib/dashboard-client/agent-credential.ts`: + - `isIsolatedAgentContext(env = process.env): boolean` (`OVERDECK_AGENT_TOKEN_FILE` set and non-empty). + - `readAgentToken(env)`: reads the file each call; must match `/^odk_[0-9a-f]{64}$/`; throws `AgentCredentialError` otherwise. + - `dashboardAuthHeaders(env)`: `{ authorization: 'Bearer ' }` in an isolated context, else `{ [INTERNAL_TOKEN_HEADER]: ensureInternalToken() }`. + - `dashboardFetch(path, init, env)`: in an isolated context with `OVERDECK_DASHBOARD_SOCKET` set, use `node:http` `request({ socketPath, path, method, headers })` and return a WHATWG `Response`. On `ENOENT`/`ECONNREFUSED`/`EPERM` from the socket, retry once over TCP at `getDashboardApiUrl()`. Otherwise use `fetch(getDashboardApiUrl() + path)`. It always adds `dashboardAuthHeaders` and removes any `x-overdeck-internal-token` header the caller set. +- Tests: `src/lib/dashboard-client/__tests__/agent-credential.test.ts` uses a temp `OVERDECK_HOME` and a real Unix-socket test server. It asserts that an isolated context sends Bearer and never creates `internal-token`, and that a non-isolated context sends the internal header. + +### WI-11 `cli-callers` — route CLI-side dashboard calls through the helper (FR-2) +Replace every `ensureInternalToken()`/`getInternalToken()` header construction on the CLI paths with `dashboardFetch` or `dashboardAuthHeaders`. Files: `src/cli/commands/dashboard-call.ts` (anchor `[INTERNAL_TOKEN_HEADER]: ensureInternalToken()`), `src/lib/agent-runtime.ts`, `src/lib/pipeline-notifier.ts`, `src/lib/cloister/deacon-event-client.ts`, `src/cli/commands/plan.ts`, `src/cli/commands/start.ts`. + +Behaviour outside an isolated context stays identical. `pipeline-notifier.ts` keeps its "skip when no credential" rule, but in an isolated context it posts with the agent token. Tests: extend each module's existing test to cover the isolated context sending Bearer, and confirm that `ensureInternalToken` is not called (spy on the module export). + +### WI-12 `in-pane-callers` — in-pane helpers use the agent token (FR-2) +- `src/lib/caveman/workspace.ts`: the memory hook script it writes (anchors near `internal-token` at lines ~183-223) reads `$OVERDECK_AGENT_TOKEN_FILE` when set and sends `Authorization: Bearer`, else today's internal token. +- `src/lib/codex/prompt-memory.ts`: use `dashboardAuthHeaders()`. +- `src/lib/channels/overdeck-bridge.ts`: the permission-request post uses `dashboardAuthHeaders()`. +- Tests: extend `src/lib/caveman/__tests__/workspace.test.ts` (asserting on the generated script text is fine: it is output, not source) and `src/lib/codex/__tests__/prompt-memory.test.ts`. + +### WI-13 `hooks-token` — hook scripts use the agent token (FR-2) +- `sync-sources/hooks/pan-hook-lib.sh` (anchor `_pan_token_path="${OVERDECK_HOME:-$HOME/.overdeck}/internal-token"`): when `OVERDECK_AGENT_TOKEN_FILE` is set, read it into `PAN_AGENT_TOKEN`, set an auth header variable to `Authorization: Bearer $PAN_AGENT_TOKEN`, and do not read `internal-token`. Otherwise keep today's behaviour. Both curl call sites (lines ~366 and ~417) use the header variable. +- `sync-sources/hooks/session-start-hook` (anchor `TOKEN_PATH="${OVERDECK_HOME:-$HOME/.overdeck}/internal-token"`), `stop-hook` (same anchor; also add the header to the planning `complete-planning` curl, anchor `/api/issues/$ISSUE_ID/complete-planning`), `user-prompt-submit-hook` (same anchor), and `permission-event-hook` get the same rule. +- Tests: `tests/scripts/hooks-agent-token.test.ts` runs `pan-hook-lib.sh`'s auth-header function and the session-start hook against a stub dashboard (a local HTTP server) with `OVERDECK_AGENT_TOKEN_FILE` set. It asserts the Bearer header, and that no `internal-token` read happens: give it an `OVERDECK_HOME` with no internal-token file and assert no file appears. + +### WI-14 `self-auth-routes` — hook and self-report routes accept a self agent token (FR-8) +- **New** `src/dashboard/server/routes/self-or-internal.ts`: `authorizeInternalOrSelfAgent(request, subjectAgentId: string | null): { ok: true } | { ok: false; response }`. It passes the internal token (header or Bearer). It passes an agent token (`resolveRequestCredential` → `kind: 'token'` with `agentId`) whose normalized `agentId` equals the normalized subject. Anything else gets 401, or 403 `{ "code": "not-self" }` for a token speaking for someone else. +- Use it in: + - `routes/agents/shared.ts` `validateAgentRuntimeEventAuth` (anchor `const provided = getHeaderFromMap(request.headers as Record, INTERNAL_TOKEN_HEADER);`). It gains a `subjectAgentId` parameter, and every caller in `routes/agents/runtime-events.ts` (heartbeat line ~117, work-complete ~138, stuck ~155, plan-checklist ~191) passes the route `:id`; + - `routes/hooks.ts` at the five `if (!hasDashboardInternalToken(request)) return jsonResponse({ error: 'unauthorized' }, { status: 401 });` sites (lines ~429, ~454, ~495, ~654, ~697; subject = the body's agent id field each handler already parses); + - `routes/agents/permissions.ts` internal permission request (lines ~291-303; subject = `:id`); + - `routes/hooks.ts` `POST /api/hooks/permission-event` (subject = body agent id). +- `src/dashboard/server/routes/issues.ts` complete-planning (anchor `'/api/issues/:id/complete-planning',`, line ~360; reached from the planning stop-hook). The WI-15 `operate` row lets agent tokens through the gate, so the handler must keep other credentials from widening: + - an agent token passes only when its role is `plan` and its agent's issue equals `:id` (`selfCallerFromCredential` resolves the issue); + - any other credential must hold `admin` (`credentialScopes(credential).includes('admin')`), so a phone, machine or connector token with `operate` gets 403; + - an uncredentialed trusted local caller passes as today. +- Tests: one route test per file covers the internal token, the own agent token, another agent's token (403 `not-self`), a token for agent A carrying agent B's `session_id` (403 `not-self`), a `session_id` with no owner (403 for an agent token), and no credential. + +### WI-15 `route-scope-rows` — route-scope rows for agent-callable routes (FR-8) +`src/dashboard/server/route-scopes.ts`: add `tell` rows for `POST /api/agents/:id/heartbeat`, `POST /api/hooks/turn-complete`, `POST /api/hooks/user-prompt-submit`, `POST /api/hooks/permission-event`, `POST /api/memory/inject`, `POST /api/memory/session/start`, `POST /api/memory/turn` and `POST /api/internal/agents/:id/permissions/request`. Add `operate` for `POST /api/issues/:id/complete-planning`, `read:state` for `GET /api/agents/:id/runtime`, `read:conversations` for `GET /api/agents/:id/conversation`, and `read:state` for `POST /api/self/cli` (the route enforces the role itself). For the pi extension (D-19), add `tell` rows for `POST /api/agents/:id/work-complete`, `/stuck`, `/plan-checklist`, `/classify-completion`, `POST /api/conversations/:name/control-ack` and `POST /api/specialists/:name/auto-complete`. This item is the only one that edits `route-scopes.ts`. Add the `POST /api/self/cli` row to the no-loss matrix, `tests/unit/lib/overdeck/no-loss-matrix.ts` (memory: a new HTTP route without one fails CI). Tests: extend the route-scopes table test to assert each row. + +### WI-16 `self-cli-route` — the forwarded-verb route and CLI forwarder (FR-7) — requiresInspection +- **New** `src/dashboard/server/services/self-cli-verbs/index.ts`: `SELF_CLI_VERBS: readonly SelfCliVerb[]`, concatenated from the family files `core.ts`, `messaging.ts`, `planning.ts`, `review.ts`, `swarm.ts` and `misc.ts` (each `export const VERBS: SelfCliVerb[] = []` at first). + - `SelfCliVerb = { prefix: string[]; roles: AgentTokenRole[]; issuePositional?: number; positionals: number; flags: Record; stdin?: boolean }`. + - `matchSelfCliVerb(argv)` returns the longest-prefix row or null. +- **New** `src/dashboard/server/services/self-cli-argv.ts`: `buildSelfCliArgv(row, argv, caller)` validates every token against the row (flags only from `row.flags`; values as `{flag,value}` pieces; positionals as `{ref}` pieces; the issue positional must equal `caller.issueId` case-insensitively, else `SelfJobArgError('issue-mismatch')`). It returns argv built only through `buildSelfJobArgv`'s piece types (extend `self-job-argv.ts` with an exported `buildArgvFromPieces(prefix, pieces)` if needed, keeping the H-6 ref rule). +- Argument kinds (D-7): a row may set `textTail: true`, meaning trailing positionals after the fixed ones are joined into one `rest` piece placed after `--`; and `stdin: true`, meaning the body's `stdin` string (at most 1 MiB) goes to the job's stdin. Extend `SelfJobRunInput` in `services/self-jobs.ts` with `stdin?: string`; when it is set, the runner writes it to the child's stdin and closes it (keep the injected-runner design). +- **New** `src/dashboard/server/routes/self-cli.ts`: `POST /api/self/cli` with body `{ argv: string[], stdin?: string }` (argv at most 64 elements, each at most 8 KiB). + - Caller from `selfCallerFromCredential`. A role not in the row gets 403 `{ code: "role-not-allowed" }`; no row gets 404 `{ code: "verb-not-forwarded" }`; a validation error gets 400. + - It starts the job with `selfJobs` (extend `SelfJobRunInput` to take a prebuilt argv) and answers `selfJobAnswer`. + - Register it with the existing self routes. +- Rows may set `issueFlag`, `workspacePath` flags and `longRunning` (D-7). In `services/self-jobs.ts`, a self-cli job keeps full stdout/stderr up to `SELF_JOB_MAX_BUFFER` and uses `SELF_CLI_LONG_JOB_TIMEOUT_MS` when its row is `longRunning`. The timeout is injected, so tests use fake timers. +- **New** `src/cli/isolated-forward.ts`: `maybeForwardIsolatedVerb(argv = process.argv.slice(2)): Promise`. It returns null outside an isolated context. Otherwise it posts to `/api/self/cli` through `dashboardFetch`, follows `next` with `GET /api/self/jobs/:id/wait` until done, writes stdout and stderr, and returns the exit code. On 404 `verb-not-forwarded` it returns null so the verb runs locally. +- `src/cli/index.ts`: before `await runCliWithTelemetry(() => program.parseAsync(`, add `const forwarded = await maybeForwardIsolatedVerb(); if (forwarded !== null) process.exit(forwarded);`. +- Rows in `core.ts` (this item): `task claim|done|block|unblock|next|cancel`, `memory edit|retire|pin|unpin` (every isolated role), `done`, `handoff`, `worker report`, `lane report`, `memory add|search`. Roles: every isolated role for `memory`; `work`, `strike`, `knowledge` for `done`; `work`, `strike` for `task`; `work` for `handoff`; `worker` for `worker report` and `lane report` (both `stdin: true`). A `worker` token never gets `done` or `task` (`roles/worker.md`: "Never run `pan done`, `pan review`, or `pan task done`"). +- Tests: `src/dashboard/server/__tests__/self-cli-route.test.ts` (role refusal, issue mismatch, disallowed flag, unknown verb 404, a valid `task done` job, a `worker report` with stdin reaching the job, `worker report --file ~/.overdeck/internal-token` refused with 400 `path-outside-workspace`, a stdout over 16 KiB returned whole, and a `longRunning` job still running after 15 minutes of fake time), and `src/cli/__tests__/isolated-forward.test.ts` (forwards when isolated, returns null otherwise, honours the exit code). + +### WI-17 `forward-messaging` — forward tell, ask, sync-main (FR-7) +Add rows in `self-cli-verbs/messaging.ts`: `tell` (all isolated roles; positional 0 is the target and not the issue; `textTail: true` for the message), `ask` (`work`, `strike`; `textTail: true`), `sync-main` (`work`, `strike`; issue positional 0), `review request` (`work`, `strike`; issue positional 0). Test: forwarding `['tell','conv-flywheel','three word message']` runs `pan tell conv-flywheel -- three word message`, and the message arrives intact. Flags follow the D-7 rule, read from each verb's commander definition (`src/cli/index.ts` / its command module). Tests: row-level cases in `self-cli-route.test.ts`. + +### WI-18 `forward-planning-review` — forward plan finalize and the review/test verbs (FR-7) +- `self-cli-verbs/planning.ts`: `plan finalize` and `plan done` (role `plan`; issue positional 0 when given; with no positional the server injects the caller's issue). +- `self-cli-verbs/review.ts`: `admin specialists done` (roles `review`, `test`), `review spawn-reviewer` (role `review`) and `admin seed-uat-fixtures` (role `test`). The issue positional must match. +- Tests: rows reject a `work` token for `admin specialists done` (a work agent must never record its own review verdict). + +### WI-19 `forward-swarm-misc` — forward swarm, worker, backlog, knowledge (FR-7) +- `self-cli-verbs/swarm.ts`: `swarm dispatch|merge|status|wait|resume|recover|freeze`, `foreman` and `spawn` (role `work`; issue positional when the subcommand takes one), and `workspace add-repo` (role `work`, issue positional; the cloister prompt builders tell polyrepo work agents to run it, and it writes another repository's git dir, which the sandbox denies). +- `self-cli-verbs/misc.ts`: `worker run` (roles `work`, `plan`; `issueFlag: 'issue'`; `--brief` marked `workspacePath`; `--prompt` text allowed; `longRunning`), `worker wait` (roles `work`, `plan`; `longRunning`), `worker stop` (roles `work`, `plan`). Test: `pan worker run --issue --prompt 'x y'` forwards with the server-injected issue; `--issue ` gets 400. `backlog write-sequence` (role `sequencer`), `knowledge` (role `knowledge`). +- Tests: row cases. + +### WI-20 `peer-rule` — isolated process trees are not trusted local callers (FR-9, NFR-1) — requiresInspection +- **New** `src/lib/agent-isolation/roots.ts`: + - `rootRegistrationLauncherLine(rootFile)` returns the bash line that writes `{"pid":$$,"startTime":}` to `rootFile` (temp file, then `mv`), guarded by `[ -r /proc/$$/stat ]`. + - `readLiveRoots(deps)` lists the root files and drops and deletes stale entries. +- **New** `src/dashboard/server/isolated-peer.ts`: + - `resolveIsolatedPeer(socket: { remoteAddress, remotePort, localAddress, localPort }, deps = realProcFs): Promise`, implementing D-10 with `fs/promises` only. + - A `WeakMap>` caches per socket. + - Returns false immediately when there are no live roots or `/proc/net/tcp` is absent. +- `src/dashboard/server/routes/dashboard-auth.ts`. Keep the file at or below its count; move logic into `isolated-peer.ts`. + - `ensurePeerIdentityFresh(request)` (anchor `export function ensurePeerIdentityFresh`) also awaits `resolveIsolatedPeer` for a literal-loopback peer that carries no credential, and stores the result on the request's socket. + - `localPeerKind` (anchor `if (addr === '127.0.0.1' || addr === '::1') return 'loopback';`) returns `null` when the socket is marked isolated. + - `isTrustedLocalNodeRequest` awaits the same resolution: make its callers await an async variant, `isTrustedLocalNodeRequestAsync`, at `routes/workspace-wake.ts:95`. +- `ISOLATED_PEER_SELF_AUTH_ROUTES` (D-10): for `POST /api/agents/:id/lifecycle` carrying `x-overdeck-pty-token`, the rule is skipped and `localPeerKind` answers as today. +- Tests: `src/dashboard/server/__tests__/isolated-peer.test.ts` with an injected fake `/proc` (tcp table, children, fd links). A connection owned by a descendant is isolated; an unrelated pid is not; a stale root is ignored and deleted; no roots means no fs reads. A gate test asserts that a marked socket gets 401 on `POST /api/dashboard/session`, and that a marked socket's `POST /api/agents/x/lifecycle` with `x-overdeck-pty-token` still reaches the handler. + +### WI-21 `traefik-trust` — no uncredentialed Traefik trust under isolation (FR-10) +- `src/dashboard/server/routes/dashboard-auth.ts` `localPeerKind`: when `readAgentIsolationConfig().enabled` is true, the `traefik` branch returns `null` (the cookie path still authenticates through `resolveDashboardCredential`). +- The session mint's 401 for a Traefik-forwarded request answers `{ "error": "sign in: open http://localhost: on this machine, or use a #overdeck_token= link from `pan serve`", "code": "isolation-sign-in" }`. +- Tests: extend the dashboard-auth tests. A Traefik-forwarded uncredentialed mint gets 401 `isolation-sign-in` with isolation on and 200 with it off. + +### WI-22 `admission-pidns` — PID-namespace-aware gate admission (FR-15) +- `src/lib/cloister/quality-gate-admission.ts`: + - Add `pidNs?: string` to the ticket, owner and breaker records written by `publishExclusive` (anchor `await publishExclusive(path, { pid: process.pid, acquiredAt: now() })`), read from `readlinkSync('/proc/self/ns/pid')` once per process (or `undefined` off Linux). + - `ownerIsStale` (anchor `return now - owner.acquiredAt > staleMs || !isProcessAlive(owner.pid)`) and the breaker check treat a record whose `pidNs` differs from ours as alive until `staleMs`. + - Put the helper in a new `quality-gate-admission-pidns.ts` if the file would grow past its count. +- Tests: extend `tests/unit/lib/cloister/quality-gate-admission.test.ts` with injected `isProcessAlive` and `pidNs`. A foreign-namespace owner within `staleMs` is kept; past `staleMs` it is cleared. + +### WI-23 `codex-clamp` — isolated Codex never runs full access (FR-12) +- `src/lib/agents/runtime-command.ts` `getCodexLauncherFields` (anchor `const codexPermMode = codexConfig?.permissionMode ?? 'workspace';`): add a parameter `isolated: boolean`. When it is true and the mode is `full-access`, use `workspace`. Callers pass `isAgentIsolationActive(role)`. Conversations use `src/lib/overdeck/conversation-runtime.ts`'s own path and are unchanged. +- **Implementation checkpoint CP-5:** run `codex sandbox --help` and the Codex config docs for a permission profile that denies reads of given paths. If one exists, add the D-8 read-deny set through it in `initCodexHome`. If not, leave a code comment citing CP-5 and keep the class `write-sandbox`. +- Tests: `getCodexLauncherFields` with `isolated: true` and `full-access` yields `danger-full-access` never; `isolated: false` is unchanged. + +### WI-24 `capability-doctor` — harness isolation class and `pan doctor` (FR-13) +- `packages/contracts/src/harness-capabilities.ts`: add `readonly agentIsolation: 'os-sandbox' | 'write-sandbox' | 'harness-default' | 'none'` to `HarnessCapabilities`, and set it in every capabilities constant per the matrix above. +- **New** `src/cli/commands/doctor-agent-isolation.ts`: `checkAgentIsolation(deps): Promise` (local `CheckResult` re-declaration as `doctor-permission-mode.ts` does). Rows: + - `Agent isolation`: ok, `on`, or warn, `off (agents.isolation.enabled: false)`. + - On Linux with Claude Code configured: `Claude Code sandbox`: ok when `bwrap` and `socat` are on PATH, else **error** naming the missing ones, with the fix `sudo apt-get install bubblewrap socat`. + - `Dashboard peer rule`: warn on non-Linux. + - One row per configured harness of class `write-sandbox`, `harness-default` or `none`, with the D-14 message. + - `Docker access`: warn when `allow_docker` is true. +- `src/cli/commands/doctor.ts`: one line `for (const c of await checkAgentIsolation()) checks.push(c); // PAN-5754` after the `checkClaudeCode()` line. +- Tests: `src/cli/commands/__tests__/doctor-agent-isolation.test.ts` with injected PATH lookups, platform and config. + +### WI-25 `docs` — documentation (FR-16) +- **New** `configuration/agent-isolation.mdx`, and add `"configuration/agent-isolation"` to `docs.json` next to `"configuration/permissions"`. Sections: + - Who is isolated (D-1). + - What an isolated Claude Code agent can and cannot reach (D-8 lists). + - The per-harness table (classes and messages). + - The config keys with defaults. + - Prerequisites (`bubblewrap`, `socat`) and the fail-closed behaviour: a launch without them is refused with the install command. + - Signing in on `overdeck.localhost` (D-11). + - Docker opt-in (R-3). + - Residual risks R-1 to R-9. +- **New** `docs/AGENT-ISOLATION.md` (developer): architecture (policy → settings file, guard hook, agent socket, forwarded verbs table, peer rule, root registry), the probe table, and how to add a forwarded verb row. +- `docs/DASHBOARD-AUTH.md`: the agent socket; the peer rule under "Remote request gate" rule 4; the Traefik change; `POST /api/self/cli` under "`/api/self/*`". +- `docs/SECURITY-AUDIT-2026-11-29.md`: the F-9 and F-4 rows and the F-9 paragraph record "Fixed by PAN-5754 for Claude Code agents", with the residual risks. +- `configuration/harnesses.mdx`: an "Agent isolation" column or subsection with each harness's class. +- `CLAUDE.md`: one Key Invariants line ("Isolated agents (token role not conversation/flywheel) use their agent token only; Claude Code agents run Bash in the sandbox; see docs/AGENT-ISOLATION.md") and a Topic Index row. +- `.overdeck/context/codebase/concerns.md`: update the "Claude Code Auto permission mode filters nothing" entry with the isolation boundary. Leave its `last-verified` line unchanged. +- **New** `changelog.d/pan-5754.md` under `#### New`. +- Verify: `npm run lint:docs`. + +### WI-26 `pi-extension-token` — the pi extension uses the agent token (FR-2, FR-17) +- `packages/pi-extension/src/index.ts`: the token read (anchor `const token = (await readFile(join(overdeckHome, 'internal-token'), 'utf8')).trim()`) first checks `process.env.OVERDECK_AGENT_TOKEN_FILE`. When it is set, the extension reads that file, sends `Authorization: Bearer ` on every dashboard post (`postWithTimeout`, `postJsonWithTimeout`, `postDashboard`), and never reads `internal-token`. Otherwise it behaves as today. +- Tests: extend `packages/pi-extension/src/__tests__/index.test.ts`. Assert the Bearer header with the env var set, and the internal-token header without it. + +### WI-27 `pi-routes-self-auth` — routes the pi extension calls accept a self agent token (FR-8, FR-17) +- `src/dashboard/server/routes/conversations.ts` control-ack (anchor `'/api/conversations/:name/control-ack',`, line ~741). Use `authorizeInternalOrSelfAgent` with subject = `:name` for an agent id, or the conversation's tmux session for a conversation. +- `src/dashboard/server/routes/specialists/legacy-routes.ts` auto-complete (anchor `'/api/specialists/:name/auto-complete',`, line ~601). An agent token passes only with role `review` or `test` and when the body's issue equals the token agent's issue; other credentials keep today's check. +- `routes/agents/runtime-events.ts` classify-completion (line ~173) has no handler auth today. Leave it, but note in `docs/DASHBOARD-AUTH.md` that the WI-15 `tell` row now admits any `tell`-scoped token. +- Tests: one route test per file: own token passes, another agent's token gets 403 `not-self`, and a `work` token on auto-complete gets 403. + +### WI-28 `verb-coverage` — every agent-facing verb is forwarded or known-local (FR-7, H1) +- **New** `src/dashboard/server/__tests__/self-cli-coverage.test.ts`. A data table lists every `pan` verb that isolated roles are told to run, taken from `roles/*.md`, the cloister prompt builders (`src/lib/cloister/*prompt*.ts`) and the agent skills `pan-task`, `pan-done`, `pan-tell`, `pan-worker`, `pan-foreman`, `pan-memory`, `pan-handoff`, `pan-sync-main` and `pan-plan` (`sync-sources/skills//SKILL.md`). Each verb carries its disposition: `forwarded:`, or `local-read`. + - `local-read` is allowed only for read-only verbs: `task show`, `task next`, `show`, `status`, `memory search|show|list|read`, `conv pending|current|list|show|whoami`, `worker list` and `lane` reads. + - For each `forwarded` verb, the test asserts that `matchSelfCliVerb(argv)` finds a row whose `roles` include the listed roles. +- The table is test data, not a scan of source files (NFR-4). + +### WI-29 `launch-sites-runtimes` — isolation at the runtime entry points (FR-1, FR-4, FR-12) +Crash recovery (`src/lib/cloister/service-crash.ts` line ~433, `runtime.spawnAgent({`) and session rotation (`src/lib/cloister/session-rotation.ts` line ~249) launch through the runtime registry, not the WI-7 sites. Each runtime also builds its own launch: the Codex runtime builds its own command without `generateLauncherScript` (`src/lib/runtimes/codex.ts` lines ~674-699); ohmypi, Muse, Kimi and Prime Agent call `generateLauncherScript` from their runtime modules. +- In every runtime `spawnAgent` implementation (`src/lib/runtimes/claude-code.ts`, `codex.ts`, `ohmypi.ts`, `pi.ts`, `muse.ts`, `kimi-code.ts`, `prime-agent.ts`, `acp.ts`), call `prepareAgentIsolation` for the spawn's owner. When the caller already passed an `isolation` value (the WI-7 sites), reuse it and do not mint twice. + - Generator-based runtimes pass it to `generateLauncherScript`. + - The Codex runtime emits the same `export`/`unset`/root-registration lines into its own command and applies the D-13 clamp. +- `src/lib/remote/remote-agents.ts` (Fly VMs) is out of scope. **Checkpoint CP-7:** confirm the Fly VM holds no copy of this host's `internal-token`. If it does, file a follow-up issue and link it from `docs/AGENT-ISOLATION.md`. +- Tests: `src/lib/cloister/__tests__/isolation-runtime-launch.test.ts`. A crash restart through `service-crash.ts` and a rotation through `session-rotation.ts` of a `work` agent each produce a launch with the token export; a Codex runtime spawn of an isolated agent writes `workspace-write`. + +## Acceptance criteria (map to items) + +- WI-1: `isIsolatedTokenRole('work')` returns true and `isIsolatedTokenRole('flywheel')` returns false; `readAgentIsolationConfig({})` returns `{ enabled: true, allowDocker: false, allowWrite: [] }`. +- WI-2: after `ensureAgentMcpToken`, the token file exists at `/agent-tokens/agent//mcp-token` with mode 0600; `ensureIsolationToken` rejects when the registry write fails. +- WI-3: `buildIsolationPolicy` output lists `/internal-token` in `denyRead` and `denyWrite`, the owner's token dir in `allowRead`, and `/hooks` in `denyWrite`; docker.sock is in `maskedSocketDirs` only when `allowDocker` is false. +- WI-4: the rendered settings contain `"allowUnsandboxedCommands": false` and only `Read(//…)`/`Edit(//…)` rules; the PreToolUse matcher is `Edit|Write|MultiEdit|NotebookEdit`. +- WI-5: the guard prints a deny decision for a target under `/config.yaml`, including through a symlink in the cwd, and prints nothing for a file in the workspace. +- WI-6: an isolated claude-code launcher script contains `--settings` and `unset OVERDECK_INTERNAL_TOKEN`; a non-isolated launcher is unchanged byte for byte. +- WI-7 and WI-8: a `work` spawn carries `isolation`; a plain conversation does not; a lane conversation does. +- WI-9: over the agent socket, an uncredentialed `GET /api/agents` gets 401 and an agent-token request gets 200. +- WI-10 and WI-11: in an isolated context, no `internal-token` file is created and requests carry `Authorization: Bearer odk_…`. +- WI-12: the generated caveman memory hook script sends the Bearer header when `OVERDECK_AGENT_TOKEN_FILE` is set. +- WI-13: hook scripts send the Bearer header with `OVERDECK_AGENT_TOKEN_FILE` set and never read `internal-token`. +- WI-14: a heartbeat from agent A's token for agent B returns 403 `not-self`; A's own heartbeat returns 2xx; a connector token with `operate` on complete-planning returns 403. +- WI-15: the route-scope table maps each listed route to the stated scope. +- WI-16: a `worker` token forwarding `done` returns 403 `role-not-allowed`; a `work` token forwarding `task done ` returns 400 `issue-mismatch`; a `review` token forwarding `task done` returns 403 `role-not-allowed`; an unknown verb returns 404 and the CLI runs it locally. +- WI-17 to WI-19: each listed verb has a row with the stated roles; a `work` token cannot forward `admin specialists done`. +- WI-20: a loopback connection owned by a descendant of a registered root gets 401 on `POST /api/dashboard/session`; with no roots registered, the mint is unchanged. +- WI-21: an uncredentialed Traefik-forwarded mint returns 401 `isolation-sign-in` with isolation enabled. +- WI-22: a foreign-PID-namespace owner younger than `staleMs` keeps its slot. +- WI-23: an isolated Codex launch with `codex.permissionMode: full-access` writes `sandbox_mode = "workspace-write"`. +- WI-24: `pan doctor` prints an error row naming `socat` when it is missing on Linux, and a warn row for each configured `none`-class harness. +- WI-26: with `OVERDECK_AGENT_TOKEN_FILE` set, the pi extension's heartbeat post carries `Authorization: Bearer odk_…` and no internal-token header. +- WI-27: agent A's token on agent B's control-ack gets 403 `not-self`; a `work` token on specialists auto-complete gets 403. +- WI-28: every verb in the coverage table with disposition `forwarded` resolves to a row that allows the listed roles. +- WI-29: a crash restart and a session rotation of an isolated agent each launch with `OVERDECK_AGENT_TOKEN_FILE` exported. +- D-12 (WI-6): an isolated claude-code launch with `socat` missing is refused with the D-12 error, and no pane starts. +- WI-25: `configuration/agent-isolation.mdx` exists, is linked from `docs.json`, and names `agents.isolation.enabled`, `allow_docker` and `allow_write`; `npm run lint:docs` passes. + +**Live verification (review/test).** On a host with `bwrap` and `socat` (or a scratch socat on PATH for the test process only), start one isolated Claude Code work agent on a throwaway issue. From its Bash, all of these must hold: +- `cat ~/.overdeck/internal-token` fails; +- `curl --noproxy '' --proxy "$HTTP_PROXY" -X POST http://127.0.0.1:3011/api/dashboard/session` gets 401; +- connecting to the Herdr socket fails; +- `pan task done` for its own item succeeds; +- `pan task done` naming another issue fails; +- `echo x >> ~/.bashrc` fails. + +Use an isolated browser profile for any Playwright step. + +## Implementation checkpoints + +- **CP-1 Live probes need socat.** When `socat` is missing, run live checks with a scratch copy on `PATH` for the probe process only (`apt-get download socat && dpkg -x`). Never install system packages. If neither is possible, record the live verification as not run in the PR and rely on unit tests. +- **CP-2 Own agent directory writes.** D-8 denies writes to all of `agents/`. If a local (non-forwarded) verb an isolated role runs fails with `EROFS` writing its own agent directory, add `allowWrite` for that directory and keep `denyWrite` on its `launcher.sh`, `overdeck-mcp.json` and `git-guard/` (deny inside allow holds, P2). +- **CP-3 `git push -u`.** `.git/config` is write-denied, so `git push -u` cannot record the upstream. Verify what work agents run. If `-u` is used, set the branch upstream at workspace creation (outside the sandbox), and make the agent git guard (`src/lib/launcher-git-guard.ts`) drop `-u`/`--set-upstream` when the upstream is already set. +- **CP-4 macOS.** Not probed. The settings file is the same and the peer rule is off. Doctor warns. +- **CP-5 Codex read deny.** See WI-23. +- **CP-6 Muse.** If `muse sandbox --help` documents read-deny paths, record them in the docs as a follow-up issue; do not configure it in this issue. + +## Intersecting repo rules (restated) + +- No `execSync` in dashboard server code or anything it imports. The peer rule uses `fs/promises`. +- Retry, backoff and delay tests use `vi.useFakeTimers()`, never real `setTimeout` waits. The self-cli wait loop tests inject the wait. +- One variant per operation in `src/lib`: no Effect wrapper around a Promise helper, and no sync twin without a documented sync caller. +- New tests must not read source files to assert content, and must add no `skipIf` or `.only`. +- File-size ratchet: no allowlist raise; extract into a new module instead. +- A new HTTP route needs a `no-loss-matrix.ts` row. +- Never `git stash`. Commit per item with an `Item: ` trailer. +- Quality gates: `npm run typecheck`, `npm run lint`, `npx vitest run `. Never the full `npm test` on the host. + +## Non-goals + +- A separate uid or root setup per machine. +- Sandboxing the verification gate or the post-merge deploy (R-1). It needs its own issue. +- Isolating agents launched on remote Fly VMs (`src/lib/remote/remote-agents.ts`): they run on a separate machine (CP-7). +- Configuring Muse's, grok's or opencode's own permission systems. +- Making the session mint require a credential for the local browser. +- Moving `overdeck.db` writes behind the dashboard (R-4). +- Hiding harness login credentials (Claude OAuth, `gh`) from agents (R-7). +- A Settings UI for the isolation keys. Config is `config.yaml` only. +- Changing the auto-approve hook. + +## Planning Q&A + +Auto mode (`pan plan --auto`): no questions were asked. Every default is recorded in `plan.autoDecisions` in the xBRIEF. The main ones: +1. The comment's "plan and implement it as one issue" supersedes "Design only". +2. The socket deny is applied as `denyRead` + `denyWrite` (D-9). +3. Fail closed when sandbox prerequisites are missing (D-12; changed from fail-open after plan critique round 1). +4. Traefik trust is off under isolation (D-11). +5. Docker is blocked by default (R-3). +6. The Flywheel keeps the operator credential (D-1). + +## Critique response + +### fail-open leaves the credential readable on this host +Accepted. D-12 now fails closed. An isolated Claude Code launch on Linux checks `bwrap` and `socat` and is refused with an actionable error when either is missing. The settings file sets `failIfUnavailable: true` as a second guard. A WI-6 acceptance criterion covers the refused launch with `socat` missing. The work agent flags the `socat` install requirement to the operator before merge. + +### forwarded file flags read operator secrets +Accepted. D-7 now excludes file-reading flags unless a row marks them `workspacePath`; such a value must `realpath` inside the caller's workspace and outside the read-deny set (400 `path-outside-workspace`). `worker report` takes its report only on stdin. WI-16 tests `worker report --file ~/.overdeck/internal-token`. + +### hook payloads have no subject agent ID +Accepted. D-16 now resolves the subject of the session-keyed hook routes on the server, from `session_id` to its owning agent or conversation. A token is accepted only when that owner matches. A session with no owner is refused for agent tokens. WI-14 tests token A with B's `session_id`. + +### alternate runtime launches bypass isolation +Accepted. New WI-29 prepares isolation inside every runtime's `spawnAgent`, which covers crash recovery, session rotation, the Codex runtime's own command, ohmypi, Muse, Kimi, Prime Agent, pi and ACP. Tests cover a crash restart and a rotation. Remote Fly launches are a NonGoal with checkpoint CP-7. + +### worker run cannot pass its required issue +Accepted. D-7 adds an `issueFlag` row option: a supplied `--issue` must equal the caller's issue, and the server strips it and injects the caller's own. WI-19 forwards `worker run` with it and tests `pan worker run --issue `. + +### generic self jobs truncate and time out long commands +Accepted. Self-cli jobs keep full output up to 4 MiB. `longRunning` rows (`worker run`, `worker wait`, `swarm wait`) get a 24 h job timeout, and the forwarder follows wait chunks until the job ends. A lost job exits 75 with a re-run message. WI-16 tests a report over 16 KiB and a job that outlives 15 minutes. + +### Unresolved after two critic rounds + +- forwarded handoff can create an operator conversation +- root registration fails open +- validated file flags can be swapped before the self job reads them + diff --git a/.pan/specs/2026-12-03-PAN-5754-design-isolate-agents-from-the-operator-credential.xbrief.json b/.pan/specs/2026-12-03-PAN-5754-design-isolate-agents-from-the-operator-credential.xbrief.json new file mode 100644 index 00000000000..406db4b1cd3 --- /dev/null +++ b/.pan/specs/2026-12-03-PAN-5754-design-isolate-agents-from-the-operator-credential.xbrief.json @@ -0,0 +1,2182 @@ +{ + "xBRIEFInfo": { + "version": "0.8", + "created": "2026-12-03T20:19:30Z", + "author": "overdeck/0.0.0", + "description": "Plan for PAN-5754: Design: isolate agents from the operator credential", + "updated": "2026-12-03T21:27:51.915Z" + }, + "plan": { + "id": "pan-5754", + "title": "Design: isolate agents from the operator credential", + "status": "running", + "uid": "6bde0b77-c4ed-4d9d-bee0-71eec7f8a969", + "author": "agent:claude-opus-5-5", + "sequence": 4, + "created": "2026-12-03T20:19:30Z", + "updated": "2026-12-03T21:27:51.915Z", + "references": [ + { + "uri": "https://github.com/eltmon/overdeck/issues/5754", + "label": "PAN-5754", + "type": "issue" + }, + { + "uri": "https://github.com/eltmon/overdeck/issues/5696", + "label": "PAN-5696", + "type": "issue" + }, + { + "uri": "https://github.com/eltmon/overdeck/issues/5699", + "label": "PAN-5699", + "type": "issue" + } + ], + "tags": [ + "security", + "agent-isolation", + "sandbox", + "auth", + "pan-5687-followup" + ], + "narratives": { + "Problem": "Every managed agent runs as the operator's user and can act as the operator on the dashboard in one command. It can read ~/.overdeck/internal-token, mint a root session from loopback (a loopback caller always mints), or drive another agent's pane through the Herdr or tmux socket. This is audit finding F-9, and it is the root of F-4's auto-approval risk. Planning probes also showed that Claude Code's sandbox proxy forwards to host loopback and the managed Traefik, and that CIDR deny rules are ignored, so a sandbox alone does not close the mint.", + "Proposal": "Isolated agents (token role not conversation/flywheel) authenticate only with their own agent token from hooks and the CLI. Claude Code agents launch with an Overdeck-generated --settings file: sandboxed Bash with read-deny on the operator secret set (own token re-allowed), masked terminal-backend socket directories, a write allowlist with denies on files executed outside the sandbox, and a PreToolUse write guard for the file tools. The dashboard serves an agent Unix socket that only accepts credentials, refuses local trust to connections owned by an isolated process tree (Linux /proc lookup against a root registry), and stops trusting uncredentialed Traefik-forwarded requests while isolation is on. CLI verbs that need admin routes or terminal sockets are forwarded to POST /api/self/cli and run as role- and issue-bound self jobs. Codex is clamped to workspace-write. Every other harness is classified, and pan doctor and the docs name the gaps. Gate admission becomes PID-namespace aware.", + "NonGoals": "- No separate uid or root setup per machine.\n- No sandboxing of the verification gate or post-merge deploy (residual R-1, separate issue).\n- No configuration of Muse, grok or opencode permission systems beyond the token change.\n- No change that makes the local browser's session mint require a credential (only Traefik-forwarded trust changes under isolation).\n- No moving overdeck.db writes behind the dashboard (R-4).\n- No hiding of harness login credentials such as Claude OAuth or the gh token (R-7).\n- No Settings UI for agents.isolation keys.\n- No change to the auto-approve hook.\n- Overdeck never installs bubblewrap or socat itself.\n- Operator conversations and the Flywheel must not gain a sandbox, an isolation settings file or an agent-token-only credential." + }, + "autoDecisions": [ + { + "summary": "Plan and implement in this issue despite the title's 'Design only'.", + "rationale": "The operator's 2026-12-03 comment says #5696 is closed and to plan and implement it as one issue; that supersedes the original body." + }, + { + "summary": "Implement the 'deny-write on terminal-backend socket directories' intent as denyRead + denyWrite on those directories.", + "rationale": "Probe P6 showed deny-write does not stop connect() once Unix sockets are allowed; denyRead masking (P7) does. Both are applied so the wording and the effect both hold." + }, + { + "summary": "When bubblewrap or socat is missing, isolated Claude Code launches are refused (fail closed) with an actionable error; pan doctor reports an error too.", + "rationale": "Plan critique round 1: failing open leaves the credential readable with only a doctor message. The operator chose secure by default; the error names the one-line install and the opt-out key. The work agent must flag the socat install to the operator before merge." + }, + { + "summary": "The Flywheel keeps the operator credential like operator conversations.", + "rationale": "The Flywheel merges, deploys and approves restarts with operator authority by standing operator decision; it is the operator's delegate, not a pipeline agent." + }, + { + "summary": "Uncredentialed Traefik-forwarded requests are not trusted while isolation is on.", + "rationale": "Probe P12 showed the sandbox proxy reaches Traefik through a bridge gateway that the dashboard trusts as local, and an in-tree browser reaches it directly; the original client cannot be identified. Existing cookies keep working and the #overdeck_token= link covers new browsers." + }, + { + "summary": "Docker is blocked for isolated Claude Code agents unless agents.isolation.allow_docker is true.", + "rationale": "The Docker socket is root-equivalent and would void the isolation; secure by default per the operator's direction." + }, + { + "summary": "The CLI reaches the dashboard through a new credential-only Unix socket, and privileged or socket-touching verbs are forwarded as self jobs.", + "rationale": "Inside the sandbox loopback TCP works only through an undocumented proxy path, while allowAllUnixSockets is documented; PAN-4927 self jobs already run closed verbs with identity bound to the token." + }, + { + "summary": "Codex isolated launches are clamped to workspace-write; other harnesses get the token change plus doctor/docs disclosure.", + "rationale": "Built from the installed binaries' --help: Codex offers a write sandbox, Muse its own default sandbox, the rest none. That is the closest equivalent each offers." + }, + { + "summary": "Plan as one large xBRIEF instead of sibling issues.", + "rationale": "The operator explicitly asked for one issue; items are decomposed into small independently testable slices with a parallel-friendly DAG." + } + ], + "metadata": { + "sizeJustification": "The operator's 2026-12-03 comment on PAN-5754 says 'Plan and implement it as one issue.' The pieces are also interlocked: the CLI token switch breaks agents unless the forwarded-verb route and route-scope rows ship with it, and the sandbox breaks socket-touching verbs unless they are forwarded. Each item is still a small, independently testable slice, and the DAG lets most run in parallel.", + "canonicalFilename": "2026-12-03-PAN-5754-design-isolate-agents-from-the-operator-credential.xbrief.json", + "promotionIntent": "automatic" + }, + "items": [ + { + "id": "iso-config", + "title": "Add agents.isolation config and the isolated-role predicate", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "simple", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/config-yaml/schema-agent-isolation.ts", + "src/lib/config-yaml/schema.ts", + "src/lib/config-yaml/load.ts", + "src/lib/agent-isolation/config.ts", + "src/lib/agent-isolation/paths.ts", + "src/lib/agent-isolation/__tests__/config.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/lib/agent-isolation/__tests__/config.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/agent-isolation/__tests__/config.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-1", + "FR-14" + ] + }, + "narrative": { + "Action": "PRD WI-1. Create schema-agent-isolation.ts with AgentIsolationConfig {enabled?, allow_docker?, allow_write?}; add one line `isolation?: import('./schema-agent-isolation.js').AgentIsolationConfig;` inside `agents?: {` in schema.ts. Create src/lib/agent-isolation/config.ts with readAgentIsolationConfig (defaults enabled true, allowDocker false, allowWrite []; expands ~; drops relative paths with one warning), isIsolatedTokenRole(role) (false only for 'conversation' and 'flywheel'), isAgentIsolationActive(role). Create src/lib/agent-isolation/paths.ts with agentTokensDir, agentTokenDir(kind,id), isolationDir, isolationOwnerDir(kind,id), isolationRootsDir, agentApiSocketPath (/agent-api/dashboard.sock) and the env var name constants OVERDECK_AGENT_TOKEN_FILE, OVERDECK_DASHBOARD_SOCKET, OVERDECK_ISOLATED. In src/lib/config-yaml/load.ts stripProjectSecurity, also drop agents.isolation (keep agents.caveman and agents.rtk) so a committed .pan.yaml cannot turn isolation off." + }, + "items": [ + { + "id": "iso-config.ac1", + "title": "Given role 'work', 'review' or 'worker', when isIsolatedTokenRole is called, then it returns true; given 'conversation' or 'flywheel' it returns false", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-config.ac2", + "title": "Given an empty config, when readAgentIsolationConfig runs, then it returns { enabled: true, allowDocker: false, allowWrite: [] }", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-config.ac3", + "title": "Given agents.isolation.enabled: false, when isAgentIsolationActive('work') is called, then it returns false", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-config.ac4", + "title": "Given allow_write ['~/x', 'rel/y'], when readAgentIsolationConfig runs, then it returns ['/x'] and emits exactly one warning naming 'rel/y'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-config.ac5", + "title": "Given a project config with agents.isolation.enabled false and agents.rtk set, when stripProjectSecurity runs, then the result has no agents.isolation and keeps agents.rtk", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "token-location", + "title": "Move agent tokens under agent-tokens/ and add a fail-closed isolation mint", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/mcp/agent-token.ts", + "src/lib/mcp/agent-injection.ts", + "tests/unit/lib/mcp/agent-token.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run tests/unit/lib/mcp/agent-token.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "tests/unit/lib/mcp/agent-token.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-3", + "NFR-2" + ] + }, + "narrative": { + "Action": "PRD WI-2 / D-4 / D-5. Replace agentMcpTokenPath(dir) with agentMcpTokenPathFor({agentId, agentKind}) returning agentTokenDir(kind, normalizedId)/mcp-token; ensureAgentMcpToken writes there (dir 0700, file 0600); revokeAgentMcpTokens unlinks the new file and the legacy /mcp-token when dir is known. mintOverdeckTokenFile in agent-injection.ts uses the new path. Add ensureIsolationToken(owner) that calls ensureAgentMcpToken without the overdeckMcpEnabledFor gate and rethrows failures as Error('agent isolation: token mint failed for : '). If the token test file has another name, extend the existing agent-token test file instead." + }, + "items": [ + { + "id": "token-location.ac1", + "title": "Given a fresh OVERDECK_HOME, when ensureAgentMcpToken runs for agent-pan-1, then /agent-tokens/agent/agent-pan-1/mcp-token exists with mode 0600", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "token-location.ac2", + "title": "Given a legacy /mcp-token, when revokeAgentMcpTokens runs with that dir, then both the legacy file and the new file are removed", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "token-location.ac3", + "title": "Given a registry write that does not persist, when ensureIsolationToken runs, then it rejects with a message starting 'agent isolation: token mint failed for'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "iso-policy", + "title": "Build the pure isolation policy and its input resolver", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "complex", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": true, + "inspectionDepth": "deep", + "files_scope": [ + "src/lib/agent-isolation/policy.ts", + "src/lib/agent-isolation/policy-input.ts", + "src/lib/agent-isolation/__tests__/policy.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/lib/agent-isolation/__tests__/policy.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/agent-isolation/__tests__/policy.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-4", + "FR-5" + ], + "foundationFor": [ + "claude-settings", + "write-guard-hook", + "launch-isolation" + ], + "acJustification": "Five ACs: the policy is the security foundation; read, write, socket, extras and the allowlist each need a check.", + "parallelSafeReason": "Creates new files only (policy.ts, policy-input.ts and its test); no other item edits them." + }, + "narrative": { + "Action": "PRD WI-3 / D-8. buildIsolationPolicy(input) is pure and returns {denyRead, allowRead, allowWrite, denyWrite, maskedSocketDirs, mkdirBeforeLaunch} with exactly the D-8 path lists (read-deny operator secret set incl. agent-tokens/ with allowRead for the owner's token dir; socket masks for Herdr sessions dir, tmux- dir, /sockets, XDG_RUNTIME_DIR, /tmp/.X11-unix, docker sockets unless allowDocker; write allowlist where contributes ONLY overdeck.db/panopticon.db/cache.db with -wal/-shm, logs/, tmp/ and verification-workers/admission/ (every other entry, incl. agent-api/, stays read-only); browser-profiles/ in read-deny; write denylist incl. workspace .git/.claude/.mcp.json, /hooks and /config, cache bin dirs). serializePolicy returns {version:1, allowWrite, denyWrite} for the guard hook. policy-input.ts resolves real inputs asynchronously (execFile git rev-parse --git-common-dir for the workspace and each child dir with a .git file; herdrSocketPath(); process.getuid(); existing cache dirs)." + }, + "items": [ + { + "id": "iso-policy.ac1", + "title": "Given a standard input, when buildIsolationPolicy runs, then /internal-token appears in both denyRead and denyWrite and /agent-tokens/agent/ appears in allowRead", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-policy.ac2", + "title": "Given a workspace whose git common dir is /r/.git, when buildIsolationPolicy runs, then /r/.git is in allowWrite and /r/.git/hooks and /r/.git/config are in denyWrite", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-policy.ac3", + "title": "Given allowDocker false, when buildIsolationPolicy runs, then /var/run/docker.sock is in maskedSocketDirs; given allowDocker true it is absent", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-policy.ac4", + "title": "Given extraAllowWrite ['/data/x'], when buildIsolationPolicy runs, then '/data/x' is in allowWrite and the tmux socket dir is in mkdirBeforeLaunch", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "iso-policy.ac5", + "title": "Given a standard input, when buildIsolationPolicy runs, then the allowWrite entries under are exactly the DB files, logs/, tmp/ and verification-workers/admission/, and /agent-api is not writable", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "claude-settings", + "title": "Render the Claude Code isolation settings file", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/agent-isolation/claude-settings.ts", + "src/lib/agent-isolation/__tests__/claude-settings.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/lib/agent-isolation/__tests__/claude-settings.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/agent-isolation/__tests__/claude-settings.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-4" + ] + }, + "narrative": { + "Action": "PRD WI-4. renderIsolationClaudeSettings(policy, guardHookPath, policyFile) returns the JSON in the PRD: sandbox {enabled true, failIfUnavailable true, allowUnsandboxedCommands false, autoAllowBashIfSandboxed true, network {allowAllUnixSockets true, allowedDomains ['*']}, filesystem {denyRead (incl. masked socket dirs), allowRead, allowWrite, denyWrite (incl. masked socket dirs)}}, permissions.deny with Read(//abs) and Edit(//abs) rules (directories get /**), hooks.PreToolUse matcher 'Edit|Write|MultiEdit|NotebookEdit' running 'OVERDECK_ISOLATION_POLICY= '. writeIsolationFiles(owner, policy) writes claude-settings.json and policy.json under isolationOwnerDir (0600, dir 0700, temp+rename)." + }, + "items": [ + { + "id": "claude-settings.ac1", + "title": "Given a policy, when renderIsolationClaudeSettings runs, then every denyRead path appears as a Read(//...) deny rule and no permission rule starts with a single '/' followed by a non-slash", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "claude-settings.ac2", + "title": "Given a policy, when renderIsolationClaudeSettings runs, then sandbox.allowUnsandboxedCommands is false, sandbox.failIfUnavailable is true and sandbox.network.allowAllUnixSockets is true", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "claude-settings.ac3", + "title": "Given an owner, when writeIsolationFiles runs, then claude-settings.json and policy.json exist under /isolation/// with mode 0600", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "write-guard-hook", + "title": "Add the agent-isolation-guard PreToolUse hook", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "sync-sources/hooks/agent-isolation-guard*", + "tests/scripts/agent-isolation-guard.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run tests/scripts/agent-isolation-guard.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "tests/scripts/agent-isolation-guard.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-4", + "NFR-4" + ] + }, + "narrative": { + "Action": "PRD WI-5. Bash script (set -u, jq) reading hook JSON from stdin; target = .tool_input.file_path or .tool_input.notebook_path; resolve with realpath -m (realpath for an existing symlink); allow (print nothing, exit 0) when under an allowWrite root and no denyWrite root from $OVERDECK_ISOLATION_POLICY; otherwise print the PreToolUse deny JSON with reason 'agent isolation: is outside this agent's writable paths'; deny when the policy file is missing or unreadable. Mode 0755. sync-hooks.ts already copies every hook file to ~/.overdeck/bin." + }, + "items": [ + { + "id": "write-guard-hook.ac1", + "title": "Given a policy allowing the workspace, when the hook gets a Write to a workspace file, then it prints nothing and exits 0", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "write-guard-hook.ac2", + "title": "Given a policy denying /config.yaml, when the hook gets an Edit to a cwd symlink pointing at that file, then it prints a permissionDecision 'deny' JSON", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "write-guard-hook.ac3", + "title": "Given OVERDECK_ISOLATION_POLICY naming a missing file, when the hook runs, then it prints a permissionDecision 'deny' JSON", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "launch-isolation", + "title": "Wire isolation into the launcher (settings flag, env, root registration)", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "complex", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/agent-isolation/launch.ts", + "src/lib/agent-isolation/launcher-lines.ts", + "src/lib/launcher-generator.ts", + "src/lib/__tests__/launcher-generator.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/lib/__tests__/launcher-generator.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/__tests__/launcher-generator.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-2", + "FR-4", + "FR-11", + "NFR-2", + "NFR-3" + ], + "acJustification": "Five ACs: the launcher is where the fail-closed rule, the token env, the settings flag and the unchanged non-isolated path each need a check.", + "parallelSafeReason": "Owns launcher-generator.ts and the new launch.ts/launcher-lines.ts; the launch-site items that call it are ordered after it by edges." + }, + "narrative": { + "Action": "PRD WI-6 / D-3 / D-15. prepareAgentIsolation(owner) returns {} unless isAgentIsolationActive(owner.role); otherwise, for a claude-code launch on Linux, check bwrap and socat on PATH (injected dependency) and throw the D-12 error 'agent isolation: Claude Code sandbox unavailable (missing: ). Install with: sudo apt-get install bubblewrap socat, or set agents.isolation.enabled: false to run agents unisolated' when either is missing (fail closed); then ensureIsolationToken (throws => launch fails), resolve+build the policy, write settings+policy files for claude-code launches, and return {isolation: {settingsFile?, env: {OVERDECK_AGENT_TOKEN_FILE, OVERDECK_DASHBOARD_SOCKET, OVERDECK_ISOLATED:'1', NODE_USE_ENV_PROXY:'1'}, unsetEnv:['OVERDECK_INTERNAL_TOKEN'], mkdirs, rootFile}}. In launcher-generator.ts add LauncherConfig.isolation; emit mkdir -p -m 700, exports, unset and rootRegistrationLauncherLine(rootFile) (from peer-rule) after the env block and before cd; append --settings to the claude command in buildCommand's conversation branch and buildNonConversationCommand; prefix the review sub-role post-exit pan tell / pan admin agents exited lines with 'env -u OVERDECK_AGENT_TOKEN_FILE'. Keep launcher-generator.ts within its file-size cap by putting helpers in launcher-lines.ts. If the existing launcher test file has another name, extend that file." + }, + "items": [ + { + "id": "launch-isolation.ac1", + "title": "Given an isolated claude-code LauncherConfig, when generateLauncherScript runs, then the script contains '--settings', 'export OVERDECK_AGENT_TOKEN_FILE=' and 'unset OVERDECK_INTERNAL_TOKEN'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-isolation.ac2", + "title": "Given a LauncherConfig without isolation, when generateLauncherScript runs, then the output is byte-identical to the output before this change for the same config", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-isolation.ac3", + "title": "Given an isolated review sub-role launch, when generateLauncherScript runs, then the post-exit pan tell and pan admin agents exited lines start with 'env -u OVERDECK_AGENT_TOKEN_FILE'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-isolation.ac4", + "title": "Given ensureIsolationToken rejects, when prepareAgentIsolation runs for role 'work', then it rejects and no launcher script is written", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-isolation.ac5", + "title": "Given a Linux claude-code launch for role 'work' with socat missing from PATH, when prepareAgentIsolation runs, then it rejects with a message naming socat and 'sudo apt-get install bubblewrap socat'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "launch-sites-agents", + "title": "Spread prepareAgentIsolation at the agent spawn, recovery and resume sites", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/agents/spawn.ts", + "src/lib/agents/spawn-prep.ts", + "src/lib/agents/recovery.ts", + "src/lib/agents/messaging.ts", + "src/lib/agents/__tests__/spawn-isolation.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/lib/agents/__tests__/spawn-isolation.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/agents/__tests__/spawn-isolation.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-1", + "FR-4", + "FR-11" + ] + }, + "narrative": { + "Action": "PRD WI-7. Next to each prepareClaudeOverdeckMcp / prepareCodexOverdeckMcp call in spawn.ts, spawn-prep.ts, recovery.ts and messaging.ts, spread `...(await prepareAgentIsolation({ same owner }))` into the launcher config, and pass `isolated: isAgentIsolationActive(role)` to getCodexLauncherFields (added by codex-clamp). An isolation error fails the spawn like a missing binary." + }, + "items": [ + { + "id": "launch-sites-agents.ac1", + "title": "Given a spawn for role 'work', when the launcher config is built, then it carries an isolation field with OVERDECK_AGENT_TOKEN_FILE in env", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-sites-agents.ac2", + "title": "Given a spawn for role 'flywheel', when the launcher config is built, then it has no isolation field", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-sites-agents.ac3", + "title": "Given a resume through messaging.ts for a work agent, when the launcher config is built, then it carries an isolation field", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "launch-sites-planning-conv", + "title": "Spread prepareAgentIsolation at the planning and conversation launch sites", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/planning/spawn-planning-session.ts", + "src/dashboard/server/routes/misc/planning.ts", + "src/lib/overdeck/conversation-runtime.ts", + "src/lib/overdeck/__tests__/conversation-isolation.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/lib/overdeck/__tests__/conversation-isolation.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/overdeck/__tests__/conversation-isolation.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-1", + "FR-11" + ] + }, + "narrative": { + "Action": "PRD WI-8. Planning launches (role 'plan') in spawn-planning-session.ts and routes/misc/planning.ts get the isolation spread. conversation-runtime.ts passes role conversationTokenRole(tokenRow, role, tmuxSession): a plain conversation resolves to 'conversation' (not isolated, FR-11), a lane conversation to 'worker' (isolated), the Flywheel conversation to 'flywheel' (not isolated)." + }, + "items": [ + { + "id": "launch-sites-planning-conv.ac1", + "title": "Given a plain operator conversation launch, when the launch command is built, then it contains no '--settings' isolation flag and no OVERDECK_AGENT_TOKEN_FILE export", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-sites-planning-conv.ac2", + "title": "Given a lane conversation launch, when the launch command is built, then it contains the '--settings' isolation flag", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-sites-planning-conv.ac3", + "title": "Given a planning session launch, when the launcher config is built, then it carries an isolation field", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "agent-socket", + "title": "Serve the dashboard HTTP app on the agent Unix socket", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/agent-api-socket.ts", + "src/dashboard/server/server.ts", + "src/dashboard/server/__tests__/agent-api-socket.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/agent-api-socket.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/agent-api-socket.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-6" + ] + }, + "narrative": { + "Action": "PRD WI-9 / D-6. installAgentApiSocket(): mkdir 0700, unlink stale socket, net.createServer(socket => deliverHttpSocket(socket) || socket.destroy()), listen(agentApiSocketPath()), chmod 0600; return a closer that closes and unlinks. Call it in server.ts right after installChannelListener on the primary dashboard and register the closer with shutdown. A request on the socket has no peer address, so it is never a trusted local caller." + }, + "items": [ + { + "id": "agent-socket.ac1", + "title": "Given the socket is installed, when an uncredentialed GET /api/agents arrives over it, then the response status is 401", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "agent-socket.ac2", + "title": "Given the socket is installed, when GET /api/agents arrives over it with a valid agent token, then the response status is 200", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "agent-socket.ac3", + "title": "Given the socket is installed, when its file mode is read, then it is 0600", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "cli-credential", + "title": "Add the isolated-context credential and transport helper", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/dashboard-client/agent-credential.ts", + "src/lib/dashboard-client/__tests__/agent-credential.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/lib/dashboard-client/__tests__/agent-credential.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/dashboard-client/__tests__/agent-credential.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-2" + ] + }, + "narrative": { + "Action": "PRD WI-10 / D-3 / D-6. isIsolatedAgentContext(env), readAgentToken(env) (re-read each call; must match ^odk_[0-9a-f]{64}$ else AgentCredentialError), dashboardAuthHeaders(env) (Bearer in isolated context, else the internal-token header via ensureInternalToken), dashboardFetch(path, init, env): in isolated context with OVERDECK_DASHBOARD_SOCKET use node:http request({socketPath}) and return a WHATWG Response; on ENOENT/ECONNREFUSED/EPERM retry once over TCP at getDashboardApiUrl(); never fall back to the internal token; always strip a caller-set x-overdeck-internal-token header." + }, + "items": [ + { + "id": "cli-credential.ac1", + "title": "Given OVERDECK_AGENT_TOKEN_FILE pointing at a valid token, when dashboardFetch runs against a Unix-socket test server, then the request carries 'Authorization: Bearer odk_' and no internal-token file is created in OVERDECK_HOME", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "cli-credential.ac2", + "title": "Given no OVERDECK_AGENT_TOKEN_FILE, when dashboardAuthHeaders runs, then it returns the x-overdeck-internal-token header", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "cli-credential.ac3", + "title": "Given the socket path does not exist, when dashboardFetch runs in an isolated context, then it falls back to TCP with the Bearer header", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "cli-callers", + "title": "Route CLI-side dashboard calls through the credential helper", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/cli/commands/dashboard-call.ts", + "src/lib/agent-runtime.ts", + "src/lib/pipeline-notifier.ts", + "src/lib/cloister/deacon-event-client.ts", + "src/cli/commands/plan.ts", + "src/cli/commands/start.ts", + "src/lib/__tests__/pipeline-notifier.test.ts", + "src/lib/dashboard-client/__tests__/cli-callers-isolated.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/lib/__tests__/pipeline-notifier.test.ts src/lib/dashboard-client/__tests__/cli-callers-isolated.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "the named test files pass", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-2" + ] + }, + "narrative": { + "Action": "PRD WI-11. Replace every ensureInternalToken()/getInternalToken() header construction in these files with dashboardFetch or dashboardAuthHeaders. Behaviour outside an isolated context is unchanged. pipeline-notifier keeps its skip-without-credential rule but posts with the agent token in an isolated context. Extend src/lib/__tests__/pipeline-notifier.test.ts and add src/lib/dashboard-client/__tests__/cli-callers-isolated.test.ts for the other callers." + }, + "items": [ + { + "id": "cli-callers.ac1", + "title": "Given an isolated context, when pipeline-notifier forwards an event, then the request carries the Bearer agent token and ensureInternalToken is not called", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "cli-callers.ac2", + "title": "Given an isolated context, when dashboard-call's helper runs, then no internal-token file is created in OVERDECK_HOME", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "cli-callers.ac3", + "title": "Given a non-isolated context, when the same calls run, then they send the x-overdeck-internal-token header as before", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "in-pane-callers", + "title": "Use the agent token in the in-pane memory hook, Codex prompt memory and Channels bridge", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "simple", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/caveman/workspace.ts", + "src/lib/codex/prompt-memory.ts", + "src/lib/channels/overdeck-bridge.ts", + "src/lib/caveman/__tests__/workspace.test.ts", + "src/lib/codex/__tests__/prompt-memory.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/lib/caveman/__tests__/workspace.test.ts src/lib/codex/__tests__/prompt-memory.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "the caveman and prompt-memory tests pass", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-2" + ] + }, + "narrative": { + "Action": "PRD WI-12. The memory hook script caveman/workspace.ts generates reads $OVERDECK_AGENT_TOKEN_FILE when set and sends Authorization: Bearer, otherwise today's internal token. codex/prompt-memory.ts and channels/overdeck-bridge.ts use dashboardAuthHeaders(). Extend the existing tests (asserting on the generated script output is allowed; it is output, not source)." + }, + "items": [ + { + "id": "in-pane-callers.ac1", + "title": "Given OVERDECK_AGENT_TOKEN_FILE is referenced, when the caveman memory hook script is generated, then it contains an Authorization: Bearer branch that does not read internal-token", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "in-pane-callers.ac2", + "title": "Given an isolated context, when prompt-memory posts /api/memory/inject, then the request carries the Bearer agent token", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "hooks-token", + "title": "Make the Claude Code hook scripts use the agent token", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "sync-sources/hooks/pan-hook-lib.sh", + "sync-sources/hooks/session-start-hook*", + "sync-sources/hooks/stop-hook*", + "sync-sources/hooks/user-prompt-submit-hook*", + "sync-sources/hooks/permission-event-hook*", + "tests/scripts/hooks-agent-token.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run tests/scripts/hooks-agent-token.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "tests/scripts/hooks-agent-token.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-2", + "NFR-4" + ] + }, + "narrative": { + "Action": "PRD WI-13. When OVERDECK_AGENT_TOKEN_FILE is set, each hook reads it and sends 'Authorization: Bearer ' and does not read /internal-token; otherwise behaviour is unchanged. Covers pan-hook-lib.sh (both curl sites), session-start-hook, stop-hook (incl. the planning complete-planning curl), user-prompt-submit-hook and permission-event-hook. Test with a local stub HTTP server." + }, + "items": [ + { + "id": "hooks-token.ac1", + "title": "Given OVERDECK_AGENT_TOKEN_FILE set and a stub dashboard, when session-start-hook runs, then the stub receives 'Authorization: Bearer odk_' and no x-overdeck-internal-token header", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "hooks-token.ac2", + "title": "Given OVERDECK_AGENT_TOKEN_FILE set and an OVERDECK_HOME without internal-token, when pan-hook-lib.sh's event emit runs, then no internal-token file is created", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "hooks-token.ac3", + "title": "Given OVERDECK_AGENT_TOKEN_FILE unset, when session-start-hook runs, then the stub receives the x-overdeck-internal-token header as before", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "self-auth-routes", + "title": "Let hook and self-report routes accept an agent token that speaks for itself", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "complex", + "kind": "api", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/routes/self-or-internal.ts", + "src/dashboard/server/routes/agents/shared.ts", + "src/dashboard/server/routes/agents/runtime-events.ts", + "src/dashboard/server/routes/hooks.ts", + "src/dashboard/server/routes/agents/permissions.ts", + "src/dashboard/server/routes/issues.ts", + "src/dashboard/server/__tests__/self-or-internal.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/self-or-internal.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/self-or-internal.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-8" + ], + "parallelSafeReason": "Edits only the hook and runtime route handlers plus a new helper; route-scopes.ts belongs to route-scope-rows and the pi routes to pi-routes-self-auth." + }, + "narrative": { + "Action": "PRD WI-14 / D-16. authorizeInternalOrSelfAgent(request, subjectAgentId) passes the internal token or an agent token whose normalized agentId equals the subject; another agent's token gets 403 {code:'not-self'}; none gets 401. Use it in validateAgentRuntimeEventAuth, which gains a subjectAgentId parameter passed from every caller in routes/agents/runtime-events.ts (heartbeat, work-complete, stuck, plan-checklist; subject = :id), the five hasDashboardInternalToken sites in hooks.ts (session-keyed routes: resolve the owner of the payload's session_id on the server with the lookup the handlers already use, compare it with the token agentId; a session with no owner is refused for agent tokens), the internal permission request in agents/permissions.ts (subject = :id) and POST /api/hooks/permission-event. complete-planning in src/dashboard/server/routes/issues.ts (anchor '/api/issues/:id/complete-planning', line ~360) accepts an agent token only when its role is 'plan' and its agent's issue equals :id; any other credential must hold admin (so a phone/machine/connector token with operate gets 403); an uncredentialed trusted local caller passes as today." + }, + "items": [ + { + "id": "self-auth-routes.ac1", + "title": "Given agent A's token, when A posts its own heartbeat to /api/agents/A/heartbeat, then the response is 2xx", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "self-auth-routes.ac2", + "title": "Given agent A's token, when A posts a heartbeat for agent B, then the response is 403 with code 'not-self'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "self-auth-routes.ac3", + "title": "Given agent A's token and a user-prompt-submit payload carrying agent B's session_id, when it is posted, then the response is 403 with code 'not-self'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "self-auth-routes.ac4", + "title": "Given a work-role token or a connector token with operate, when it posts /api/issues//complete-planning, then the response is 403; given a plan-role token for its own issue, it is accepted", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "route-scope-rows", + "title": "Add route-scope rows for agent-callable routes", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "simple", + "kind": "api", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/route-scopes.ts", + "tests/unit/lib/overdeck/no-loss-matrix.ts", + "src/dashboard/server/__tests__/route-scopes.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/route-scopes.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/route-scopes.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-8" + ] + }, + "narrative": { + "Action": "PRD WI-15. In route-scopes.ts add 'tell' rows for POST /api/agents/:id/heartbeat, /api/hooks/turn-complete, /api/hooks/user-prompt-submit, /api/hooks/permission-event, /api/memory/inject, /api/memory/session/start, /api/memory/turn, /api/internal/agents/:id/permissions/request; 'operate' for POST /api/issues/:id/complete-planning; 'read:state' for GET /api/agents/:id/runtime and POST /api/self/cli; 'read:conversations' for GET /api/agents/:id/conversation; for the pi extension also 'tell' for POST /api/agents/:id/work-complete, /stuck, /plan-checklist, /classify-completion, POST /api/conversations/:name/control-ack and POST /api/specialists/:name/auto-complete. Add the no-loss-matrix row for the new POST /api/self/cli route in tests/unit/lib/overdeck/no-loss-matrix.ts. This item is the only one that edits route-scopes.ts. Use the existing route-scopes test file name." + }, + "items": [ + { + "id": "route-scope-rows.ac1", + "title": "Given the route-scope table, when requiredScopeFor('POST', '/api/agents/x/heartbeat') is called, then it returns 'tell'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "route-scope-rows.ac2", + "title": "Given the route-scope table, when requiredScopeFor('POST', '/api/issues/PAN-1/complete-planning') is called, then it returns 'operate'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "route-scope-rows.ac3", + "title": "Given the route-scope table, when requiredScopeFor('POST', '/api/self/cli') is called, then it returns 'read:state'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "self-cli-route", + "title": "Add POST /api/self/cli, the forwarded-verb table and the CLI forwarder", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "expert", + "kind": "api", + "issueLabel": "pan-5754", + "requiresInspection": true, + "inspectionDepth": "deep", + "files_scope": [ + "src/dashboard/server/services/self-cli-verbs/index.ts", + "src/dashboard/server/services/self-cli-verbs/core.ts", + "src/dashboard/server/services/self-cli-verbs/messaging.ts", + "src/dashboard/server/services/self-cli-verbs/planning.ts", + "src/dashboard/server/services/self-cli-verbs/review.ts", + "src/dashboard/server/services/self-cli-verbs/swarm.ts", + "src/dashboard/server/services/self-cli-verbs/misc.ts", + "src/dashboard/server/services/self-cli-argv.ts", + "src/dashboard/server/services/self-job-argv.ts", + "src/dashboard/server/services/self-jobs.ts", + "src/dashboard/server/routes/self-cli.ts", + "src/cli/isolated-forward.ts", + "src/cli/index.ts", + "src/dashboard/server/__tests__/self-cli-route.test.ts", + "src/cli/__tests__/isolated-forward.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/self-cli-route.test.ts src/cli/__tests__/isolated-forward.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/self-cli-route.test.ts passes", + "src/cli/__tests__/isolated-forward.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-7" + ], + "foundationFor": [ + "forward-messaging", + "forward-planning-review", + "forward-swarm-misc" + ], + "acJustification": "Five ACs: the route is the security boundary (role, issue, flag, unknown-verb and stdin handling each need their own check).", + "parallelSafeReason": "Creates the self-cli files; the forward-* items that add rows to its family files are ordered after it by edges." + }, + "narrative": { + "Action": "PRD WI-16 / D-7. SELF_CLI_VERBS concatenated from family files (messaging, planning, review, swarm, misc start as empty arrays; core holds this item's rows: task claim|done|block|unblock|next|cancel (roles work, strike), done (work, strike, knowledge), handoff (work), worker report and lane report (worker; stdin only, no --file), memory add|search|edit|retire|pin|unpin (every isolated role); a worker token never gets done or task, per roles/worker.md). matchSelfCliVerb picks the longest prefix. Rows may set issueFlag (a supplied --issue must equal the caller's issue; the server strips it and injects --issue=), workspacePath flags (file-reading flags such as --file/--brief/--*-file/--path/--from are excluded unless marked; a marked value must realpath inside the caller's workspace and outside the D-8 read-deny set, else 400 path-outside-workspace), longRunning (job timeout SELF_CLI_LONG_JOB_TIMEOUT_MS = 24 h, injected for fake-timer tests), textTail (trailing free text joined into one rest piece after '--') and stdin (body stdin string <= 1 MiB written to the job's stdin; extend SelfJobRunInput with stdin?: string and have the injected runner write and close it). buildSelfCliArgv validates flags only from row.flags (D-7 exclusion rule), positionals as ref pieces, issue positional equal to caller.issueId (case-insensitive) else SelfJobArgError('issue-mismatch'), built only through buildSelfJobArgv piece types. POST /api/self/cli body {argv, stdin?} (argv <=64 elements, each <=8 KiB): role not allowed -> 403 role-not-allowed; no row -> 404 verb-not-forwarded; validation -> 400; else start a self job with the prebuilt argv (self-cli jobs keep full stdout/stderr up to SELF_JOB_MAX_BUFFER) and answer selfJobAnswer. The forwarder exits 75 with 'forwarded job lost (dashboard restarted?); re-run the command' on 404 unknown-job. maybeForwardIsolatedVerb() in src/cli/isolated-forward.ts returns null outside an isolated context or on 404, otherwise posts via dashboardFetch, follows next via GET /api/self/jobs/:id/wait, writes stdout/stderr and returns the exit code; index.ts calls it before program.parseAsync. Register the route with the other self routes." + }, + "items": [ + { + "id": "self-cli-route.ac1", + "title": "Given a work token, when it forwards ['task','done','x','--issue','PAN-9'] or names another issue positional, then the route returns 400 (disallowed flag or issue-mismatch)", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "self-cli-route.ac2", + "title": "Given a review token forwarding ['task','done','item-1'] or a worker token forwarding ['done'], when the route runs, then it returns 403 with code 'role-not-allowed'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "self-cli-route.ac3", + "title": "Given any token, when it forwards an argv matching no row, then the route returns 404 'verb-not-forwarded' and maybeForwardIsolatedVerb returns null", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "self-cli-route.ac4", + "title": "Given a work token and a valid ['task','done','item-1'], when forwarded, then a self job runs 'pan task done item-1' with the caller's identity env and the CLI exits with the job's exit code", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "self-cli-route.ac5", + "title": "Given a worker token forwarding ['worker','report','--file','~/.overdeck/internal-token'], when the route runs, then it returns 400 and no job starts; a two-line stdin report instead reaches the child exactly, and job stdout over 16 KiB is returned whole", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "forward-messaging", + "title": "Forward tell, ask and sync-main for isolated agents", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "api", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/services/self-cli-verbs/messaging.ts", + "src/dashboard/server/__tests__/self-cli-messaging.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/self-cli-messaging.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/self-cli-messaging.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-7" + ] + }, + "narrative": { + "Action": "PRD WI-17. Rows: tell (all isolated roles; positional 0 is the target, not the issue; textTail for the message), ask (work, strike; textTail), sync-main (work, strike; issue positional 0), review request (work, strike; issue positional 0). Flags per the D-7 rule, read from each verb's commander definition in src/cli/index.ts or its command module." + }, + "items": [ + { + "id": "forward-messaging.ac1", + "title": "Given a test token, when it forwards ['tell','conv-flywheel','three word message'], then the self job argv is ['tell','conv-flywheel','--','three word message'] and the message reaches the target intact", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "forward-messaging.ac2", + "title": "Given a work token for PAN-5, when it forwards ['sync-main','PAN-6'], then the route returns 400 issue-mismatch", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "forward-messaging.ac3", + "title": "Given a review token, when it forwards ['ask', ...], then the route returns 403 role-not-allowed", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "forward-planning-review", + "title": "Forward plan finalize and the review/test verdict verbs", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "api", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/services/self-cli-verbs/planning.ts", + "src/dashboard/server/services/self-cli-verbs/review.ts", + "src/dashboard/server/__tests__/self-cli-planning-review.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/self-cli-planning-review.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/self-cli-planning-review.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-7" + ] + }, + "narrative": { + "Action": "PRD WI-18. planning.ts: 'plan finalize' and 'plan done' (role plan; issue positional 0 when given, otherwise the server injects the caller's issue). review.ts: 'admin specialists done' (roles review, test), 'review spawn-reviewer' (role review), 'admin seed-uat-fixtures' (role test); the issue positional must match. Flags per D-7." + }, + "items": [ + { + "id": "forward-planning-review.ac1", + "title": "Given a work token, when it forwards ['admin','specialists','done', ...], then the route returns 403 role-not-allowed", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "forward-planning-review.ac2", + "title": "Given a plan token for PAN-5, when it forwards ['plan','finalize'], then the self job argv is 'plan finalize PAN-5'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "forward-planning-review.ac3", + "title": "Given a review token for PAN-5, when it forwards ['review','spawn-reviewer', ...] naming PAN-5, then a self job starts", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "forward-swarm-misc", + "title": "Forward swarm, worker, backlog and knowledge verbs", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "api", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/services/self-cli-verbs/swarm.ts", + "src/dashboard/server/services/self-cli-verbs/misc.ts", + "src/dashboard/server/__tests__/self-cli-swarm-misc.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/self-cli-swarm-misc.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/self-cli-swarm-misc.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-7" + ] + }, + "narrative": { + "Action": "PRD WI-19. swarm.ts: 'swarm dispatch|merge|status|wait|resume|recover|freeze', 'foreman' and 'spawn' (role work; issue positional when the subcommand takes one) and 'workspace add-repo' (role work; issue positional; polyrepo work agents run it per the cloister prompt builders). misc.ts: 'worker run' (roles work, plan; issueFlag 'issue'; --brief marked workspacePath; longRunning), 'worker wait' (work, plan; longRunning), 'worker stop' (work, plan); 'swarm wait' in swarm.ts is longRunning; 'backlog write-sequence' (role sequencer), 'knowledge' (role knowledge). Flags per D-7." + }, + "items": [ + { + "id": "forward-swarm-misc.ac1", + "title": "Given a work token for PAN-5, when it forwards ['swarm','dispatch','PAN-5'], then a self job starts running 'pan swarm dispatch PAN-5'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "forward-swarm-misc.ac2", + "title": "Given a test token, when it forwards ['swarm','merge', ...], then the route returns 403 role-not-allowed", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "forward-swarm-misc.ac3", + "title": "Given a sequencer token, when it forwards ['backlog','write-sequence'], then a self job starts", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "forward-swarm-misc.ac4", + "title": "Given a work token for PAN-5, when it forwards ['worker','run','--issue','PAN-5','--prompt','x y'], then the job argv carries --issue=PAN-5 injected by the server; with --issue PAN-6 the route returns 400", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "peer-rule", + "title": "Refuse local trust to connections owned by an isolated process tree", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "expert", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": true, + "inspectionDepth": "deep", + "files_scope": [ + "src/lib/agent-isolation/roots.ts", + "src/dashboard/server/isolated-peer.ts", + "src/dashboard/server/routes/dashboard-auth.ts", + "src/dashboard/server/routes/workspace-wake.ts", + "src/dashboard/server/__tests__/isolated-peer.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/isolated-peer.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/isolated-peer.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-9", + "NFR-1", + "NFR-3" + ], + "foundationFor": [ + "traefik-trust", + "launch-isolation" + ], + "acJustification": "Five ACs: the peer rule is a security boundary with a required exception for the PTY supervisor.", + "parallelSafeReason": "Creates isolated-peer.ts and roots.ts and edits dashboard-auth.ts; traefik-trust, which also edits dashboard-auth.ts, is ordered after it by an edge." + }, + "narrative": { + "Action": "PRD WI-20 / D-10. roots.ts: rootRegistrationLauncherLine(rootFile) (bash writing {pid:$$,startTime:} via temp+mv, guarded by [ -r /proc/$$/stat ]) and readLiveRoots (drops+deletes stale). isolated-peer.ts: resolveIsolatedPeer(socket, deps) using fs/promises only: /proc/net/tcp{,6} row -> inode; descendants of live roots via /proc//task//children; match /proc//fd -> socket:[inode]; WeakMap cache per socket; return false fast with no roots or no /proc/net/tcp. dashboard-auth.ts: ensurePeerIdentityFresh also awaits it for an uncredentialed literal-loopback peer and marks the socket; localPeerKind returns null for a marked socket; add isTrustedLocalNodeRequestAsync and use it at workspace-wake.ts. ISOLATED_PEER_SELF_AUTH_ROUTES: POST /api/agents/:id/lifecycle carrying x-overdeck-pty-token skips the rule (the PTY supervisor sits in the isolated tree and its handler checks its own pty-token). Keep dashboard-auth.ts within its file-size count (logic lives in isolated-peer.ts). No execSync." + }, + "items": [ + { + "id": "peer-rule.ac1", + "title": "Given a fake /proc where the connection's inode belongs to a descendant of a live registered root, when resolveIsolatedPeer runs, then it returns true", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "peer-rule.ac2", + "title": "Given a fake /proc where the inode belongs to an unrelated pid, when resolveIsolatedPeer runs, then it returns false", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "peer-rule.ac3", + "title": "Given a root file whose pid start time differs, when readLiveRoots runs, then the entry is ignored and the file is deleted", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "peer-rule.ac4", + "title": "Given a socket marked isolated, when an uncredentialed POST /api/dashboard/session arrives, then the response is 401; given no registered roots, the mint behaves as before and no /proc reads happen", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "peer-rule.ac5", + "title": "Given a socket marked isolated, when POST /api/agents/x/lifecycle arrives with x-overdeck-pty-token, then the gate passes it to the handler (the PTY supervisor keeps recording lifecycle)", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "traefik-trust", + "title": "Stop trusting uncredentialed Traefik-forwarded requests while isolation is on", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "simple", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/routes/dashboard-auth.ts", + "src/dashboard/server/routes/dashboard-session.ts", + "src/dashboard/server/__tests__/dashboard-auth-isolation.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/dashboard-auth-isolation.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/dashboard-auth-isolation.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-10" + ] + }, + "narrative": { + "Action": "PRD WI-21 / D-11. In localPeerKind, when readAgentIsolationConfig().enabled, the traefik branch returns null (cookies still authenticate through resolveDashboardCredential). The session mint answers a Traefik-forwarded uncredentialed request with 401 {error naming http://localhost: and the #overdeck_token= link from pan serve, code:'isolation-sign-in'}." + }, + "items": [ + { + "id": "traefik-trust.ac1", + "title": "Given isolation enabled and a managed-Traefik peer forwarding a local client with no credential, when POST /api/dashboard/session arrives, then the response is 401 with code 'isolation-sign-in'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "traefik-trust.ac2", + "title": "Given isolation disabled, when the same request arrives, then the session is minted as before", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "traefik-trust.ac3", + "title": "Given isolation enabled and a valid overdeck_session cookie through Traefik, when a GET /api/agents arrives, then it is authorized", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "admission-pidns", + "title": "Make gate admission tolerant of PID namespaces", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/cloister/quality-gate-admission.ts", + "src/lib/cloister/quality-gate-admission-pidns.ts", + "tests/unit/lib/cloister/quality-gate-admission.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run tests/unit/lib/cloister/quality-gate-admission.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "tests/unit/lib/cloister/quality-gate-admission.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-15" + ] + }, + "narrative": { + "Action": "PRD WI-22 / D-17. Stamp ticket, owner and breaker records with pidNs (readlink /proc/self/ns/pid once per process; undefined off Linux). ownerIsStale and the breaker check treat a record whose pidNs differs from ours as alive until staleMs. Put helpers in quality-gate-admission-pidns.ts if the main file would grow past its count. Use the existing admission test file name; inject isProcessAlive and pidNs, no real timers." + }, + "items": [ + { + "id": "admission-pidns.ac1", + "title": "Given an owner record from another PID namespace younger than staleMs whose pid looks dead locally, when the queue checks staleness, then the owner keeps its slot", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "admission-pidns.ac2", + "title": "Given the same owner older than staleMs, when the queue checks staleness, then the slot is cleared", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "admission-pidns.ac3", + "title": "Given an owner from our own namespace whose pid is dead, when the queue checks staleness, then the slot is cleared as before", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "codex-clamp", + "title": "Clamp isolated Codex launches to workspace-write", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "simple", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/agents/runtime-command.ts", + "src/lib/agents/__tests__/runtime-command-codex.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/lib/agents/__tests__/runtime-command-codex.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/agents/__tests__/runtime-command-codex.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-12" + ] + }, + "narrative": { + "Action": "PRD WI-23 / D-13. Add an optional `isolated = false` parameter to getCodexLauncherFields; when true and codex.permissionMode is 'full-access', use 'workspace' (workspace-write, on-request). Checkpoint CP-5: check `codex sandbox --help` and Codex config docs for a permission profile that denies reads; if one exists, add the D-8 read-deny set through it in initCodexHome, otherwise leave a comment citing CP-5. Use the existing runtime-command test file if one covers getCodexLauncherFields." + }, + "items": [ + { + "id": "codex-clamp.ac1", + "title": "Given isolated true and codex.permissionMode 'full-access', when getCodexLauncherFields runs, then the written config.toml has sandbox_mode = \"workspace-write\"", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "codex-clamp.ac2", + "title": "Given isolated false and 'full-access', when getCodexLauncherFields runs, then sandbox_mode is \"danger-full-access\" as before", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "capability-doctor", + "title": "Declare each harness's isolation class and report it in pan doctor", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "packages/contracts/src/harness-capabilities.ts", + "src/cli/commands/doctor-agent-isolation.ts", + "src/cli/commands/doctor.ts", + "src/cli/commands/__tests__/doctor-agent-isolation.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/cli/commands/__tests__/doctor-agent-isolation.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/cli/commands/__tests__/doctor-agent-isolation.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-13" + ] + }, + "narrative": { + "Action": "PRD WI-24 / D-12 / D-14. Add agentIsolation: 'os-sandbox'|'write-sandbox'|'harness-default'|'none' to HarnessCapabilities and set it per the PRD matrix in every capabilities constant. checkAgentIsolation(deps) returns rows: switch on/off; on Linux with Claude Code configured, 'Claude Code sandbox' error naming missing bwrap/socat with fix 'sudo apt-get install bubblewrap socat'; 'Dashboard peer rule' warn on non-Linux; one row per configured harness of class write-sandbox/harness-default/none with the D-14 message; 'Docker access' warn when allow_docker. Add one line in doctor.ts after the checkClaudeCode() line." + }, + "items": [ + { + "id": "capability-doctor.ac1", + "title": "Given Linux with bwrap present and socat missing, when checkAgentIsolation runs, then it returns an 'error' row whose message names socat", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "capability-doctor.ac2", + "title": "Given pi configured as a harness, when checkAgentIsolation runs, then it returns a 'warn' row saying pi has no sandbox", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "capability-doctor.ac3", + "title": "Given agents.isolation.enabled false, when checkAgentIsolation runs, then the first row is 'warn' with message containing 'off'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "capability-doctor.ac4", + "title": "Given every harness capabilities constant, when typecheck runs, then each declares agentIsolation", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "docs", + "title": "Document agent isolation for users and developers", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "docs", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "configuration/agent-isolation.mdx", + "docs.json", + "docs/AGENT-ISOLATION.md", + "docs/DASHBOARD-AUTH.md", + "docs/SECURITY-AUDIT-2026-11-29.md", + "configuration/harnesses.mdx", + "CLAUDE.md", + ".overdeck/context/codebase/concerns.md", + "changelog.d/pan-5754.md" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npm run lint:docs" + ], + "expected_outputs": [ + "lint:docs completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-16" + ] + }, + "narrative": { + "Action": "PRD WI-25. New configuration/agent-isolation.mdx (linked in docs.json next to configuration/permissions) covering who is isolated, the D-8 reach lists, the per-harness class table, config keys with defaults, bubblewrap/socat prerequisites and the fail-closed launch refusal, signing in on overdeck.localhost (D-11), the Docker opt-in, and residual risks R-1..R-9. New docs/AGENT-ISOLATION.md (architecture, probe table, how to add a forwarded-verb row). Update docs/DASHBOARD-AUTH.md (agent socket, peer rule under rule 4, Traefik change, POST /api/self/cli), docs/SECURITY-AUDIT-2026-11-29.md (F-9/F-4 rows and paragraph), configuration/harnesses.mdx (isolation class), CLAUDE.md (one Key Invariants line + Topic Index row), codebase concerns.md (auto-approve entry; keep its last-verified line), and add changelog.d/pan-5754.md under '#### New'." + }, + "items": [ + { + "id": "docs.ac1", + "title": "Given the docs site config, when docs.json is read, then it lists 'configuration/agent-isolation' and that page names agents.isolation.enabled, allow_docker and allow_write with their defaults", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "docs.ac2", + "title": "Given configuration/agent-isolation.mdx, when read, then it contains a table naming every harness with its class (os-sandbox, write-sandbox, harness-default, none) and lists residual risks R-1 to R-9", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "docs.ac3", + "title": "Given docs/SECURITY-AUDIT-2026-11-29.md, when read, then the F-9 row states it is fixed by PAN-5754 for Claude Code agents and names the residual risks", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "docs.ac4", + "title": "Given changelog.d/pan-5754.md, when npm run lint:docs runs, then it exits 0", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "pi-extension-token", + "title": "Make the pi extension authenticate with the agent token", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "simple", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "packages/pi-extension/src/index.ts", + "packages/pi-extension/src/__tests__/index.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run --config packages/pi-extension/vitest.config.ts packages/pi-extension/src/__tests__/index.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "the pi-extension index test passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-2", + "FR-17" + ] + }, + "narrative": { + "Action": "PRD WI-26 / D-19. In packages/pi-extension/src/index.ts the token read (anchor `const token = (await readFile(join(overdeckHome, 'internal-token'), 'utf8')).trim()`) first checks process.env.OVERDECK_AGENT_TOKEN_FILE; when set it reads that file, sends Authorization: Bearer on every dashboard post (postWithTimeout, postJsonWithTimeout, postDashboard) and never reads internal-token; otherwise unchanged." + }, + "items": [ + { + "id": "pi-extension-token.ac1", + "title": "Given OVERDECK_AGENT_TOKEN_FILE set, when the extension posts a heartbeat, then the request carries 'Authorization: Bearer odk_' and no x-overdeck-internal-token header", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "pi-extension-token.ac2", + "title": "Given OVERDECK_AGENT_TOKEN_FILE unset, when the extension posts a heartbeat, then it sends the x-overdeck-internal-token header as before", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "pi-routes-self-auth", + "title": "Let the pi extension's control-ack and auto-complete routes accept a self agent token", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "api", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/routes/conversations.ts", + "src/dashboard/server/routes/specialists/legacy-routes.ts", + "src/dashboard/server/__tests__/pi-routes-self-auth.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/pi-routes-self-auth.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/pi-routes-self-auth.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-8", + "FR-17" + ] + }, + "narrative": { + "Action": "PRD WI-27. conversations.ts control-ack (anchor '/api/conversations/:name/control-ack', line ~741): authorizeInternalOrSelfAgent with subject :name (agent id, or the conversation's tmux session). specialists/legacy-routes.ts auto-complete (anchor '/api/specialists/:name/auto-complete', line ~601): an agent token passes only with role review or test and when the body issue equals the token agent's issue; other credentials keep today's check. Note in the docs item that classify-completion (runtime-events.ts ~173, no handler auth) is admitted by its new 'tell' row." + }, + "items": [ + { + "id": "pi-routes-self-auth.ac1", + "title": "Given agent A's token, when it posts control-ack for agent B, then the response is 403 with code 'not-self'", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "pi-routes-self-auth.ac2", + "title": "Given a work-role token, when it posts /api/specialists/review-agent/auto-complete, then the response is 403", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "pi-routes-self-auth.ac3", + "title": "Given a review-role token for its own issue, when it posts auto-complete for that issue, then the request is accepted", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "verb-coverage", + "title": "Prove every agent-facing pan verb is forwarded or known-local", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "medium", + "kind": "test", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/dashboard/server/__tests__/self-cli-coverage.test.ts" + ], + "files_scope_confidence": "high", + "verify_commands": [ + "npx vitest run src/dashboard/server/__tests__/self-cli-coverage.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/dashboard/server/__tests__/self-cli-coverage.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-7", + "NFR-4" + ] + }, + "narrative": { + "Action": "PRD WI-28. A data table lists every pan verb isolated roles are told to run (roles/*.md, src/lib/cloister/*prompt*.ts, and the skills pan-task, pan-done, pan-tell, pan-worker, pan-foreman, pan-memory, pan-handoff, pan-sync-main, pan-plan) with disposition forwarded: or local-read. local-read is allowed only for read-only verbs (task show/next, show, status, memory search/show/list/read, conv pending/current/list/show/whoami, worker list, lane reads). For each forwarded verb assert matchSelfCliVerb finds a row allowing the listed roles. The table is test data, not a source scan (NFR-4)." + }, + "items": [ + { + "id": "verb-coverage.ac1", + "title": "Given the coverage table, when the test runs, then every 'forwarded' verb (incl. tell, ask, sync-main, review request, plan finalize, admin specialists done, review spawn-reviewer, swarm dispatch, spawn, foreman, workspace add-repo, worker run, backlog write-sequence) resolves to a row allowing its listed roles", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "verb-coverage.ac2", + "title": "Given the coverage table, when the test runs, then no verb with a mutating effect is marked local-read", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + }, + { + "id": "launch-sites-runtimes", + "title": "Prepare isolation inside every runtime spawnAgent (crash recovery, rotation, Codex and the other runtimes)", + "status": "pending", + "priority": "high", + "created": "2026-12-03T20:19:30Z", + "metadata": { + "difficulty": "complex", + "kind": "backend", + "issueLabel": "pan-5754", + "requiresInspection": false, + "inspectionDepth": "fast", + "files_scope": [ + "src/lib/runtimes/claude-code.ts", + "src/lib/runtimes/codex.ts", + "src/lib/runtimes/ohmypi.ts", + "src/lib/runtimes/pi.ts", + "src/lib/runtimes/muse.ts", + "src/lib/runtimes/kimi-code.ts", + "src/lib/runtimes/prime-agent.ts", + "src/lib/runtimes/acp.ts", + "src/lib/cloister/__tests__/isolation-runtime-launch.test.ts" + ], + "files_scope_confidence": "medium", + "verify_commands": [ + "npx vitest run src/lib/cloister/__tests__/isolation-runtime-launch.test.ts", + "npm run typecheck" + ], + "expected_outputs": [ + "src/lib/cloister/__tests__/isolation-runtime-launch.test.ts passes", + "typecheck completes without errors" + ], + "readiness": "ready", + "traces": [ + "FR-1", + "FR-4", + "FR-12" + ], + "parallelSafeReason": "Edits only src/lib/runtimes/* spawn implementations, which no other item touches; it runs after launch-isolation and codex-clamp by edges." + }, + "narrative": { + "Action": "PRD WI-29. Crash recovery (src/lib/cloister/service-crash.ts ~433) and session rotation (src/lib/cloister/session-rotation.ts ~249) call runtime.spawnAgent directly. In every runtime spawnAgent implementation call prepareAgentIsolation for the spawn owner, reusing an isolation value the caller already passed (no double mint). Generator-based runtimes pass it to generateLauncherScript; the Codex runtime (runtimes/codex.ts ~674-699, own command) emits the same export/unset/root-registration lines and applies the D-13 clamp. remote-agents.ts (Fly VMs) is out of scope; checkpoint CP-7: confirm the Fly VM holds no copy of the host internal-token, else file a follow-up issue linked from docs/AGENT-ISOLATION.md." + }, + "items": [ + { + "id": "launch-sites-runtimes.ac1", + "title": "Given an isolated work agent restarted through service-crash.ts, when the runtime launches it, then the launch exports OVERDECK_AGENT_TOKEN_FILE", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-sites-runtimes.ac2", + "title": "Given an isolated work agent rotated through session-rotation.ts, when the runtime launches it, then the launch exports OVERDECK_AGENT_TOKEN_FILE", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + }, + { + "id": "launch-sites-runtimes.ac3", + "title": "Given an isolated agent spawned through the Codex runtime with codex.permissionMode full-access, when it launches, then the Codex config has sandbox_mode = \"workspace-write\" and the command unsets OVERDECK_INTERNAL_TOKEN", + "status": "pending", + "metadata": { + "kind": "acceptance_criterion" + } + } + ] + } + ], + "edges": [ + { + "from": "iso-config", + "to": "token-location", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "iso-policy", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "launch-isolation", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "agent-socket", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "cli-credential", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "peer-rule", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "traefik-trust", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "codex-clamp", + "type": "blocks" + }, + { + "from": "iso-config", + "to": "capability-doctor", + "type": "blocks" + }, + { + "from": "token-location", + "to": "launch-isolation", + "type": "blocks" + }, + { + "from": "iso-policy", + "to": "claude-settings", + "type": "blocks" + }, + { + "from": "iso-policy", + "to": "write-guard-hook", + "type": "blocks" + }, + { + "from": "iso-policy", + "to": "launch-isolation", + "type": "blocks" + }, + { + "from": "claude-settings", + "to": "launch-isolation", + "type": "blocks" + }, + { + "from": "peer-rule", + "to": "launch-isolation", + "type": "blocks" + }, + { + "from": "peer-rule", + "to": "traefik-trust", + "type": "blocks" + }, + { + "from": "launch-isolation", + "to": "launch-sites-runtimes", + "type": "blocks" + }, + { + "from": "codex-clamp", + "to": "launch-sites-runtimes", + "type": "blocks" + }, + { + "from": "launch-isolation", + "to": "launch-sites-agents", + "type": "blocks" + }, + { + "from": "launch-isolation", + "to": "launch-sites-planning-conv", + "type": "blocks" + }, + { + "from": "codex-clamp", + "to": "launch-sites-agents", + "type": "blocks" + }, + { + "from": "cli-credential", + "to": "cli-callers", + "type": "blocks" + }, + { + "from": "cli-credential", + "to": "in-pane-callers", + "type": "blocks" + }, + { + "from": "cli-credential", + "to": "self-cli-route", + "type": "blocks" + }, + { + "from": "self-auth-routes", + "to": "pi-routes-self-auth", + "type": "blocks" + }, + { + "from": "forward-messaging", + "to": "verb-coverage", + "type": "blocks" + }, + { + "from": "forward-planning-review", + "to": "verb-coverage", + "type": "blocks" + }, + { + "from": "forward-swarm-misc", + "to": "verb-coverage", + "type": "blocks" + }, + { + "from": "self-cli-route", + "to": "forward-messaging", + "type": "blocks" + }, + { + "from": "self-cli-route", + "to": "forward-planning-review", + "type": "blocks" + }, + { + "from": "self-cli-route", + "to": "forward-swarm-misc", + "type": "blocks" + } + ] + }, + "status": "active" +} \ No newline at end of file diff --git a/CLAUDE.md b/CLAUDE.md index 00d1b0b5ca8..df9e2f87b16 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -43,6 +43,7 @@ - **One variant per operation in src/lib.** No exported Effect wrapper around in-repo Promise or sync code (Shapes A/B), no sync/async twin without a documented sync caller; `npm run lint:effect-facades` ratchets it. [docs/EFFECT-BRIDGING.md](docs/EFFECT-BRIDGING.md) - Curated facts live in `/.overdeck/memory/.md` (operator: `~/.overdeck/context/memory/`); the index is rendered at launch into every managed harness and never stored. Write them with `pan memory add`, never into harness-native memory. - Managed agents get the `overdeck` MCP server with a per-agent token minted at launch and revoked at stop (PAN-4927); tools proxy dashboard routes, so `route-scopes.ts` stays the authority. +- Isolated agents (token role not `conversation`/`flywheel`) use their agent token only, never `internal-token`; Claude Code agents run Bash in the sandbox, and verbs needing operator rights go through `POST /api/self/cli` (PAN-5754). `isolatedAgentFence` limits an isolated token to its own issue's sessions; git the dashboard runs ignores repo hooks (`git-repo-exec-guard.ts`). See [docs/AGENT-ISOLATION.md](docs/AGENT-ISOLATION.md). ## Topic Index @@ -64,6 +65,7 @@ | Semgrep (opt-in SAST): managed install, doctor, tiers | [configuration/semgrep.mdx](configuration/semgrep.mdx) | | Flywheel page and loop skill | [docs/FLYWHEEL.md](docs/FLYWHEEL.md) | | Gauntlet lanes (`pan lane`) | [reference/lanes.mdx](reference/lanes.mdx) | +| Agent isolation (sandbox, agent tokens, forwarded verbs, peer rule) | [configuration/agent-isolation.mdx](configuration/agent-isolation.mdx), [docs/AGENT-ISOLATION.md](docs/AGENT-ISOLATION.md) | | Shared Sessions share service (Cloudflare Worker, Durable Objects, TURN) | [docs/SHARED-SESSIONS.md](docs/SHARED-SESSIONS.md) | | MCP relay (Fly TLS passthrough for Public MCP, deploy runbook, CP-3) | [docs/MCP-RELAY.md](docs/MCP-RELAY.md) | | Overdeck Anywhere: machine links, secure channel, routes | [docs/ANYWHERE-ARCHITECTURE.md](docs/ANYWHERE-ARCHITECTURE.md) | diff --git a/changelog.d/pan-5754.md b/changelog.d/pan-5754.md new file mode 100644 index 00000000000..a49596b1ff9 --- /dev/null +++ b/changelog.d/pan-5754.md @@ -0,0 +1,3 @@ +#### New + +- **Agent isolation, layer 1 (install bubblewrap and socat before you upgrade on Linux):** Claude Code pipeline agents (work, review, test, plan and the other non-conversation roles) can no longer act as you on the dashboard, except for the residual risks listed in the agent isolation docs. They use a token of their own instead of `~/.overdeck/internal-token`, commands that need your rights run on the dashboard for them, and the dashboard no longer trusts their local connections. Claude Code agents also run every Bash command in Claude Code's sandbox, which hides your credentials and the terminal sockets. That sandbox needs `bwrap` and `socat` on Linux: without them every isolated Claude Code agent is refused at launch. Install them first (for example `sudo apt-get install bubblewrap socat`, `sudo dnf install bubblewrap socat` or `sudo pacman -S bubblewrap socat`), or set `agents.isolation.enabled: false` in `~/.overdeck/config.yaml` to keep the old behaviour. `pan install`, `pan sync` and `pan doctor` warn when they are missing and print the command for your distribution; `pan doctor` also reports what each harness can isolate. Sandboxed agents push over https through the `gh` credential helper (run `gh auth setup-git` once): ssh remotes, the ssh agent and keyring helpers do not work inside the sandbox, and `pan doctor` warns for each project whose agents could not push. Their package managers use a private cache, so an agent's first install downloads its packages again. Inside the sandbox no Unix socket can be opened, so the `tsx` CLI fails there; run TypeScript with `node --import tsx `. Except for the residual risks listed in those docs, this first layer stops an isolated Claude Code pipeline agent's own tool calls from reading your credentials or reaching operator-only services. It does not yet stop Overdeck itself from running agent-edited files outside the sandbox (the verification gate, workspace installs, the `pan reload` build), and it does not sandbox agents on harnesses other than Claude Code; that is [epic #6004](https://github.com/eltmon/overdeck/issues/6004). ([#5754](https://github.com/eltmon/overdeck/issues/5754)) diff --git a/configuration/agent-isolation.mdx b/configuration/agent-isolation.mdx new file mode 100644 index 00000000000..1aaa4b7b206 --- /dev/null +++ b/configuration/agent-isolation.mdx @@ -0,0 +1,243 @@ +--- +title: "Agent isolation: keep Claude Code pipeline agents away from your credential" +sidebarTitle: "Agent isolation" +description: "How Overdeck stops Claude Code work, review, test and other pipeline agents from acting as you on the dashboard, what each harness can isolate, and the agents.isolation settings." +--- + +# Agent isolation + +Every agent Overdeck launches runs as your user. Before agent isolation, any agent could act as you on the +dashboard in one command: read `~/.overdeck/internal-token`, ask the dashboard for a root session from +`127.0.0.1`, or type into another agent's pane through the Herdr or tmux socket. Agent isolation closes those +paths for Claude Code pipeline agents, except for the residual risks listed below. It is on by default. + +## What this release covers (layer 1) + +Agent isolation ships in layers. Except for the residual risks listed below, this first layer stops an isolated +Claude Code pipeline agent's **own tool calls** from reading your credentials or reaching services only you +should reach: the internal token and other secrets, the terminal sockets, operator-only dashboard routes, and +other agents' sessions. + +It does **not** yet stop Overdeck itself from running files an agent edited outside the sandbox. The +verification gate, dependency installs in a workspace and the `pan reload` build all run workspace or +repository content with your rights. It also does not sandbox agents on harnesses other than Claude Code: they +get their own token, but can still read your files. Closing both is +[epic #6004](https://github.com/eltmon/overdeck/issues/6004); until it lands, treat an isolated agent's work +as untrusted until a review passes. + +## Who is isolated + +An agent is isolated when its token role is anything other than `conversation` or `flywheel`: work, worker, +plan, strike, sequencer, knowledge, review, test and ship agents, and lane or worker conversations. + +Your own conversations and the Flywheel are not isolated. They keep the operator credential and run exactly +as before. + +## What an isolated agent uses instead + +- **Its own token.** Each agent gets an access token of its own (`odk_…`) at + `~/.overdeck/agent-tokens///mcp-token`. Its hooks and the `pan` CLI inside it send that token and + never read or create `internal-token`. The token never carries `admin`, and the hook routes accept it only for + the agent itself. +- **A credentialed transport.** The `pan` CLI reaches the dashboard through `~/.overdeck/agent-api/dashboard.sock`, + where a request passes only with a credential. Inside the Claude Code sandbox no Unix socket can be opened, so + the CLI goes through the sandbox's HTTP proxy to `localhost` instead, with the same token. +- **Forwarded commands.** Commands that need your rights or a terminal socket, such as `pan done`, + `pan task done`, `pan tell`, `pan sync-main` and `pan swarm dispatch`, run on the dashboard for the agent. + The dashboard checks that the agent's role may run the command, that it names the agent's own issue, and that + every flag and file path is allowed. Commands that only read, such as `pan status`, run inside the agent. +- **A fenced token.** The token acts only for the agent. It cannot attach to a terminal, start a conversation, + or change order books, shared skills, recovery holds or Overdeck's version. A message (`pan tell`, the + `send_message` tool) or any other change to a conversation reaches only the agent itself, its parent, the + agents and lanes it started, and the agents of its own issue. The Flywheel and your own conversations are not + targets: an agent that needs you uses `pan ask` or comments on the issue. `--steer` is not available. Memory + writes go to the project's store only (no `--user`, `--machine`, `--project` or `--always`). A handoff's + successor is pinned to the agent's own role and issue, so it stays isolated. Workers and lanes start only + through the agent's own doors (`delegate_task`, `lane_start`, `pan worker run`, `pan spawn`), on this machine + and in its own workspace: the agent cannot pick a machine, a placement, a directory, or a harness or model + that runs without an OS sandbox. + +## What an isolated Claude Code agent cannot reach + +A Claude Code agent runs every Bash command in Claude Code's OS sandbox, under a policy Overdeck writes for it. +Its file tools (Read, Edit, Write) get matching deny rules, and a write guard hook keeps Edit and Write inside the +writable paths. + +- **Hidden files.** `internal-token`, `access-tokens.json`, `account.json`, `machine-key.json`, + `machine-links.json`, `ssh-machines.json`, Overdeck's databases (`overdeck.db`, `panopticon.db`, `cache.db` + and their `-wal` and `-shm` files), and the `credentials/`, `github-app/`, `cliproxy/`, `kimi-cliproxy-home/`, + `secrets/`, `vault/`, `certs/`, `browser-profiles/` and `agent-tokens/` directories under `~/.overdeck`. The + agent sees only its own token directory. In your home directory: `~/.ssh` (except `known_hosts` and + `config`), `~/.fly`, `~/.docker/config.json`, `~/.aws`, `~/.kube`, `~/.config/gcloud`, `~/.npmrc`, + `~/.config/doctl`, `~/.config/glab-cli`, `~/.wrangler` and `~/.config/.wrangler`, `~/.config/restic`, + `~/.config/rclone`, `~/.sentryclirc` and `~/.config/sentry`, `~/.gnupg`, `~/.codex`, and the Chrome, Chromium + and Firefox profiles. Inside the sandbox npm therefore reads no `~/.npmrc` (a private registry token there is + out of reach), and commit signing with gpg does not work. The Read tool follows a symlink to its target, so a link in the workspace does not get + past these rules. +- **Blocked sockets.** Every Unix socket, unless you allow Docker. Then the Herdr and tmux sockets, + `~/.overdeck/sockets`, your user runtime directory (D-Bus) and X11 stay blocked. +- **Read-only places.** Everything except the workspace, `/tmp`, `logs/` and `tmp/` and the gate admission queue + in `~/.overdeck`, and the agent's own package cache. Claude Code makes the repository's shared git directory + writable for a worktree, so Overdeck denies every entry in it by name except objects, refs, reflogs and the + agent's own worktree directory: git's config files (shared and per worktree), `HEAD`, `index`, + `packed-refs`, `hooks/`, `info/`, the worktree pointer files and other worktrees' directories are read-only. + The launcher first creates a `commondir` file containing `.` at the top of the shared git directory if it is + missing (`.` names that directory itself, so git behaves the same), so that it can be denied too. If that + file exists with anything other than `.` (a trailing newline is fine) in it, or is not a regular file, + isolated launches in the repository are refused and `pan doctor` reports it. Overdeck creates no `rr-cache`, + an existing one is read-only, and the agent's git runs with `rerere.enabled=false`, so git does not write + one; the agent could still create one by hand, like any new top-level file (R-13). + A plain clone's whole `.git` is read-only, because its admin files sit beside its data. The workspace's + `.git` pointer file, `.claude/` and `.mcp.json` are read-only too. +- **Shared package caches.** Your caches (`~/.cache`, `~/.bun`, `~/.npm`, pnpm, yarn, Gradle, Cargo, Go) hold + programs that run outside the sandbox, so they are read-only. Package managers in the agent use a private + cache at `~/.overdeck/agent-caches///` instead (through `XDG_CACHE_HOME`, `BUN_INSTALL_CACHE_DIR`, + `npm_config_cache` and similar variables). Only the agent's Bash commands get these variables + (`CLAUDE_ENV_FILE`); its hooks and MCP servers run outside the sandbox and keep the shared caches. The first + install in an agent downloads its packages again; the cache is deleted when the agent stops. +- **Dashboard trust.** The dashboard never treats a connection from an isolated agent's processes as a local + browser, so the agent cannot mint a root session from `127.0.0.1` (Linux; see the risks below for macOS). If + the check cannot read `/proc`, the connection counts as an agent's. A request that carries an agent token is + judged by that token, whatever process sent it. +- **Repository code in Overdeck's own git.** Git that the dashboard runs, including in agent workspaces, ignores + the repository's hooks and fsmonitor command (`core.hooksPath=/dev/null`, `core.fsmonitor=false`, set through + `GIT_CONFIG_COUNT`). Terminal panes and the Codex app server do not inherit this, so an agent's own commits + still run the project's hooks, inside its sandbox. Git the dashboard runs skips every hook, including the + repository's pre-push checks (in an agent workspace those are files the agent can edit, so they were never a + control there). + +## What changes inside the sandbox + +- **No Unix sockets.** A tool that opens one fails with `EPERM`. The `tsx` CLI is one: it opens an IPC socket, + so run TypeScript with `node --import tsx ` instead. Node's own child-process IPC still works. +- **Packed branches.** Deleting a branch that git has packed fails, because `packed-refs` is read-only. +- **Fetching and merging `main`.** `git fetch` works; `pan sync-main` and `pan done` run on the dashboard. + +## Each harness + +`pan doctor` prints one warning for each harness you configure that cannot fully isolate an agent. + +| Harness | Class | What isolation gives | +|---|---|---| +| Claude Code | `os-sandbox` | Everything above: its own token, the sandbox, the deny rules and the write guard. | +| Codex | `write-sandbox` | Its own token, and writes confined to the workspace (`full-access` is clamped to `workspace`). It can still read your secret files. | +| Muse | `harness-default` | Its own token. Muse runs in its own default sandbox, which Overdeck does not configure. | +| pi, ohmypi, kimi-code, opencode, grok, antigravity, prime-agent, acp | `none` | Its own token only. The agent can still read your secret files. | + +## Settings + +The keys live in `~/.overdeck/config.yaml` only. A project's `.pan.yaml` cannot set them. + +```yaml +agents: + isolation: + enabled: true # default true; false runs every agent unisolated, as before + allow_docker: false # default false; true lets isolated agents reach the Docker socket + allow_write: [] # default []; extra writable paths, absolute or ~/ +``` + +- `enabled` (default `true`): `false` restores the old behaviour for every launch. +- `allow_docker` (default `false`): see "Docker" below. +- `allow_write` (default `[]`): extra paths an isolated agent may write. A relative path is ignored with a + warning. + +## Prerequisites on Linux: bubblewrap and socat + +Claude Code's sandbox needs `bwrap` and `socat` on `PATH`. Without them an isolated Claude Code launch is +**refused** before any pane starts, with this message: + +``` +agent isolation: Claude Code sandbox unavailable (missing: socat). Install with: sudo apt-get install bubblewrap socat, or set agents.isolation.enabled: false to run agents unisolated +``` + +The message names only the missing binaries and the install command for your distribution. Overdeck never +installs system packages, and it never runs an isolated agent without its sandbox. `pan doctor` reports the same +condition as an error, and `pan install` and `pan sync` warn about it before any agent starts. Install both with +your distribution's package manager: + +| Distribution | Command | +|---|---| +| Debian, Ubuntu | `sudo apt-get install bubblewrap socat` | +| Fedora, RHEL, Rocky | `sudo dnf install bubblewrap socat` | +| Arch, Manjaro | `sudo pacman -S bubblewrap socat` | +| openSUSE, SLES | `sudo zypper install bubblewrap socat` | +| Alpine | `sudo apk add bubblewrap socat` | + +**Before upgrading a Linux install to this release, install both**, or set `agents.isolation.enabled: false` +first. Otherwise every isolated Claude Code agent is refused at launch until you do. + +## Pushing from an isolated agent + +An isolated Claude Code agent pushes its branch over https through a git credential helper. The sandbox denies +`~/.ssh` and every socket, so an ssh remote, the ssh agent, `libsecret` (D-Bus) and `git credential-cache` do +not work, and neither does a `store` helper whose file is under `~/.overdeck/credentials/`. The `gh` helper +works: run `gh auth setup-git` once. `pan doctor` warns for each registered project whose agents could not push. + +## Signing in on overdeck.localhost + +A sandboxed process can reach the managed Traefik through Claude Code's proxy, so while isolation is on the +dashboard no longer trusts an uncredentialed request that comes through Traefik. A browser that already has its +dashboard session (the cookie lasts 30 days) is unaffected. A new browser profile on `overdeck.localhost` signs +in in one of two ways: + +- open `http://localhost:3011` on this machine once, or +- use the `#overdeck_token=` link that `pan serve` prints. + +The dashboard answers such a request with `401` and the code `isolation-sign-in`. + +## Docker + +Isolated agents cannot reach the Docker socket. Access to it is root-equivalent on most hosts. If your agents +must run `docker` themselves (for example to bring up a workspace stack from inside the agent), set +`allow_docker: true`; `pan doctor` then warns. Claude Code's sandbox can only allow all Unix sockets or none, +so `allow_docker: true` also lets the agent reach every socket outside the blocked directories listed above. + +## Residual risks + +Agent isolation does not cover these. Each needs its own fix. + +- **R-1. Code that runs outside the sandbox.** The verification gate, dependency installs in a workspace and the + `pan reload` build run workspace or repository content (`npm run …`, install scripts) with your rights, so + an agent's edits reach your rights there. This is the main gap layer 1 leaves; see + [epic #6004](https://github.com/eltmon/overdeck/issues/6004). +- **R-2. Harnesses without a sandbox.** A `none`-class harness can still read your secret files, and it can reach + the dashboard as a local caller by detaching from its process tree (`setsid`). +- **R-3. Docker.** `allow_docker: true` gives the agent the Docker socket, which is root-equivalent. +- **R-4. Overdeck state.** Isolated agents cannot read or write Overdeck's databases; they reach state through the + dashboard with their own token. They can still write `~/.overdeck/logs/` and `~/.overdeck/tmp/`. +- **R-5. Tools outside the sandbox.** An MCP server that you or the project configured (for example Playwright) + runs outside the sandbox and does what the agent asks of it. +- **R-6. macOS.** The dashboard's process-tree check needs `/proc`, so on macOS it is off and `pan doctor` says so. +- **R-7. Harness logins.** Credentials the agent itself needs, such as `~/.claude/.credentials.json` and the `gh` + token (agents push through the gh helper), stay readable. A repo-scoped push credential is tracked in + [#5996](https://github.com/eltmon/overdeck/issues/5996). +- **R-8. config.yaml.** `~/.overdeck/config.yaml` stays readable, because the CLI reads it on every call. It can + hold provider API keys and tracker tokens. +- **R-9. Other agents' files.** Files under `~/.overdeck/agents//` of other agents (the PTY supervisor token, + delivered `secrets/`) stay readable, so an agent could forge another agent's lifecycle events or read its + delivered secrets. +- **R-10. Other loopback services.** The sandbox proxy filters hosts, not ports. An agent needs the dashboard + port, so it can also reach other services that listen on `localhost`. A port filter is tracked in + [#5997](https://github.com/eltmon/overdeck/issues/5997). +- **R-11. Relayed requests.** A request with no credential that another local process relays for the agent (for + example a dev-server proxy) is judged by that process. Tracked in + [#5998](https://github.com/eltmon/overdeck/issues/5998). +- **R-12. Shared refs.** The agent can move local and remote-tracking refs in the repository's shared git + directory (refs are data that git never runs). It cannot delete a ref that git has packed. +- **R-13. The shared git directory.** Existing entries and `commondir` are denied by name, but the agent can + still add other new files at the top of the repository's shared git directory (a deny on a missing name would + make it unreadable inside the sandbox and break git there), and it can write the shared object store. Tracked + in [#6002](https://github.com/eltmon/overdeck/issues/6002) and [epic #6004](https://github.com/eltmon/overdeck/issues/6004). + +Three narrower gaps are also still open: + +- **Handoff authoring.** A forwarded `pan handoff` always starts an isolated work conversation for the agent's own + issue, but the default external authoring session that writes the handoff document reads the agent's transcript + and is not itself isolated. +- **Root registration.** The process-tree check knows an agent only after its launcher records its process. If + that record cannot be written (no `/proc`, a full disk), the agent's connections count as local again. +- **File paths in forwarded commands.** The dashboard checks a file path an agent passes to a forwarded command, + then the command opens it. An agent that swaps the file for a symlink in between could make the command read + something else. + +Developer details: `docs/AGENT-ISOLATION.md` in the repository. diff --git a/configuration/harnesses.mdx b/configuration/harnesses.mdx index bf5b3ddc3a0..a1c169ef409 100644 --- a/configuration/harnesses.mdx +++ b/configuration/harnesses.mdx @@ -1476,6 +1476,7 @@ name. Every field is required, so a harness cannot leave a decision undeclared. | `skillMention` | How the composer `$` menu inserts a skill: `slash` writes `/` (Claude Code), `dollar` writes `$` (Codex), `null` means no `$` menu. | | `conversationSkillApply` | How pack skills added to a running conversation load (`pan skills add`, `add_skills`, **Add skills…**): `hot-reload` re-points the plugin dir and sends `/reload-plugins` (Claude Code); `restart` stores them and loads them on a resume (Codex); `null` means the harness gets no conversation packs, so the dashboard hides **Add skills…** and the route answers 409. | | `startupMenuStallSignal` | A launch that shows a blocking menu and has written no transcript 180 s later is reported as a startup stall (`paneQuestion`). Only Claude Code declares it (PAN-4242). | +| `agentIsolation` | How an isolated pipeline agent is kept from the operator credential (PAN-5754): `os-sandbox` (Claude Code: every command runs in its OS sandbox under Overdeck's isolation policy), `write-sandbox` (Codex: writes are confined, operator secrets stay readable), `harness-default` (Muse: its own sandbox, not configured by Overdeck), `none` (every other harness: only the agent token is used). `pan doctor` warns for each configured harness that is not `os-sandbox`. See [Agent isolation](/configuration/agent-isolation). | The rule for harness-specific code: diff --git a/docs.json b/docs.json index 47abe4218c1..5c8f809f880 100644 --- a/docs.json +++ b/docs.json @@ -138,6 +138,7 @@ "configuration/knowledge", "configuration/harnesses", "configuration/permissions", + "configuration/agent-isolation", "configuration/model-routing", "configuration/model-presets", "configuration/local-models", diff --git a/docs/AGENT-ISOLATION.md b/docs/AGENT-ISOLATION.md new file mode 100644 index 00000000000..62f6b6af6ab --- /dev/null +++ b/docs/AGENT-ISOLATION.md @@ -0,0 +1,188 @@ +# Agent isolation (developer notes) + +PAN-5754 keeps Claude Code pipeline agents from acting as the operator on the dashboard, except for the residual +risks listed on the user page. User-facing page: +[configuration/agent-isolation.mdx](../configuration/agent-isolation.mdx). Design and decisions (D-1 … D-19): +`.pan/drafts/PAN-5754.md` on the feature branch that shipped it. + +**Scope: layer 1.** Except for the residual risks listed below, it stops an isolated Claude Code pipeline agent's +own tool calls from reading operator credentials or reaching operator-only services. It does not yet stop Overdeck's own processes from running agent-edited files outside the +sandbox (the verification gate, workspace installs, the `pan reload` build), and it does not sandbox agents on +non-Claude harnesses. Both are [epic #6004](https://github.com/eltmon/overdeck/issues/6004). + +## Who is isolated + +`isIsolatedTokenRole(role)` (`src/lib/agent-isolation/config.ts`) is the one predicate: every token role except +`conversation` and `flywheel`. `isAgentIsolationActive(role)` adds the `agents.isolation.enabled` switch, read from +the global `config.yaml` only (`stripProjectSecurity` drops `agents.isolation` from `.pan.yaml`). Per-request code +(the Traefik trust check) uses `agentIsolationEnabled()`, which re-reads the file only when its mtime changes. + +## The pieces + +- **Agent token.** `ensureAgentMcpToken` writes each owner's token to + `/agent-tokens///mcp-token` (0700/0600). `ensureIsolationToken` mints it whatever the MCP switch + says and throws, so an isolated launch fails closed. +- **Policy.** `buildIsolationPolicy` (`agent-isolation/policy.ts`) is pure: `denyRead` (the operator secret set, + Overdeck's databases, the home credentials found at launch (`HOME_SECRET_ENTRIES`) and the masked socket + dirs), `allowRead` (own token dir, `~/.ssh/known_hosts` and `config`), `allowWrite` (workspace, `/tmp`, only + `GIT_COMMON_WRITABLE_ENTRIES` of each shared git dir plus the agent's own worktree git dir, the + `OVERDECK_HOME_WRITABLE_ENTRIES` allowlist, the private cache, `allow_write`), `denyWrite` (adds, by name, every + top-level entry of the common dir present at launch except the data dirs, every other worktree's dir, the own + worktree dir's `config.worktree`, `commondir` and `gitdir`, and a plain clone's whole git dir; Claude Code + mounts a worktree's common dir writable itself, P29), `maskedSocketDirs`, `mkdirBeforeLaunch`, + `createBeforeLaunch` (the shared and own `config.worktree`, created empty so their denies apply to a real + file) and `allowAllUnixSockets` (only with `allow_docker`). A deny on a missing path makes it unreadable inside + the sandbox, and git reads missing `commondir` and `shallow`, so `commondir` gets a `.` placeholder + (created with noclobber, never overwritten or followed through a symlink; `.` names the git dir itself) and is + denied, `shallow` gets none, and no other missing name is denied (R-13). `commondirProblem` + (`agent-isolation/commondir-check.ts`) refuses an isolated launch when a repo's main git dir holds a + `commondir` that is not a regular file holding `.` (a trailing newline is fine): `prepareAgentLaunchAccess` runs + it before the MCP token and `prepareAgentIsolation` before the isolation token, so a refused launch mints + nothing. The main git dir is found from the filesystem (`mainGitDirOf`), never through git, which would itself + follow that `commondir`; `pan doctor` reports the same per registered project. Overdeck creates no `rr-cache` (an + existing one is denied as an entry), and `bash-env.sh` sets `rerere.enabled=false` in the sandboxed git's + `GIT_CONFIG_*` entries, overriding an entry for the same key (`SANDBOX_GIT_CONFIG`); a hand-made `rr-cache` is + like any new top-level file (R-13). + `resolveIsolationPolicyInput` gathers the real paths (async only), including `--git-dir` and `--git-common-dir` + per repo root. +- **Private caches.** `agentCacheEnv` (`agent-isolation/cache-env.ts`) points package managers at + `/agent-caches///` for a Claude Code launch, through `bash-env.sh` in the isolation dir, which the + launcher names in `CLAUDE_ENV_FILE`: sandboxed Bash sources it, hooks and MCP servers never see it. + `revokeAgentMcpTokens` deletes the cache, so it lives as long as the token. +- **Claude Code settings.** `renderIsolationClaudeSettings` turns the policy into the `--settings` file: the sandbox + block (`failIfUnavailable`, no unsandboxed retry, Unix sockets per `allowAllUnixSockets`, every domain), + `Read(//…)`/`Edit(//…)` deny rules (bare and `/**`), and the PreToolUse write guard. `writeIsolationFiles` writes `claude-settings.json` and + `policy.json` under `/isolation///`. +- **Write guard.** `sync-sources/hooks/agent-isolation-guard` (installed by `pan sync`): Edit/Write/MultiEdit/ + NotebookEdit allowed only under an `allowWrite` root and no `denyWrite` root, judged by the canonical path + (`realpath -m`, or a node fallback where BSD `realpath` has no `-m`). It fails closed. +- **Launch.** `prepareAgentIsolation` (`agent-isolation/launch.ts`) checks `bwrap`/`socat` for a Linux Claude Code + launch (D-12), mints the token, builds the policy and writes the settings. The launcher + (`agent-isolation/launcher-lines.ts`) then creates the masked socket dirs, exports `OVERDECK_AGENT_TOKEN_FILE`, + `OVERDECK_DASHBOARD_SOCKET`, `OVERDECK_ISOLATED=1` and `NODE_USE_ENV_PROXY=1`, unsets `OVERDECK_INTERNAL_TOKEN`, + registers the root, and passes `--settings "$PAN_ISO_SETTINGS"`. Skill-override settings are merged into a + per-launch copy (Claude Code keeps one `--settings` value). Every launch site calls `prepareAgentLaunchAccess` + (`mcp/agent-injection.ts`); runtimes that build their own launch call `runtimeLaunchIsolation` + (`agent-isolation/runtime-launch.ts`). The review sub-role's post-exit `pan` calls run with + `env -u OVERDECK_AGENT_TOKEN_FILE` (D-15). +- **Credential helper.** `src/lib/dashboard-client/agent-credential.ts`: `dashboardAuthHeaders` (Bearer agent + token when isolated, else the internal-token header) and `dashboardFetch` (agent socket first; on + `ENOENT`/`ECONNREFUSED`/`EPERM` the sandbox proxy from `HTTP_PROXY` (`sandboxProxyRoute`, an absolute-URL request + with the proxy's credentials), else TCP; never the internal token). Inside the Claude Code sandbox the socket + call always fails, because `socket(AF_UNIX)` is denied. Hooks run outside the sandbox and use `PAN_AUTH_HEADER` + from `pan-hook-lib.sh` over the socket. +- **Agent socket.** `installAgentApiSocket` (`src/dashboard/server/agent-api-socket.ts`) serves the HTTP app on + `/agent-api/dashboard.sock`. A Unix-socket request has no peer address, so it passes the gate only with a + credential. +- **Self routes for hooks.** `routes/self-or-internal.ts`: hook and self-report routes accept the internal token or + an agent token for its own subject (path `:id`, or the owner of the body's `session_id`); anything else for another + agent is 403 `not-self`. Their `tell`/`operate` rows are in `route-scopes.ts`. +- **Forwarded verbs.** `POST /api/self/cli` (`routes/self-cli.ts`) runs a forwarded `pan` verb as a self job. The + CLI calls `maybeForwardIsolatedVerb` (`src/cli/isolated-forward.ts`) before parsing. A row's + `allowedTargetPositional` (the `tell` target) must pass `isolatedTargetAllowed`. +- **Token fence.** `isolatedAgentFence` (`src/dashboard/server/isolated-agent-fence.ts`) runs beside + `linkActorFence` in the remote request gate and the `/ws/terminal` upgrade. While isolation is on, an + isolated-role token (or an agent token with no role) is refused on `/ws/terminal` and `/ws/forward`, on + conversation creates (`/api/conversations`, `/api/fleet/conversations`, `/api/machines/work/conversations`), on + operator-wide writes (order books, shared skills, recovery holds, self-update, UI open), and on any write to a + conversation or message to an agent that `isolatedTargetAllowed` refuses (403 `isolated-fenced`). Allowed + targets: self, the parent (a worker's `parentId`, a lane's launching conversation), the agents and lanes the + caller started, and agents of the caller's issue. `/api/self/handoff` pins `--role` and `--issue` for an + isolated caller as the forwarded row does; `/api/self/memory/facts` refuses the user and machine stores. + The bare and fleet start routes (`POST /api/workers`, `/api/lanes`, `/api/fleet/*`, `/api/machines/work/*`) are + fenced; `isolatedLaunchRefusal` refuses a self worker or lane body that sets `machine`, `needs` (a lane also + `at`, `project`) or a `harness` (directly, or through a `model`'s provider default) without an `os-sandbox` + class, and the forwarded `pan spawn --model` is a `sandboxedModel` flag. `isolatedTargetFor` returns the + canonical target id, which the forwarded `tell` runs with. `src/dashboard/server/__tests__/isolated-agent-fence.test.ts` + classifies every non-GET `operate`/`tell` row (`fenced`, `target` or `handler`); a new row fails it until classified. +- **Git guard.** `applyGitRepoExecGuard` (`src/lib/git-repo-exec-guard.ts`), applied by the side-effect module + `src/dashboard/server/path-env.ts` (the first import of `main.ts`), adds + `core.hooksPath=/dev/null` and `core.fsmonitor=false` through `GIT_CONFIG_COUNT`, so git the dashboard and its + children run never executes a workspace's hooks (`core.hooksPath` may be relative to the worktree) or + fsmonitor command. `buildPaneServerEnv` (`child-env.ts`) drops it for the tmux server, which panes inherit, and + the Codex app server's spawn drops it too. +- **Peer rule.** `src/dashboard/server/isolated-peer.ts`: for an uncredentialed loopback request, the dashboard + finds the connection's inode in `/proc/net/tcp{,6}` and checks whether a process in a live root's tree holds it + (D-10). Marked connections are not trusted local callers. A failed lookup (neither table readable, or any + thrown error) marks the connection as isolated and logs a warning. Separately, `localPeerKind` answers null for + any request that carries an agent token, so such a request is judged by its token whatever its peer. Roots: `/isolation/roots/.json`, read by + `readLiveRoots` (`agent-isolation/roots.ts`), which deletes stale entries. `POST /api/agents/:id/lifecycle` with + `x-overdeck-pty-token` is exempt (`ISOLATED_PEER_SELF_AUTH_ROUTES`). +- **Traefik.** While isolation is on, `localPeerKind` never answers `traefik` (D-11); the mint answers 401 + `isolation-sign-in`. +- **Codex.** `codexLaunchPermissions` (`agent-isolation/codex.ts`) clamps `full-access` to `workspace` for isolated + launches. +- **Gate admission.** Admission records carry `pidNs`; a record from another PID namespace is alive until + `staleMs` (`cloister/quality-gate-admission-pidns.ts`). +- **Doctor.** `checkAgentIsolation` (`src/cli/commands/doctor-agent-isolation.ts`) and the `agentIsolation` + harness capability (`os-sandbox`, `write-sandbox`, `harness-default`, `none`). On Linux with Claude Code it also + warns per registered project whose origin no sandboxed credential helper can push to + (`judgePushCredential`, `agent-isolation/push-credential.ts`). + +## Adding a forwarded verb + +1. Add a row to the family file in `src/dashboard/server/services/self-cli-verbs/` (`core`, `messaging`, + `planning`, `review`, `swarm`, `misc`). Read the verb's commander definition first. +2. List only the roles that run it. Set `issuePositional` or `issueFlag` when the verb names an issue. +3. Allow flags exactly as the verb defines them, minus anything that selects another agent, issue, session, model + or harness, or that forces or bypasses a gate. A flag the verb reads as a file is `workspacePath`; a path + positional goes in `pathPositionals` and must be the last positional. +4. Mark `longRunning` for verbs that wait on other work, `stdin` for verbs that read their input from stdin. +5. Add the verb to the coverage table in `src/dashboard/server/__tests__/self-cli-coverage.test.ts` and a row case + to `self-cli-route.test.ts`. + +## Probes (Claude Code 2.1.335, Linux, 2026-12-03) + +| # | Setting | Observed | +|---|---|---| +| P1 | `denyRead` on a directory | masked (`ENOENT`) | +| P2 | `denyWrite` inside `allowWrite` | deny wins | +| P4 | default Unix sockets | every `connect()` is `EPERM` | +| P5 | `allowUnixSockets` paths on Linux | no effect | +| P6 | `allowAllUnixSockets` + `denyWrite` on the dir | connect **succeeds** | +| P7 | `allowAllUnixSockets` + `denyRead` on the dir | blocked | +| P8 | `allowRead` inside a `denyRead` dir | that subdirectory is readable | +| P10 | sandbox proxy to `127.0.0.1:3011` | HTTP 200: the proxy reaches host loopback | +| P12 | `deniedDomains` with CIDR | ignored | +| P13 | process view | own PID namespace | +| P14 | Node `fetch` | needs `NODE_USE_ENV_PROXY=1` | +| P15 | git with the common dir writable, `hooks/` and `config` denied | commit works; hooks and config writes fail | +| P17 | `Read(/abs)` deny rule | does not match (single `/` is relative) | +| P18 | `Read(//abs)`, `Edit(//dir/**)` | block the file tools even when a hook answers allow | +| P20 | sandbox `denyRead` vs the Read tool | the Read tool still reads; file tools need their own rules | +| P23 | Codex `workspace-write` | reads secrets; HOME writes blocked | +| P25 | `allowAllUnixSockets: false` | `socket(AF_UNIX)` is `EPERM`; Node `fork` IPC (a socketpair) still works | +| P26 | the D-8 git allowlist in a linked worktree | commit, merge, fetch, push and status work; `config`, `config.worktree` (shared and own), `commondir`, `gitdir`, `hooks/`, `info/`, `packed-refs` and another worktree's dir are read-only | +| P27 | `bun install` and `npx vitest run` with private caches and no Unix sockets | both work | +| P28 | the Read tool on a workspace symlink to a `Read(//…)`-denied file or directory | refused: the rule matches the target | +| P29 | Claude Code started in a linked worktree | it mounts the shared git dir writable (protecting `hooks/`, `worktrees/`, `objects/info`), so only named denies keep its other entries read-only | +| P30 | a `denyWrite` path that does not exist | creation is refused, and the path reads as `EACCES` inside the sandbox: git then fails on a missing `commondir` (`git fetch`, `git branch`, `git worktree list`) | +| P31 | the rendered policy in a linked worktree of this repo | commit, fetch, merge, `git push --dry-run` with the repo's real helper chain, `git branch`, `git log --all` and `git worktree list` work; `mv`, `rm` and `ln -sf` over the own `config.worktree`, `commondir` and `gitdir` fail; every top-level entry present at launch is read-only | +| P32 | `CLAUDE_ENV_FILE` set by the launcher | Bash commands see its exports; a hook does not | +| P33 | the `tsx` CLI with Unix sockets denied | fails (`listen EPERM` on its IPC pipe); `node --import tsx` works, and the CLI transport reaches `/api/health` through the proxy | + +P25–P33 ran on Claude Code 2.1.336 with a scratch `socat` on `PATH`. + +Hooks, stdio MCP servers and the status line run outside the sandbox. Without bubblewrap or socat Claude Code runs +unsandboxed unless `sandbox.failIfUnavailable` is set. + +## Residual risks + +R-1 … R-13 are listed on the user page (follow-ups: R-1 and R-13 epic #6004, R-7 #5996, R-10 #5997, R-11 +#5998, R-13 #6002). Each needs its own issue; none is closed by this design. The page also +lists three gaps the plan critique left open: the external handoff author is not isolated (the forwarded handoff +itself is pinned to `--role=work` and the caller's issue), root registration fails open when the launcher cannot +write its record, and a `workspacePath` value is checked before the self job opens it (a symlink swap in between +is possible). + +## Planning checkpoints + +- CP-1 (live verification): the review-fix pass ran P25–P33 through `claude -p --settings` with a scratch `socat` + on `PATH`, P31 against the rendered settings of a real worktree; a full isolated agent launch on this host + still waits for `socat`. +- CP-3: `git push -u` with `.git/config` unwritable still pushes and exits 0 (only the upstream write fails), so + work agents need no change. +- CP-5: codex-cli 0.173 offers no read-deny setting; Codex stays `write-sandbox`. +- CP-6: `muse sandbox --help` documents only Windows setup; no read-deny paths to record. +- CP-7: nothing under `src/lib/remote` copies the internal token to a Fly VM, and remote launches carry no + isolation. diff --git a/docs/DASHBOARD-AUTH.md b/docs/DASHBOARD-AUTH.md index 23d12df31d5..37bd22b29de 100644 --- a/docs/DASHBOARD-AUTH.md +++ b/docs/DASHBOARD-AUTH.md @@ -109,10 +109,10 @@ fresh (`readActiveAccessTokenRecord`, `revokeAccessTokensMatching`), never the in-memory snapshot, so it works in CLI processes too. - **Token file.** `ensureAgentMcpToken(owner)` writes the plaintext to - `/mcp-token`, mode `0600`, by temp file plus rename. The owner - directory is `~/.overdeck/agents//` for agents and - `~/.overdeck/conversations/conv-/` (`conversationStateDir`) for - conversations. It reuses the file's token while that token is active, names + `~/.overdeck/agent-tokens///mcp-token` (directory `0700`, file + `0600`), by temp file plus rename (PAN-5754 D-4: outside the owner's state + dir, so an isolated agent's sandbox hides every other owner's token). Revoke + also unlinks the pre-PAN-5754 `/mcp-token`. It reuses the file's token while that token is active, names the same owner and role, and has exactly the role's scopes; otherwise it revokes the owner's tokens and mints one. A mint the registry lost to another process's write is minted once more, then the call throws. @@ -281,6 +281,30 @@ an unknown one. `pan mcp serve` takes the token from `OVERDECK_MCP_TOKEN` or a server per `POST`, no session); `GET /mcp` and `DELETE /mcp` answer 405 with `Allow: POST`. Over Tailscale Funnel, `/mcp` accepts only OAuth tokens (403 `public MCP accepts only OAuth sign-ins` otherwise) and is rate limited; see "Public MCP (PAN-4947)". See [configuration/mcp.mdx](../configuration/mcp.mdx). +### The agent socket (PAN-5754) + +The primary dashboard also serves its HTTP app on +`~/.overdeck/agent-api/dashboard.sock` (directory `0700`, socket `0600`, +`src/dashboard/server/agent-api-socket.ts`). A Unix-socket request has no +peer address, so it is never a trusted local caller and passes the gate only +with a credential. An isolated agent's CLI uses it with its agent token +(`dashboardFetch`), falling back to TCP only when the socket is missing, +refused or blocked. + +### Hook and self-report routes (PAN-5754 D-16) + +The routes hooks and in-pane helpers call (`POST /api/agents/:id/heartbeat`, +`work-complete`, `stuck`, `plan-checklist`, the internal permission request, +`/api/hooks/*`, the memory hook routes, conversation `control-ack`) accept the +internal token or an agent token that speaks for itself: the path `:id`, or the +owner of the body's `session_id` (`routes/self-or-internal.ts`). A token for +another agent gets **403** `{ "code": "not-self" }`; a session with no owner is +refused for agent tokens. `complete-planning` admits an agent token only as the +issue's own planner, and any other credential needs `admin`. Specialists +`auto-complete` admits an agent token only as a review or test agent of the +body's issue. `classify-completion` has no handler auth, so its `tell` row +admits any `tell`-scoped token (it only classifies text). + ### `/api/self/*` (PAN-4927) A self route acts for the agent that calls it. The route-scope table admits it @@ -296,6 +320,13 @@ gets **404** `{ "code": "agent-gone" }`. The agent always comes from the token; a self route never reads an agent, issue or conversation from the body, query or headers. +`POST /api/self/cli` (`read:state`, PAN-5754 D-7) runs a forwarded `pan` verb +for an isolated agent: `{ argv, stdin? }` is matched against the closed table in +`services/self-cli-verbs/`; a role the row does not list gets **403** +`role-not-allowed`, an argv no row matches **404** `verb-not-forwarded`, and a +disallowed flag, another issue or a path outside the caller's workspace **400**. +The job keeps whole stdout and stderr up to 4 MiB; `longRunning` rows get 24 h. + Self routes that run a CLI-only operation start a **job** (`src/dashboard/server/services/self-jobs.ts`). A job runs one verb from a closed set of `pan` commands (`services/self-job-argv.ts`), with argv built @@ -1016,6 +1047,20 @@ reach any route at all: as the mint): pass. With `require_token_mint`, a literal-loopback peer that carries `X-Forwarded-For`, `X-Forwarded-Host` or `Forwarded` counts as remote; a managed-Traefik peer whose forwarded client is local stays local. + Agent isolation (PAN-5754) narrows this rule twice: + - **Peer rule (D-10).** On Linux, for a literal-loopback request with no + credential, `ensurePeerIdentityFresh` resolves once per connection whether + a process in a live isolated launcher's tree owns the connection + (`src/dashboard/server/isolated-peer.ts`: `/proc/net/tcp{,6}` inode, the + roots in `~/.overdeck/isolation/roots/`, `/proc//fd`). Such a + connection is not a trusted local caller and never mints a session. + `POST /api/agents/:id/lifecycle` with `x-overdeck-pty-token` is exempt + (its handler checks the PTY token). With no live roots nothing in `/proc` + is read; without `/proc/net/tcp` (macOS) the rule is off. + - **Traefik (D-11).** While `agents.isolation.enabled` is true, a + Traefik-forwarded request is never a trusted local caller; the mint + answers **401** `{ "code": "isolation-sign-in" }`. A browser with the + session cookie authenticates by credential and is unaffected. 5. Otherwise: **401** `{ "error": "unauthorized" }`. The gate normalizes the path before deciding (query, absolute-form target, diff --git a/docs/FLYWHEEL.md b/docs/FLYWHEEL.md index b6db2502e45..8cd9773934b 100644 --- a/docs/FLYWHEEL.md +++ b/docs/FLYWHEEL.md @@ -6,7 +6,7 @@ User guide: [features/flywheel.mdx](../features/flywheel.mdx). Every agent the loop starts carries provenance `startedBy: 'flywheel:conv-flywheel'` (PAN-3634), resolved by `resolveCliStartedBy()` from `OVERDECK_CONVERSATION=conv-flywheel` on the shell the conversation runs in — there is no run id to stamp or read anymore. The planning auto-handoff and its deferred retry carry that same token to the work agent only when the planning session they hand off from was itself Flywheel-started (`planningHandoffStartedBy()`); otherwise they send `planning-auto-handoff`, an operator origin. This is what the emergency brake and the memory governor's shed key their operator-started exemption on: only a `flywheel:`-prefixed `startedBy` is ever reaped automatically. -Pipeline role agents (plan, work, review, test, strike) escalate a stall to the Flywheel with `pan tell conv-flywheel " : …"`, as their role prompts' "Signal the flywheel before you stall" section says. When no Flywheel is running the tell fails with "not running", and the prompt tells the agent to post the same analysis as an issue comment, which keeps it on record (the loop has no step that reads issue comments). `messageAgent` finds the Flywheel's harness by its full row name `conv-flywheel`, so the tell reaches a Flywheel on any harness. The retired name `flywheel-orchestrator` reaches no session; `src/lib/agents/__tests__/role-escalation-target.test.ts` fails if a rendered role prompt or a `sync-sources/` file names it as a `pan tell` target (PAN-5615). +Pipeline role agents (plan, work, review, test, strike) escalate a stall with `pan ask ": …"`, as their role prompts' "Signal the flywheel before you stall" section says: it lands on the Needs-you list the Flywheel reads, and a push-back is also posted as an issue comment for the record. They cannot `pan tell conv-flywheel`: these roles are isolated (PAN-5754), and an isolated agent's messages reach only its own issue's agents, its parent and the agents it started. The retired name `flywheel-orchestrator` reaches no session; `src/lib/agents/__tests__/role-escalation-target.test.ts` fails if a rendered role prompt or a `sync-sources/` file names it as a `pan tell` target (PAN-5615), or if one of these role prompts escalates with a tell to the Flywheel. PAN-3917 cut the Flywheel page and its `pause`/`resume`/`abort`/`report`/`stats` verbs along with the stored run records. PAN-3964 brought the page and the verbs back as a **derived view**: every status the page shows is computed when it is read, from sources that already exist. Nothing new is stored in SQLite. The only files are the loop's own `.pan/flywheel/state.md` and `.pan/flywheel/report.md`. diff --git a/docs/SECURITY-AUDIT-2026-11-29.md b/docs/SECURITY-AUDIT-2026-11-29.md index c2fae114cc6..49ee6aee53b 100644 --- a/docs/SECURITY-AUDIT-2026-11-29.md +++ b/docs/SECURITY-AUDIT-2026-11-29.md @@ -18,9 +18,10 @@ data, send input to an agent, or run commands. The issue is shipped in 0.93.0. - [#5707](https://github.com/eltmon/overdeck/pull/5707), merged, adds a permanent guard test over every dashboard route and raw Node listener. -- F-9 is a threat-model limitation, not a separate boundary. Agent isolation - is designed in [#5754](https://github.com/eltmon/overdeck/issues/5754), which - also narrows F-4's auto-approval. The desktop follow-up +- F-9 is a threat-model limitation, not a separate boundary. It is fixed by + [#5754](https://github.com/eltmon/overdeck/issues/5754) for Claude Code + agents (agent isolation), which also narrows F-4's auto-approval; residual + risks R-1 to R-9 are listed in `configuration/agent-isolation.mdx`. The desktop follow-up [#5758](https://github.com/eltmon/overdeck/issues/5758) is fixed: the embedded server binds `127.0.0.1` unless `HOST` is set. The desktop follow-up [#5759](https://github.com/eltmon/overdeck/issues/5759) and the service @@ -84,12 +85,12 @@ fix. | F-1 | critical | Any web page can call unguarded mutating routes (CSRF) | Fixed, [#5689](https://github.com/eltmon/overdeck/pull/5689) (merged) | | F-2 | critical | DNS rebinding reads every GET route | Fixed, [#5691](https://github.com/eltmon/overdeck/pull/5691) (merged) | | F-3 | high | Shell injection through `:issueId` in the Command Deck planning routes | Fixed, [#5694](https://github.com/eltmon/overdeck/pull/5694) (merged) | -| F-4 | high | Untrusted tracker text reaches agents that approve their own commands | Fixed, [#5806](https://github.com/eltmon/overdeck/pull/5806) (merged; released in 0.93.0): only owner, member and collaborator comments reach the prompt, and all tracker text is enveloped as untrusted. Narrowing auto-approval stays with [#5754](https://github.com/eltmon/overdeck/issues/5754) | +| F-4 | high | Untrusted tracker text reaches agents that approve their own commands | Fixed, [#5806](https://github.com/eltmon/overdeck/pull/5806) (merged; released in 0.93.0): only owner, member and collaborator comments reach the prompt, and all tracker text is enveloped as untrusted. Auto-approval is narrowed by [#5754](https://github.com/eltmon/overdeck/issues/5754): an isolated Claude Code agent runs Bash only in the sandbox with no unsandboxed retry, and its deny rules hold even when the hook answers allow | | F-5 | high | `GET /api/settings` returns API keys and tracker tokens unmasked | Fixed, [#5737](https://github.com/eltmon/overdeck/pull/5737) (merged), with `/api/settings/resolved`, Compare settings and provider-env conflicts; follow-ups [#5738](https://github.com/eltmon/overdeck/issues/5738), [#5739](https://github.com/eltmon/overdeck/issues/5739) | | F-6 | high | Workspace file names reach a shell in the clean preview | Fixed, [#5703](https://github.com/eltmon/overdeck/pull/5703) (merged) | | F-7 | medium | Any Docker container on the host is a trusted local caller | Fixed, [#5811](https://github.com/eltmon/overdeck/pull/5811) (merged; released in 0.93.0): only the managed Traefik container is trusted | | F-8 | medium | The git and `gh` shims guard where an agent pushes from, not what it does | Fixed, [#5816](https://github.com/eltmon/overdeck/pull/5816) and [#5820](https://github.com/eltmon/overdeck/pull/5820) (merged; released in 0.93.0) | -| F-9 | limitation | Any agent can type into another agent's Herdr pane. Not a separate boundary: agents run as the operator's user and can act as the operator (see F-9 below) | [#5754](https://github.com/eltmon/overdeck/issues/5754) (design; [#5699](https://github.com/eltmon/overdeck/issues/5699) closed as tracked there) | +| F-9 | limitation | Any agent can type into another agent's Herdr pane. Not a separate boundary: agents run as the operator's user and can act as the operator (see F-9 below) | Fixed by [#5754](https://github.com/eltmon/overdeck/issues/5754) for Claude Code agents: agent tokens for hooks and the CLI, a sandbox that hides the operator credential and the terminal sockets, and no local trust for isolated process trees. Other harnesses get the token change only; residual risks R-1 to R-9 in `configuration/agent-isolation.mdx` ([#5699](https://github.com/eltmon/overdeck/issues/5699) closed as tracked there) | | F-10 | medium | Connect: any device on an account can take over another machine's directory entry | Fixed, [#5724](https://github.com/eltmon/overdeck/pull/5724) and [#5732](https://github.com/eltmon/overdeck/pull/5732) (merged); deployed 2026-12-01 (account, then connect Worker) | | F-11 | medium | Account: device-flow consent phishing yields a device token | Fixed, [#5854](https://github.com/eltmon/overdeck/pull/5854) (merged; account Worker deployed 2026-12-02): the Authorize step shows where and when the sign-in was requested and what the token can do | | F-12 | medium | Share and connect: TURN credentials can be minted without limit | Fixed, [#5731](https://github.com/eltmon/overdeck/pull/5731) (merged); deployed (connect Worker 2026-12-01, share Worker 2026-12-02) | @@ -291,7 +292,15 @@ below is the code as it was before the fix: (a separate uid or the harness sandbox), and a non-Claude equivalent. It shares its root with F-4 ([#5696](https://github.com/eltmon/overdeck/issues/5696), closed by the #5806 fix), a prompt-injected, auto-approved agent holding the - operator token. + operator token. **Fixed by PAN-5754 for Claude Code agents:** isolated agents + (every token role but `conversation` and `flywheel`) authenticate with their + own agent token, run Bash in Claude Code's sandbox with the operator secret + set and the Herdr/tmux socket directories masked, and are never trusted local + callers. Residual risks: R-1 (the verification gate and deploy run workspace + code unsandboxed), R-2 (harnesses without a sandbox keep file access), R-3 + (`allow_docker`), R-4 (Overdeck state writes), R-5 (MCP servers outside the + sandbox), R-6 (no peer rule on macOS), R-7 (harness logins), R-8 + (`config.yaml`), R-9 (other agents' per-agent files). - **F-10:** `services/connect/src/directory-state.ts:326-352` never compares the row's `deviceId` with the caller. diff --git a/docs/TELEMETRY.md b/docs/TELEMETRY.md index 7ee67de7834..39c52cd4e03 100644 --- a/docs/TELEMETRY.md +++ b/docs/TELEMETRY.md @@ -187,7 +187,7 @@ the public contract and lists every allowed value. | `channel_error_class` | `none`, `unreachable`, `identity_refused`, `unknown_peer`, `unsupported`, `no_relay_plan`, `descriptor_failed`, `wrong_machine`, `heartbeat_failed`, `revoked` | | `channel_route` | `lan`, `tailnet`, `ssh`, `public`, `direct`, `relay`, `stored` | | `cli_verb` | `abort`, `approve`, `backlog`, `backup`, `clean`, `context`, `destroy`, `dev`, `diff`, `doctor`, `done`, `down`, `edit`, `finalize`, `fork`, `handoff`, `health`, `init`, `issues`, `kill`, `list`, `migrate`, `mode`, `open`, `pause`, `pending`, `plan`, `project`, `projects`, `recover`, `reload`, `reopen`, `request`, `reset`, `restart`, `restore`, `resume`, `review`, `scope`, `serve`, `show`, `skills`, `spawn-reviewer`, `staffing`, `start`, `status`, `strike`, `sync`, `sync-main`, `tell`, `unarchive-conversation`, `unpause`, `untroubled`, `up`, `update`, `validate`, `wipe`, `write-sequence`, `other` | -| `client_route` | `/api/activity`, `/api/agent-directory`, `/api/agent-requests`, `/api/agents`, `/api/agents/:id/answer-question`, `/api/agents/:id/message`, `/api/agents/:id/permissions/:requestId/respond`, `/api/agents/:id/plan-action`, `/api/agents/:id/send-now`, `/api/agents/:id/tell`, `/api/backend-restart-recovery`, `/api/backend-restart-recovery/dismiss`, `/api/backend-restart-recovery/resume-all`, `/api/backend-restart-recovery/stop`, `/api/connectors/self`, `/api/conversations`, `/api/conversations/:id`, `/api/conversations/:id/codex-approval`, `/api/conversations/:id/pane-choice`, `/api/conversations/:id/permission`, `/api/conversations/:id/pi-ask-answer`, `/api/conversations/:name/abort`, `/api/conversations/:name/about`, `/api/conversations/:name/archive`, `/api/conversations/:name/attachments/:file`, `/api/conversations/:name/bookmarks`, `/api/conversations/:name/changes`, `/api/conversations/:name/changes/lines`, `/api/conversations/:name/compact`, `/api/conversations/:name/delete-image`, `/api/conversations/:name/diffs`, `/api/conversations/:name/diffs/:turnId`, `/api/conversations/:name/diffs/full`, `/api/conversations/:name/diffs/vs-main`, `/api/conversations/:name/kickoff`, `/api/conversations/:name/message`, `/api/conversations/:name/message-locator`, `/api/conversations/:name/message/cancel`, `/api/conversations/:name/messages`, `/api/conversations/:name/plan-action`, `/api/conversations/:name/preview-ports`, `/api/conversations/:name/pull-requests`, `/api/conversations/:name/pull-requests/sync`, `/api/conversations/:name/release`, `/api/conversations/:name/release/complete`, `/api/conversations/:name/release/transfer/:transferId`, `/api/conversations/:name/release/undo`, `/api/conversations/:name/resume`, `/api/conversations/:name/rewind`, `/api/conversations/:name/rewind/options`, `/api/conversations/:name/scheduled-messages`, `/api/conversations/:name/scheduled-messages/:id`, `/api/conversations/:name/schedules`, `/api/conversations/:name/schedules/:id`, `/api/conversations/:name/send-now`, `/api/conversations/:name/skills`, `/api/conversations/:name/stop`, `/api/conversations/:name/switch-model`, `/api/conversations/:name/thinking-level`, `/api/conversations/:name/tool-body/:toolUseId`, `/api/conversations/:name/unarchive`, `/api/conversations/:name/upload-image`, `/api/conversations/archived`, `/api/conversations/auto-settle-on-merge`, `/api/conversations/pending-input`, `/api/costs/display-currency`, `/api/costs/request-digest`, `/api/costs/summary`, `/api/disk-alert`, `/api/explorer/download`, `/api/explorer/edit-workspaces/:workspaceId`, `/api/explorer/edit-workspaces/:workspaceId/changes`, `/api/explorer/edit-workspaces/:workspaceId/discard`, `/api/explorer/edit-workspaces/:workspaceId/merge`, `/api/explorer/edit-workspaces/:workspaceId/pr`, `/api/explorer/upload`, `/api/fleet/conversations`, `/api/fleet/issues/:id/activity`, `/api/fleet/issues/:id/start`, `/api/fleet/machines`, `/api/fleet/needs-you`, `/api/fleet/placement`, `/api/fleet/search`, `/api/fleet/workers`, `/api/fleet/workers/:id/stop`, `/api/flywheel/status`, `/api/github/identities`, `/api/harness-auto-update`, `/api/issues`, `/api/issues/:id`, `/api/issues/:id/check-runs`, `/api/issues/:id/costs`, `/api/issues/resource-allocated`, `/api/lanes`, `/api/lanes/:name`, `/api/lanes/:name/stop`, `/api/machines/conversations`, `/api/machines/heartbeat`, `/api/machines/issue-activity`, `/api/machines/needs-you`, `/api/machines/projects`, `/api/machines/projects/:key/file`, `/api/machines/projects/:key/source`, `/api/machines/self`, `/api/machines/work/conversations`, `/api/machines/work/issues/:id/start`, `/api/machines/work/lanes`, `/api/machines/work/lanes/:name/reap`, `/api/machines/work/lanes/:name/status`, `/api/machines/work/projects`, `/api/machines/work/projects/:jobId`, `/api/machines/work/workers`, `/api/needs-you`, `/api/orders`, `/api/orders/:id`, `/api/orders/:id/items`, `/api/orders/:id/items/:issue`, `/api/orders/:id/preview-brief`, `/api/orders/:id/start`, `/api/orders/backlog-candidates`, `/api/palette/search`, `/api/phones/self`, `/api/phones/self/notification-preferences`, `/api/phones/self/push-key`, `/api/pipeline/membership`, `/api/pull-requests`, `/api/pull-requests/conversations`, `/api/push/history`, `/api/registered-projects`, `/api/resources/actions/execute`, `/api/resources/actions/preview`, `/api/self/done`, `/api/self/handoff`, `/api/self/jobs/:id`, `/api/self/jobs/:id/wait`, `/api/self/lanes`, `/api/self/lanes/report`, `/api/self/lanes/wait`, `/api/self/machine-link-requests`, `/api/self/machine-link-requests/:id/wait`, `/api/self/memory/facts`, `/api/self/memory/search`, `/api/self/pull-request-watches`, `/api/self/pull-request-watches/:id`, `/api/self/pull-requests`, `/api/self/secret-requests`, `/api/self/secret-requests/:id/wait`, `/api/self/skills`, `/api/self/tasks/block`, `/api/self/tasks/claim`, `/api/self/tasks/done`, `/api/self/worker-report`, `/api/self/workers`, `/api/self/workers/:id`, `/api/self/workers/:id/wait`, `/api/settings/resolved`, `/api/shutdown`, `/api/shutdown/cancel`, `/api/shutdown/force-all`, `/api/shutdown/force-stop`, `/api/shutdown/preview`, `/api/skills/overrides`, `/api/skills/packs`, `/api/skills/packs/available`, `/api/skills/packs/preview`, `/api/telemetry/client-config`, `/api/ui/open`, `/api/usage-limit-hold`, `/api/usage-limit-hold/resume-all`, `/api/usage-limit-hold/stop`, `/api/versions/self`, `/api/versions/self/update`, `/api/workers`, `/api/workers/:id/status`, `/api/workers/:id/stop`, `/events/stream`, `/events/version`, `other` | +| `client_route` | `/api/activity`, `/api/agent-directory`, `/api/agent-requests`, `/api/agents`, `/api/agents/:id/answer-question`, `/api/agents/:id/classify-completion`, `/api/agents/:id/conversation`, `/api/agents/:id/heartbeat`, `/api/agents/:id/message`, `/api/agents/:id/permissions/:requestId/respond`, `/api/agents/:id/plan-action`, `/api/agents/:id/plan-checklist`, `/api/agents/:id/runtime`, `/api/agents/:id/send-now`, `/api/agents/:id/stuck`, `/api/agents/:id/tell`, `/api/agents/:id/work-complete`, `/api/backend-restart-recovery`, `/api/backend-restart-recovery/dismiss`, `/api/backend-restart-recovery/resume-all`, `/api/backend-restart-recovery/stop`, `/api/connectors/self`, `/api/conversations`, `/api/conversations/:id`, `/api/conversations/:id/codex-approval`, `/api/conversations/:id/pane-choice`, `/api/conversations/:id/permission`, `/api/conversations/:id/pi-ask-answer`, `/api/conversations/:name/abort`, `/api/conversations/:name/about`, `/api/conversations/:name/archive`, `/api/conversations/:name/attachments/:file`, `/api/conversations/:name/bookmarks`, `/api/conversations/:name/changes`, `/api/conversations/:name/changes/lines`, `/api/conversations/:name/compact`, `/api/conversations/:name/control-ack`, `/api/conversations/:name/delete-image`, `/api/conversations/:name/diffs`, `/api/conversations/:name/diffs/:turnId`, `/api/conversations/:name/diffs/full`, `/api/conversations/:name/diffs/vs-main`, `/api/conversations/:name/kickoff`, `/api/conversations/:name/message`, `/api/conversations/:name/message-locator`, `/api/conversations/:name/message/cancel`, `/api/conversations/:name/messages`, `/api/conversations/:name/plan-action`, `/api/conversations/:name/preview-ports`, `/api/conversations/:name/pull-requests`, `/api/conversations/:name/pull-requests/sync`, `/api/conversations/:name/release`, `/api/conversations/:name/release/complete`, `/api/conversations/:name/release/transfer/:transferId`, `/api/conversations/:name/release/undo`, `/api/conversations/:name/resume`, `/api/conversations/:name/rewind`, `/api/conversations/:name/rewind/options`, `/api/conversations/:name/scheduled-messages`, `/api/conversations/:name/scheduled-messages/:id`, `/api/conversations/:name/schedules`, `/api/conversations/:name/schedules/:id`, `/api/conversations/:name/send-now`, `/api/conversations/:name/skills`, `/api/conversations/:name/stop`, `/api/conversations/:name/switch-model`, `/api/conversations/:name/thinking-level`, `/api/conversations/:name/tool-body/:toolUseId`, `/api/conversations/:name/unarchive`, `/api/conversations/:name/upload-image`, `/api/conversations/archived`, `/api/conversations/auto-settle-on-merge`, `/api/conversations/pending-input`, `/api/costs/display-currency`, `/api/costs/request-digest`, `/api/costs/summary`, `/api/disk-alert`, `/api/explorer/download`, `/api/explorer/edit-workspaces/:workspaceId`, `/api/explorer/edit-workspaces/:workspaceId/changes`, `/api/explorer/edit-workspaces/:workspaceId/discard`, `/api/explorer/edit-workspaces/:workspaceId/merge`, `/api/explorer/edit-workspaces/:workspaceId/pr`, `/api/explorer/upload`, `/api/fleet/conversations`, `/api/fleet/issues/:id/activity`, `/api/fleet/issues/:id/start`, `/api/fleet/machines`, `/api/fleet/needs-you`, `/api/fleet/placement`, `/api/fleet/search`, `/api/fleet/workers`, `/api/fleet/workers/:id/stop`, `/api/flywheel/status`, `/api/github/identities`, `/api/harness-auto-update`, `/api/hooks/permission-event`, `/api/hooks/turn-complete`, `/api/hooks/user-prompt-submit`, `/api/internal/agents/:id/permissions/request`, `/api/issues`, `/api/issues/:id`, `/api/issues/:id/check-runs`, `/api/issues/:id/complete-planning`, `/api/issues/:id/costs`, `/api/issues/resource-allocated`, `/api/lanes`, `/api/lanes/:name`, `/api/lanes/:name/stop`, `/api/machines/conversations`, `/api/machines/heartbeat`, `/api/machines/issue-activity`, `/api/machines/needs-you`, `/api/machines/projects`, `/api/machines/projects/:key/file`, `/api/machines/projects/:key/source`, `/api/machines/self`, `/api/machines/work/conversations`, `/api/machines/work/issues/:id/start`, `/api/machines/work/lanes`, `/api/machines/work/lanes/:name/reap`, `/api/machines/work/lanes/:name/status`, `/api/machines/work/projects`, `/api/machines/work/projects/:jobId`, `/api/machines/work/workers`, `/api/memory/inject`, `/api/memory/session/start`, `/api/memory/turn`, `/api/needs-you`, `/api/orders`, `/api/orders/:id`, `/api/orders/:id/items`, `/api/orders/:id/items/:issue`, `/api/orders/:id/preview-brief`, `/api/orders/:id/start`, `/api/orders/backlog-candidates`, `/api/palette/search`, `/api/phones/self`, `/api/phones/self/notification-preferences`, `/api/phones/self/push-key`, `/api/pipeline/membership`, `/api/pull-requests`, `/api/pull-requests/conversations`, `/api/push/history`, `/api/registered-projects`, `/api/resources/actions/execute`, `/api/resources/actions/preview`, `/api/self/cli`, `/api/self/done`, `/api/self/handoff`, `/api/self/jobs/:id`, `/api/self/jobs/:id/wait`, `/api/self/lanes`, `/api/self/lanes/report`, `/api/self/lanes/wait`, `/api/self/machine-link-requests`, `/api/self/machine-link-requests/:id/wait`, `/api/self/memory/facts`, `/api/self/memory/search`, `/api/self/pull-request-watches`, `/api/self/pull-request-watches/:id`, `/api/self/pull-requests`, `/api/self/secret-requests`, `/api/self/secret-requests/:id/wait`, `/api/self/skills`, `/api/self/tasks/block`, `/api/self/tasks/claim`, `/api/self/tasks/done`, `/api/self/worker-report`, `/api/self/workers`, `/api/self/workers/:id`, `/api/self/workers/:id/wait`, `/api/settings/resolved`, `/api/shutdown`, `/api/shutdown/cancel`, `/api/shutdown/force-all`, `/api/shutdown/force-stop`, `/api/shutdown/preview`, `/api/skills/overrides`, `/api/skills/packs`, `/api/skills/packs/available`, `/api/skills/packs/preview`, `/api/specialists/:name/auto-complete`, `/api/telemetry/client-config`, `/api/ui/open`, `/api/usage-limit-hold`, `/api/usage-limit-hold/resume-all`, `/api/usage-limit-hold/stop`, `/api/versions/self`, `/api/versions/self/update`, `/api/workers`, `/api/workers/:id/status`, `/api/workers/:id/stop`, `/events/stream`, `/events/version`, `other` | | `client_route_area` | `access-tokens`, `account`, `activity`, `admin`, `agent-directory`, `agent-requests`, `agents`, `anywhere`, `artifacts`, `autopreso`, `backend-restart-recovery`, `backlog`, `boot-reconciliation`, `cache`, `cache-status`, `claude-code`, `cliproxy`, `cloister`, `color-themes`, `command-deck`, `commands`, `computer-use`, `confirmations`, `connectors`, `context`, `conversations`, `costs`, `dashboard`, `deacon`, `deft`, `deploy`, `dev`, `devices`, `diffs`, `directory`, `discovered-sessions`, `disk-alert`, `effort`, `environment`, `events`, `explorer`, `fleet`, `flywheel`, `fs`, `git-activity`, `github`, `github-quota`, `godview`, `harness-auto-update`, `health`, `hooks`, `internal`, `issues`, `jev`, `joins`, `knowledge-viewer`, `lanes`, `linear-mcp-auth`, `linked-conversations`, `machines`, `mcp`, `mcp-oauth`, `memory`, `merge-queue`, `merge-train`, `metrics`, `model-presets`, `models`, `needs-you`, `no-resume-mode`, `orders`, `pairing`, `palette`, `parked`, `phones`, `pipeline`, `planning`, `prereqs`, `project-mappings`, `projects`, `pull-requests`, `push`, `rally`, `registered-projects`, `registry`, `remote`, `resources`, `restart-gate`, `resume-all`, `review`, `self`, `semgrep`, `session-trees`, `settings`, `shadow`, `share-probe`, `shares`, `show`, `shutdown`, `skills`, `specialists`, `system`, `tailscale`, `telemetry`, `terminals`, `tiered`, `tracker-status`, `trackers`, `triggers`, `tts`, `ui`, `update`, `usage-limit-hold`, `vault`, `velocity`, `version`, `versions`, `voice`, `webhooks`, `workers`, `workspace-registry`, `workspace-stack-health`, `workspaces`, `other` | | `close_out_variant` | `card`, `inspector` | | `count_bucket` | `0`, `1-2`, `3-5`, `6-10`, `11+` | diff --git a/packages/contracts/src/harness-behavior.test.ts b/packages/contracts/src/harness-behavior.test.ts index 2018ff33213..e7c6270ac9e 100644 --- a/packages/contracts/src/harness-behavior.test.ts +++ b/packages/contracts/src/harness-behavior.test.ts @@ -149,6 +149,22 @@ describe("HarnessCapabilities (PAN-4562)", () => { expect(getHarnessBehavior(runtime).capabilities.conversationRewind).toBe(tier) }) + it.each([ + ["claude-code", "os-sandbox"], + ["codex", "write-sandbox"], + ["muse", "harness-default"], + ["pi", "none"], + ["ohmypi", "none"], + ["acp", "none"], + ["kimi-code", "none"], + ["opencode", "none"], + ["grok", "none"], + ["antigravity", "none"], + ["prime-agent", "none"], + ] as const)("%s declares agentIsolation=%s (PAN-5754 D-14)", (runtime, tier) => { + expect(getHarnessBehavior(runtime).capabilities.agentIsolation).toBe(tier) + }) + it("declares startupMenuStallSignal only for Claude Code (PAN-4242)", () => { for (const runtime of RUNTIMES) { expect(getHarnessBehavior(runtime).capabilities.startupMenuStallSignal).toBe(runtime === "claude-code") diff --git a/packages/contracts/src/harness-capabilities.ts b/packages/contracts/src/harness-capabilities.ts index e447b069a07..2f5022b7d77 100644 --- a/packages/contracts/src/harness-capabilities.ts +++ b/packages/contracts/src/harness-capabilities.ts @@ -95,8 +95,17 @@ export interface HarnessCapabilities { * transcript line. */ readonly startupMenuStallSignal: boolean + /** + * PAN-5754 D-14: how an isolated agent on this harness is kept from the operator credential. + * os-sandbox = Overdeck runs every command in the harness's OS sandbox under its isolation policy; + * write-sandbox = writes are confined but operator secrets stay readable; harness-default = the + * harness's own sandbox, not configured by Overdeck; none = only the agent token is used. + */ + readonly agentIsolation: HarnessAgentIsolation } +export type HarnessAgentIsolation = "os-sandbox" | "write-sandbox" | "harness-default" | "none" + export const HARNESS_CAPABILITY_KEYS = [ "contextChannel", "initialPromptMustLand", @@ -125,6 +134,7 @@ export const HARNESS_CAPABILITY_KEYS = [ "skillMention", "conversationSkillApply", "startupMenuStallSignal", + "agentIsolation", ] as const satisfies readonly (keyof HarnessCapabilities)[] export const CLAUDE_CODE_CAPABILITIES: HarnessCapabilities = { @@ -155,6 +165,7 @@ export const CLAUDE_CODE_CAPABILITIES: HarnessCapabilities = { skillMention: "slash", conversationSkillApply: "hot-reload", startupMenuStallSignal: true, + agentIsolation: "os-sandbox", } export const OHMYPI_CAPABILITIES: HarnessCapabilities = { @@ -185,6 +196,7 @@ export const OHMYPI_CAPABILITIES: HarnessCapabilities = { skillMention: null, conversationSkillApply: null, startupMenuStallSignal: false, + agentIsolation: "none", } /** @@ -232,6 +244,7 @@ export const CODEX_CAPABILITIES: HarnessCapabilities = { skillMention: "dollar", conversationSkillApply: "restart", startupMenuStallSignal: false, + agentIsolation: "write-sandbox", } export const ACP_CAPABILITIES: HarnessCapabilities = { @@ -262,6 +275,7 @@ export const ACP_CAPABILITIES: HarnessCapabilities = { skillMention: null, conversationSkillApply: null, startupMenuStallSignal: false, + agentIsolation: "none", } export const KIMI_CODE_CAPABILITIES: HarnessCapabilities = { @@ -294,6 +308,7 @@ export const KIMI_CODE_CAPABILITIES: HarnessCapabilities = { skillMention: null, conversationSkillApply: null, startupMenuStallSignal: false, + agentIsolation: "none", } export const OPENCODE_CAPABILITIES: HarnessCapabilities = { @@ -324,6 +339,7 @@ export const OPENCODE_CAPABILITIES: HarnessCapabilities = { skillMention: null, conversationSkillApply: null, startupMenuStallSignal: false, + agentIsolation: "none", } export const GROK_CAPABILITIES: HarnessCapabilities = { @@ -370,6 +386,7 @@ export const MUSE_CAPABILITIES: HarnessCapabilities = { skillMention: null, conversationSkillApply: null, startupMenuStallSignal: false, + agentIsolation: "harness-default", } export const PRIME_AGENT_CAPABILITIES: HarnessCapabilities = { @@ -400,4 +417,5 @@ export const PRIME_AGENT_CAPABILITIES: HarnessCapabilities = { skillMention: null, conversationSkillApply: null, startupMenuStallSignal: false, + agentIsolation: "none", } diff --git a/packages/contracts/src/telemetry.ts b/packages/contracts/src/telemetry.ts index 204215673bd..8e207f6ff40 100644 --- a/packages/contracts/src/telemetry.ts +++ b/packages/contracts/src/telemetry.ts @@ -208,11 +208,18 @@ const TELEMETRY_CLIENT_ROUTES = [ "/api/agent-requests", "/api/agents", "/api/agents/:id/answer-question", + "/api/agents/:id/classify-completion", + "/api/agents/:id/conversation", + "/api/agents/:id/heartbeat", "/api/agents/:id/message", "/api/agents/:id/permissions/:requestId/respond", "/api/agents/:id/plan-action", + "/api/agents/:id/plan-checklist", + "/api/agents/:id/runtime", "/api/agents/:id/send-now", + "/api/agents/:id/stuck", "/api/agents/:id/tell", + "/api/agents/:id/work-complete", "/api/backend-restart-recovery", "/api/backend-restart-recovery/dismiss", "/api/backend-restart-recovery/resume-all", @@ -232,6 +239,7 @@ const TELEMETRY_CLIENT_ROUTES = [ "/api/conversations/:name/changes", "/api/conversations/:name/changes/lines", "/api/conversations/:name/compact", + "/api/conversations/:name/control-ack", "/api/conversations/:name/delete-image", "/api/conversations/:name/diffs", "/api/conversations/:name/diffs/:turnId", @@ -291,9 +299,14 @@ const TELEMETRY_CLIENT_ROUTES = [ "/api/flywheel/status", "/api/github/identities", "/api/harness-auto-update", + "/api/hooks/permission-event", + "/api/hooks/turn-complete", + "/api/hooks/user-prompt-submit", + "/api/internal/agents/:id/permissions/request", "/api/issues", "/api/issues/:id", "/api/issues/:id/check-runs", + "/api/issues/:id/complete-planning", "/api/issues/:id/costs", "/api/issues/resource-allocated", "/api/lanes", @@ -315,6 +328,9 @@ const TELEMETRY_CLIENT_ROUTES = [ "/api/machines/work/projects", "/api/machines/work/projects/:jobId", "/api/machines/work/workers", + "/api/memory/inject", + "/api/memory/session/start", + "/api/memory/turn", "/api/needs-you", "/api/orders", "/api/orders/:id", @@ -334,6 +350,7 @@ const TELEMETRY_CLIENT_ROUTES = [ "/api/registered-projects", "/api/resources/actions/execute", "/api/resources/actions/preview", + "/api/self/cli", "/api/self/done", "/api/self/handoff", "/api/self/jobs/:id", @@ -368,6 +385,7 @@ const TELEMETRY_CLIENT_ROUTES = [ "/api/skills/packs", "/api/skills/packs/available", "/api/skills/packs/preview", + "/api/specialists/:name/auto-complete", "/api/telemetry/client-config", "/api/ui/open", "/api/usage-limit-hold", diff --git a/packages/pi-extension/src/__tests__/index.test.ts b/packages/pi-extension/src/__tests__/index.test.ts index 48e19313518..aeeb53b912c 100644 --- a/packages/pi-extension/src/__tests__/index.test.ts +++ b/packages/pi-extension/src/__tests__/index.test.ts @@ -204,6 +204,26 @@ describe('handleSessionStart', () => { expect(fetchCalls[0]!.headers['x-overdeck-internal-token']).toBe('test-token') }) + it('PAN-5754: sends the Bearer agent token and no internal-token header when OVERDECK_AGENT_TOKEN_FILE is set', async () => { + mkdirSync(join(h.home, '.overdeck'), { recursive: true }) + writeFileSync(join(h.home, '.overdeck', 'internal-token'), 'test-token\n') + const tokenFile = join(h.home, 'mcp-token') + writeFileSync(tokenFile, `odk_${'9'.repeat(64)}\n`) + const previous = process.env['OVERDECK_AGENT_TOKEN_FILE'] + process.env['OVERDECK_AGENT_TOKEN_FILE'] = tokenFile + try { + await handleSessionStart( + { agentId: 'agent-pan-636', home: h.home, pid: 4242, now }, + { reason: 'new', sessionId: 'sess-abc' }, + ) + } finally { + if (previous === undefined) delete process.env['OVERDECK_AGENT_TOKEN_FILE'] + else process.env['OVERDECK_AGENT_TOKEN_FILE'] = previous + } + expect(fetchCalls[0]!.headers['authorization']).toBe(`Bearer odk_${'9'.repeat(64)}`) + expect(fetchCalls[0]!.headers['x-overdeck-internal-token']).toBeUndefined() + }) + it('buffers to pending-events.jsonl when dashboard returns 503', async () => { fetchResponse = { status: 503 } await handleSessionStart( diff --git a/packages/pi-extension/src/index.ts b/packages/pi-extension/src/index.ts index b6570517558..1532c1e9639 100644 --- a/packages/pi-extension/src/index.ts +++ b/packages/pi-extension/src/index.ts @@ -232,6 +232,20 @@ async function readInternalToken(env: HookEnv): Promise { } } +/** + * PAN-5754 D-19: an isolated agent (OVERDECK_AGENT_TOKEN_FILE set by its launcher) sends its own + * agent token and never reads internal-token; otherwise the internal-token header as before. + */ +async function dashboardAuthHeaders(env: HookEnv): Promise> { + const tokenFile = process.env['OVERDECK_AGENT_TOKEN_FILE'] + if (tokenFile) { + const token = (await readFile(tokenFile, 'utf8').catch(() => '')).trim() + return token ? { authorization: `Bearer ${token}` } : {} + } + const token = await readInternalToken(env) + return token ? { [INTERNAL_TOKEN_HEADER]: token } : {} +} + async function postEvent(env: HookEnv, body: Record): Promise { await postDashboard(env, HEARTBEAT_PATH(env.agentId), body) } @@ -254,9 +268,7 @@ async function postWithTimeout(env: HookEnv, url: string, body: Record controller.abort(), POST_TIMEOUT_MS) try { - const token = await readInternalToken(env) - const headers: Record = { 'Content-Type': 'application/json' } - if (token) headers[INTERNAL_TOKEN_HEADER] = token + const headers: Record = { 'Content-Type': 'application/json', ...(await dashboardAuthHeaders(env)) } const res = await fetch(url, { method: 'POST', headers, @@ -277,9 +289,7 @@ async function postJsonWithTimeout(env: HookEnv, url: string, body: Record controller.abort(), POST_TIMEOUT_MS) try { - const token = await readInternalToken(env) - const headers: Record = { 'Content-Type': 'application/json' } - if (token) headers[INTERNAL_TOKEN_HEADER] = token + const headers: Record = { 'Content-Type': 'application/json', ...(await dashboardAuthHeaders(env)) } const res = await fetch(url, { method: 'POST', headers, diff --git a/roles/plan.md b/roles/plan.md index e682c14c805..91b6472e5fd 100644 --- a/roles/plan.md +++ b/roles/plan.md @@ -123,15 +123,17 @@ Status is a JSON field, not a directory. `plan.status` advances `draft → propo ## Signal the flywheel before you stall -If you are about to **stop short of your deliverable** — self-abort, refuse to fix-forward an orthogonal failure, decide the work needs a different path, or park on a question for the operator — you MUST first notify the orchestrator, *before* you park: +If you are about to **stop short of your deliverable** — self-abort, refuse to fix-forward an orthogonal failure, decide the work needs a different path, or park on a question for the operator — you MUST first raise it with `pan ask`, *before* you park: ```bash -pan tell conv-flywheel "plan : — " +pan ask "plan: . How should this proceed?" \ + --option "" --option "" \ + --context $'- \n- **