Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
fix(pane): accept pane socket paths of 100 bytes or more
Jack Rudenko7836e09a7066
diff --git a/ai-docs/architecture/mcp-sessions.md b/ai-docs/architecture/mcp-sessions.mdindex 3d3e05a5..c8979f22 100644--- a/ai-docs/architecture/mcp-sessions.md+++ b/ai-docs/architecture/mcp-sessions.md@@ -52,7 +52,7 @@ A refusal is an `invalid_args` error before any credential work. `create_sessionargument becomes `--agent <name>`; an unknown name is refused by the child itself (FAILED`agent_rejected`), so claudish runs no agent probe of its own.-**A session is created in this order**: the flag check, `assertMagmuxAvailable` (magmux ≥ 0.17.0,+**A session is created in this order**: the flag check, `assertMagmuxAvailable` (magmux ≥ 0.18.0,else `Error: magmux_unavailable: …`), credential pre-hydration, the parent session read, a panereservation (`Error: pane_limit: …` past 48 live panes per user), `prompt.md`, `spawn.json`, then thepane. `create_session` returns `{session_id, state}` once the pane exists, without waiting for boot.@@ -348,8 +348,8 @@ redraw at that size has landed, so a capture with that `since_seq` already seesare a JSON `ContractError`; `resize` is the only verb that emits the two codes it added,`resize_unsupported` (the magmux has no `resize` op) and `delivery_unavailable` (magmux refused, orthe pane is unreachable). `capabilities` lists `resize` since the pin moved to magmux 0.15.1. The-resize floor was 0.15.1, not 0.15.0 (the first release with the op; the pane floor is now 0.17.0, for-the input gate's transcript binding): 0.15.0 kept the scroll region's old+resize floor was 0.15.1, not 0.15.0 (the first release with the op; the pane floor is now 0.18.0, for+deep socket paths, above the 0.17.0 the input gate's transcript binding needs): 0.15.0 kept the scroll region's oldbottom after a row grow and clamped cursor-down to it, so Claude Code's relative-move redrawcollapsed its input box onto the old last row and `pathPrimary` never settled the next turn. Thefake child redraws with relative cursor-down for that reason. The per-pane check of magmux's `verbs` stays as the defence against adiff --git a/ai-docs/architecture/pane-session.md b/ai-docs/architecture/pane-session.mdindex 5ca22edf..f377ebb5 100644--- a/ai-docs/architecture/pane-session.md+++ b/ai-docs/architecture/pane-session.md@@ -121,7 +121,8 @@ discovery can pick the wrong one (read in source, `controller_claude.go:532-645`A pane locked onto another session can report `busy dialog:<kind>` for a dialog that is not on itsown screen, and can see "a turn started" in the other session and refuse its retype (a false "may-have been submitted"). So claudish requires magmux 0.17.0, which takes `--session-id` and+have been submitted"). So claudish requires the binding magmux 0.17.0 introduced (the floor is+now 0.18.0, for deep socket paths; see "magmux socket traps"): it takes `--session-id` and`--transcript` bound to the `-e` that follows, claims exactly that file (also before it exists),never falls back to discovery, and echoes the binding per pane in `list`.@@ -835,12 +836,14 @@ reserves N panes before a run's spawn loop; each start consumes one, whether it## magmux socket traps- **Always pass `--sock-dir`**, and strip `MAGMUX_*`: an inherited `MAGMUX_SOCK_DIR` moves the- socket (measured). An invalid `--id` or `--sock-dir` is IGNORED, with exit 0 and a stderr line, and- magmux binds somewhere else; `ignoring --id`, `ignoring --sock-dir` and `magmux: socket` on stderr- are therefore fatal (`pane_lost`). Ids are validated client-side (`[A-Za-z0-9_-]{1,64}`, not all- digits — an all-digit id collides with a pid socket).-- **A socket path must be under 100 bytes**, or the bind fails; `sockPathFor` asserts it, which is why- test roots are `/tmp/cpt-<8 hex>`.+ socket (measured). An invalid `--id` is IGNORED, with a stderr line, and magmux binds under its pid;+ an unusable `--sock-dir` / `MAGMUX_SOCK_DIR` exits 1 with `magmux: --sock-dir "<dir>": <reason>`+ (or `magmux: MAGMUX_SOCK_DIR "<dir>": …`), and a failed bind prints `magmux: socket <path>: <err>`.+ All three on stderr are fatal (`FATAL_MAGMUX_STDERR`, `pane_lost`). Ids are validated client-side+ (`[A-Za-z0-9_-]{1,64}`, not all digits — an all-digit id collides with a pid socket).+- **A socket path may be any length.** magmux ≥ 0.18.0 binds and dials a socket deeper than+ `sun_path` (104 bytes on darwin, 108 on linux), so `CLAUDISH_PANE_ROOT` can sit anywhere, such as+ inside a sandbox's home. `sockPathOf` (`process-identity.ts`) is the one place the path is built.- **`--id` sockets are never reaped after a SIGKILL** (seven stale ones were found during research).claudish unlinks its own sockets, and the sweep cleans recordless ones.- **EOF is not death.** magmux keeps its panes when a client leaves, and it closes slow subscribers@@ -855,14 +858,15 @@ reserves N panes before a run's spawn loop; each start consumes one, whether itpane's life. `capture` and `capture_session` are memory reads. `aboveBoxChangedAt` moves only when arow ABOVE the input box (located by the cursor) changes, so the status line ticking under the box never holds a quiet windowopen. 4 fps (research recommended 2–4) halves boot, witness and settle latency at no idle cost.-- `assertMagmuxAvailable` requires `magmux --version` ≥ 0.17.0 (cached per binary; the floor is the- transcript binding, not the gate alone: 0.16.0 had the gate but bound it by discovery), and every- connect re-checks `capabilities` (`protocol: 1`, version ≥ 0.17.0) and then the binding (`list`).- An older magmux is refused with `magmux_unavailable: <path> is version <v>; panes need >= 0.17.0- (…); upgrade: brew upgrade MadAppGang/tap/magmux`; claudish never falls back to the box-reading- path or to print mode: one validator per fact. The release job bundles the magmux pinned in- `.github/magmux.env` (v0.17.0), test.yml runs the pane suites against that pin, and release.yml- checks the pin against `MIN_MAGMUX_VERSION`.+- `assertMagmuxAvailable` requires `magmux --version` ≥ `MIN_MAGMUX_VERSION` (0.18.0, the first+ release that binds and dials a deep socket; cached per binary). It is also above the transcript+ binding, which needs 0.17.0, not the gate alone: 0.16.0 had the gate but bound it by discovery.+ Every connect re-checks `capabilities` (`protocol: 1`, version ≥ `MIN_MAGMUX_VERSION`) and then+ the binding (`list`). An older magmux is refused with `magmux_unavailable: <path> is version <v>;+ panes need >= 0.18.0 (…); upgrade: brew upgrade MadAppGang/tap/magmux`; claudish never falls back+ to the box-reading path or to print mode: one validator per fact. The release job bundles the+ magmux pinned in `.github/magmux.env` (v0.18.0), test.yml runs the pane suites against that pin,+ and release.yml checks the pin against `MIN_MAGMUX_VERSION`.- **Latent, outside this driver:** `team-grid.ts` (CLI `--grid`) does not pass `--sock-dir`, so aninherited `MAGMUX_SOCK_DIR` would move its socket (F7).diff --git a/ai-docs/architecture/testing.md b/ai-docs/architecture/testing.mdindex 51c4f204..c4e3c3ad 100644--- a/ai-docs/architecture/testing.md+++ b/ai-docs/architecture/testing.md@@ -236,9 +236,8 @@ and the fake dumps the argv, env, cwd and `--settings` it was given.**The environment is built by ALLOWLIST** (`makePaneTestEnv()`, and `serverEnv(layout)` for areal MCP server), never by deleting from `process.env`: no `ANTHROPIC_*` or provider key survivesbecause none is listed, and `HOME`, `CLAUDE_CONFIG_DIR`, `ZDOTDIR` and `XDG_CONFIG_HOME` all point-into a temp directory. `CLAUDISH_PANE_ROOT` is a fresh `/tmp/cpt-<8 hex>` per test or layout:-short, so socket paths stay under magmux's 100-byte limit, and never the user's-`/tmp/claudish-mux-<uid>`, whose startup sweep and 48-pane limit belong to the user's own+into a temp directory. `CLAUDISH_PANE_ROOT` is a fresh `/tmp/cpt-<8 hex>` per test or layout,+never the user's `/tmp/claudish-mux-<uid>`, whose startup sweep and 48-pane limit belong to the user's ownsessions.**Drop `CLAUDISH_PANE_CHILD` from any env spread from `process.env`.** The flag reaches everything adiff --git a/docs/usage/magmux.md b/docs/usage/magmux.mdindex 3dc18a1e..bb3da582 100644--- a/docs/usage/magmux.md+++ b/docs/usage/magmux.md@@ -60,17 +60,19 @@ has finished, and closes the pane when the slot or session ends.**Requirements:**-- **magmux 0.17.0 or newer.** The npm package bundles it on macOS and Linux; otherwise+- **magmux 0.18.0 or newer.** The npm package bundles it on macOS and Linux; otherwise`brew install MadAppGang/tap/magmux` (or `brew upgrade MadAppGang/tap/magmux`). With an oldermagmux, or none, `team(mode:"run")`, `create_session` and `claudish team` / `--team` refuse with- `magmux_unavailable: <path> is version <v>; panes need >= 0.17.0 …`; claudish never substitutes- print mode. 0.17.0 is the floor because claudish now delivers every prompt through magmux's- Claude Code input gate, bound to the pane's own transcript: magmux types the prompt only into an- empty input box, presses Enter only when the box holds exactly that text, and says whether it was- submitted. A prompt that is never accepted fails with `prompt_not_accepted`, and its- `reason_detail` quotes magmux's answer — for example `magmux not_accepted still_in_box: …`,- `busy vim_mode: vim editing mode is on …`, or `magmux could not tell whether the prompt was- submitted …` — instead of a silent empty answer.+ `magmux_unavailable: <path> is version <v>; panes need >= 0.18.0 …`; claudish never substitutes+ print mode. 0.18.0 is the floor because it is the first magmux that binds and dials its socket+ at any path depth, so a pane socket path may be any length (`CLAUDISH_PANE_ROOT` can sit+ anywhere, such as inside a sandbox's home). It also carries what 0.17.0 introduced: claudish+ delivers every prompt through magmux's Claude Code input gate, bound to the pane's own+ transcript: magmux types the prompt only into an empty input box, presses Enter only when the+ box holds exactly that text, and says whether it was submitted. A prompt that is never accepted+ fails with `prompt_not_accepted`, and its `reason_detail` quotes magmux's answer — for example+ `magmux not_accepted still_in_box: …`, `busy vim_mode: vim editing mode is on …`, or `magmux+ could not tell whether the prompt was submitted …` — instead of a silent empty answer.- **macOS or Linux.** Windows is not supported for MCP `team`, `create_session`, or CLI`claudish team` / `--team`.diff --git a/docs/usage/mcp-server.md b/docs/usage/mcp-server.mdindex 2d795a69..1adf1b75 100644--- a/docs/usage/mcp-server.md+++ b/docs/usage/mcp-server.md@@ -13,7 +13,7 @@ The server exposes **15 tools** across four groups: low-level (3), agentic (3),Every `team` slot and every `create_session` session is a real, interactive Claude Code sessionrunning your model, inside its own headless [magmux](magmux.md) pane. That needs:-- **magmux 0.17.0 or newer.** It is bundled with the npm package on macOS and Linux; otherwise+- **magmux 0.18.0 or newer.** It is bundled with the npm package on macOS and Linux; otherwiseinstall it with `brew install MadAppGang/tap/magmux`. Without it, `team(mode:"run")`,`create_session` and the CLI's `claudish team` / `--team` refuse with`Error: magmux_unavailable: …` instead of falling back to anything else.@@ -443,7 +443,7 @@ Set a session's terminal size. The child gets a real resize signal and Claude Conew width; the next `capture_session` reports the new `cols`/`rows` under a new `seq`. Allowed inevery state, mid-turn included. When several callers resize the same session, the last one wins.-Works with every magmux sessions accept (0.17.0 or newer). Resizing itself needs 0.15.1: 0.15.0+Works with every magmux sessions accept (0.18.0 or newer). Resizing itself needs 0.15.1: 0.15.0added the resize op, but a pane that grew taller kept its old scroll region, which garbled ClaudeCode's input box and stopped its turns from ending. `list_sessions` and`team` list `resize` in `capabilities`. If magmux lacks the `resize` verb, the call answers@@ -677,7 +677,7 @@ CLAUDISH_MCP_TOOLS=session OPENROUTER_API_KEY=sk-or-v1-... claudish --mcp**Check magmux** (needed by `team` and sessions):```bash-magmux --version # 0.17.0 or newer+magmux --version # 0.18.0 or newer```---@@ -690,7 +690,7 @@ magmux --version # 0.17.0 or newer**Rate limits:** OpenRouter has rate limits. Heavy parallel usage might hit them.-**Platforms:** `team` and sessions need magmux 0.17.0+ and run on macOS and Linux only; Windows is not supported for them.+**Platforms:** `team` and sessions need magmux 0.18.0+ and run on macOS and Linux only; Windows is not supported for them.---diff --git a/packages/cli/src/mcp-e2e/runner.ts b/packages/cli/src/mcp-e2e/runner.tsindex 106d3ca1..a7470e26 100644--- a/packages/cli/src/mcp-e2e/runner.ts+++ b/packages/cli/src/mcp-e2e/runner.ts@@ -113,9 +113,8 @@ const PANE_FAKE_CHILD = resolve();/**- * A short pane root per replica (`/tmp/cpt-<8 hex>`, so socket paths stay < 100- * bytes): the server's startup sweep, its pane limit and its records stay inside it,- * never the user's `/tmp/claudish-mux-<uid>`.+ * A pane root per replica (`/tmp/cpt-<8 hex>`): the server's startup sweep, its pane+ * limit and its records stay inside it, never the user's `/tmp/claudish-mux-<uid>`.*/function newPaneRoot(): string {return `/tmp/cpt-${randomBytes(4).toString("hex")}`;diff --git a/packages/cli/src/pane/pane-launch-version-probe.test.ts b/packages/cli/src/pane/pane-launch-version-probe.test.tsindex 6abd5f25..14690a16 100644--- a/packages/cli/src/pane/pane-launch-version-probe.test.ts+++ b/packages/cli/src/pane/pane-launch-version-probe.test.ts@@ -70,7 +70,7 @@ describe("magmux version probe", () => {"B1: six overlapping callers share exactly one probe",async () => {const fake = fakeMagmux(`sleep 0.3-printf '%s\\n' 'magmux 0.17.0 (test-build)'`);+printf '%s\\n' 'magmux ${MIN_MAGMUX_VERSION} (test-build)'`);const results = await Promise.all(Array.from({ length: 6 }, () => assertMagmuxAvailable(fake.binary))@@ -78,7 +78,7 @@ printf '%s\\n' 'magmux 0.17.0 (test-build)'`);expect(results).toHaveLength(6);for (const result of results) {- expect(result).toEqual({ binary: fake.binary, version: "0.17.0" });+ expect(result).toEqual({ binary: fake.binary, version: MIN_MAGMUX_VERSION });}expect(fake.runs()).toBe(1);},@@ -88,11 +88,11 @@ printf '%s\\n' 'magmux 0.17.0 (test-build)'`);test("B2: accepts a version printed only on stderr",async () => {- const fake = fakeMagmux("printf '%s\\n' 'magmux 0.17.0' >&2");+ const fake = fakeMagmux(`printf '%s\\n' 'magmux ${MIN_MAGMUX_VERSION}' >&2`);expect(await assertMagmuxAvailable(fake.binary)).toEqual({binary: fake.binary,- version: "0.17.0",+ version: MIN_MAGMUX_VERSION,});expect(fake.runs()).toBe(1);},@@ -105,11 +105,11 @@ printf '%s\\n' 'magmux 0.17.0 (test-build)'`);const fake = fakeMagmux(`if [ "$(wc -l < "$counter")" -eq 1 ]; thenexit 0fi-printf '%s\\n' 'magmux 0.17.0'`);+printf '%s\\n' 'magmux ${MIN_MAGMUX_VERSION}'`);expect(await assertMagmuxAvailable(fake.binary)).toEqual({binary: fake.binary,- version: "0.17.0",+ version: MIN_MAGMUX_VERSION,});expect(fake.runs()).toBe(2);},@@ -122,7 +122,7 @@ printf '%s\\n' 'magmux 0.17.0'`);const fake = fakeMagmux(`printf '%s\\n' 'magmux development build'printf '%s\\n' 'version metadata unavailable' >&2`);- await expectUnavailable(fake.binary, "is version unknown", ">= 0.17.0");+ await expectUnavailable(fake.binary, "is version unknown", `>= ${MIN_MAGMUX_VERSION}`);expect(fake.runs()).toBe(2);},testTimeout@@ -133,8 +133,7 @@ printf '%s\\n' 'version metadata unavailable' >&2`);async () => {const fake = fakeMagmux("printf '%s\\n' 'magmux 0.16.0'");- expect(MIN_MAGMUX_VERSION).toBe("0.17.0");- await expectUnavailable(fake.binary, "is version 0.16.0", ">= 0.17.0");+ await expectUnavailable(fake.binary, "is version 0.16.0", `>= ${MIN_MAGMUX_VERSION}`);expect(fake.runs()).toBe(1);},testTimeout@@ -146,7 +145,7 @@ printf '%s\\n' 'version metadata unavailable' >&2`);const fake = fakeMagmux(`if [ "$(wc -l < "$counter")" -eq 1 ]; thenprintf '%s\\n' 'magmux 0.16.0'else- printf '%s\\n' 'magmux 0.17.0'+ printf '%s\\n' 'magmux ${MIN_MAGMUX_VERSION}'fi`);await expectUnavailable(fake.binary, "is version 0.16.0");@@ -154,7 +153,7 @@ fi`);expect(await assertMagmuxAvailable(fake.binary)).toEqual({binary: fake.binary,- version: "0.17.0",+ version: MIN_MAGMUX_VERSION,});expect(fake.runs()).toBe(2);},@@ -164,8 +163,8 @@ fi`);test("B7: a successful probe is cached for subsequent calls",async () => {- const fake = fakeMagmux("printf '%s\\n' 'magmux 0.17.0'");- const expected = { binary: fake.binary, version: "0.17.0" };+ const fake = fakeMagmux(`printf '%s\\n' 'magmux ${MIN_MAGMUX_VERSION}'`);+ const expected = { binary: fake.binary, version: MIN_MAGMUX_VERSION };expect(await assertMagmuxAvailable(fake.binary)).toEqual(expected);expect(fake.runs()).toBe(1);@@ -193,7 +192,7 @@ exit 7`);test("B8: a non-executable binary rejects with a version-command failure",async () => {- const fake = fakeMagmux("printf '%s\\n' 'magmux 0.17.0'");+ const fake = fakeMagmux(`printf '%s\\n' 'magmux ${MIN_MAGMUX_VERSION}'`);chmodSync(fake.binary, 0o644);await expectUnavailable(fake.binary, "--version failed");@@ -205,11 +204,11 @@ exit 7`);test("B9: accepts a release candidate and returns only its version triple",async () => {- const fake = fakeMagmux("printf '%s\\n' 'magmux 0.17.0-rc1'");+ const fake = fakeMagmux(`printf '%s\\n' 'magmux ${MIN_MAGMUX_VERSION}-rc1'`);expect(await assertMagmuxAvailable(fake.binary)).toEqual({binary: fake.binary,- version: "0.17.0",+ version: MIN_MAGMUX_VERSION,});expect(fake.runs()).toBe(1);},diff --git a/packages/cli/src/pane/pane-launch.test.ts b/packages/cli/src/pane/pane-launch.test.tsindex 3c058bc8..61d6ba49 100644--- a/packages/cli/src/pane/pane-launch.test.ts+++ b/packages/cli/src/pane/pane-launch.test.ts@@ -3,11 +3,12 @@ import { chmodSync, mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync }import { tmpdir } from "node:os";import { join } from "node:path";import {+ FATAL_MAGMUX_STDERR,HOST_IDENTITY_VARS,LINUX_ENV_STRING_LIMIT,+ MIN_MAGMUX_VERSION,OWNER_START36,PaneEnvTooLargeError,- PaneRootError,SHELL_SHIM,assertMagmuxAvailable,buildClaudishPaneArgv,@@ -18,11 +19,16 @@ import {launcherScript,mintPaneId,paneCommand,- sockPathFor,sockRootFor,versionAtLeast,} from "./pane-launch.js";-import { WATCHER_ARGV0, WATCHER_SCRIPT, isLaunchDirPath, watcherArgv } from "./process-identity.js";+import {+ WATCHER_ARGV0,+ WATCHER_SCRIPT,+ isLaunchDirPath,+ sockPathOf,+ watcherArgv,+} from "./process-identity.js";const dirs: string[] = [];afterEach(() => {@@ -35,6 +41,12 @@ function tmp(): string {return d;}+/** The release just below `v`: one patch down, or the last patch of the previous minor. */+function versionBelow(v: string): string {+ const [major = 0, minor = 0, patch = 0] = v.split(".").map((x) => Number.parseInt(x, 10));+ return patch > 0 ? `${major}.${minor}.${patch - 1}` : `${major}.${minor - 1}.9`;+}+describe("launcher and shim", () => {test("the launcher cds to the realpath cwd, then execs claudish; no watcher, no PATH line", () => {const s = launcherScript(@@ -211,9 +223,15 @@ describe("ids, socket paths and the socket root", () => {expect(isValidPaneId("c1-a-t01-abcdef")).toBe(true);});- test("a socket path of 100 bytes or more is refused", () => {- expect(sockPathFor("/tmp/r", "c1-x")).toBe("/tmp/r/magmux-c1-x.sock");- expect(() => sockPathFor(`/tmp/${"d".repeat(80)}`, "c1-abcdefghij")).toThrow(PaneRootError);+ // REGRESSION: G-10 deep socket paths (>= 100 bytes) refused — Fixed in /dev:fix session dev-fix-20261017-g10-socket+ test("a 121-byte pane socket path is accepted", () => {+ expect(sockPathOf("/tmp/r", "c1-x")).toBe("/tmp/r/magmux-c1-x.sock");+ const id = "c1-abcdefghij";+ const fixed = Buffer.byteLength(join("/tmp/", `magmux-${id}.sock`)) + 1; // + the "/" after the root+ const root = `/tmp/${"d".repeat(121 - fixed)}`;+ const want = join(root, `magmux-${id}.sock`);+ expect(Buffer.byteLength(want)).toBe(121);+ expect(sockPathOf(root, id)).toBe(want);});test("CLAUDISH_PANE_ROOT overrides the default root", () => {@@ -274,20 +292,23 @@ describe("watcher argv and version gate", () => {test("the magmux version probe never blocks the event loop; an old version is refused", async () => {const dir = tmp();const slow = join(dir, "magmux-slow");- writeFileSync(slow, "#!/bin/sh\nsleep 0.6\necho 'magmux 0.17.0 (fake)'\n");+ writeFileSync(slow, `#!/bin/sh\nsleep 0.6\necho 'magmux ${MIN_MAGMUX_VERSION} (fake)'\n`);chmodSync(slow, 0o755);let ticks = 0;const timer = setInterval(() => ticks++, 50);try {- expect(await assertMagmuxAvailable(slow)).toEqual({ binary: slow, version: "0.17.0" });+ expect(await assertMagmuxAvailable(slow)).toEqual({+ binary: slow,+ version: MIN_MAGMUX_VERSION,+ });} finally {clearInterval(timer);}expect(ticks).toBeGreaterThanOrEqual(5); // a synchronous probe would let none runconst old = join(dir, "magmux-old");- writeFileSync(old, "#!/bin/sh\necho 'magmux 0.16.0'\n");+ writeFileSync(old, `#!/bin/sh\necho 'magmux ${versionBelow(MIN_MAGMUX_VERSION)}'\n`);chmodSync(old, 0o755);- await expect(assertMagmuxAvailable(old)).rejects.toThrow(/panes need >= 0.17.0/);+ await expect(assertMagmuxAvailable(old)).rejects.toThrow(`panes need >= ${MIN_MAGMUX_VERSION}`);});test("versionAtLeast", () => {@@ -296,4 +317,29 @@ describe("watcher argv and version gate", () => {expect(versionAtLeast("0.16.0", "0.17.0")).toBe(false);expect(versionAtLeast("1.0.0", "0.17.0")).toBe(true);});++ // REGRESSION: G-10 deep socket paths (>= 100 bytes) refused — Fixed in /dev:fix session dev-fix-20261017-g10-socket+ test("panes need magmux 0.18.0, the first release that binds and dials a deep socket", async () => {+ expect(MIN_MAGMUX_VERSION).toBe("0.18.0");+ const dir = tmp();+ const old = join(dir, "magmux-0.17.0");+ writeFileSync(old, "#!/bin/sh\necho 'magmux 0.17.0'\n");+ chmodSync(old, 0o755);+ await expect(assertMagmuxAvailable(old)).rejects.toThrow(+ "is version 0.17.0; panes need >= 0.18.0"+ );+ });++ // REGRESSION: G-10 deep socket paths (>= 100 bytes) refused — Fixed in /dev:fix session dev-fix-20261017-g10-socket+ test("magmux's loud --sock-dir / MAGMUX_SOCK_DIR refusal and a bind failure are fatal stderr", () => {+ expect(FATAL_MAGMUX_STDERR.test('magmux: --sock-dir "/x": not a directory')).toBe(true);+ expect(+ FATAL_MAGMUX_STDERR.test(+ 'magmux: MAGMUX_SOCK_DIR "/x": cannot stat it: stat /x: no such file or directory'+ )+ ).toBe(true);+ expect(+ FATAL_MAGMUX_STDERR.test("magmux: socket /x/magmux-a.sock: bind: permission denied")+ ).toBe(true);+ });});diff --git a/packages/cli/src/pane/pane-launch.ts b/packages/cli/src/pane/pane-launch.tsindex bd252fd1..51fed3cd 100644--- a/packages/cli/src/pane/pane-launch.ts+++ b/packages/cli/src/pane/pane-launch.ts@@ -37,7 +37,7 @@ import { STRIPPED_CHILD_VARS } from "../launcher/magmux-wrapper.js";import { resolveClaudishSpawn } from "../spawn-claudish.js";import { isPaneShellManagedKey } from "./child-env.js";import { DEFAULT_PANE_COLS, DEFAULT_PANE_ROWS } from "./pane-size.js";-import { type WatcherArgs, isValidPaneId, sockPathOf, watcherArgv } from "./process-identity.js";+import { type WatcherArgs, isValidPaneId, watcherArgv } from "./process-identity.js";/* ───────────────────────────── socket root ───────────────────────────── */@@ -114,16 +114,6 @@ export function mintPaneId(kind: "t" | "s", label: string): string {return id;}-/** Unix socket paths must stay under 100 bytes, or magmux silently binds elsewhere. */-export function sockPathFor(root: string, id: string): string {- const p = sockPathOf(root, id);- if (Buffer.byteLength(p) >= 100)- throw new PaneRootError(- `pane socket path ${p} is ${Buffer.byteLength(p)} bytes; it must be < 100`- );- return p;-}-/* ───────────────────────────── environment ───────────────────────────── *//** Variables that steer a TUI's rendering and integrations (X-M16): never in a pane. */@@ -490,11 +480,12 @@ export const KNOWN_CLAUDISH_FLAGS: readonly string[] = Object.keys(CLAUDISH_FLAG/* ───────────────────────────── magmux binary ───────────────────────────── *//**- * 0.17.0: the Claude Code input gate with a declared transcript (`--session-id`,- * `--transcript`, and `list`'s `bound`/`sessionId`/`transcriptPath`). A pre-release such as- * `0.17.0-rc1` passes: `versionAtLeast` compares the numeric triple only.+ * The first magmux that binds and dials its socket at any path depth (0.18.0). It also carries+ * what 0.17.0 introduced: the Claude Code input gate with a declared transcript+ * (`--session-id`, `--transcript`, and `list`'s `bound`/`sessionId`/`transcriptPath`). A+ * pre-release such as `0.18.0-rc1` passes: `versionAtLeast` compares the numeric triple only.*/-export const MIN_MAGMUX_VERSION = "0.17.0";+export const MIN_MAGMUX_VERSION = "0.18.0";export class MagmuxUnavailableError extends Error {readonly code = "magmux_unavailable";@@ -520,7 +511,7 @@ const magmuxCache = new Map<string, MagmuxBinary>();const magmuxProbes = new Map<string, Promise<MagmuxBinary>>();const execFileAsync = promisify(execFile);-/** The magmux binary and its version (≥ MIN_MAGMUX_VERSION), cached per process. Never a `-p` fallback. */+/** The magmux binary and its version (≥ `MIN_MAGMUX_VERSION`), cached per process. Never a `-p` fallback. */export async function assertMagmuxAvailable(binary?: string): Promise<MagmuxBinary> {const key = binary ?? "";const cached = magmuxCache.get(key);@@ -553,7 +544,7 @@ async function probeMagmux(binary?: string): Promise<MagmuxBinary> {if (!version) version = await readMagmuxVersion(found);if (!version || !versionAtLeast(version, MIN_MAGMUX_VERSION))throw new MagmuxUnavailableError(- `magmux_unavailable: ${found} is version ${version || "unknown"}; panes need >= ${MIN_MAGMUX_VERSION} (the Claude Code input gate bound to a named transcript); upgrade: brew upgrade MadAppGang/tap/magmux`+ `magmux_unavailable: ${found} is version ${version || "unknown"}; panes need >= ${MIN_MAGMUX_VERSION} (a socket at any path depth, and the Claude Code input gate bound to a named transcript); upgrade: brew upgrade MadAppGang/tap/magmux`);return { binary: found, version };}@@ -658,8 +649,12 @@ export function spawnPaneWatcher(args: WatcherArgs): ChildProcess {return proc;}-/** Fatal magmux stderr: it ignores an invalid id or socket dir and binds somewhere else. */-export const FATAL_MAGMUX_STDERR = /ignoring --id|ignoring --sock-dir|magmux: socket/;+/**+ * Fatal magmux stderr: an invalid `--id` (magmux ignores it and binds under its pid), an+ * unusable `--sock-dir` / `MAGMUX_SOCK_DIR` (magmux exits 1), or a failed socket bind.+ */+export const FATAL_MAGMUX_STDERR =+ /ignoring --id|magmux: (?:--sock-dir|MAGMUX_SOCK_DIR) |magmux: socket/;export interface MagmuxSpawnInput {binary: string;diff --git a/packages/cli/src/pane/pane-registry.test.ts b/packages/cli/src/pane/pane-registry.test.tsindex 08a05a24..d35d0960 100644--- a/packages/cli/src/pane/pane-registry.test.ts+++ b/packages/cli/src/pane/pane-registry.test.ts@@ -18,7 +18,12 @@ import {} from "node:fs";import { join } from "node:path";import { waitForExit } from "../process-tree.js";-import { assertMagmuxAvailable, ensureSockRoot, spawnPaneWatcher } from "./pane-launch.js";+import {+ MIN_MAGMUX_VERSION,+ assertMagmuxAvailable,+ ensureSockRoot,+ spawnPaneWatcher,+} from "./pane-launch.js";import {MAX_LIVE_PANES,PaneLimitError,@@ -433,7 +438,7 @@ describe.skipIf(!MAGMUX)(`pane registry, real magmux (${MAGMUX ? "" : NO_MAGMUX_test("R3-M1: a magmux spawn failure reaps at once — record and dirs gone, no watcher, livePaneCount 0", async () => {const t = env();const fake = join(t.tmp, "magmux-fake");- writeFileSync(fake, "#!/bin/sh\necho 'magmux 0.17.0 (fake)'\n");+ writeFileSync(fake, `#!/bin/sh\necho 'magmux ${MIN_MAGMUX_VERSION} (fake)'\n`);chmodSync(fake, 0o755);await assertMagmuxAvailable(fake); // passes the version gate …rmSync(fake);diff --git a/packages/cli/src/pane/pane-session.ts b/packages/cli/src/pane/pane-session.tsindex 2aade0b3..f8280938 100644--- a/packages/cli/src/pane/pane-session.ts+++ b/packages/cli/src/pane/pane-session.ts@@ -58,7 +58,6 @@ import {launcherScript,mintPaneId,resolveClaudishLaunch,- sockPathFor,sockRootFor,spawnPaneMagmux,spawnPaneWatcher,@@ -96,6 +95,7 @@ import {liveEscaped,readProcessTableAsync,recordPathOf,+ sockPathOf,verifiedGroupSnapshot,} from "./process-identity.js";import { type Delivery, planDelivery, writeTurnFile } from "./prompt-delivery.js";@@ -3061,7 +3061,7 @@ function preparePane(let dirs: { ctlDir: string; turnDir: string } | null = null;try {const paneId = mintPaneId(o.kind, o.label);- const sockPath = sockPathFor(root, paneId);+ const sockPath = sockPathOf(root, paneId);const cwd = realpathSync(o.cwd);const launch = o.claudishSpawn ?? resolveClaudishLaunch(parentEnv);dirs = createLaunchDirs(root);diff --git a/packages/cli/src/pane/test-helpers/hermetic-env.ts b/packages/cli/src/pane/test-helpers/hermetic-env.tsindex d28c2874..ab2dd8f4 100644--- a/packages/cli/src/pane/test-helpers/hermetic-env.ts+++ b/packages/cli/src/pane/test-helpers/hermetic-env.ts@@ -6,7 +6,7 @@* `CLAUDE_CONFIG_DIR`, `ZDOTDIR` and `XDG_CONFIG_HOME` all point into a temp dir, so* nothing reads or writes the real `~/.claude`, `~/.claudish` or the keychain.*- * `sockRoot` is a short `/tmp/cpt-<8 hex>` so socket paths stay under 100 bytes.+ * `sockRoot` is a per-test `/tmp/cpt-<8 hex>`, never the user's `/tmp/claudish-mux-<uid>`.** `assertNoOrphans` is the per-test no-orphan check: no process whose argv contains the* test's sockRoot or a session id, no process in any of the pane pgids, and no socket,diff --git a/packages/cli/src/test-helpers/contract-mcp.ts b/packages/cli/src/test-helpers/contract-mcp.tsindex 59254d8c..88c83a44 100644--- a/packages/cli/src/test-helpers/contract-mcp.ts+++ b/packages/cli/src/test-helpers/contract-mcp.ts@@ -37,8 +37,8 @@ export const MAGMUX_AVAILABLE = findMagmuxBinaryOrNull() !== null;export const NO_MAGMUX_MESSAGE = "magmux not installed — not checked";/**- * A short pane root per layout (`/tmp/cpt-<8 hex>`, so socket paths stay < 100 bytes),- * passed to the server as CLAUDISH_PANE_ROOT: its sweep, its pane limit and the+ * A pane root per layout (`/tmp/cpt-<8 hex>`), passed to the server as+ * CLAUDISH_PANE_ROOT: its sweep, its pane limit and the* no-orphan check stay inside the test (§20.4).*/const paneRoots = new Map<string, string>();