Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
docs(control): name the set a drift alarm, not a gate — and say what it omits
Claude Code6efcd9eff975
diff --git a/docs/node-identity.md b/docs/node-identity.mdindex a9c814cc5..fd26e61f8 100644--- a/docs/node-identity.md+++ b/docs/node-identity.md@@ -62,9 +62,12 @@ On 2026-08-13, on a stock Linux host with no `hidepid`:unprivileged local user — a different uid, no relationship to the victim — could read a liveapp-wide bearer straight out of the process table.- The bearer is all `/control/*` required. `open-terminal --cmd C` opens a terminal running an- arbitrary command and is **not** in the confirm-gated `DESTRUCTIVE` set (only `write` and `close`- are, `src/main/canvas-control-core.ts`). So this was **arbitrary command execution as the victim- user**, from any account on the machine, with no prompt.+ arbitrary command and is **not** in the confirm-gated `DESTRUCTIVE_VERBS` set (only `write` and+ `close` are, `src/shared/control-verbs.ts`). So this was **arbitrary command execution as the+ victim user**, from any account on the machine, with no prompt. (Note what that set is and is+ not: the dialogs are hand-written per case in `Canvas.tsx`'s dispatch, and `close-worktree+ --mode remove` is confirmed by a human without being in the set. The set is what the two `case`+ blocks read for their `confirmBusy()` refusal, and a drift alarm over that agreement.)- The same shape existed on SSH hosts: `RemoteHooks.verifyTunnel` passed the bearer as `-H` on acurl command line, i.e. argv on the host, readable by every other account there.diff --git a/src/core/agents/hook-identity-enforcement.test.ts b/src/core/agents/hook-identity-enforcement.test.tsindex 5c4ba3e66..b0dd515e1 100644--- a/src/core/agents/hook-identity-enforcement.test.ts+++ b/src/core/agents/hook-identity-enforcement.test.ts@@ -386,7 +386,7 @@ describe('write/close keep the human in the loop, token or no token', () => {})it('never waves them through as tolerant', () => {- // The confirm-gated pair (src/main/canvas-control-core.ts `isDestructiveVerb`) is untouched by+ // The confirm-gated pair (src/shared/control-verbs.ts `isDestructiveVerb`) is untouched by// this feature. Tolerance would be the one way identity could weaken it, so it is pinned here;// the set itself is covered in canvas-control-core.test.ts.expect(TOLERANT_CONTROL_VERBS.has('write')).toBe(false)diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.tsindex f6db80b68..cc7ac7725 100644--- a/src/core/agents/hook-server.ts+++ b/src/core/agents/hook-server.ts@@ -813,7 +813,8 @@ class HookServer {// `-e` argv into a long-lived tmux CLIENT process whose /proc/<pid>/cmdline is mode 444 on a// stock Linux (no hidepid), so any unprivileged local user read a live app-wide bearer and// could drive canvas control — including `open-terminal --cmd`, which is NOT in the- // confirm-gated DESTRUCTIVE set. Every client already sources the 0600 endpoint file FIRST+ // confirm-gated DESTRUCTIVE_VERBS set (src/shared/control-verbs.ts). Every client already+ // sources the 0600 endpoint file FIRST// and prefers it, so nothing legitimate loses anything: the only regression surface is a// session whose endpoint file is unreadable AND whose env held a good token, a state that// means the data dir has vanished and the hook is meant to be inert anyway.diff --git a/src/core/local-send-keys.realtmux.test.ts b/src/core/local-send-keys.realtmux.test.tsindex 588827acc..832ceb2ed 100644--- a/src/core/local-send-keys.realtmux.test.ts+++ b/src/core/local-send-keys.realtmux.test.ts@@ -3,9 +3,14 @@// `paste-injection.realtty.test.ts` proves what the framed BODY does to a reader. This file proves// what the ARGV does to tmux, which is a different parser and had a different hole: `send-keys -l`// does not stop option parsing, so a payload beginning with `-` was consumed by tmux as FLAGS.-// `-R`, `-K`, `-l` and `--` are all accepted flags that exit 0, so the delivery reported success,-// typed nothing at all — and then sent its Enter anyway, submitting whatever the human had already-// composed in that pane.+// Measured on tmux 3.4, every one of `-R -K -l -- -H -F -N 3` exits 0 while typing nothing,+// so the delivery reported success — and then sent its Enter anyway, submitting whatever the human+// had already composed in that pane.+//+// `-R` is the worst of them and the reason the harm is not merely "the write was dropped": it+// RESETS THE PANE DISPLAY, so the composed line is wiped from the screen while readline still+// holds it. The human sees an empty prompt; the Enter that follows submits the line they can no+// longer see.//// The remote counterpart (`remoteTmuxSendKeysArgs`) has carried `--` since it was written; the// local one never did. Same rule, one implementation missing it — the drift `sanitizePasteText`'s@@ -26,6 +31,17 @@ import { sanitizePasteText } from './paste-injection'const SOCKET = `nt-sendkeys-test-${process.pid}`const SESSION = 'probe'+/**+ * The socket lives in the test's OWN temp dir, not `/tmp/tmux-<uid>/`.+ *+ * `kill-server` stops the server but does not unlink the socket file, so a per-pid socket name in+ * the shared dir leaves one stale entry behind per run, forever. Pointing `TMUX_TMPDIR` at `work`+ * makes `afterAll`'s `rm -rf` the one cleanup path for everything this file created.+ */+function tmuxEnv(): NodeJS.ProcessEnv {+ return { ...process.env, TMUX_TMPDIR: work }+}+function findTmux(): string | null {for (const c of ['/usr/bin/tmux', '/usr/local/bin/tmux', '/opt/homebrew/bin/tmux', '/bin/tmux']) {if (fs.existsSync(c)) return c@@ -38,7 +54,7 @@ let work: string/** `tmux <args>`, throwing on a non-zero exit exactly as `PtyManager`'s `runAsync` would. */function tmux(args: string[]): string {- return execFileSync(TMUX as string, args, { encoding: 'utf8' })+ return execFileSync(TMUX as string, args, { encoding: 'utf8', env: tmuxEnv() })}/** Type `body` into the probe pane the way the HARNESS does it — always safely quoted. */@@ -66,7 +82,10 @@ function drain(tag: string): void {function freshPane(): void {try {// Quiet: on the first run there is no server yet and tmux says so on stderr.- execFileSync(TMUX as string, ['-L', SOCKET, 'kill-session', '-t', SESSION], { stdio: 'ignore' })+ execFileSync(TMUX as string, ['-L', SOCKET, 'kill-session', '-t', SESSION], {+ stdio: 'ignore',+ env: tmuxEnv()+ })} catch {// no session yet}diff --git a/src/core/tmux-naming.test.ts b/src/core/tmux-naming.test.tsindex e30771189..d1a401ac9 100644--- a/src/core/tmux-naming.test.ts+++ b/src/core/tmux-naming.test.ts@@ -31,7 +31,9 @@ describe('localTmuxSendKeysArgs', () => {expect(args).toEqual(['-L', 'sock', 'send-keys', '-t', 'nt-x', '-l', '--', 'hello'])})it('puts `--` immediately before the body, whatever the body is', () => {- for (const body of ['-R', '-K', '--', '-l', '-N 3', '\x1b[200~x\x1b[201~\r']) {+ // Every payload here exits 0 as a FLAG on tmux 3.4 — i.e. was accepted, typed nothing, and let+ // the caller believe it had been delivered. `-R` additionally resets the pane display.+ for (const body of ['-R', '-K', '-l', '--', '-H', '-F', '-N 3', '\x1b[200~x\x1b[201~\r']) {const args = localTmuxSendKeysArgs(TMUX_SOCKET, 'nt-x', body)expect(args[args.length - 2]).toBe('--')expect(args[args.length - 1]).toBe(body)diff --git a/src/core/tmux-naming.ts b/src/core/tmux-naming.tsindex bbe004d04..e7dbce385 100644--- a/src/core/tmux-naming.ts+++ b/src/core/tmux-naming.ts@@ -27,11 +27,17 @@ export function isSessionName(target: string): boolean {* SECURITY — the literal-text `send-keys` argv for a LOCAL pane, with option parsing ENDED.** `-l` means "these are literal characters", but it does NOT stop tmux reading further arguments- * as options. A payload beginning with `-` is therefore taken as flags, and several of them exit- * 0: `-R` (reset terminal state), `-K`, `-l`, `--`. The delivery then reported SUCCESS having- * typed nothing — and `sendText`'s legacy branch went on to send its Enter, submitting whatever- * the human had already composed in that pane. An agent's `write --text -R` was a remote "press- * Enter on whatever is half-typed in that terminal" with no text of its own to show the approver.+ * as options. A payload beginning with `-` is therefore taken as flags, and on tmux 3.4 every one+ * of `-R -K -l -- -H -F -N 3` exits 0 while typing nothing. The delivery then reported+ * SUCCESS — and `sendText`'s legacy branch went on to send its Enter, submitting whatever the+ * human had already composed in that pane. An agent's `write --text -R` was a remote "press Enter+ * on whatever is half-typed in that terminal" with no text of its own to show the approver, and+ * `-R` resets the pane DISPLAY as well, so the line being submitted had just been wiped off the+ * screen while readline still held it.+ *+ * The other direction of the same bug is the everyday one: any legitimate text starting with `-`+ * — a dictation insert, a note push, a `/rename` of a title beginning with a dash — was silently+ * not typed at all.** `--` is the whole fix, and the remote path (`remoteTmuxSendKeysArgs`) has always had it — its* doc comment even says why. Only the local path was missing it. This function exists so the twodiff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.tsindex 252a92a6c..13b9aab28 100644--- a/src/main/canvas-control-core.ts+++ b/src/main/canvas-control-core.ts@@ -62,19 +62,20 @@ const VERBS: ControlVerb[] = []/**- * The confirm-gated set. It MOVED to `src/shared/control-verbs.ts` and is re-exported here so- * main-side callers read the same one the gate does.+ * MOVED to `src/shared/control-verbs.ts` — read that file's header before trusting this set for+ * anything. It is re-exported here so main-side callers are unchanged.*- * WHERE IT IS ENFORCED: `Canvas.tsx`'s `switch (verb)` — `case 'write'` and `case 'close'` read+ * WHERE IT IS READ: `Canvas.tsx`'s `switch (verb)` — `case 'write'` and `case 'close'` call* `isDestructiveVerb(verb)` before their `confirmBusy()` refusal. That is the only consumer, and- * until it existed this set gated nothing at all: it lived in `src/main`, which the renderer- * cannot import, so the actual confirm was hand-written per case and adding a verb to the set- * changed no behaviour — while `TOLERANT_CONTROL_VERBS`' doc comment, `hook-server.ts`'s- * `buildPtyEnv` note and `docs/node-identity.md` (twice, including invariant 6) all told a reader- * it was what decided.+ * until it existed the set was read by nothing but its own unit test: it lived here in `src/main`,+ * which the renderer cannot import, while `TOLERANT_CONTROL_VERBS`' doc comment, `hook-server.ts`'s+ * `buildPtyEnv` note and `docs/node-identity.md:65` all named it as the confirm-gated set.*- * A verb that needs gating is added to the shared set, not by hand-writing a third confirm block;- * `src/renderer/canvas/control-destructive.test.ts` fails if the two disagree again.+ * Two things it still is NOT, both spelled out in the shared file: adding a verb here does not+ * gate it (each case hand-writes its own `setConfirm`), and it is not the complete list of+ * actions a human confirms (`close-worktree --mode remove` is confirmed and is not in it). What+ * the shared home buys is a drift alarm — `control-destructive.test.ts` fails when the set and the+ * dispatch stop agreeing.*/export { isDestructiveVerb, DESTRUCTIVE_VERBS } from '../shared/control-verbs'diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex c55e9b805..ed29ecb24 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -6970,11 +6970,13 @@ export function Canvas() {// aimed at THIS harmless prompt into a deletion. `confirmBusy` covers every confirm// state, not just `confirm`. Reject instead.//- // `isDestructiveVerb` is read here rather than assumed: the set is the authority on- // which verbs are confirm-gated, and until this line it was a security-shaped constant- // that gated nothing — every reader of invariant 6 or TOLERANT_CONTROL_VERBS' doc- // comment believed adding a verb to it gated that verb. Reading it is what makes the- // set true.+ // `isDestructiveVerb` is read here rather than restated: until this line the set was+ // read by nothing but its own unit test, while TOLERANT_CONTROL_VERBS' doc comment,+ // hook-server's buildPtyEnv note and docs/node-identity.md:65 all named it as the+ // confirm-gated set. Reading it is what ties the two together — it does not make the+ // dialog below conditional on the set, and adding a verb to the set would not give+ // that verb a dialog. See `src/shared/control-verbs.ts` for what this does and does+ // not buy.if (isDestructiveVerb(verb) && confirmBusy()) {reply({ ok: false, error: 'a confirmation is already pending — try again' })returndiff --git a/src/renderer/canvas/control-destructive.test.ts b/src/renderer/canvas/control-destructive.test.tsindex 4a55a15bb..e672a4a17 100644--- a/src/renderer/canvas/control-destructive.test.ts+++ b/src/renderer/canvas/control-destructive.test.ts@@ -6,16 +6,21 @@ import { isDestructiveVerb, DESTRUCTIVE_VERBS } from '@shared/control-verbs'* A STRUCTURAL test on purpose.** `DESTRUCTIVE` / `isDestructiveVerb` named `write` and `close` as "the confirm-gated set" and was- * imported by nothing but its own unit test — it could not be anything else, because it lived in- * `src/main` and the gate is in the renderer, which cannot import from there. The live gate was a- * hand-written `if (confirmBusy())` inside each of the two `switch (verb)` cases, so the SET gated- * nothing: adding a verb to it changed no behaviour, while `TOLERANT_CONTROL_VERBS`' doc comment,- * `hook-server.ts`'s `buildPtyEnv` note and `docs/node-identity.md` (twice, including invariant 6)- * all tell a reader that the set is what decides.+ * read by nothing but its own unit test — it could not be anything else, because it lived in+ * `src/main` and the dispatch is in the renderer, which cannot import from there. The refusal was+ * a hand-written `if (confirmBusy())` inside each of the two `switch (verb)` cases, so the SET+ * decided nothing, while `TOLERANT_CONTROL_VERBS`' doc comment, `hook-server.ts`'s `buildPtyEnv`+ * note and `docs/node-identity.md:65` all name it as what decides.*- * The dispatch now reads the set. There is no unit seam to assert that through — the switch lives- * inside a 7000-line React component's IPC listener — and the failure mode being pinned is exactly- * "a reader trusts the constant", which is a property of the SOURCE. So the source is the subject.+ * WHAT THIS FILE IS: a drift alarm, not proof of a gate. The dialog is still hand-written in each+ * case, so these assertions cannot show that a verb IS confirmed — only that the set and the cases+ * that read it still agree, in both directions. That is the thing that had already broken once.+ * `close-worktree --mode remove` is confirmed by a human through `requestRemoveWorktree` and is+ * deliberately outside the set, so it is invisible here by design.+ *+ * Structural because there is no unit seam — the switch lives inside a 7000-line React component's+ * IPC listener — and because the failure mode being pinned is exactly "a reader trusts the+ * constant", which is a property of the SOURCE. So the source is the subject.*/const src = readFileSync(new URL('./Canvas.tsx', import.meta.url), 'utf8')@@ -28,7 +33,7 @@ function caseBody(verb: string): string {return end === -1 ? rest : rest.slice(0, end)}-describe('destructive verbs are confirm-gated through the shared set', () => {+describe('the confirm-gated set and the dispatch that reads it stay in agreement', () => {it('the dispatch imports the set rather than restating it', () => {expect(src).toMatch(/import \{[^}]*isDestructiveVerb[^}]*\} from '@shared\/control-verbs'/)})@@ -46,10 +51,14 @@ describe('destructive verbs are confirm-gated through the shared set', () => {})}- it('no OTHER verb is silently confirm-gated behind the set', () => {+ it('no other case reads isDestructiveVerb', () => {// Every `isDestructiveVerb(verb)` in the dispatch must sit in a case the set actually holds.// If a third case ever grows one, either the set or the dispatch is wrong — say so here rather// than let the two drift apart the way the constant and the switch already did once.+ //+ // This scans for the CALL, so a hand-written confirm that never reads the set is invisible to+ // it — `close-worktree --mode remove` is exactly that, on purpose. This is not "no other verb+ // is confirm-gated"; it is "no other case claims to be gated by this set".const labels = [...src.matchAll(/\n {10}case '([a-z-]+)': \{/g)].map((m) => m[1])const gated = labels.filter((v) => /isDestructiveVerb\(verb\)/.test(caseBody(v)))expect(new Set(gated)).toEqual(new Set(DESTRUCTIVE_VERBS))diff --git a/src/shared/control-verbs.ts b/src/shared/control-verbs.tsindex ad021fe40..59cfcb7c9 100644--- a/src/shared/control-verbs.ts+++ b/src/shared/control-verbs.ts@@ -1,4 +1,5 @@-// The control verbs that must not act until a human has said yes in a dialog.+// The control verbs whose `Canvas.tsx` dispatch case is confirm-gated AND says so through this+// set. Read the second half of that sentence literally — see WHAT THIS SET DOES NOT DO below.//// IN `src/shared` BECAUSE IT HAS TWO SIDES, and that is the whole point of this file existing.// The set was defined in `src/main/canvas-control-core.ts` and the gate it describes lives in the@@ -6,10 +7,29 @@// includes only `src/renderer`, `src/shared` and the preload types. So the set stayed a// security-shaped constant imported by nothing but its own unit test, while// `TOLERANT_CONTROL_VERBS`' doc comment, `hook-server.ts`'s `buildPtyEnv` note and-// `docs/node-identity.md` (twice, including invariant 6) all described it as "the confirm-gated-// set". It described the dispatch; it did not decide it. Adding a verb to it changed nothing.+// `docs/node-identity.md:65` all named it as "the confirm-gated set". It described the dispatch;+// it did not decide it. Adding a verb to it changed nothing.//-// Here, both sides can read the same set, so adding a verb GATES that verb.+// WHAT THIS SET DOES NOT DO — and the reason this paragraph exists is that the defect above was a+// comment claiming a mechanism that was not there:+//+// Adding a verb here does NOT gate it. Measured: adding `'restart'` produces no dialog at all.+// Every case still hand-writes its own `setConfirm({ … })`, and this set is only read for the+// `confirmBusy()` refusal that precedes it. A newly added verb still needs its own confirm+// block, written by hand, in its own case.+//+// What both sides reading one set buys is a DRIFT ALARM, not a gate:+// `src/renderer/canvas/control-destructive.test.ts` fails if the set and the hand-written+// confirm cases stop agreeing in either direction. That is worth having — the set and the+// dispatch had already drifted once, which is how it came to gate nothing — but it is an alarm,+// and calling it a gate would repeat the exact mistake this file was created to fix.+//+// NOR IS IT THE COMPLETE LIST OF CONFIRM-GATED ACTIONS. `close-worktree --mode remove`+// (`Canvas.tsx`'s `case 'close-worktree'`) opens a human confirm through `requestRemoveWorktree`,+// which carries its own `confirmBusy()` refusal, and it is deliberately NOT in this set: its gate+// is the pre-existing worktree-removal dialog, reached by a different route, and widening the set+// to cover it would change its refusal path for no benefit. Anyone auditing "what asks the human+// first" must read the dispatch, not only this set.//// Typed on `string`, not `ControlVerb`: that type belongs to the main-side verb model, which is// exactly what the renderer cannot see, and the renderer's dispatch receives a raw `verb: string`@@ -18,7 +38,11 @@export const DESTRUCTIVE_VERBS: ReadonlySet<string> = new Set(['write', 'close'])/**- * Is this verb one the human must confirm before it acts?+ * Does this verb's dispatch case take its `confirmBusy()` refusal from the shared set?+ *+ * NOT "is a human asked about this verb" — `close-worktree --mode remove` is confirmed by a human+ * and answers `false` here (see the file header). And not "is this verb gated": the dialog itself+ * is hand-written per case, so this returning `true` for a new verb would gate nothing on its own.** `open-terminal --cmd` is deliberately NOT in the set and never was; the 2026-08-13 argv-leak* writeup in `docs/node-identity.md` is the record of what that costs when the bearer leaks.