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
refactor(identity): delete two dead paths, one of them certified by an impossible test
Claude Codeac89467135bf
diff --git a/docs/node-identity.md b/docs/node-identity.mdindex b94e27e77..6b999f898 100644--- a/docs/node-identity.md+++ b/docs/node-identity.md@@ -181,7 +181,7 @@ The bearer is required everywhere; this table is about the *node* token on top o| `/control/list` | Accepted unless the node is latched | 403 | Tolerant: leaks canvas shape, changes nothing. || `/control/<mutation>` | Warned during the window, refused after the cutoff, refused immediately if latched | 403 | Refusal happens **before** the handler. `write`/`close` still ask the human. || `/codex-thread/{start,bind}` | **Refused** (403) | 403 | Strict from the day they existed — no upgrade population to protect. |-| `/codex-thread/fallback` | Accepted **when tokenless** | 403 | A report that carries a token must carry the right one. |+| `/codex-thread/fallback` | **Always accepted** | 403 | It reports a DEGRADE and grants nothing; refusing it would silence it in exactly the tokenless case it exists for. |**Why `/hook/*` never 403s a missing token.** It is the fail-open contract, and it is load-bearingrather than timid. The legitimate tokenless callers are real and permanent: the **phone** (it injects@@ -191,6 +191,12 @@ there does not degrade a feature — it silently stops an agent's status, contexand the managed script's `curl -sS` has no `--fail`, so a 403 exits 0 and the node goes dark with noerror anywhere. `forged` is the single exception because nothing legitimate can produce it.+**A pre-upgrade codex session degrades to plain codex until it is relaunched.** Its launcher reads+the per-node capability from an env var this build no longer sets, and the value the previous build+put there is the OLD derivation (`base64url(HMAC(secret, nodeId))`, no dot), which the current+verifier reads as `legacy` — a 403 on `/codex-thread/{start,bind}`. There is no compat path and no+useful one to write: relaunching the node is the fix, and it takes one restart.+**Why `/context-link/*` refuses with prose and a 200.** The shim turns any non-200 into "Could notread linked context (nodeterm unreachable)". That would be a lie, and it tells the agent nothing itcan act on. A sentence it can read is the better failure.diff --git a/src/core/codex-identity-proxy.ts b/src/core/codex-identity-proxy.tsindex 34ef36022..ce0c955bd 100644--- a/src/core/codex-identity-proxy.ts+++ b/src/core/codex-identity-proxy.ts@@ -344,12 +344,17 @@ nt_preflight() {# THIS node id — a lookup by name, never a scan, so a session can only ever present its own. It# is deliberately NOT an env var any more: that channel put the credential on the tmux \`-e\`# argv, world-readable on a stock Linux, and the credential's whole job is to prove WHICH node- # is calling. \$NODETERM_CODEX_NODE_TOKEN survives only as a one-release fallback for a session- # spawned by the previous build, which carries the var and has no file yet.+ # is calling.+ #+ # There is deliberately NO \$NODETERM_CODEX_NODE_TOKEN fallback. One shipped, for a session the+ # previous build spawned, and it could never have worked: that build's value is the OLD+ # derivation — base64url(HMAC(secret, nodeId)), no dot — which the current verifier reads as a+ # foreign kid, i.e. \`legacy\`, and /codex-thread/{start,bind} demand \`verified\`. So it 403s and+ # the launcher degrades anyway, one round-trip later. A pre-upgrade codex session runs plain+ # codex until it is relaunched; that is the honest behaviour, not a regression from the fallback.if [ -n "\${NODETERM_NODE_TOKEN_DIR-}" ]; thennt_node_token=$(head -n 1 "$NODETERM_NODE_TOKEN_DIR/$NODETERM_NODE_ID" 2>/dev/null) || nt_node_token=''fi- [ -n "$nt_node_token" ] || nt_node_token="\${NODETERM_CODEX_NODE_TOKEN-}"# The '.' IS the token: the wire shape is kid.mac (one derivation shared with /hook/*). A gate# without the dot rejects every token this app mints and degrades every codex node to plain# codex — silently, because falling back is what this script is built to do.diff --git a/src/core/codex-launcher-sh.test.ts b/src/core/codex-launcher-sh.test.tsindex 0cda48311..684c6870e 100644--- a/src/core/codex-launcher-sh.test.ts+++ b/src/core/codex-launcher-sh.test.ts@@ -12,7 +12,7 @@ import fs from 'node:fs'import os from 'node:os'import path from 'node:path'import { promisify } from 'node:util'-import { randomBytes } from 'node:crypto'+import { createHmac, randomBytes } from 'node:crypto'import { buildCodexLauncherScript } from './codex-identity-proxy'import { hookServer } from './agents/hook-server'import { nodeAuthKid, nodeAuthToken } from './agents/node-auth-token'@@ -297,20 +297,28 @@ describe('the per-node capability, over the file channel', () => {expect(fallbacks).toEqual([])})- it('prefers the FILE over a stale env var left over from a pre-upgrade session', async () => {- // Charset-valid but wrong. If the env var won, the route would 403 and the node would degrade.+ it('is unmoved by a stale env var left over from a pre-upgrade session', async () => {+ // Charset-valid but minted for the WRONG node. If anything still read that variable, the route+ // would 403 and this node would degrade to plain codex.await callLauncher([], { NODETERM_CODEX_NODE_TOKEN: nodeAuthToken(SECRET, 'node-2') })expect(started).toEqual([{ nodeId: 'node-1', cwd: fs.realpathSync(dir) }])expect(fallbacks).toEqual([])})- it('still honors the env var for one release, when no file was materialised', async () => {- // A session spawned by the previous build carries the var and has no token file yet.+ it('ignores NODETERM_CODEX_NODE_TOKEN entirely — the "one release" fallback was never real', async () => {+ // The fallback shipped for "a session spawned by the previous build", and the test that+ // certified it fed a NEW-format token into the OLD variable — an input the previous build never+ // produced. What that build actually set is base64url(HMAC(secret, nodeId)) with NO dot, which+ // the current verifier reads as a foreign kid ⇒ `legacy` ⇒ 403 on /codex-thread/{start,bind}.+ // So the fallback bought one wasted round-trip and the same degrade. A pre-upgrade session runs+ // plain codex until it is relaunched.sweepNodeTokenFile('node-1')fs.rmSync(path.join(nodeTokenDir(), 'node-1'), { force: true })- await callLauncher([], { NODETERM_CODEX_NODE_TOKEN: nodeAuthToken(SECRET, 'node-1') })- expect(started).toEqual([{ nodeId: 'node-1', cwd: fs.realpathSync(dir) }])- expect(fallbacks).toEqual([])+ const oldFormat = createHmac('sha256', SECRET).update('node-1').digest('base64url')+ expect(oldFormat).not.toContain('.') // the shape the previous build actually wrote+ await callLauncher([], { NODETERM_CODEX_NODE_TOKEN: oldFormat })+ expect(started).toEqual([])+ expect(fallbacks).toEqual([{ nodeId: 'node-1', reason: 'node-token-unavailable' }])})it('a missing token file and no env var → node-token-unavailable → plain codex', async () => {diff --git a/src/main/index.ts b/src/main/index.tsindex 443de37ac..b04f75c1b 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -1787,12 +1787,12 @@ app.whenReady().then(async () => {return isSafeRemoteTranscriptPath(abs, remoteHome) ? abs : undefined}const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])- // nodeId → did its LAST hook POST carry a token this instance minted for it. Recorded only;- // nothing reads it yet, and nothing here may branch on it (a `false` is the ordinary case for any- // client that predates the token — see HookEventMeta). The Server Edition keeps the same map.- const nodeVerified = new Map<string, boolean>()- hookServer.setRawListener((agentId, nodeId, payload, meta) => {- if (nodeId) nodeVerified.set(nodeId, meta.verified)+ // `meta` carries the per-node `verified` flag and is deliberately UNUSED here: A13 moved+ // enforcement into the hook server, which refuses before a listener is ever called. This shell+ // used to keep a `nodeVerified` map written on every event and read by nothing. The parameter+ // stays because the flag is part of the listener contract and both shells must take it+ // (invariant 4, pinned by hook-verified-parity.test.ts); a second copy of the answer is not.+ hookServer.setRawListener((agentId, nodeId, payload, _meta) => {if (agentId === 'grok') {// This branch records two associations, neither of which grok's envelope states outright.// Everything the claude path does below hangs off `transcript_path`, and grok has none.diff --git a/src/server/agent-status.ts b/src/server/agent-status.tsindex 748f0776c..fda130412 100644--- a/src/server/agent-status.ts+++ b/src/server/agent-status.ts@@ -165,12 +165,12 @@ export function wireAgentStatus(}const SUBAGENT_TOOLS = new Set(['Agent', 'Task'])- // nodeId → did its LAST hook POST carry a token this instance minted for it. Recorded only;- // nothing reads it yet, and nothing here may branch on it (a `false` is the ordinary case for any- // client that predates the token — see HookEventMeta). The desktop shell keeps the same map.- const nodeVerified = new Map<string, boolean>()- hooks.setRawListener((agentId, nodeId, payload, meta) => {- if (nodeId) nodeVerified.set(nodeId, meta.verified)+ // `meta` carries the per-node `verified` flag and is deliberately UNUSED here: A13 moved+ // enforcement into the hook server, which refuses before a listener is ever called. This shell+ // used to keep a `nodeVerified` map written on every event and read by nothing. The parameter+ // stays because the flag is part of the listener contract and both shells must take it+ // (invariant 4, pinned by hook-verified-parity.test.ts); a second copy of the answer is not.+ hooks.setRawListener((agentId, nodeId, payload, _meta) => {if (agentId === 'grok') {// This branch records two associations, neither of which grok's envelope states outright.// Everything the claude path does below hangs off `transcript_path`, and grok has none.