Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
refactor(session): rename the channel module and vocabulary to session
Jack Rudenkoa13d7e4caf8b
diff --git a/CLAUDE.md b/CLAUDE.mdindex 7249abc4..b29735a5 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -26,11 +26,11 @@ lives in `ROADMAP.md`.on Stop hooks), prompt delivery by file with read coverage, boot dialogs never accepted, the panewatcher and identity-checked reap, socket traps, the frozen mod contract v1, the session registryread as telemetry (and why no in-child mod or argv prompt). Read before editing `pane/`, team spawn- or channel spawn+ or MCP session spawn- `custom-endpoints.md`, `predefined-endpoints.md` — user config; the 25-vendor bundled catalog- `onepassword.md` — secret resolution, the four denial causes, the handshake lock, route pinning- `keychain.md` — the macOS Keychain backend: enumerate-for-presence vs read-for-value, the `security` traps, the Providers-tab write/delete-- `mcp-channel.md` — the 14-tool MCP surface and its four groups, sessions on panes (`send_input`+- `mcp-sessions.md` — the 14-tool MCP surface and its four groups, sessions on panes (`send_input`queueing, `capture_session`, the session records the magus monitor reads), `run_prompt`'s ClaudeCode print path, progress keepalive- `team-capture.md` — why `team`'s exit 0 proves nothing, and why a slot's answer is every@@ -233,7 +233,7 @@ for rationale. Three write-ups already died this way.### Workflow<!-- learned: 2026-04-06 session: df311293 source: explicit_rule -->-- Don't run claudish directly in main bash — use dedicated channel sessions or `/delegate`+- Don't run claudish directly in main bash — use dedicated MCP sessions (`create_session`) or `/delegate`<!-- learned: 2026-09-02 source: near_miss -->- NEVER `git stash` from a worktree. The stash stack is shared with the main checkout andevery sibling worktree, and concurrent sessions push and pop it. A bare push/pop pair isdiff --git a/ROADMAP.md b/ROADMAP.mdindex a15039e2..b6107495 100644--- a/ROADMAP.md+++ b/ROADMAP.md@@ -10,7 +10,7 @@ For shipped features see `CLAUDE.md`; for the engineering rationale behind themStatus: **removed** (10.7.0). The server no longer declares `experimental: {"claude/channel": {}}`and sends no `notifications/claude/channel` frame; hosts poll `list_sessions` and read the session-records. Rationale and what replaced each fact: `ai-docs/architecture/mcp-channel.md` ("Push+records. Rationale and what replaced each fact: `ai-docs/architecture/mcp-sessions.md` ("Pushnotifications were removed").The old phases are closed with it: Phase 1 (the SEP-1686 forward-compat fields `task_id`,@@ -26,7 +26,7 @@ default, drop the legacy method) have no legacy method left to migrate from.(`modelcontextprotocol/typescript-sdk#1041`).- A live `create_session` run shows the completion arriving in the orchestrator agent's context.-**Effort if triggered**: small. The facts are already in `SessionManager` (`channelEventFor`, the+**Effort if triggered**: small. The facts are already in `SessionManager` (`sessionEventFor`, the`waits.jsonl` transitions); a push is one subscriber on the pane's `onTransition` and `onChange`hooks plus a payload builder and its wire-format test.@@ -79,7 +79,7 @@ The conclusion drawn at the time — that this would both fire into a void and d### Re-measured 2026-07-29 against Claude Code **2.1.220** — one blocker is gone, one is confirmed harder-Probes: `packages/cli/src/channel/test-helpers/capability-probe.ts` (agent context, `-p`) and+Probes: `packages/cli/src/mcp-session/test-helpers/capability-probe.ts` (agent context, `-p`) and`progress-regression-mock.ts` driven through an interactive tmux session (terminal UI).Full findings: `ai-docs/sessions/dev-arch-20260729-171308-1dad34b5/capability-findings.md`.@@ -124,7 +124,7 @@ that reaches a reader. It is not, however, a substitute on the *liveness* axis,- Re-measurement against 2.1.220: `ai-docs/sessions/dev-arch-20260729-171308-1dad34b5/capability-findings.md` (lost — same)- Idle-timeout measurement against 2.1.231 (the three-arm probe): `ai-docs/reports/mcp-progress-keepalive/findings.md`- Keepalive implementation design: `ai-docs/reports/mcp-progress-keepalive/architecture.md`-- Test artifacts: `packages/cli/src/channel/test-helpers/progress-regression-mock.ts`, `capability-probe.ts`, `capability-probe-2.ts`+- Test artifacts: `packages/cli/src/mcp-session/test-helpers/progress-regression-mock.ts`, `capability-probe.ts`, `capability-probe-2.ts`- Field evidence of the transport-kill bug the latch defends against: <https://github.com/GLips/Figma-Context-MCP/issues/362>- Stale `progressToken` claim: <https://github.com/anthropics/claude-code/issues/58687>@@ -291,7 +291,7 @@ If a trigger condition has been met, move the item to *In Progress* and create t## Consolidate the two channel test-helper stand-ins-`packages/cli/src/channel/test-helpers/` now holds **two** helpers that can echo argv:+`packages/cli/src/mcp-session/test-helpers/` now holds **two** helpers that can echo argv:- `fake-claudish.ts` — the original; consumed by BOTH `channel/session-manager.test.ts` and`team-orchestrator.test.ts`, the latter via `--print-argv` to assert the exact spawndiff --git a/ai-docs/architecture/README.md b/ai-docs/architecture/README.mdindex f9f34b48..b5a6f656 100644--- a/ai-docs/architecture/README.md+++ b/ai-docs/architecture/README.md@@ -32,11 +32,11 @@ three earlier write-ups this material cites were lost.| [`behavior-layer.md`](behavior-layer.md) | Layer 4, the harness-convention SUPERVISOR: the rule engine, the four hooks, the 115-call plan-mode measurement it was built on, and opt-in telemetry | write a `behavior/` rule, or change harness-conformance handling || [`advisor.md`](advisor.md) | `--advisor` for any main model: why it is independent of `--monitor` yet keeps four of its launch bits, the decorator around the ROUTED handler, id capture by tool name (the `toolu_` prefix that made it a no-op on every foreign provider), the tee and retained session-keyed state, the ten stub paths and advice origin, Claude Code's advisor gates, metered panel billing, and the inherited-placeholder 401 | touch `--advisor`, `advisor-decorator.ts`, `native-handler-advisor.ts`, `advisor-startup.ts`, monitor-gated launch code, or native auth in `claude-runner.ts` || [`headless-vs-interactive.md`](headless-vs-interactive.md) | Why `-p` is NOT interactive-without-a-TTY: an UNKNOWN `--agent` is SILENTLY unvalidated under `--input-format stream-json` (measured, exit 0, no stream frame, `result: success`), upstream closed it as not planned, why magmux is in the dependency tree, the one `-p` the MCP server starts (`run_prompt` on a Claude model) and why it is safe, and why a driver cannot rely on magmux's pane states | drive Claude Code headlessly, add a child-spawn flag, or assume a headless run behaves like an interactive one |-| [`pane-session.md`](pane-session.md) | MCP `team` slots, CLI `team` and `create_session` as interactive Claude Code in headless magmux panes: the transcript as turn oracle, boot from screen content and closed dialog lists ("never accept"), the four settle paths with the measured `secondaryQuietMs` (32 s), prompt delivery by file with read coverage and exact `require_pattern` semantics, the environment snapshot and shell shim, the pane watcher and the identity-checked reap, the socket traps, `seq` ownership, the D9/D10 bounds, the phase table, and the frozen mod contract v1 | edit `pane/`, team or channel spawn, the settle rule, prompt delivery, the reap or sweep, or any field the mod contract carries |+| [`pane-session.md`](pane-session.md) | MCP `team` slots, CLI `team` and `create_session` as interactive Claude Code in headless magmux panes: the transcript as turn oracle, boot from screen content and closed dialog lists ("never accept"), the four settle paths with the measured `secondaryQuietMs` (32 s), prompt delivery by file with read coverage and exact `require_pattern` semantics, the environment snapshot and shell shim, the pane watcher and the identity-checked reap, the socket traps, `seq` ownership, the D9/D10 bounds, the phase table, and the frozen mod contract v1 | edit `pane/`, team or MCP session spawn, the settle rule, prompt delivery, the reap or sweep, or any field the mod contract carries || [`picker.md`](picker.md) | The OpenTUI model picker: why it is an inline dialog and not a dashboard (the density gate that manufactured the rejected build), the provider list as the default screen with nothing prefetched (3915 → 1436 ms), the discovery outcome that stopped `[]` meaning five things, the local served-by index (22 network queries measured at 10 018 ms), the no-terminal gate's complement law, and the capture and compile traps | change `picker/`, `selectModel`, discovery outcomes or fetchers, `should-open-picker.ts`, or a TUI test that asserts on a frame || [`context-window.md`](context-window.md) | Why setting one env lever accomplishes nothing, why the status line reports the ENFORCED window, and local-model token accounting | change context-window resolution, the status line, or token accounting || [`theming.md`](theming.md) | One detected theme for every surface, and the module-load palette-snapshot bug class it keeps producing (found six times) | add a colored CLI line or TUI surface |-| [`mcp-channel.md`](mcp-channel.md) | The 14-tool MCP surface (groups low-level / agentic / session / debug, `CLAUDISH_MCP_TOOLS`), sessions on panes: the flag check, the owner's verdict, `send_input` queueing, the session records (`spawn.json`, `waits.jsonl`, `meta.json`, `events.jsonl`, `screen.txt`) and what the monitor reads, `get_diagnostics`; `run_prompt`'s two paths (the Claude Code print call on the user's login, the proxy with no `max_tokens`); why the channel push was removed; and the `notifications/progress` keepalive | add or rename an MCP tool or group, change `run_prompt`, or change sessions or their records |+| [`mcp-sessions.md`](mcp-sessions.md) | The 14-tool MCP surface (groups low-level / agentic / session / debug, `CLAUDISH_MCP_TOOLS`), sessions on panes: the flag check, the owner's verdict, `send_input` queueing, the session records (`spawn.json`, `waits.jsonl`, `meta.json`, `events.jsonl`, `screen.txt`) and what the monitor reads, `get_diagnostics`; `run_prompt`'s two paths (the Claude Code print call on the user's login, the proxy with no `max_tokens`); why the channel push was removed; and the `notifications/progress` keepalive | add or rename an MCP tool or group, change `run_prompt`, or change sessions or their records || [`team-capture.md`](team-capture.md) | Why exit 0 proves nothing under `claude -p` (the measurement behind `require_pattern`), and why a slot's answer is every assistant message of its turn, read from the transcript, starting after the task file was read | change how `team` classifies output or builds `response-<slot>.md` || [`team-lifecycle.md`](team-lifecycle.md) | Why nothing kills a slot on a timer, the measurement that removed the deadline, why `run` returns once every prompt is accepted (≤ 120 s), the run registry by `run_id`, the `blocked` rule, the team record ended exactly once, and one driver with two owners | add a deadline, change when `team` returns, or touch per-slot liveness, cancel or the run record || [`debugging.md`](debugging.md) | Debug logging, `CLAUDISH_UPSTREAM_ERROR_LOG`, raw SSE capture, and the failed-translation workflow | diagnose a model producing wrong, empty, or garbled output |diff --git a/ai-docs/architecture/context-window.md b/ai-docs/architecture/context-window.mdindex b9aaf16e..e5de3f56 100644--- a/ai-docs/architecture/context-window.md+++ b/ai-docs/architecture/context-window.md@@ -10,7 +10,7 @@ Claude Code resolves its compaction point as `min(CLAUDE_CODE_AUTO_COMPACT_WINDO**The status line reports the ENFORCED window, not the spec window.** `TokenTracker.writeFile` derives `context_left_percent` from `inputTokens` alone — folding in the session-CUMULATIVE `outputTokens` made the value decay with session AGE and pin at 0 forever once lifetime output passed the window (measured: input 94,018 of a 372,000 window reporting 0% left). Both generated status-line variants then recompute against `min(spec window, CLAUDE_CODE_MAX_CONTEXT_TOKENS ?? 200000, CLAUDE_CODE_AUTO_COMPACT_WINDOW)` and render `18% (164k/200k of 372k)` when those disagree, so a clamp is visible on day one instead of costing days of half-context work.-The status line is a generated **shell one-liner** (and a generated JS file on Windows), so TypeScript cannot catch a typo in it — test the generated artifact by executing it (`status-line-context.test.ts`). The token file's path is ONE rule, `resolveTokenFilePath` in `session/token-file.ts`, used by the tracker that writes it, the status line and the end-of-session summary: an ASSIGNED `CLAUDISH_TOKEN_FILE` (a team slot's or channel session's own path; tests use it too), else `<home>/.claudish/tokens-<port>.json` with `<home>` read `$HOME`-first — Bun's `os.homedir()` ignores a runtime `HOME`, so a tracker that called it wrote a file the summary never read under a redirected HOME. claude-runner publishes the session's file to Claude Code as both `CLAUDISH_TOKEN_FILE` and `CLAUDISH_PUBLISHED_TOKEN_FILE`; when a claudish started from that session's Bash tool sees the two equal, the file is its parent's status-line file, not an assignment, and it keeps its own (sharing one made each status line show the other's model and cost). Bash integer division truncates where JS `Math.round` rounds, so the bash variant uses `((x*200/w)+1)/2` to keep both platforms on the same number.+The status line is a generated **shell one-liner** (and a generated JS file on Windows), so TypeScript cannot catch a typo in it — test the generated artifact by executing it (`status-line-context.test.ts`). The token file's path is ONE rule, `resolveTokenFilePath` in `session/token-file.ts`, used by the tracker that writes it, the status line and the end-of-session summary: an ASSIGNED `CLAUDISH_TOKEN_FILE` (a team slot's or MCP session's own path; tests use it too), else `<home>/.claudish/tokens-<port>.json` with `<home>` read `$HOME`-first — Bun's `os.homedir()` ignores a runtime `HOME`, so a tracker that called it wrote a file the summary never read under a redirected HOME. claude-runner publishes the session's file to Claude Code as both `CLAUDISH_TOKEN_FILE` and `CLAUDISH_PUBLISHED_TOKEN_FILE`; when a claudish started from that session's Bash tool sees the two equal, the file is its parent's status-line file, not an assignment, and it keeps its own (sharing one made each status line show the other's model and cost). Bash integer division truncates where JS `Math.round` rounds, so the bash variant uses `((x*200/w)+1)/2` to keep both platforms on the same number.## Context Tracking for Local Modelsdiff --git a/ai-docs/architecture/headless-vs-interactive.md b/ai-docs/architecture/headless-vs-interactive.mdindex fe4e2725..0476320a 100644--- a/ai-docs/architecture/headless-vs-interactive.md+++ b/ai-docs/architecture/headless-vs-interactive.md@@ -222,7 +222,7 @@ which `--permission-mode default` produces no dialog (measured), and `--no-auto-reserved flag. A permission dialog therefore appears only for plan approval(`--permission-mode plan`). `PaneSession` recognises it, and AskUserQuestion, from a closed list ofnamed dialog headers on the screen plus the pending tool in the transcript; team fails such a slot-`blocked`, a channel session waits in `AWAITING_PERMISSION` or `AWAITING_INPUT` for `send_input`.+`blocked`, an MCP session waits in `AWAITING_PERMISSION` or `AWAITING_INPUT` for `send_input`.## What this means when you are writing code here@@ -246,7 +246,7 @@ named dialog headers on the screen plus the pending tool in the transcript; team`run_prompt` (and each Claude entry of `compare_models`) on a bare Claude name runs`claudish -p --model <model> --output-format json --tools "" --strict-mcp-config--setting-sources "" --disable-slash-commands --no-session-persistence` with the prompt on stdin-(`mcp/run-prompt-claude-code.ts`; the full rationale is in [`mcp-channel.md`](mcp-channel.md)+(`mcp/run-prompt-claude-code.ts`; the full rationale is in [`mcp-sessions.md`](mcp-sessions.md)"`run_prompt`: two paths"). It has to be a Claude Code call because claudish may not read theClaude Code login itself, and it can be `-p` because none of what makes `-p` untrustworthy applies:diff --git a/ai-docs/architecture/mcp-channel.md b/ai-docs/architecture/mcp-sessions.mdsimilarity index 97%rename from ai-docs/architecture/mcp-channel.mdrename to ai-docs/architecture/mcp-sessions.mdindex cb89a196..6cc694d4 100644--- a/ai-docs/architecture/mcp-channel.md+++ b/ai-docs/architecture/mcp-sessions.md@@ -5,9 +5,9 @@# MCP sessions and tool surfaceThe MCP server runs async model sessions (`create_session` and the other session tools) that the-host polls, plus `run_prompt` and `team`. The file keeps its old name, `mcp-channel.md`, because-`CLAUDE.md` and the index link to it; the channel push it was named for is gone (see "Push-notifications were removed").+host polls, plus `run_prompt` and `team`. It was `mcp-channel.md`, named for the channel push,+which is gone (see "Push notifications were removed"); the module it describes moved from+`packages/cli/src/channel/` to `packages/cli/src/mcp-session/` in the same rename.## Architecture@@ -16,7 +16,7 @@ Uses the low-level `Server` class (not `McpServer`) from `@modelcontextprotocol/and `serverInfo.version` is `VERSION` from `version.ts` (generated from `packages/cli/package.json`;it said `9.0.0` until 10.7.0).-## Components (`packages/cli/src/channel/`)+## Components (`packages/cli/src/mcp-session/`)- **SessionManager** — the sessions' policy and records: creates sessions, owns the queue of`send_input`, decides a turn's verdict, writes the session records, enforces `timeout_seconds`@@ -111,7 +111,7 @@ in the background (worst case ≈ 12 s). A second call returns the same state wi**`timeout` is its own state, never `failed`.** A session killed by its own `timeout_seconds` isTIMEOUT in memory, `meta.json` `status: "timeout"`, and `to: "timeout"` in `waits.jsonl`. Until-Phase 3 of the channel work the channel wire said `failed` for it, because the SEP-1686 projection+Phase 3 of the channel work the channel push said `failed` for it, because the SEP-1686 projectionhad no `timeout` key and fell through to `working`; that projection (`mapEventToTaskStatus`) wasdeleted with the push in 10.7.0, and the records never had the split.@@ -141,7 +141,7 @@ not answered (RB2).````since` keys the wait (the `closed` line repeats it); `turns` is `turnsCompleted` at the-open; `to` is the channel event of the new state (`channelEventFor`: `running`, `tool_executing`,+open; `to` is the session event of the new state (`sessionEventFor`: `running`, `tool_executing`,`completed`, `failed`, `cancelled`, `timeout`, …), never another wait (the phase table has nowait-to-wait edge). The vocabulary outlived the push it was named for: the field is a recordcontract the monitor reads, so it keeps those words. It is append-only because an observer polling the directory (the magus@@ -187,7 +187,7 @@ sessions directory and reports progress to the Claude Code window that started a`mcpPid` is also the pane record's owner, and the watchers make the monitor's liveness inferencesound: when the writer dies, its panes die with it.-**`hostPid` is structural, computed once at startup** (`hostPidFrom`, `channel/parent-session.ts`).+**`hostPid` is structural, computed once at startup** (`hostPidFrom`, `mcp-session/parent-session.ts`).A compiled binary or `bun src/index.ts` is the direct child of Claude Code, so `hostPid` is`process.ppid`. An npm/bun global install runs Claude Code → `node bin/claudish.cjs` → `bundist/index.js`, so the launcher puts `CLAUDISH_LAUNCHER_PID` (itself) and@@ -198,7 +198,7 @@ environment strips the pair and `CLAUDE_CODE_SESSION_ID`, so a claudish MCP servpane cannot inherit the host's identity either.**`parentClaudeSessionId` is the host session record's id, read once per call**-(`parentSessionForCall`, `channel/parent-session.ts`). At `create_session` and+(`parentSessionForCall`, `mcp-session/parent-session.ts`). At `create_session` and`team(mode:"run")` time claudish reads `<configDir>/sessions/<hostPid>.json` (`configDir` is`CLAUDE_CONFIG_DIR`, else `$HOME/.claude`) and records its `sessionId` when the file parses,its `pid` equals `hostPid` and the id is well formed. Only when no record can be read does it@@ -332,7 +332,7 @@ answers the session's current 160×50 screen `{seq, cols, rows, cursor, lines, fat about 1 Hz. Their errors are a JSON `ContractError`. `team` gains the same verbs as modes(`list`, `status`, `capture`, `cancel`).-The tool list is pinned by an EXACT frozen array in `channel/e2e-channel.test.ts`, so+The tool list is pinned by an EXACT frozen array in `mcp-session/e2e-channel.test.ts`, soadding or removing a tool without updating that test fails CI. That is deliberate:it is a wire contract, and an accidental change to the tool surface should be loud.@@ -354,7 +354,8 @@ no trace.`session` was `channel` until 10.7.0. The rename removed the old name with no alias, per thethesaurus rule, so `channel` now falls into the unknown-value rule and selects everything. The-stderr startup line shows `tools: channel, 14 tools`, but an MCP host does not show stderr.+stderr startup line shows `tools: channel, 14 tools` after the unknown-value warning, but an MCP+host does not show stderr.`compare_models` moved to `debug` at the same time: it sends one prompt to several models insequence and shows raw answers, which is a route check, not work. Real multi-model work is `team`.@@ -470,7 +471,7 @@ the same facts from the records. The frames were never a keepalive either (nextWhere the facts are now: `list_sessions` rows (`state`, `activity`, `idle_seconds`, accounting),`get_output`, `get_diagnostics`, `capture_session`, and the session records (`spawn.json`,`waits.jsonl`, `meta.json`, `events.jsonl`, `screen.txt`), which the magus monitor reads and which-are byte-identical to before. `waits.jsonl` keeps the channel-event vocabulary in its `to` field.+are byte-identical to before. `waits.jsonl` keeps the same event names in its `to` field.`team` progress is `team(mode:"status")`. The `notifications/progress` keepalive stays.The trigger to reconsider is in `ROADMAP.md`: Claude Code delivering `notifications/tasks/status`@@ -482,7 +483,7 @@ Diagnostic script: `scripts/pane-drive.ts` drives one pane session from the comm## Testing```bash-bun test ./packages/cli/src/channel/+bun test ./packages/cli/src/mcp-session/```Sessions are panes, so the suites that start one run a REAL headless magmux with the pane@@ -491,7 +492,7 @@ fake child (`pane/test-helpers/fake-interactive-child.ts`) as `CLAUDISH_BIN`, unsocket, record or launcher directory is left. Without magmux they skip with "magmux not installed —not checked". `testing.md` has the rules.-- `session-manager.test.ts` — the pure seams (`channelEventFor` over every `SlotState`,+- `session-manager.test.ts` — the pure seams (`sessionEventFor` over every `SlotState`,`toMetaRecord`, `sessionRowOf`, `normaliseTimeoutSeconds`), the two-generation disk reader, thehostile-id and bounded-read guards, live pane sessions (one-shot and promptless `waits.jsonl`transitions, a send queued while STARTING (G7) or RUNNING, the timeout staying TIMEOUT in memory,diff --git a/ai-docs/architecture/onepassword.md b/ai-docs/architecture/onepassword.mdindex b0122451..f2f008ce 100644--- a/ai-docs/architecture/onepassword.md+++ b/ai-docs/architecture/onepassword.md@@ -20,7 +20,7 @@ All 1Password logic lives in `packages/cli/src/providers/onepassword.ts` (dependThe ambiguity is resolved from OUTSIDE the error, by probing screen-lock state: `defaultScreenLockProbe` runs `ioreg -n Root -d1 -a` and matches `CGSSessionScreenIsLocked` (present only while locked; ~15ms; darwin-only — other platforms return false and keep terminal behavior). `isLockedDenial(err, env)` = denial **&&** no `OP_SERVICE_ACCOUNT_TOKEN` (token auth never shows a desktop prompt, so waiting would be theatre) **&&** screen locked. `withSdkRetry` now **wraps** the transient-IPC loop (`withSdkTransientRetry`) in an OUTER lock-round loop, keeping the two time domains separate: the inner loop owns millisecond-scale IPC blips (150ms·attempt), the outer owns the human-scale "go unlock your Mac" wait. Every non-locked-denial error propagates from the inner loop unchanged.-On a locked denial the user gets a friendly explanation (printed ONCE, on round 1 — re-explaining every 10s reads as nagging) plus a 10-second countdown, up to `LOCK_RETRY_ROUNDS` (3) → 3 retries ≈ 30s. The countdown **breaks early** the moment the probe reports unlocked, so approving is immediately followed by the prompt. Cancellation degrades by CAPABILITY, not by mode (interactive and non-interactive must behave identically — an explicit product decision): TTY stdin → Esc/q/Ctrl-C; otherwise Ctrl-C via SIGINT. The live `\r\x1b[2K` redraw and ANSI styling apply ONLY when `process.stderr.isTTY` (checked at call time, not module load) — under an MCP host or channel session stderr is a captured pipe, which gets one static line per round instead. Test seams: `setScreenLockProbe()` and `setLockRetryTiming({seconds, tickMs})` — the latter is MANDATORY in tests or the suite gains 30 real seconds.+On a locked denial the user gets a friendly explanation (printed ONCE, on round 1 — re-explaining every 10s reads as nagging) plus a 10-second countdown, up to `LOCK_RETRY_ROUNDS` (3) → 3 retries ≈ 30s. The countdown **breaks early** the moment the probe reports unlocked, so approving is immediately followed by the prompt. Cancellation degrades by CAPABILITY, not by mode (interactive and non-interactive must behave identically — an explicit product decision): TTY stdin → Esc/q/Ctrl-C; otherwise Ctrl-C via SIGINT. The live `\r\x1b[2K` redraw and ANSI styling apply ONLY when `process.stderr.isTTY` (checked at call time, not module load) — under an MCP host or MCP session stderr is a captured pipe, which gets one static line per round instead. Test seams: `setScreenLockProbe()` and `setLockRetryTiming({seconds, tickMs})` — the latter is MANDATORY in tests or the suite gains 30 real seconds.**A THIRD recoverable cause: `peer`.** `LockCause` is now `"screen" | "app" | "peer"`. A peer denial is another LIVE claudish holding `~/.claudish/op-handshake.lock` — a sibling standing at the 1Password prompt right now. It is EVIDENCE, not inference: the lock is written `O_EXCL` by exactly one process, carries its pid, and is removed the instant its handshake returns, so a live foreign holder means precisely "wait and you will get your turn". It cannot be confused with a real Cancel, because a Cancel happens INSIDE the holder's own handshake and the denied peer holds nothing — so the `aa71ce3` guard is untouched. Precedence is screen → app → peer: waiting behind a sibling is pointless while the Mac is locked, since the sibling cannot finish either.@@ -32,7 +32,7 @@ On a locked denial the user gets a friendly explanation (printed ONCE, on round## Concurrent-spawn denial prevention (v7.22.0+)-A THIRD situation produces the same `Denied authorization for SDK client`, and unlike the two above it is neither a decision nor a lock state: **several claudish processes racing the DesktopAuth handshake at once**. 1Password arbitrates that handshake across the whole MACHINE, not per process — it authorizes ONE client and instantly denies every concurrent peer. `runSdkExclusive` serializes SDK calls WITHIN a process (the `-4` IPC fix), but `team-orchestrator.ts` and channel `create_session` spawn N sibling PROCESSES, each building its own client, and no in-process queue can span those.+A THIRD situation produces the same `Denied authorization for SDK client`, and unlike the two above it is neither a decision nor a lock state: **several claudish processes racing the DesktopAuth handshake at once**. 1Password arbitrates that handshake across the whole MACHINE, not per process — it authorizes ONE client and instantly denies every concurrent peer. `runSdkExclusive` serializes SDK calls WITHIN a process (the `-4` IPC fix), but `team-orchestrator.ts` and `create_session` spawn N sibling PROCESSES, each building its own client, and no in-process queue can span those.Measured on a real 7-model `team` run (session `team-20260729-163623`): all seven children spawned within 6ms, five hit the denial, and only the models whose key was already in the shell env survived — `errors/01.log` shows a model that COMPLETED while still logging two denials. Reduced repro with lock state held constant (unlocked in both arms): 6 children in a tight loop → **5 denied**; the same 6 staggered 4s apart → **0 denied**; a single child → fine. So this is not the locked-screen case and the lock probe does not fire for it (`isLockedDenial` requires a locked screen, and a denial while unlocked stays TERMINAL).diff --git a/ai-docs/architecture/pane-session.md b/ai-docs/architecture/pane-session.mdindex c18e46ed..4d5ed761 100644--- a/ai-docs/architecture/pane-session.md+++ b/ai-docs/architecture/pane-session.md@@ -6,7 +6,7 @@ Every MCP `team` slot (`run`, `run-and-judge` and the judge children), every CLIover that pane's socket. There is no `-p`, no `--stdin`, no stream-json and no positional promptanywhere in that path. The driver is `packages/cli/src/pane/`; its public surface is`pane/index.ts` and its live object is `PaneSession`. Team (`team-orchestrator.ts`) and the-channel (`channel/session-manager.ts`) are its two owners.+MCP sessions (`mcp-session/session-manager.ts`) are its two owners.One exception: CLI `--grid` (`team-grid.ts`) still launches `claudish --model X -y --quiet'<prompt>'` print-mode children in a VISIBLE magmux with `-w`. It is a viewer for a human, not@@ -265,7 +265,7 @@ dialog also needs the screen: `hasChoiceDialog` is a CLOSED list (R3-H1) — a nbelow the last `⏺` block, and no input box. An unrecognised layout is "not a dialog", an honestunknown, never `blocked`: numbered prose with a `No, …(esc)` line over a running Bash is a capturednegative fixture. The owner decides what a block means: team fails the slot `blocked` with the-question as its detail (D19, team has no answering verb); the channel waits in AWAITING_INPUT or+question as its detail (D19, team has no answering verb); an MCP session waits in AWAITING_INPUT orAWAITING_PERMISSION. A caller reaches a permission dialog only through `--permission-mode plan`:`-y` beats `--permission-mode default`, and `--no-auto-approve` is reserved.@@ -488,7 +488,7 @@ reserves N panes before a run's spawn loop; each start consumes one, whether it300 ms apart, so N REPLs do not write `~/.claude.json` in the same instant.- **No claudish timer ends a team slot after its prompt was accepted.** Boot and admission boundonly the time before any work exists. Stop hooks and background agents are waited for without a- bound. A channel session's `timeout_seconds` is the caller's own deadline and the only+ bound. An MCP session's `timeout_seconds` is the caller's own deadline and the onlypost-acceptance timer. See [`team-lifecycle.md`](team-lifecycle.md).## The phase tablediff --git a/ai-docs/architecture/routing.md b/ai-docs/architecture/routing.mdindex 3057c60d..7700a3f6 100644--- a/ai-docs/architecture/routing.md+++ b/ai-docs/architecture/routing.md@@ -228,7 +228,7 @@ config TUI's Routing header and its own interaction with `--config`, which nothi**How the flag travels.** `index.ts` strips `--default-provider` from argv and exports its valueas `CLAUDISH_DEFAULT_PROVIDER` before `parseArgs` and before any subcommand runs(`planDefaultProviderFlag`). After that the env var is the flag's only carrier: `route()`, the-proxy, `--probe` and every child claudish (team, channel sessions) read it there. It cannot be read+proxy, `--probe` and every child claudish (team, MCP sessions) read it there. It cannot be readany later, for two reasons: `--probe` runs and exits inside `parseArgs`'s argv loop, and a childprocess inherits env, not argv. `--default-provider ""` exports an empty value, which disablesthe hop. The export runs after `--op-env` and `--op`, which overwrite env unconditionally, so thediff --git a/ai-docs/architecture/team-lifecycle.md b/ai-docs/architecture/team-lifecycle.mdindex 4df7d689..aac2a8d0 100644--- a/ai-docs/architecture/team-lifecycle.md+++ b/ai-docs/architecture/team-lifecycle.md@@ -275,8 +275,8 @@ the mapping — `status.txt` prints model names beside slot ids.## One driver, two owners-`team` and the channel once had two implementations of one job: team drove a-stream-json capture and hand-rolled everything around it, while the channel+`team` and the MCP sessions once had two implementations of one job: team drove a+stream-json capture and hand-rolled everything around it, while the session managerwrapped the same capture in a reducer with a state machine. Both went with printmode. Both owners now drive the same `PaneSession` (`pane/`), which owns theMECHANISM — boot, delivery, the transcript turn oracle, settle, the reap — and asks@@ -284,11 +284,11 @@ its owner for POLICY at exactly two points:- `decide(turn)` when a turn settles. Team's answer writes `response-<slot>.md`(byte-exact, once) and returns `classifyRunOutput` with the caller's- `require_pattern` and `min_output_bytes` (`team-capture.md`); the channel's+ `require_pattern` and `min_output_bytes` (`team-capture.md`); the session manager'sclassifies a one-shot turn with no floor and no pattern, or continues aninteractive one.- `onBlocked(block)` when a turn stops on a question or a dialog. Team fails the- slot `blocked`; the channel waits for `send_input`.+ slot `blocked`; an MCP session waits for `send_input`.So nothing team-specific leaks into the pane module, and nothing pane-specific intothe policy. Two details that used to need explicit rules now follow from the@@ -300,7 +300,7 @@ pane is reaped.## Spawn plumbing: what was shared, and what was deliberately notThe obvious next step looked like making `team` a client of-`SessionManager.createSession`, so each slot would be a channel session+`SessionManager.createSession`, so each slot would be an MCP sessionaddressable by `get_output`, `get_diagnostics` and `cancel_session`. That wasevaluated and rejected. Reading what `createSession` actually does shows why:@@ -311,7 +311,7 @@ evaluated and rejected. Reading what `createSession` actually does shows why:session manager would also need team's whole-answer handling.- `session-manager.ts` already imports `classifyRunOutput` FROM`team-orchestrator.ts`. Adding team's options would complete the inversion: a- channel session manager that knows what a blind-vote panel is.+ session manager that knows what a blind-vote panel is.The addressability was also worth less than it looked. `team` already answers thesame questions through `mode:"status"`, `mode:"capture"` and `mode:"cancel"`, sodiff --git a/ai-docs/architecture/testing.md b/ai-docs/architecture/testing.mdindex 310e0774..b05cd2c5 100644--- a/ai-docs/architecture/testing.md+++ b/ai-docs/architecture/testing.md@@ -95,8 +95,8 @@ like a confident answer. Prefer "unknown" to a plausible guess in any automated## A fixture must live where the test lives, never in scratch space-`channel/test-helpers/captured-stream-json.ts` reads real captured stream-json frames at-MODULE LOAD, via an IIFE. Its `PROBE_DIR` originally pointed at+`channel/test-helpers/captured-stream-json.ts` (the directory is now `mcp-session/`) read real+captured stream-json frames at MODULE LOAD, via an IIFE. Its `PROBE_DIR` originally pointed at`ai-docs/sessions/dev-arch-*/probes/` — where the probe that recorded them happened to write.`.gitignore:56` excludes `ai-docs/sessions/`. So the files existed on exactly one machine and@@ -181,7 +181,7 @@ widen them to clear a red run: the budget is the entire assertion.MCP `team` slots and `create_session` run as interactive Claude Code in headless magmux panes(`pane-session.md`), so every suite that starts one — `pane/*.integration.test.ts`,-`pane/pane-registry.test.ts`, the channel and team suites, `mcp-contract.e2e.test.ts`,+`pane/pane-registry.test.ts`, the MCP session and team suites, `mcp-contract.e2e.test.ts`,`mcp-shutdown.e2e.test.ts` — runs a REAL `magmux --headless`. The transport's behaviour (frames,`exit` events, `close_pane`, slow-subscriber drops, socket paths) is magmux's, and a simulatedmagmux would test our model of it instead.diff --git a/docs/settings-reference.md b/docs/settings-reference.mdindex f6f54338..48252648 100644--- a/docs/settings-reference.md+++ b/docs/settings-reference.md@@ -391,7 +391,7 @@ CLAUDISH_CONFIG=/abs/qa-config.json claudish --model [email protected] "task"|---|---|| Precedence | The `--config` flag wins over `CLAUDISH_CONFIG`; a dangling `--config` (or one followed by another flag) is a usage error, not a silent fallback || Flag visibility | Consumed and stripped before `parseArgs()`, so the child `claude` process never sees it |-| Child processes | Re-exported as an absolute `CLAUDISH_CONFIG`, so `claudish` children spawned by team and channel modes inherit the same override |+| Child processes | Re-exported as an absolute `CLAUDISH_CONFIG`, so `claudish` children spawned by team and MCP sessions inherit the same override || Writes | `claudish config` saves target the override file — the machine config is never mutated with override-derived data || Env vars | Still resolve first: a shell env var or `.env` entry beats the override file's `apiKeys` || Scope | Config only. OAuth credential files (`kimi-oauth.json`, `gemini-oauth.json`, …) stay machine-level |diff --git a/docs/usage/magmux.md b/docs/usage/magmux.mdindex abc9b917..2d2ed401 100644--- a/docs/usage/magmux.md+++ b/docs/usage/magmux.md@@ -50,7 +50,7 @@ Measurements and the upstream status are in `ai-docs/architecture/headless-vs-in----## Headless panes: MCP `team` and channel sessions+## Headless panes: MCP `team` and MCP sessionsThis is what claudish uses magmux for most. Every slot of an MCP `team` run, every CLI`claudish team` / `--team --mode json` slot, and every `create_session` session runs as an@@ -74,8 +74,8 @@ has finished, and closes the pane when the slot or session ends.| `team(mode:"list")` | every run the MCP server holds, with one row per slot: state, activity, idle seconds, tokens || `team(mode:"status", path)` | one run's rows under `run.slots` || `team(mode:"capture", path, slot)` | that slot's current 160×50 screen |-| `capture_session(session_id)` | a channel session's current 160×50 screen |-| `list_sessions` | every channel session, same row shape |+| `capture_session(session_id)` | an MCP session's current 160×50 screen |+| `list_sessions` | every MCP session, same row shape |A capture carries a `seq` that grows with every visible change; pass it back as `since_seq` and anunchanged screen answers `{unchanged: true}`, so polling about once a second is cheap. Seediff --git a/packages/cli/src/auth/credentials/api-key-credential.ts b/packages/cli/src/auth/credentials/api-key-credential.tsindex 261dc84c..4f2acd2f 100644--- a/packages/cli/src/auth/credentials/api-key-credential.ts+++ b/packages/cli/src/auth/credentials/api-key-credential.ts@@ -15,7 +15,7 @@* types one into the config, means it.** When step 4 or 5 resolves a key, the value is written THROUGH into process.env- * so spawned child processes (MCP team/channel) inherit it and never touch the+ * so spawned child processes (MCP team/session) inherit it and never touch the* SDK or the keychain. The authority is the ONLY code that pushes keys from* either vault into process.env.*diff --git a/packages/cli/src/auth/credentials/prehydrate.ts b/packages/cli/src/auth/credentials/prehydrate.tsindex 1b2b7f99..2805ae9f 100644--- a/packages/cli/src/auth/credentials/prehydrate.ts+++ b/packages/cli/src/auth/credentials/prehydrate.ts@@ -11,7 +11,7 @@* "Denied authorization for SDK client"** claudish already serializes SDK calls WITHIN a process (`runSdkExclusive` in- * op-source.ts — the -4 IPC fix), but `team` and channel `create_session` spawn+ * op-source.ts — the -4 IPC fix), but `team` and `create_session` spawn* N sibling PROCESSES, and no in-process queue can span those. Each child* constructs its own SDK client and they all race.*@@ -57,7 +57,7 @@* (`rescueRoutableResolutions` only runs on a "missing" verdict). The child,* handed that same bare name, re-walks the WHOLE chain and asks 1Password about* every candidate the parent short-circuited past — so it builds its own SDK- * client after all. Measured: 17 channel children logged+ * client after all. Measured: 17 MCP session children logged* "Denied authorization for SDK client" on runs where pre-hydration had already* succeeded (see baseline-evidence.md in this feature's session dir).*diff --git a/packages/cli/src/claude-runner.ts b/packages/cli/src/claude-runner.tsindex 47c34ad9..058694db 100644--- a/packages/cli/src/claude-runner.ts+++ b/packages/cli/src/claude-runner.ts@@ -815,7 +815,7 @@ export function createTempSettingsFile(const tempPath = join(claudishDir, `settings-${timestamp}.json`);// The file the proxy's TokenTracker writes: one a parent ASSIGNED (a team slot's or- // channel session's own CLAUDISH_TOKEN_FILE), else `tokens-<port>.json` in .claudish.+ // MCP session's own CLAUDISH_TOKEN_FILE), else `tokens-<port>.json` in .claudish.// An enclosing claudish session's PUBLISHED file (inherited by a claudish run from its// Bash tool) is not an assignment — see assignedTokenFile. Resolved by the same// function as the tracker and the summary, so the status line can never be pointed at@@ -2269,10 +2269,10 @@ function setupSignalHandlers(// `128 + signum`, the shell convention for "died from signal N" — NOT 0.//// This one line manufactured the 900-second silent success. A supervisor- // (the channel session manager's timeout, `team`'s deadline, a CI runner)+ // (the MCP session manager's timeout, `team`'s deadline, a CI runner)// would SIGTERM the process group, this handler would run its cleanup and// exit 0, and every layer above read that 0 as "the run succeeded". The- // channel manager then let the exit UPGRADE a state its timeout handler+ // session manager then let the exit UPGRADE a state its timeout handler// had already recorded as failed, and wrote `status: "completed"` to// meta.json for a session that had been killed. A graceful shutdown is// still a shutdown: the process did not finish its work, and its exitdiff --git a/packages/cli/src/config-override.ts b/packages/cli/src/config-override.tsindex af168e98..2ffa6fa5 100644--- a/packages/cli/src/config-override.ts+++ b/packages/cli/src/config-override.ts@@ -110,7 +110,7 @@ export interface ConfigOverrideDeps {/*** Decide the override for a run. Precedence: an explicit `--config` flag wins;- * otherwise `CLAUDISH_CONFIG` (which is how spawned team/channel child claudish+ * otherwise `CLAUDISH_CONFIG` (which is how spawned team/MCP session child claudish* processes inherit the parent's override).** Both `--config <file>` and `--config=<file>` are accepted. A flag with nodiff --git a/packages/cli/src/handlers/shared/upstream-error-capture.ts b/packages/cli/src/handlers/shared/upstream-error-capture.tsindex 2a44e5ac..e2cd325b 100644--- a/packages/cli/src/handlers/shared/upstream-error-capture.ts+++ b/packages/cli/src/handlers/shared/upstream-error-capture.ts@@ -68,11 +68,11 @@ export function captureUpstreamError(record: UpstreamErrorRecord): boolean {// Redacted BEFORE truncation, and before the bytes hit disk.//// A 401/403 body routinely echoes the credential that failed, and this file- // is no longer only a path a user opted into: channel sessions now point+ // is no longer only a path a user opted into: MCP sessions now point// every child at `<sessionDir>/upstream-errors.jsonl` and `get_diagnostics`// hands its contents to an agent. Redacting at write time is the only point// that covers every reader — the same rule and the same reason as team's- // error log (team-orchestrator.ts:1070) and the channel's `events.jsonl`.+ // error log (team-orchestrator.ts:1070) and an MCP session's `events.jsonl`.//// Before truncation specifically, so the cut cannot fall inside a key and// leave a usable prefix of it in the file.diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.tsindex 64355d42..3ee1d254 100644--- a/packages/cli/src/index.ts+++ b/packages/cli/src/index.ts@@ -92,7 +92,7 @@ process.on("exit", () => {* Why: the old eager hydration ran the SDK (DesktopAuth prompt) at the top of* EVERY process launch whenever a config environment existed — so `--update`,* `--version`, `--help`, and OAuth-only (codex) sessions all prompted, and every- * spawned team/channel child re-prompted (the "storm"). Point-of-need touches+ * spawned team/MCP session child re-prompted (the "storm"). Point-of-need touches* 1Password only when a key is actually needed; no-key runs never prompt. This* also changes precedence: environments are now a lazy op source (env/config* already set wins), not a startup overwrite.@@ -267,7 +267,7 @@ async function applyConfigOverride(): Promise<void> {setConfigFileOverride(plan.path);// Propagate to the whole process tree via the (absolute) env fallback: team- // mode and channel sessions spawn CHILD `claudish` processes, which re-read+ // mode and MCP sessions spawn CHILD `claudish` processes, which re-read// CLAUDISH_CONFIG here and apply the same override. The child `claude` ignores// it. Absolute so a child with a different cwd still resolves the same file.process.env.CLAUDISH_CONFIG = plan.path;@@ -276,7 +276,7 @@ async function applyConfigOverride(): Promise<void> {// `--default-provider <name>`: strip it from argv and export it as// CLAUDISH_DEFAULT_PROVIDER before parseArgs and every subcommand dispatch. The env// variable is the ONE place the flag lives after this: route(), the proxy, `--probe`-// and every child claudish (team, channel sessions) read it through+// and every child claudish (team, MCP sessions) read it through// `resolveDefaultProvider`. `--probe` is why this cannot wait for parseArgs: it// runs and exits inside parseArgs's argv loop, so a flag read there or after it// never reached it, in either argv order.diff --git a/packages/cli/src/logger.ts b/packages/cli/src/logger.tsindex 511f1007..5895188e 100644--- a/packages/cli/src/logger.ts+++ b/packages/cli/src/logger.ts@@ -202,7 +202,7 @@ function redactLogLine(message: string, timestamp: string): string {* two claudish processes that start in the same second therefore compute the* same path and each wipes what the other wrote.*- * That is not a rare race: `team` and channel `create_session` spawn their+ * That is not a rare race: `team` and `create_session` spawn their* children together, so a three-model run reliably lands three processes inside* one second. Measured 2026-09-16 on exactly such a run, the surviving file held* three interleaved `[Proxy] Server started` lines on three different ports anddiff --git a/packages/cli/src/mcp-e2e/runner.ts b/packages/cli/src/mcp-e2e/runner.tsindex 7299b7bd..106d3ca1 100644--- a/packages/cli/src/mcp-e2e/runner.ts+++ b/packages/cli/src/mcp-e2e/runner.ts@@ -29,7 +29,7 @@ import {writeFileSync,} from "node:fs";import { join, resolve } from "node:path";-import { userHomeFrom } from "../channel/home-dir.js";+import { userHomeFrom } from "../mcp-session/home-dir.js";import { redactSecrets } from "../redact.js";import { REAL_CONFIG_PATH, buildArmConfig, buildArmEnv, checkPreconditions } from "./env.js";import { driveServer } from "./jsonrpc-client.js";@@ -41,7 +41,7 @@ const SERVER_ENTRY = resolve(REPO_ROOT, "packages/cli/src/index.ts");const LOG_ROOT = resolve(REPO_ROOT, "logs/mcp-e2e");// Where the server under test writes: env.ts passes HOME through and strips// CLAUDISH_SESSIONS_DIR, so the server resolves `$HOME/.claudish/sessions` by-// the shared rule in channel/home-dir.ts. `os.homedir()` would ignore HOME.+// the shared rule in mcp-session/home-dir.ts. `os.homedir()` would ignore HOME.const SESSIONS_DIR = join(userHomeFrom(process.env), ".claudish", "sessions");// ── args ─────────────────────────────────────────────────────────────────────diff --git a/packages/cli/src/mcp-server.ts b/packages/cli/src/mcp-server.tsindex 7770ceca..d8af5af7 100644--- a/packages/cli/src/mcp-server.ts+++ b/packages/cli/src/mcp-server.ts@@ -21,9 +21,9 @@ import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotimport { config } from "dotenv";import { searchCatalogModels } from "./adapters/model-catalog.js";import { prehydrateCredentialsForSpawn } from "./auth/credentials/prehydrate.js";-import { SessionManager } from "./channel/index.js";-import { parentSessionForCall } from "./channel/parent-session.js";import { isSubscriptionProvider } from "./handlers/shared/remote-provider-types.js";+import { SessionManager } from "./mcp-session/index.js";+import { parentSessionForCall } from "./mcp-session/parent-session.js";import {type HeartbeatHandle,NOOP_HEARTBEAT,@@ -2004,7 +2004,7 @@ function defineTools(sessionManager: SessionManager): ToolDefinition[] {});// The conversation live in the calling window, from the host's session- // record: one read at call time, no wait. See channel/parent-session.ts.+ // record: one read at call time, no wait. See mcp-session/parent-session.ts.const parentClaudeSessionId = await parentSessionForCall({hostPid: sessionManager.hostPid,});diff --git a/packages/cli/src/channel/channel-wire-format.test.ts b/packages/cli/src/mcp-session/channel-wire-format.test.tssimilarity index 100%rename from packages/cli/src/channel/channel-wire-format.test.tsrename to packages/cli/src/mcp-session/channel-wire-format.test.tsdiff --git a/packages/cli/src/channel/e2e-channel.test.ts b/packages/cli/src/mcp-session/e2e-channel.test.tssimilarity index 100%rename from packages/cli/src/channel/e2e-channel.test.tsrename to packages/cli/src/mcp-session/e2e-channel.test.tsdiff --git a/packages/cli/src/channel/home-dir.test.ts b/packages/cli/src/mcp-session/home-dir.test.tssimilarity index 100%rename from packages/cli/src/channel/home-dir.test.tsrename to packages/cli/src/mcp-session/home-dir.test.tsdiff --git a/packages/cli/src/channel/home-dir.ts b/packages/cli/src/mcp-session/home-dir.tssimilarity index 100%rename from packages/cli/src/channel/home-dir.tsrename to packages/cli/src/mcp-session/home-dir.tsdiff --git a/packages/cli/src/channel/host-pid.contract.test.ts b/packages/cli/src/mcp-session/host-pid.contract.test.tssimilarity index 100%rename from packages/cli/src/channel/host-pid.contract.test.tsrename to packages/cli/src/mcp-session/host-pid.contract.test.tsdiff --git a/packages/cli/src/channel/index.ts b/packages/cli/src/mcp-session/index.tssimilarity index 81%rename from packages/cli/src/channel/index.tsrename to packages/cli/src/mcp-session/index.tsindex 2ec76692..e465049f 100644--- a/packages/cli/src/channel/index.ts+++ b/packages/cli/src/mcp-session/index.ts@@ -1,7 +1,7 @@export { ScrollbackBuffer } from "./scrollback-buffer.js";export {SessionManager,- channelEventFor,+ sessionEventFor,normaliseTimeoutSeconds,sessionRowOf,toMetaRecord,@@ -12,10 +12,10 @@ export type {SessionDiagnostics,SessionOutput,} from "./session-manager.js";-export { CHANNEL_EVENT_TYPES } from "./types.js";+export { SESSION_EVENT_TYPES } from "./types.js";export type {SessionInfo,SessionCreateOptions,SessionManagerOptions,- ChannelEventType,+ SessionEventType,} from "./types.js";diff --git a/packages/cli/src/channel/parent-session.contract.test.ts b/packages/cli/src/mcp-session/parent-session.contract.test.tssimilarity index 100%rename from packages/cli/src/channel/parent-session.contract.test.tsrename to packages/cli/src/mcp-session/parent-session.contract.test.tsdiff --git a/packages/cli/src/channel/parent-session.ts b/packages/cli/src/mcp-session/parent-session.tssimilarity index 100%rename from packages/cli/src/channel/parent-session.tsrename to packages/cli/src/mcp-session/parent-session.tsdiff --git a/packages/cli/src/channel/scrollback-buffer.test.ts b/packages/cli/src/mcp-session/scrollback-buffer.test.tssimilarity index 100%rename from packages/cli/src/channel/scrollback-buffer.test.tsrename to packages/cli/src/mcp-session/scrollback-buffer.test.tsdiff --git a/packages/cli/src/channel/scrollback-buffer.ts b/packages/cli/src/mcp-session/scrollback-buffer.tssimilarity index 100%rename from packages/cli/src/channel/scrollback-buffer.tsrename to packages/cli/src/mcp-session/scrollback-buffer.tsdiff --git a/packages/cli/src/channel/session-create-options.test.ts b/packages/cli/src/mcp-session/session-create-options.test.tssimilarity index 100%rename from packages/cli/src/channel/session-create-options.test.tsrename to packages/cli/src/mcp-session/session-create-options.test.tsdiff --git a/packages/cli/src/channel/session-manager.test.ts b/packages/cli/src/mcp-session/session-manager.test.tssimilarity index 100%rename from packages/cli/src/channel/session-manager.test.tsrename to packages/cli/src/mcp-session/session-manager.test.tsdiff --git a/packages/cli/src/channel/session-manager.ts b/packages/cli/src/mcp-session/session-manager.tssimilarity index 99%rename from packages/cli/src/channel/session-manager.tsrename to packages/cli/src/mcp-session/session-manager.tsindex 3d5f98a0..c35351b6 100644--- a/packages/cli/src/channel/session-manager.ts+++ b/packages/cli/src/mcp-session/session-manager.ts@@ -1,6 +1,6 @@// ─── SessionManager ──────────────────────────────────────────────────────────//-// Lifecycle owner for channel sessions. Each session is one INTERACTIVE Claude Code,+// Lifecycle owner for MCP sessions. Each session is one INTERACTIVE Claude Code,// launched through claudish (`claudish -i --model X -y --quiet --session-id <uuid>// --add-dir <turnDir> [caller flags]`) inside its own headless magmux pane and driven// over the pane's socket (packages/cli/src/pane/, architecture §2). There is no `-p`,@@ -78,8 +78,8 @@ import { sessionsDirFrom } from "./home-dir.js";import { hostPidFrom } from "./parent-session.js";import { ScrollbackBuffer } from "./scrollback-buffer.js";import type {- ChannelEventType,SessionCreateOptions,+ SessionEventType,SessionInfo,SessionManagerOptions,} from "./types.js";@@ -105,8 +105,8 @@ export interface DiagnosticEvent {export interface SessionDiagnostics {sessionId: string;state: SlotState;- /** The current channel event (10.4.0's `status` key, RB7). */- event: ChannelEventType;+ /** The current session event (10.4.0's `status` key, RB7). */+ event: SessionEventType;reason: FailureReason | null;detail: string | null;/** The model as the caller asked for it. */@@ -310,11 +310,11 @@ const STATE_OF_10_4_STATUS: Record<string, SlotState> = {};/**- * The channel event for a session state (architecture §3.4). Pure; the wire, the+ * The event for a session state (architecture §3.4). Pure; the wire, the* wait log's `to` and `get_diagnostics.event` all read it.*/-export function channelEventFor(snap: { state: SlotState; activity: string | null }): {- event: ChannelEventType;+export function sessionEventFor(snap: { state: SlotState; activity: string | null }): {+ event: SessionEventType;tool: string | null;} {switch (snap.state) {@@ -1116,7 +1116,7 @@ export class SessionManager {wait: "closed",since: entry.waitSince,at: entry.info.completedAt ?? new Date().toISOString(),- to: channelEventFor(entry.info).event,+ to: sessionEventFor(entry.info).event,});entry.waitSince = null;}@@ -1176,7 +1176,7 @@ export class SessionManager {at,});}- const { tool } = channelEventFor(snap);+ const { tool } = sessionEventFor(snap);if (tool && tool !== entry.lastLoggedTool)this.appendEvent(entry, { type: "tool", name: tool, at });entry.lastLoggedTool = tool;@@ -1240,7 +1240,7 @@ export class SessionManager {return {sessionId,state: info.state,- event: channelEventFor(info).event,+ event: sessionEventFor(info).event,reason: isTerminalState(info.state) && info.state !== "COMPLETED" ? info.reason : null,detail: info.detail,// The resolved chain, both halves: what the caller asked for, and the pinned@@ -1523,7 +1523,7 @@ export class SessionManager {return {sessionId: info.sessionId,state: info.state,- event: channelEventFor(info).event,+ event: sessionEventFor(info).event,reason: info.reason,detail: info.detail,model: info.model,@@ -1680,7 +1680,7 @@ export class SessionManager {wait: "closed",since: entry.waitSince ?? at,at,- to: channelEventFor(snap).event,+ to: sessionEventFor(snap).event,});entry.waitSince = null;}@@ -1695,7 +1695,7 @@ export class SessionManager {entry: SessionEntry,line:| { wait: "open"; since: string; turns: number }- | { wait: "closed"; since: string; at: string; to: ChannelEventType }+ | { wait: "closed"; since: string; at: string; to: SessionEventType }): void {if (entry.waitLogBytes >= WAIT_LOG_LIMIT) return;const payload = `${JSON.stringify(line)}\n`;diff --git a/packages/cli/src/channel/session-records.contract.test.ts b/packages/cli/src/mcp-session/session-records.contract.test.tssimilarity index 100%rename from packages/cli/src/channel/session-records.contract.test.tsrename to packages/cli/src/mcp-session/session-records.contract.test.tsdiff --git a/packages/cli/src/channel/session-state-records.contract.test.ts b/packages/cli/src/mcp-session/session-state-records.contract.test.tssimilarity index 100%rename from packages/cli/src/channel/session-state-records.contract.test.tsrename to packages/cli/src/mcp-session/session-state-records.contract.test.tsdiff --git a/packages/cli/src/channel/session-timeout.test.ts b/packages/cli/src/mcp-session/session-timeout.test.tssimilarity index 100%rename from packages/cli/src/channel/session-timeout.test.tsrename to packages/cli/src/mcp-session/session-timeout.test.tsdiff --git a/packages/cli/src/channel/spawn-record.contract.test.ts b/packages/cli/src/mcp-session/spawn-record.contract.test.tssimilarity index 100%rename from packages/cli/src/channel/spawn-record.contract.test.tsrename to packages/cli/src/mcp-session/spawn-record.contract.test.tsdiff --git a/packages/cli/src/channel/team-run-record.contract.test.ts b/packages/cli/src/mcp-session/team-run-record.contract.test.tssimilarity index 100%rename from packages/cli/src/channel/team-run-record.contract.test.tsrename to packages/cli/src/mcp-session/team-run-record.contract.test.tsdiff --git a/packages/cli/src/channel/test-helpers/capability-probe-2.ts b/packages/cli/src/mcp-session/test-helpers/capability-probe-2.tssimilarity index 100%rename from packages/cli/src/channel/test-helpers/capability-probe-2.tsrename to packages/cli/src/mcp-session/test-helpers/capability-probe-2.tsdiff --git a/packages/cli/src/channel/test-helpers/capability-probe.ts b/packages/cli/src/mcp-session/test-helpers/capability-probe.tssimilarity index 100%rename from packages/cli/src/channel/test-helpers/capability-probe.tsrename to packages/cli/src/mcp-session/test-helpers/capability-probe.tsdiff --git a/packages/cli/src/channel/test-helpers/progress-regression-mock.ts b/packages/cli/src/mcp-session/test-helpers/progress-regression-mock.tssimilarity index 100%rename from packages/cli/src/channel/test-helpers/progress-regression-mock.tsrename to packages/cli/src/mcp-session/test-helpers/progress-regression-mock.tsdiff --git a/packages/cli/src/channel/test-helpers/stats-buffer-signal-child.ts b/packages/cli/src/mcp-session/test-helpers/stats-buffer-signal-child.tssimilarity index 100%rename from packages/cli/src/channel/test-helpers/stats-buffer-signal-child.tsrename to packages/cli/src/mcp-session/test-helpers/stats-buffer-signal-child.tsdiff --git a/packages/cli/src/channel/types.ts b/packages/cli/src/mcp-session/types.tssimilarity index 90%rename from packages/cli/src/channel/types.tsrename to packages/cli/src/mcp-session/types.tsindex 71dc4079..29c21dec 100644--- a/packages/cli/src/channel/types.ts+++ b/packages/cli/src/mcp-session/types.ts@@ -1,20 +1,20 @@-// ─── Channel Mode Types ──────────────────────────────────────────────────────+// ─── MCP Session Types ───────────────────────────────────────────────────────import type { FailureReason, PaneSessionOptions, SlotState } from "../pane/index.js";/**- * Every value the channel wire's `event` field may carry, as a runtime list so a+ * Every value a session row's `event` field may carry, as a runtime list so a* test can walk it (`event-task-status.test.ts` checks each one against- * `EVENT_TO_TASK_STATUS`). `ChannelEventType` is derived from it.+ * `EVENT_TO_TASK_STATUS`). `SessionEventType` is derived from it.*- * It is its own union, derived from the session's `SlotState` by `channelEventFor`+ * It is its own union, derived from the session's `SlotState` by `sessionEventFor`* (session-manager.ts): the stream-json `SessionStatus` it once mirrored is gone with* that transport. 10.4.0's `finishing` is not here (architecture §20.3 item 5, RB1): a* pane session decides a one-shot verdict at settle, so the "exiting" interval it named* does not exist; the wait for Claude Code's end-of-turn record is `activity:"finishing"`* on a RUNNING row.*/-export const CHANNEL_EVENT_TYPES = [+export const SESSION_EVENT_TYPES = ["starting","running","tool_executing",@@ -28,17 +28,17 @@ export const CHANNEL_EVENT_TYPES = [] as const;/**- * The values the channel wire's `event` field may carry.+ * The values a session row's `event` field may carry.** `EVENT_TO_TASK_STATUS` (mcp-server.ts) maps each onto SEP-1686's 5-value* `TaskStatus`; it is a `Record` over this type, so an event without a projection is a* compile error. `timeout` has its own key (→ `failed`): before it existed the timeout* path fell through to `?? "working"` and reported a dead session as still working.*/-export type ChannelEventType = (typeof CHANNEL_EVENT_TYPES)[number];+export type SessionEventType = (typeof SESSION_EVENT_TYPES)[number];/**- * One channel session, in memory (architecture §3.3). Persisted as `meta.json` through+ * One MCP session, in memory (architecture §3.3). Persisted as `meta.json` through* `toMetaRecord`, which keeps every 10.4.0 key under its 10.4.0 name (the magus monitor* reads them) and adds the pane keys.*/@@ -101,7 +101,7 @@ export interface SessionInfo {/*** The Claude Code conversation live in the calling window when* create_session ran: the host session record's `sessionId`, else- * `CLAUDE_CODE_SESSION_ID` (channel/parent-session.ts). Absent when neither+ * `CLAUDE_CODE_SESSION_ID` (mcp-session/parent-session.ts). Absent when neither* is a well-formed id.*/parentClaudeSessionId?: string;@@ -114,7 +114,7 @@ export interface SessionInfo {export interface SessionCreateOptions {/*** The model as the caller asked for it. This is the session's DISPLAY- * identity — `SessionInfo.model`, channel `meta.model`, `list_sessions` — and+ * identity — `SessionInfo.model`, the session's `meta.model`, `list_sessions` — and* the agent correlates on it, so it is never rewritten.*/model: string;@@ -179,7 +179,7 @@ export interface SessionManagerOptions {terminalRetentionMs?: number;/*** Test override for the host pid recorded in `spawn.json`. Default:- * `hostPidFrom(process.env, process.ppid)` (channel/parent-session.ts). An+ * `hostPidFrom(process.env, process.ppid)` (mcp-session/parent-session.ts). An* override records no `launcherPid`.*/hostPid?: number;diff --git a/packages/cli/src/mcp/run-prompt-claude-code.ts b/packages/cli/src/mcp/run-prompt-claude-code.tsindex 82c1dd5c..0d2c7518 100644--- a/packages/cli/src/mcp/run-prompt-claude-code.ts+++ b/packages/cli/src/mcp/run-prompt-claude-code.ts@@ -15,7 +15,7 @@* The prompt goes on stdin, the child runs in an empty temporary directory (otherwise* CLAUDE.md and memory load: 8 718 input tokens instead of ~590), and the child's* environment drops the three `ANTHROPIC_*` variables that would take the request off- * the login. Rationale and measurements: ai-docs/architecture/mcp-channel.md+ * the login. Rationale and measurements: ai-docs/architecture/mcp-sessions.md* ("run_prompt") and headless-vs-interactive.md (why `-p` is safe for this one call).*/diff --git a/packages/cli/src/pane/contract.ts b/packages/cli/src/pane/contract.tsindex 0e074419..5cb59ab7 100644--- a/packages/cli/src/pane/contract.ts+++ b/packages/cli/src/pane/contract.ts@@ -6,7 +6,7 @@* Pasted verbatim from the session architecture §8 (including CA-12 `contract_version`* / `capabilities` and CA-13 `run_id`). Fields never change meaning or type within* version 1; new fields may only be ADDED. `FailureReason` lives here because both- * owners (team and the channel) produce it.+ * owners (team and the MCP sessions) produce it.*/export const CONTRACT_VERSION = 1;diff --git a/packages/cli/src/pane/index.ts b/packages/cli/src/pane/index.tsindex a67c2a38..14c1091a 100644--- a/packages/cli/src/pane/index.ts+++ b/packages/cli/src/pane/index.ts@@ -1,5 +1,5 @@/**- * The pane module's public surface (architecture §2, D1). Team and the channel import+ * The pane module's public surface (architecture §2, D1). Team and the MCP sessions import* from here only; internal files are imported directly only by their own tests.* `child-env.ts` runs in the pane child and is imported by the CLI entry, not here.*/diff --git a/packages/cli/src/pane/pane-session.ts b/packages/cli/src/pane/pane-session.tsindex 2076e3be..3738f628 100644--- a/packages/cli/src/pane/pane-session.ts+++ b/packages/cli/src/pane/pane-session.ts@@ -14,13 +14,13 @@** No claudish timer ends a turn after its prompt was accepted (D10). The only bounds are* boot (90 s) and admission of the CREATED prompt (30 s), before any work exists, and a- * channel session's own `timeoutMs`.+ * MCP session's own `timeoutMs`.*/import type { ChildProcess } from "node:child_process";import { readFileSync, realpathSync, rmSync, statSync, writeFileSync } from "node:fs";import { join } from "node:path";-import { claudeConfigDir } from "../channel/parent-session.js";+import { claudeConfigDir } from "../mcp-session/parent-session.js";import { waitForExit } from "../process-tree.js";import { redactSecrets } from "../redact.js";import type { CaptureResult, CaptureUnchanged, FailureReason, SlotState } from "./contract.js";@@ -173,7 +173,7 @@ export interface PaneSessionOptions {bootTimeoutMs?: number;/** initialDelivery only */admitTimeoutMs?: number;- /** whole-session deadline → TIMEOUT (channel only; team never passes it) */+ /** whole-session deadline → TIMEOUT (MCP sessions only; team never passes it) */timeoutMs?: number;/** coalesced ≤ 4/s */onChange?: (snap: PaneSnapshot, prev: SlotState) => void;diff --git a/packages/cli/src/pane/reason-detail.ts b/packages/cli/src/pane/reason-detail.tsindex 451882a7..79579e29 100644--- a/packages/cli/src/pane/reason-detail.ts+++ b/packages/cli/src/pane/reason-detail.ts@@ -5,7 +5,7 @@* instead of having to open `status.json` or `get_diagnostics`.** `reasonDetail` is pure; both row builders (team's `toSlotRow` / `teamRunRowFromDisk`- * and the channel's `sessionRowOf`) call it. `upstreamRecordsFor` is the one bounded+ * and the MCP session manager's `sessionRowOf`) call it. `upstreamRecordsFor` is the one bounded* read of the upstream-error capture file, done only when the rule can use it.** Only the provider's `error.message` is ever lifted out of an upstream body: the bodydiff --git a/packages/cli/src/providers/model-parser.ts b/packages/cli/src/providers/model-parser.tsindex 8e4c0686..fa520d31 100644--- a/packages/cli/src/providers/model-parser.ts+++ b/packages/cli/src/providers/model-parser.ts@@ -122,7 +122,7 @@ export const LEGACY_PREFIX_PATTERNS = _getLegacyPrefixPatterns();** [email protected][email protected]+or@minimax/minimax-m2.5*- * Why a chain form exists at all: `team` and channel `create_session` spawn child+ * Why a chain form exists at all: `team` and `create_session` spawn child* claudish processes with an EXPLICIT spec rather than the bare name, because a* bare name makes the child re-resolve credentials and open its own 1Password SDK* client — and that handshake is arbitrated machine-wide, so N children racing itdiff --git a/packages/cli/src/providers/onepassword.ts b/packages/cli/src/providers/onepassword.tsindex 08a6ea6b..587ef647 100644--- a/packages/cli/src/providers/onepassword.ts+++ b/packages/cli/src/providers/onepassword.ts@@ -1286,7 +1286,7 @@ export function setLockRetryTiming(opts?: { seconds?: number; tickMs?: number })}// Styling is applied ONLY when stderr is a real terminal. Under an MCP host or-// a channel session stderr is a captured pipe, where raw escape codes turn a+// a MCP session stderr is a captured pipe, where raw escape codes turn a// helpful message into noise in the log.const styled = (code: string, s: string): string =>process.stderr.isTTY === true ? `\x1b[${code}m${s}\x1b[0m` : s;@@ -1519,7 +1519,7 @@ export function isLockedDenial(err: unknown, env: NodeJS.ProcessEnv = process.en* The countdown itself always renders, so a piped run shows the same story.** The live `\r` redraw is used ONLY when stderr is a TTY. Under an MCP host or- * a channel session stderr is a captured pipe, where carriage returns produce+ * a MCP session stderr is a captured pipe, where carriage returns produce* an unreadable log — those get one static line per round instead.*/async function countdownForUnlock(diff --git a/packages/cli/src/proxy-server.ts b/packages/cli/src/proxy-server.tsindex 800765d3..e222658e 100644--- a/packages/cli/src/proxy-server.ts+++ b/packages/cli/src/proxy-server.ts@@ -129,7 +129,7 @@ export interface ProxyServerOptions {servedSlotIds?: string[];/*** An ordered, already-credential-filtered candidate list pinned by a PARENT- * claudish process (`team` / channel `create_session`), parsed from a `--model`+ * claudish process (`team` / `create_session`), parsed from a `--model`* chain value. Element 0 is also the `model` argument, so a chain is opt-in and* additive: absent it, routing behaves exactly as before.*@@ -782,7 +782,7 @@ export async function createProxyServer(// 2a-chain. A PINNED CHAIN from a parent process.//- // `team` / channel `create_session` resolve the route in the parent and spawn+ // `team` / `create_session` resolve the route in the parent and spawn// the child with explicit specs, because a bare name would make the child// re-resolve credentials and open its own 1Password client — one dialog per// child instead of one per run (auth/credentials/prehydrate.ts). The cost useddiff --git a/packages/cli/src/session-events/index.ts b/packages/cli/src/session-events/index.tsindex 3838f8f1..8e447aea 100644--- a/packages/cli/src/session-events/index.ts+++ b/packages/cli/src/session-events/index.ts@@ -14,8 +14,8 @@import { existsSync, readFileSync, readdirSync } from "node:fs";import { homedir } from "node:os";import { join } from "node:path";-import { projectDirNameFor } from "../channel/home-dir.js";import { log } from "../logger.js";+import { projectDirNameFor } from "../mcp-session/home-dir.js";import { translateLine } from "./event-translator.js";import { initialState, reduceEvent } from "./session-state.js";import { TranscriptTailer } from "./transcript-tailer.js";diff --git a/packages/cli/src/session/session-discovery.ts b/packages/cli/src/session/session-discovery.tsindex 3f271b48..d2c95e4e 100644--- a/packages/cli/src/session/session-discovery.ts+++ b/packages/cli/src/session/session-discovery.ts@@ -22,15 +22,15 @@import { execFile, execFileSync } from "node:child_process";import { closeSync, openSync, readSync, readdirSync, realpathSync, statSync } from "node:fs";import { basename, join } from "node:path";-import { projectDirNameFor } from "../channel/home-dir.js";-import { claudeConfigDir } from "../channel/parent-session.js";+import { projectDirNameFor } from "../mcp-session/home-dir.js";+import { claudeConfigDir } from "../mcp-session/parent-session.js";/** Head bytes scanned for the `entrypoint` marker. See `isAgentSession`. */const ENTRYPOINT_BYTES = 8192;/*** Where Claude Code keeps transcripts: `<config dir>/projects`, the config dir being- * `CLAUDE_CONFIG_DIR`, else `$HOME/.claude` (`claudeConfigDir`, `channel/parent-session.ts`).+ * `CLAUDE_CONFIG_DIR`, else `$HOME/.claude` (`claudeConfigDir`, `mcp-session/parent-session.ts`).** Resolved at CALL time from the environment it is given. It used to be a module* constant built from `os.homedir()`, which is wrong twice: it ignored a@@ -51,7 +51,7 @@ export function projectsDir(env: Record<string, string | undefined> = process.en* created `…-fresh-cwd-v1`: the `_` is replaced too. This used to replace only `/` and* `.`, so a cwd with `_`, a space or `@` produced a transcript path that did not exist.*- * ONE rule: this is `projectDirNameFor` (`channel/home-dir.ts`), which also cuts a slug+ * ONE rule: this is `projectDirNameFor` (`mcp-session/home-dir.ts`), which also cuts a slug* over 200 characters and appends Claude Code's hash. `session-events`' `slugFromCwd`* calls the same function, so no two transcript paths claudish derives can drift apart.* Callers pass a realpath (`transcriptPathFor` resolves one; git hands out real paths).@@ -144,7 +144,7 @@ export interface SessionRow {/*** Whether this session was machine-driven rather than started by a person.*- * claudish itself is a prolific source of these: every `team` member, every MCP channel+ * claudish itself is a prolific source of these: every `team` member, every MCP* `create_session`, every `-p` one-shot and every e2e test spawns a real Claude Code* session that lands in the same project directory as your own work. MEASURED across* this repository: 1,923 of 2,018 transcripts are `sdk-cli` — so 95% of an unfiltered@@ -951,7 +951,7 @@ export function findLatestSessionId(cwd: string = process.cwd(), sinceMs = 0): s//// Newest-by-mtime is only "necessarily" the session that just ran when one session// owns the directory. A second terminal in the same cwd, a `team` run or an MCP- // channel child all write here too and any of them can be the most recently touched+ // session child all write here too and any of them can be the most recently touched// at the moment claudish exits — which would print a resume command naming someone// else's conversation, as a line the user is invited to paste. Filtering by the// proxy's start time cannot make the guess right, but it does make it fail closed:diff --git a/packages/cli/src/session/token-file.ts b/packages/cli/src/session/token-file.tsindex 1fceea21..a5046ab0 100644--- a/packages/cli/src/session/token-file.ts+++ b/packages/cli/src/session/token-file.ts@@ -4,7 +4,7 @@* the writer and all its readers — kept in its own module so the proxy's tracker can* import it without the summary's pricing dependencies.*- * An inherited `CLAUDISH_TOKEN_FILE` wins: a parent (team, the MCP channel, a pane)+ * An inherited `CLAUDISH_TOKEN_FILE` wins: a parent (team, an MCP session, a pane)* names the file the child's proxy writes, and the tracker honours it. Otherwise it is* `<home>/.claudish/tokens-<port>.json`, `<home>` by the `$HOME`-first rule.*@@ -16,7 +16,7 @@*/import { join } from "node:path";-import { userHomeFrom } from "../channel/home-dir.js";+import { userHomeFrom } from "../mcp-session/home-dir.js";/*** The token file a PARENT assigned to this process: `CLAUDISH_TOKEN_FILE`, unless it is@@ -24,7 +24,7 @@ import { userHomeFrom } from "../channel/home-dir.js";* (`CLAUDISH_PUBLISHED_TOKEN_FILE` carries the same value). A claudish launched from a* claudish session's Bash tool inherits that published path; honouring it made the* nested session's tracker overwrite the parent's file, and both status lines (and the- * parent's summary) showed each other's model, cost and context. Team slots and channel+ * parent's summary) showed each other's model, cost and context. Team slots and MCP* sessions set `CLAUDISH_TOKEN_FILE` to a path of their own, which never equals it.*/export function assignedTokenFile(env: Record<string, string | undefined>): string | null {diff --git a/packages/cli/src/spawn-claudish.ts b/packages/cli/src/spawn-claudish.tsindex 636d8e93..4864b2b3 100644--- a/packages/cli/src/spawn-claudish.ts+++ b/packages/cli/src/spawn-claudish.ts@@ -1,7 +1,7 @@/*** Which `claudish` binary a spawned CHILD is.*- * `team` and channel `create_session` spawn children as `spawn("claudish", …)` —+ * `team` and `create_session` spawn children as `spawn("claudish", …)` —* by NAME, resolved through PATH. In production that is exactly right: the child* should be the installed claudish. In a TEST it is a bug, and a particularly* dishonest one, because the suite goes green or red against whatever version@@ -11,7 +11,7 @@* path DELETED from this tree came back to life during a run: installed 7.34.0* still contained an `op account get` probe removed here, and it fired on every* child spawn while the harness asserted on dev spans from the parent. And the- * channel e2e's `create_session` test failed for an afternoon against a fix that+ * MCP session e2e's `create_session` test failed for an afternoon against a fix that* was already correct in the tree — the child was the installed binary, which* still had the bug.*diff --git a/packages/cli/src/stats-buffer.ts b/packages/cli/src/stats-buffer.tsindex 199f64cc..0e6765a8 100644--- a/packages/cli/src/stats-buffer.ts+++ b/packages/cli/src/stats-buffer.ts@@ -230,10 +230,10 @@ process.on("exit", syncFlushOnExit);* `process.exit` unconditionally — so they, not that one, are what a SIGTERM* actually reaches first. While they exited 0, a claudish process that a* supervisor had KILLED reported a clean success to everything above it:- * measured 2026-08-22, a group SIGTERM against a running channel session still+ * measured 2026-08-22, a group SIGTERM against a running MCP session still* produced `code=0, signal=null` with `claude-runner.ts` already fixed.*- * That mattered most in the channel session manager, where an exit-0 was+ * That mattered most in the MCP session manager, where an exit-0 was* allowed to upgrade a state the timeout handler had already recorded as* failed, and `meta.json` was written saying `"completed"` for a session that* had been killed 15 minutes into real, billed work.diff --git a/packages/cli/src/team-orchestrator.ts b/packages/cli/src/team-orchestrator.tsindex a6d74151..6827cfc3 100644--- a/packages/cli/src/team-orchestrator.ts+++ b/packages/cli/src/team-orchestrator.ts@@ -338,7 +338,7 @@ const startsInFlight = new Map<StartFlight, Promise<unknown>>();const teamRuns = new Map<string, LiveTeamRun>();/** resolved path → run_id of the newest run started there */const newestRunByPath = new Map<string, string>();-export const SETTLED_RUN_RETENTION_MS = 30 * 60_000; // same as channel TERMINAL_RETENTION_MS+export const SETTLED_RUN_RETENTION_MS = 30 * 60_000; // same as the MCP session manager's TERMINAL_RETENTION_MSexport const MAX_SETTLED_RUNS = 20;/** Slots of one run spawn this far apart, so N REPLs do not write ~/.claude.json at once (X-L8). */export const BOOT_STAGGER_MS = 300;diff --git a/packages/cli/src/team-stats.ts b/packages/cli/src/team-stats.tsindex 095c72f2..0c6de3dd 100644--- a/packages/cli/src/team-stats.ts+++ b/packages/cli/src/team-stats.ts@@ -57,7 +57,7 @@ export function tokenFileFor(sessionPath: string, anonId: string): string {* Path-addressed rather than port-addressed on purpose: `session-stats.ts`* resolves the file from `CLAUDISH_TOKEN_FILE` in the CURRENT process's* environment, which is the wrong file for any parent reading a CHILD's- * accounting — team and the channel session manager both hand each child a path+ * accounting — team and the MCP session manager both hand each child a path* of their own choosing.*/export function readTokenStatsAt(path: string): ModelTokenStats | null {