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
fix(identity): the sentence for a node that cannot mint was unreachable while it was needed
Claude Code3fbb17ae4f1a
diff --git a/docs/node-identity.md b/docs/node-identity.mdindex 6b999f898..a9c814cc5 100644--- a/docs/node-identity.md+++ b/docs/node-identity.md@@ -236,6 +236,14 @@ the handler never runs. The date is the owner's rule — *the second minor releashipping release, whichever is later* — resolved to a concrete instant. A tightening with no date isa tightening that never happens.+**Two sentences, because two populations.** The ordinary unverified node is told to restart to pick+one up (`IDENTITY_RESTART_NOTE`) — that is the common case and the restart works. A node that can+**never** mint (a case-fold collision member, or an id outside `isSafeNodeId` arriving from a shared+`project.json`) is told the cause instead and is never advised to restart, in the window+(`IDENTITY_UNMINTABLE_WARN_NOTE`) as well as after it (`IDENTITY_UNMINTABLE_NOTE`). The window is+where that matters most: it is the *whole period* those nodes still work, so a restart loop there+costs them the only time they had to fix the id.+The cutoff is read through **`isStrictInstant`**, not a bare `>=`. A machine clock more than`NODE_IDENTITY_CLOCK_HORIZON_MS` (2 years) past the cutoff is not believed and the window stays open:a VM restored from a snapshot or a board with a bad RTC would otherwise enter strict mode on day one,@@ -254,6 +262,15 @@ managed hook script presents the header, and the boot sweep materialises a tokenpersisted node — so a live Claude node is typically latched **within seconds of app start**. Fromthat moment, a tokenless caller naming it gets a hard 403, today, with no grace and no date.+**What makes a node `verified` is the SCRIPT, not the file.** Measured: a valid token file read by a+managed hook script from a build that predates the header is still `legacy` — the file only counts+once something sends it. Locally that is covered without a restart, because the boot-time hook+install rewrites the script in the same start-up that runs the boot sweep. **An SSH host's script is+rewritten only by `RemoteHooks.setup`, which runs on CONNECT**, so the remote nodes of a project that+is already connected stay `legacy` until that project reconnects — for a long-lived SSH project, that+can be a long time. Before the cutoff it costs them nothing but the note; on 2026-10-13 it becomes a+refusal, so "reconnect the SSH project" is part of this upgrade even though "restart the node" is not.+### ⚠ …and the latch is not a defence against an attacker**It catches a MISTAKE — a session that silently stopped presenting its token — and nothing else.**diff --git a/src/core/agents/hook-identity-enforcement.test.ts b/src/core/agents/hook-identity-enforcement.test.tsindex 5f37d9c90..5c4ba3e66 100644--- a/src/core/agents/hook-identity-enforcement.test.ts+++ b/src/core/agents/hook-identity-enforcement.test.ts@@ -24,6 +24,7 @@ import {IDENTITY_REFUSED_NOTE,IDENTITY_RESTART_NOTE,IDENTITY_UNMINTABLE_NOTE,+ IDENTITY_UNMINTABLE_WARN_NOTE,NODE_IDENTITY_STRICT_AFTER,TOLERANT_CONTROL_VERBS} from './node-identity-policy'@@ -459,11 +460,13 @@ describe('a swept token must also release the latch', () => {expect(existsSync(join(nodeTokenDir(), 'Term-1'))).toBe(false)// 3. The live session has nothing left to read, so its next call is tokenless. It must land- // back in the warning window, not on a permanent 403.+ // back in the warning window, not on a permanent 403 — and it must be told the truth about+ // WHY, because this node cannot mint until `project.json` changes. This assertion used to+ // read `IDENTITY_RESTART_NOTE`, which is the loop measured in the field.expect(hookServer.isNodeProven('Term-1')).toBe(false)const res = await control('open-terminal', 'Term-1')expect(res.status).toBe(200)- expect((await res.text()).startsWith(IDENTITY_RESTART_NOTE)).toBe(true)+ expect((await res.text()).startsWith(IDENTITY_UNMINTABLE_WARN_NOTE)).toBe(true)expect(controlCalls).toEqual([{ verb: 'open-terminal', nodeId: 'Term-1' }])warn.mockRestore()})@@ -567,6 +570,84 @@ describe('a node that can NEVER have an identity is told so, and not told to res})})+/**+ * THE WINDOW IS WHERE THAT SENTENCE WAS NEEDED, AND IT WAS THE ONE PLACE IT COULD NOT REACH.+ *+ * Measured against a real hook server on 2026-08-14: node `Term-X`, a refused case-fold collision+ * member, was handed `IDENTITY_RESTART_NOTE` — "Restart this node… to pick one up" — for a node+ * that has nothing to pick up. `controlPolicy` answers `allow-with-warning` for exactly this+ * population until 2026-10-13, and the warn branch emitted one fixed string, so the unmintable+ * wording only ever appeared AFTER the cutoff (or for a latched node). For the whole warning+ * window — the entire period the note exists to serve — its audience got the restart loop instead.+ */+describe('an unmintable node during the warning window, where the loop actually happens', () => {+ const collide = (a: string, b: string): void => {+ initNodeTokens({ canvases: () => [{ nodes: [{ id: a }, { id: b }] }] })+ }++ it('runs the command AND names the cause instead of advising a restart', async () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})+ try {+ collide('Warn-1', 'warn-1')+ const res = await control('open-terminal', 'Warn-1')+ // `allow-with-warning`, not a refusal: the window's promise is that the command still runs,+ // and an unmintable node is not a suspect — it is a node whose project.json is wrong.+ expect(res.status).toBe(200)+ expect(controlCalls).toEqual([{ verb: 'open-terminal', nodeId: 'Warn-1' }])+ const body = await res.text()+ expect(body.startsWith(IDENTITY_UNMINTABLE_WARN_NOTE)).toBe(true)+ expect(body).toContain('did open-terminal')+ expect(body).not.toContain(IDENTITY_RESTART_NOTE)+ } finally {+ warn.mockRestore()+ }+ })++ it('says it in the JSON dialect too, in the `warning` field a legacy client parses', async () => {+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})+ try {+ collide('Warn-2', 'warn-2')+ const res = await control('open-terminal', 'Warn-2', undefined, 'application/json')+ expect(res.status).toBe(200)+ expect(await res.json()).toEqual({+ ok: true,+ message: 'did open-terminal',+ warning: IDENTITY_UNMINTABLE_WARN_NOTE+ })+ expect(controlCalls).toHaveLength(1)+ } finally {+ warn.mockRestore()+ }+ })++ it('says it for an id `isSafeNodeId` refuses, which no materialiser pass has ever seen', async () => {+ // The `project.json` provenance case: `fileToProject` does not validate ids, so a shared repo+ // can put a space (or a slash, or `..`) on the canvas and `nodeAuthToken` returns '' forever.+ for (const nodeId of ['has space', 'a/b', '..']) {+ const res = await control('open-terminal', nodeId)+ expect(res.status, nodeId).toBe(200)+ expect((await res.text()).startsWith(IDENTITY_UNMINTABLE_WARN_NOTE), nodeId).toBe(true)+ }+ })++ it('leaves the ORDINARY unproven node on the restart line — that is the common case', async () => {+ const res = await control('open-terminal', 'n-ordinary-warning')+ expect(res.status).toBe(200)+ const body = await res.text()+ expect(body.startsWith(IDENTITY_RESTART_NOTE)).toBe(true)+ expect(body).not.toContain(IDENTITY_UNMINTABLE_WARN_NOTE)+ })++ it('never tells anyone to Restart, and still names the deadline', () => {+ // The whole point of the pair: no capitalised imperative, because that action cannot work…+ expect(IDENTITY_UNMINTABLE_WARN_NOTE).not.toContain('Restart')+ // …and the same date as the ordinary note, because the same cutoff ends the same window.+ expect(IDENTITY_UNMINTABLE_WARN_NOTE).toContain('2026-10-13')+ // It ran; a sentence copied from the refusal would say the opposite of what just happened.+ expect(IDENTITY_UNMINTABLE_WARN_NOTE).not.toContain('did not run')+ })+})+describe('the injected clock', () => {it('is what the cutoff is read against, so a suite crosses it without touching the machine', async () => {hookServer.setIdentityClockForTests(() => new Date(NODE_IDENTITY_STRICT_AFTER.getTime() - 1))diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.tsindex ab9cc443a..f6db80b68 100644--- a/src/core/agents/hook-server.ts+++ b/src/core/agents/hook-server.ts@@ -16,6 +16,7 @@ import {IDENTITY_REFUSED_NOTE,IDENTITY_RESTART_NOTE,IDENTITY_UNMINTABLE_NOTE,+ IDENTITY_UNMINTABLE_WARN_NOTE,type IdentityDecision} from './node-identity-policy'@@ -274,14 +275,37 @@ class HookServer {this.unmintableNodes.delete(nodeId)}+ /**+ * Can this node id NEVER hold a token, however often it is restarted?+ *+ * Two sources, and neither is recomputed here: the collision set the materialiser registers, and+ * the id itself — `isSafeNodeId` is precisely the predicate `nodeAuthToken` refuses on, so an id+ * it rejects mints '' forever.+ */+ private identityUnmintable(nodeId: string): boolean {+ return !isSafeNodeId(nodeId) || this.unmintableNodes.has(nodeId)+ }+/*** Which refusal sentence this node should hear. `IDENTITY_UNMINTABLE_NOTE` names the real cause* and deliberately does NOT advise a restart; see it for why that distinction is worth a Set.*/private identityRefusalNote(nodeId: string): string {- return !isSafeNodeId(nodeId) || this.unmintableNodes.has(nodeId)- ? IDENTITY_UNMINTABLE_NOTE- : IDENTITY_REFUSED_NOTE+ return this.identityUnmintable(nodeId) ? IDENTITY_UNMINTABLE_NOTE : IDENTITY_REFUSED_NOTE+ }++ /**+ * The same choice for the WARNING WINDOW, and the reason the unmintable sentence is reachable at+ * all before the cutoff.+ *+ * An unmintable node is `allow-with-warning` for the whole window — `controlPolicy` cannot see+ * that it is unmintable, and would not change its verdict if it could, because running is the+ * right answer there. So the window was the ONE period in which these nodes were guaranteed to be+ * told to "Restart this node… to pick one up", which is the loop `IDENTITY_UNMINTABLE_NOTE` was+ * written to end. The note was unreachable exactly while it was needed.+ */+ private identityWarningNote(nodeId: string): string {+ return this.identityUnmintable(nodeId) ? IDENTITY_UNMINTABLE_WARN_NOTE : IDENTITY_RESTART_NOTE}setControlHandler(cb: NonNullable<HookServer['controlHandler']>): void {@@ -433,7 +457,9 @@ class HookServer {const result = this.controlHandler? await this.controlHandler({ verb, nodeId, args }): { ok: false, error: 'control unavailable' }- const warn = decision === 'allow-with-warning'+ // Which note, not whether: an unmintable node warned with the restart line is sent round+ // the same loop the refusal path already knows better than to send it round.+ const note = decision === 'allow-with-warning' ? this.identityWarningNote(nodeId) : ''// The POSIX-sh shim asks for text/plain: it has no JSON parser, so the server does the// rendering the Node CLI used to do client-side. Everything else keeps the JSON shape.if (wantsText) {@@ -441,14 +467,14 @@ class HookServer {? result.message ?? JSON.stringify(result.result ?? {}): result.error ?? 'control request failed'res.writeHead(result.ok ? 200 : 400, { 'content-type': 'text/plain; charset=utf-8' })- res.end(warn ? `${IDENTITY_RESTART_NOTE}\n${text}\n` : `${text}\n`)+ res.end(note ? `${note}\n${text}\n` : `${text}\n`)return}res.writeHead(result.ok ? 200 : 400, { 'content-type': 'application/json' })// A field, not a prefix: the JSON dialect is a STRUCTURED reply a legacy client parses,// and folding the note into `message` would either hide `result` (text rendering falls// back to it only when `message` is absent) or corrupt a field somebody reads.- res.end(JSON.stringify(warn ? { ...result, warning: IDENTITY_RESTART_NOTE } : result))+ res.end(JSON.stringify(note ? { ...result, warning: note } : result))return}if (reqUrl.pathname.startsWith('/context-link/')) {diff --git a/src/core/agents/node-identity-policy.ts b/src/core/agents/node-identity-policy.tsindex 03433fa41..6c3e80057 100644--- a/src/core/agents/node-identity-policy.ts+++ b/src/core/agents/node-identity-policy.ts@@ -135,13 +135,38 @@ export const IDENTITY_REFUSED_NOTE =* loop while the only real signal — a `console.warn` in the main-process log — sits somewhere they* will never look. This sentence names the cause instead, refuses to advise a restart, and points* at both real ways out: fix the id, or use the escape hatch, which does release this.+ *+ * It is one of a PAIR: this is the refusal, `IDENTITY_UNMINTABLE_WARN_NOTE` is the same cause said+ * during the warning window, where the command ran. The two differ in one clause and share the+ * rest, because the cause and the way out do not depend on which side of the cutoff you are on.*/+const UNMINTABLE_CAUSE =+ 'this node can never present an identity, so restarting it will not help: its node id is ' ++ "invalid, or it collides with another node id in this project's project.json when letter case " ++ 'is ignored. Fix the duplicate or invalid id there, or turn off Settings → Agents → "Require ' ++ 'verified node identity for canvas control".'+export const IDENTITY_UNMINTABLE_NOTE =- 'NodeTerm could not confirm which node sent this command, so it did not run — and this node can ' +- 'never present an identity, so restarting it will not help: its node id is invalid, or it ' +- "collides with another node id in this project's project.json when letter case is ignored. Fix " +- 'the duplicate or invalid id there, or turn off Settings → Agents → "Require verified node ' +- 'identity for canvas control".'+ 'NodeTerm could not confirm which node sent this command, so it did not run — and ' ++ UNMINTABLE_CAUSE++/**+ * The same cause during the WARNING WINDOW, where the command still ran.+ *+ * This sentence is the whole reason the unmintable case needed a second one. `IDENTITY_UNMINTABLE_+ * NOTE` is a refusal and says "so it did not run"; the window is `allow-with-warning`, so pasting+ * the refusal on top of a reply that plainly DID run swaps one false sentence for another. And+ * `IDENTITY_RESTART_NOTE` — what these nodes got until now — is the exact loop the unmintable+ * wording exists to break, delivered for the entire window the note was written to serve: the user+ * restarts, the node still cannot mint, the note comes back unchanged.+ *+ * It keeps `IDENTITY_RESTART_NOTE`'s closing clause verbatim, because the deadline is the same one+ * and it is the part that makes the advice urgent: on the cutoff this stops being a note.+ */+export const IDENTITY_UNMINTABLE_WARN_NOTE =+ 'NodeTerm could not confirm which node sent this command, so it ran unverified — and ' ++ UNMINTABLE_CAUSE ++ ` From ${STRICT_DATE} commands from a session without an identity are refused.`/*** Control verbs that an unproven, unverified caller may still run after the cutoff.