Skip to content

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.

fix(security): keep the identity latch from stranding a live node

Claude Coded6adb158676a
diff --git a/src/core/agents/hook-identity-enforcement.test.ts b/src/core/agents/hook-identity-enforcement.test.ts
index cbb796f11..4d1e0608f 100644
--- a/src/core/agents/hook-identity-enforcement.test.ts
+++ b/src/core/agents/hook-identity-enforcement.test.ts
@@ -12,12 +12,14 @@
// - the dated window: an unverified mutation EXECUTES and carries the restart line until
// 2026-10-13, and is refused with the same shape afterwards.
// - `write`/`close` keep their user confirmation whatever the token says.
-import { describe, it, expect, beforeAll, afterAll, beforeEach } from 'vitest'
-import { mkdtempSync, rmSync, readdirSync, readFileSync, statSync } from 'node:fs'
+import { describe, it, expect, beforeAll, afterAll, beforeEach, vi } from 'vitest'
+import { existsSync, mkdtempSync, rmSync, readdirSync, readFileSync, statSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join, resolve } from 'node:path'
import { hookServer } from './hook-server'
import { nodeAuthToken } from './node-auth-token'
+import { nodeTokenDir } from './node-token-files'
+import { initNodeTokens, refreshNodeTokens, sweepNodeToken } from './node-token-service'
import {
IDENTITY_REFUSED_NOTE,
IDENTITY_RESTART_NOTE,
@@ -343,6 +345,70 @@ describe('both shells wire the escape hatch', () => {
})
})
+/**
+ * Sweeping a node's token WITHOUT releasing the latch is the one way this feature can kill a live
+ * node outright: the latch refuses an unverified caller immediately, on both sides of the cutoff,
+ * so the node gets a hard 403 on every canvas-control call for the rest of the session — advised to
+ * restart to pick up an identity there is no longer one to pick up.
+ *
+ * The collision case is the realistic one, and it is a sequence, not a state: the refusal in
+ * `node-token-service.ts` is what keeps a fold-collision from becoming a hijack, but it fires the
+ * moment the twin appears, which can be long after the first node materialised AND proved itself.
+ */
+describe('a swept token must also release the latch', () => {
+ it('un-proves a node whose case-folding twin turns up and gets the whole set refused', async () => {
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
+ let hostile = false
+ // 1. The node is alone on the canvas, so it gets a token file…
+ initNodeTokens({
+ canvases: () => [
+ { nodes: hostile ? [{ id: 'Term-1' }, { id: 'term-1' }] : [{ id: 'Term-1' }] }
+ ]
+ })
+ expect(existsSync(join(nodeTokenDir(), 'Term-1'))).toBe(true)
+ // …and its session proves itself with it.
+ expect((await hookEvent('Term-1', nodeAuthToken(SECRET, 'Term-1'))).status).toBe(204)
+ expect(hookServer.isNodeProven('Term-1')).toBe(true)
+
+ // 2. A shared `project.json` puts the case-variant twin on the canvas. Both are refused tokens
+ // and both files are swept — correctly: on APFS they are one file, and leaving either is the
+ // hijack. Those nodes belong on `legacy`.
+ hostile = true
+ refreshNodeTokens()
+ 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.
+ 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(controlCalls).toEqual([{ verb: 'open-terminal', nodeId: 'Term-1' }])
+ warn.mockRestore()
+ })
+
+ it('un-proves a node whose token is swept on delete, closing the re-create gap', async () => {
+ // Delete/re-create reuses the id: A6 sweeps the file and rewrites it, and a shell reading in
+ // that gap is tokenless while the node is still latched from before the delete.
+ initNodeTokens({ canvases: () => [{ nodes: [{ id: 'n-recreate' }] }] })
+ expect((await hookEvent('n-recreate', nodeAuthToken(SECRET, 'n-recreate'))).status).toBe(204)
+ expect(hookServer.isNodeProven('n-recreate')).toBe(true)
+ sweepNodeToken('n-recreate')
+ expect(hookServer.isNodeProven('n-recreate')).toBe(false)
+ expect((await control('open-terminal', 'n-recreate')).status).toBe(200)
+ })
+
+ it('re-earns the latch on the very next valid event — releasing it costs nothing', async () => {
+ initNodeTokens({ canvases: () => [{ nodes: [{ id: 'n-relatch' }] }] })
+ expect((await hookEvent('n-relatch', nodeAuthToken(SECRET, 'n-relatch'))).status).toBe(204)
+ sweepNodeToken('n-relatch')
+ expect(hookServer.isNodeProven('n-relatch')).toBe(false)
+ expect((await hookEvent('n-relatch', nodeAuthToken(SECRET, 'n-relatch'))).status).toBe(204)
+ expect(hookServer.isNodeProven('n-relatch')).toBe(true)
+ expect((await control('open-terminal', 'n-relatch')).status).toBe(403)
+ })
+})
+
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.ts
index 7f49e3016..4a0ae12f8 100644
--- a/src/core/agents/hook-server.ts
+++ b/src/core/agents/hook-server.ts
@@ -228,6 +228,26 @@ class HookServer {
return this.provenNodes.has(nodeId)
}
+ /**
+ * Drop a node from the latch — called whenever its token file is SWEPT
+ * (`node-token-service.ts`), local or remote.
+ *
+ * The latch says "this node can authenticate, so a caller that cannot is not it". Sweeping the
+ * token takes that ability away, and a latch left standing over a node that no longer has a token
+ * to read is a hard 403 on every canvas-control call for the life of the session, with no window
+ * and no advice that works. The two ways in are both real: a case-folding collision (a hostile or
+ * merely careless `project.json` adds `term-1` beside a `Term-1` that had already proven itself,
+ * and the whole colliding set is refused tokens by design), and a node deleted and re-created
+ * with the same id.
+ *
+ * Un-proving is cheap to get wrong in the other direction and it does not matter: the node
+ * re-proves on its very next hook event carrying a valid token, which is the same ceremony a
+ * restart performs. Fail-open is the designed state of this whole series.
+ */
+ forgetProvenNode(nodeId: string): void {
+ this.provenNodes.delete(nodeId)
+ }
+
setControlHandler(cb: NonNullable<HookServer['controlHandler']>): void {
this.controlHandler = cb
}
diff --git a/src/core/agents/node-identity-policy.test.ts b/src/core/agents/node-identity-policy.test.ts
index d57c41562..9b74ca26b 100644
--- a/src/core/agents/node-identity-policy.test.ts
+++ b/src/core/agents/node-identity-policy.test.ts
@@ -7,9 +7,12 @@ import {
CONTEXT_LINK_POLICY_VERB,
IDENTITY_REFUSED_NOTE,
IDENTITY_RESTART_NOTE,
+ isStrictInstant,
+ NODE_IDENTITY_CLOCK_HORIZON_MS,
NODE_IDENTITY_STRICT_AFTER,
TOLERANT_CONTROL_VERBS
} from './node-identity-policy'
+import { NODE_IDENTITY_STRICT_DATE } from '@shared/node-identity'
const BEFORE = new Date('2026-09-01T00:00:00Z')
const AFTER = new Date('2026-11-01T00:00:00Z')
@@ -25,6 +28,14 @@ describe('the cutoff is a dated commitment, not a "later"', () => {
expect(IDENTITY_RESTART_NOTE).toContain('2026-10-13')
})
+ it('is built from the ONE date string the Settings row also prints', () => {
+ // The renderer cannot import this module, so the date lives in @shared and both sides derive
+ // from it. A Settings page promising a different cutoff than the server enforces would be the
+ // worst possible version of this feature.
+ expect(NODE_IDENTITY_STRICT_DATE).toBe('2026-10-13')
+ expect(NODE_IDENTITY_STRICT_AFTER.toISOString().slice(0, 10)).toBe(NODE_IDENTITY_STRICT_DATE)
+ })
+
it('names the action in both sentences, so the user is told what to do', () => {
for (const note of [IDENTITY_RESTART_NOTE, IDENTITY_REFUSED_NOTE]) {
expect(note).toContain('Restart agent')
@@ -135,6 +146,51 @@ describe('controlPolicy', () => {
})
})
+ describe('a machine clock that is not to be believed', () => {
+ // A VM restored from a snapshot, a board whose RTC came up wrong, a clock somebody set forward:
+ // the cutoff is read against `Date.now()`, so any of them puts an ordinary install into strict
+ // mode on day one, with no warning window at all and a refusal naming a date "already past".
+ // Nothing distinguishes that from an install genuinely still running years later — so the tie
+ // goes to the fail-open direction the rest of this file takes.
+ const cutoff = NODE_IDENTITY_STRICT_AFTER.getTime()
+ const wayAhead = new Date(cutoff + NODE_IDENTITY_CLOCK_HORIZON_MS + 1)
+
+ it('enforces normally right up to the horizon', () => {
+ expect(isStrictInstant(new Date(cutoff))).toBe(true)
+ expect(isStrictInstant(new Date(cutoff + NODE_IDENTITY_CLOCK_HORIZON_MS - 1))).toBe(true)
+ })
+
+ it('stops believing the clock past the horizon and keeps the window open', () => {
+ expect(isStrictInstant(wayAhead)).toBe(false)
+ expect(isStrictInstant(new Date('2038-01-01T00:00:00Z'))).toBe(false)
+ expect(
+ controlPolicy({ verdict: 'legacy', proven: false, verb: MUTATION, now: wayAhead })
+ ).toBe('allow-with-warning')
+ })
+
+ it('does not disarm the LATCH, which is the actual security boundary here', () => {
+ // The clamp only ever relaxes the DATE. A node that has proven itself is still refused when
+ // an unverified caller turns up for it — that is what makes the clamp cheap.
+ expect(controlPolicy({ verdict: 'legacy', proven: true, verb: MUTATION, now: wayAhead })).toBe(
+ 'refuse'
+ )
+ expect(controlPolicy({ verdict: 'forged', proven: false, verb: TOLERANT, now: wayAhead })).toBe(
+ 'refuse'
+ )
+ })
+
+ it('still lets an explicit `true` enforce, wherever the clock thinks it is', () => {
+ // The clamp disbelieves the CLOCK, not the user. Someone who asked for strict gets strict.
+ expect(
+ controlPolicy({ verdict: 'legacy', proven: false, verb: MUTATION, now: wayAhead, override: true })
+ ).toBe('refuse')
+ })
+
+ it('treats an invalid Date as not-strict rather than throwing', () => {
+ expect(isStrictInstant(new Date('nonsense'))).toBe(false)
+ })
+ })
+
describe('the hookIdentityStrict escape hatch', () => {
it('undefined follows the constant', () => {
expect(
diff --git a/src/core/agents/node-identity-policy.ts b/src/core/agents/node-identity-policy.ts
index ba8983221..304ff1873 100644
--- a/src/core/agents/node-identity-policy.ts
+++ b/src/core/agents/node-identity-policy.ts
@@ -22,20 +22,69 @@
* same situation is a refusal. The date is in the source, not in a comment saying "later":
* a tightening with no date is a tightening that never happens.
*/
+import { NODE_IDENTITY_STRICT_DATE } from '@shared/node-identity'
import type { NodeTokenVerdict } from './node-auth-token'
/**
* When an unverified mutation stops executing and starts being refused.
*
- * The owner's rule was "the second minor release OR 60 days after the shipping release, whichever
- * is LATER", resolved here to the concrete instant that rule lands on. Resolved, not computed: a
- * date the code can print is a date a user can plan around, and a rule that has to be re-derived
- * from a release calendar is a rule that quietly never fires. Also in docs/node-identity.md.
+ * Built from the ONE date string in `@shared/node-identity` — the Settings row prints that same
+ * string, and the renderer cannot import this file. See there for where the date comes from.
*/
-export const NODE_IDENTITY_STRICT_AFTER = new Date('2026-10-13T00:00:00Z')
+export const NODE_IDENTITY_STRICT_AFTER = new Date(`${NODE_IDENTITY_STRICT_DATE}T00:00:00Z`)
-/** The date as the user reads it. Derived, so the sentence and the constant cannot drift apart. */
-const STRICT_DATE = NODE_IDENTITY_STRICT_AFTER.toISOString().slice(0, 10)
+const STRICT_DATE = NODE_IDENTITY_STRICT_DATE
+
+/**
+ * How far past the cutoff the LOCAL CLOCK may read before the cutoff stops being believed at all.
+ *
+ * The cutoff is compared against `Date.now()`, and a machine clock is not evidence. A VM restored
+ * from a snapshot, a board whose RTC came up wrong, or a clock somebody set forward on purpose can
+ * put a perfectly ordinary install years into the future — and it then enters strict mode on day
+ * one, with no warning window, refusing every unverified mutation with a sentence naming a date
+ * that has "already passed". The symptom reads as "the token is broken", so nobody looks at the
+ * clock, and the escape hatch is the last place they think to go.
+ *
+ * There is no way to tell that case apart from an install genuinely still running years after the
+ * cutoff: an old binary can run forever, so `now` far ahead of anything in this source proves
+ * nothing on its own. Since the two are indistinguishable, the tie is broken by which mistake is
+ * worse — and the whole series fails OPEN by design, so the answer is to keep the window open.
+ *
+ * That costs almost nothing, because **the cutoff is not the security boundary — the latch is.**
+ * Trust on first proof refuses an unverified caller for a node that has ever proven itself,
+ * immediately, on both sides of the cutoff and regardless of this clamp. What the cutoff governs is
+ * only the population that has NEVER proven anything, i.e. exactly the pre-token sessions the
+ * warning window exists for, and fail-open is that population's designed state.
+ *
+ * Two years, because that is comfortably longer than the upgrade population survives (tmux sessions
+ * and un-updated installs do not last it out) and comfortably shorter than the clock skews that
+ * actually occur, which are measured in decades (an RTC default year, an epoch reset, a licence
+ * clock set forward).
+ *
+ * The same reasoning as `license.ts`'s rollback anchor, pointed the other way: there, the clock
+ * direction the USER benefits from (setting it back to revive an expired token) is the one that is
+ * refused, via `Math.max(Date.now(), lastSeen)`. Here the direction a user benefits from is setting
+ * the clock BACK to dodge the cutoff — and that buys them nothing worth defending, because
+ * `hookIdentityStrict: false` grants exactly the same thing with one click. So there is no security
+ * to trade away by disbelieving a clock that reads absurdly far forward; there is only a silent
+ * day-one lockout to remove.
+ */
+export const NODE_IDENTITY_CLOCK_HORIZON_MS = 2 * 365 * 24 * 60 * 60 * 1000
+
+/**
+ * Is `now` an instant at which the dated cutoff should be enforced?
+ *
+ * Clamped at BOTH ends: before the cutoff the window is open (the point of the window), and beyond
+ * `NODE_IDENTITY_CLOCK_HORIZON_MS` past it the clock is not believed and the window is open again.
+ * Exported so the clamp is testable as a rule rather than only through `controlPolicy`'s table.
+ */
+export function isStrictInstant(now: Date): boolean {
+ const t = now.getTime()
+ const cutoff = NODE_IDENTITY_STRICT_AFTER.getTime()
+ // NaN (an invalid Date from a broken injected clock) fails both comparisons ⇒ not strict, which
+ // is the fail-open direction this whole file takes.
+ return t >= cutoff && t < cutoff + NODE_IDENTITY_CLOCK_HORIZON_MS
+}
/**
* Prefixed onto the reply of an unverified mutation that STILL RAN.
@@ -134,6 +183,8 @@ export function controlPolicy({
}
if (proven) return 'refuse'
if (TOLERANT_CONTROL_VERBS.has(verb)) return 'allow'
- const strict = override ?? now.getTime() >= NODE_IDENTITY_STRICT_AFTER.getTime()
+ // `isStrictInstant`, not a bare `>=`: a machine clock years ahead of the cutoff would otherwise
+ // put this install in strict mode on day one with no warning window at all. See the constant.
+ const strict = override ?? isStrictInstant(now)
return strict ? 'refuse' : 'allow-with-warning'
}
diff --git a/src/core/agents/node-token-service.ts b/src/core/agents/node-token-service.ts
index cc72a8336..1ec447c83 100644
--- a/src/core/agents/node-token-service.ts
+++ b/src/core/agents/node-token-service.ts
@@ -61,6 +61,25 @@ function collidingGroups(ids: Iterable<string>): Map<string, string[]> {
return colliding
}
+/**
+ * Every sweep in this file goes through here, and never through `sweepNodeTokenFile` directly.
+ *
+ * Taking a node's token away and LEAVING it in the trust-on-first-proof latch is the one way this
+ * feature can strand a live session: the latch refuses an unverified caller immediately, on both
+ * sides of the cutoff, so a node that proved itself and then had its file swept gets a hard 403 on
+ * every canvas-control call for the rest of the session — with a sentence telling it to restart to
+ * pick up an identity there is no longer one to pick up. The realistic sequence is exactly the
+ * collision case below: `Term-1` boots alone, materialises, proves itself; a shared `project.json`
+ * later puts `term-1` on the canvas; the next persist refuses the whole set and sweeps both files.
+ *
+ * The refusal itself is right — those nodes belong on `legacy`, the designed fail-open state — so
+ * the fix is to put them all the way back on it, latch included.
+ */
+function sweepToken(nodeId: string): void {
+ sweepNodeTokenFile(nodeId)
+ hookServer.forgetProvenNode(nodeId)
+}
+
/** Loud on purpose: this is the only signal that a node is on `legacy` for a reason. */
function warnCollision(group: readonly string[]): void {
console.warn(
@@ -110,14 +129,14 @@ export function ensureNodeToken(nodeId: string, opts?: { force?: boolean }): voi
const group = collidingGroups([...canvasNodeIds(), nodeId]).get(nodeId)
if (group) {
warnCollision(group)
- for (const id of group) sweepNodeTokenFile(id)
+ for (const id of group) sweepToken(id)
return
}
materialiseOne(secret, nodeId, opts?.force ?? false)
}
export function sweepNodeToken(nodeId: string): void {
- sweepNodeTokenFile(nodeId)
+ sweepToken(nodeId)
}
/** The node ids of ONE persisted canvas. The remote materialiser is per SSH project, not global:
@@ -146,6 +165,11 @@ export function remoteNodeTokenMinter(): ((nodeId: string) => string) | null {
const group = collidingGroups([...canvasNodeIds(), nodeId]).get(nodeId)
if (group) {
warnCollision(group)
+ // The latch is keyed by node id and is instance-global — an SSH node proves itself over the
+ // same hook server — so a refusal here has to release it too, or the remote node is stranded
+ // exactly as a local one would be. The FILE lives on the host and the caller sweeps it there;
+ // only the latch is ours to clear.
+ hookServer.forgetProvenNode(nodeId)
return ''
}
return nodeAuthToken(secret, nodeId)
@@ -193,8 +217,10 @@ export function refreshNodeTokens(opts?: { force?: boolean }): void {
for (const group of new Set(colliding.values())) {
warnCollision(group)
// Sweep, don't merely skip: an earlier pass may have written one of these before its twin
- // appeared on the canvas, and that surviving file is the token the twin would read.
- for (const id of group) sweepNodeTokenFile(id)
+ // appeared on the canvas, and that surviving file is the token the twin would read. `sweepToken`
+ // (not `sweepNodeTokenFile`) because that same earlier pass may already have let the node PROVE
+ // itself, and a latch outliving the token is a permanent 403 — see the helper.
+ for (const id of group) sweepToken(id)
}
for (const id of new Set(ids)) {
if (colliding.has(id)) continue
diff --git a/src/renderer/components/settings/sections/AgentsSection.identity.test.tsx b/src/renderer/components/settings/sections/AgentsSection.identity.test.tsx
new file mode 100644
index 000000000..f8fbf9eed
--- /dev/null
+++ b/src/renderer/components/settings/sections/AgentsSection.identity.test.tsx
@@ -0,0 +1,101 @@
+// @vitest-environment jsdom
+//
+// The escape hatch has to exist IN THE UI, because the situations it rescues are exactly the ones
+// where the user cannot tell what went wrong: canvas control stops working and the reply says the
+// node has no identity. A hatch that can only be reached by hand-editing settings.json is a hatch
+// only the author knows about.
+//
+// Two properties, and the tri-state is the whole point of both:
+// - `undefined` (follow the dated rollout) is a THIRD value, not a synonym for `false`. Rendering
+// this as a Switch would collapse the default into one of the two explicit answers the first
+// time anybody touched the row.
+// - the date the row prints is the date the hook server enforces. One string, imported.
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
+import { act } from 'react'
+import { createRoot, type Root } from 'react-dom/client'
+import { NODE_IDENTITY_STRICT_DATE } from '@shared/node-identity'
+import { useSettings } from '../../../state/settings'
+import { AgentsSection } from './AgentsSection'
+
+;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
+
+let root: Root
+let host: HTMLElement
+
+function select(): HTMLSelectElement {
+ const el = host.querySelector<HTMLSelectElement>(
+ 'select[aria-label="Require verified node identity"]'
+ )
+ expect(el, 'the identity row must be in the Agents section').toBeTruthy()
+ return el!
+}
+
+/** Drive the native <select> the way React sees a user changing it. */
+function choose(value: string): void {
+ const el = select()
+ act(() => {
+ el.value = value
+ el.dispatchEvent(new Event('change', { bubbles: true }))
+ })
+}
+
+beforeEach(async () => {
+ // The section probes the local Claude CLI on mount; the probe swallows its own failures, but a
+ // real `window.nodeTerminal` keeps the settings store's coalesced save from throwing later.
+ ;(window as unknown as { nodeTerminal: unknown }).nodeTerminal = {
+ settings: { save: vi.fn(async () => undefined) },
+ claude: { cliCaps: vi.fn(async () => null) }
+ }
+ useSettings.setState((s) => ({ settings: { ...s.settings, hookIdentityStrict: undefined } }))
+ host = document.createElement('div')
+ document.body.appendChild(host)
+ root = createRoot(host)
+ await act(async () => {
+ root.render(<AgentsSection isActive />)
+ })
+})
+
+afterEach(() => {
+ act(() => root.unmount())
+ host.remove()
+ useSettings.setState((s) => ({ settings: { ...s.settings, hookIdentityStrict: undefined } }))
+})
+
+describe('the node-identity escape hatch in Settings', () => {
+ it('offers three choices, because the setting is a tri-state', () => {
+ expect([...select().options].map((o) => o.value)).toEqual(['auto', 'on', 'off'])
+ })
+
+ it('shows the default as Automatic while the setting is absent', () => {
+ expect(select().value).toBe('auto')
+ })
+
+ it('writes `false` for "Not required" — the state a stranded user needs', () => {
+ choose('off')
+ expect(useSettings.getState().settings.hookIdentityStrict).toBe(false)
+ })
+
+ it('writes `true` for "Always required" (opt in before the date)', () => {
+ choose('on')
+ expect(useSettings.getState().settings.hookIdentityStrict).toBe(true)
+ })
+
+ it('writes `undefined`, NOT `false`, when the user goes back to Automatic', () => {
+ // The distinction this test exists for: `false` is a permanent opt-out that survives the
+ // cutoff, `undefined` is "follow the rollout". Mapping Automatic onto `false` would quietly
+ // opt every user who ever opened this row out of the feature.
+ choose('off')
+ choose('auto')
+ expect(useSettings.getState().settings.hookIdentityStrict).toBeUndefined()
+ })
+
+ it('tells the user what it does, in their terms, and names the cutoff date', () => {
+ const text = host.textContent ?? ''
+ expect(text).toContain('Require verified node identity for canvas control')
+ // The date is imported from @shared, never typed into the copy: a Settings page promising a
+ // different cutoff from the one the hook server enforces is worse than no copy at all.
+ expect(text).toContain(NODE_IDENTITY_STRICT_DATE)
+ // …and it says what turning it off buys, since that is the sentence a stranded user is hunting.
+ expect(text).toMatch(/restores the behaviour from before this feature/)
+ })
+})
diff --git a/src/renderer/components/settings/sections/AgentsSection.tsx b/src/renderer/components/settings/sections/AgentsSection.tsx
index 2777db04c..377ed6bda 100644
--- a/src/renderer/components/settings/sections/AgentsSection.tsx
+++ b/src/renderer/components/settings/sections/AgentsSection.tsx
@@ -23,6 +23,7 @@ import {
} from '@shared/agents/approval-mode'
import { AgentIcon } from '../../../lib/agentIcons'
import { hintLabel } from '@shared/platform-utils'
+import { NODE_IDENTITY_STRICT_DATE } from '@shared/node-identity'
import { SegmentedPill } from '@renderer/ui/SegmentedPill'
import { Button } from '@renderer/ui/Button'
import { Select } from '@renderer/ui/Select'
@@ -61,6 +62,22 @@ const ROWS = {
title: 'One-click approvals',
keywords: ['approve', 'deny', 'approval', 'permission', 'hook', 'phone', 'canvas', 'one click', 'claude']
},
+ nodeIdentity: {
+ title: 'Verified node identity',
+ keywords: [
+ 'identity',
+ 'verify',
+ 'verified',
+ 'node',
+ 'token',
+ 'canvas control',
+ 'context link',
+ 'security',
+ 'hook',
+ 'strict',
+ 'refused'
+ ]
+ },
hibernation: {
title: 'Hibernate idle agents',
keywords: [
@@ -102,6 +119,33 @@ function permissionModeDescription(): string {
// capable list cannot change while the app runs.
const otherModeAgents = permissionModeAgentIds({ exclude: ['claude'] })
+/**
+ * `settings.hookIdentityStrict` is the only OPTIONAL key in `Settings`, because it is a TRI-state
+ * and `undefined` ("follow the dated rollout") is a different answer from `false` ("never enforce").
+ * A `Switch` cannot express that — it would silently collapse the default into one of the two
+ * explicit choices the first time anybody touched it — so this row is a `Select` over three values
+ * that map back onto `boolean | undefined`.
+ *
+ * The date is imported, never typed here: a Settings page promising a different cutoff from the one
+ * the hook server enforces is the worst possible version of this feature.
+ */
+const IDENTITY_CHOICES = ['auto', 'on', 'off'] as const
+type IdentityChoice = (typeof IDENTITY_CHOICES)[number]
+
+const IDENTITY_LABELS: Record<IdentityChoice, string> = {
+ auto: `Automatic (required from ${NODE_IDENTITY_STRICT_DATE})`,
+ on: 'Always required',
+ off: 'Not required'
+}
+
+function identityChoice(value: boolean | undefined): IdentityChoice {
+ return value === undefined ? 'auto' : value ? 'on' : 'off'
+}
+
+function identityValue(choice: IdentityChoice): boolean | undefined {
+ return choice === 'auto' ? undefined : choice === 'on'
+}
+
export function AgentsSection({ isActive }: { isActive: boolean }): React.JSX.Element {
const settings = useSettings((s) => s.settings)
const update = useSettings((s) => s.update)
@@ -218,6 +262,27 @@ export function AgentsSection({ isActive }: { isActive: boolean }): React.JSX.El
}
/>
</SearchableRow>
+ <SearchableRow {...ROWS.nodeIdentity}>
+ <FieldRow
+ label="Require verified node identity for canvas control"
+ description={`Commands that open, write to or close nodes — and that read a linked node's context — must present the identity NodeTerm issued to the node they say they came from. Automatic starts refusing the ones that can't from ${NODE_IDENTITY_STRICT_DATE}; until then they still run and the reply tells you to restart that node. Set this to "Not required" if an upgrade left a running session unable to drive the canvas: it restores the behaviour from before this feature, past ${NODE_IDENTITY_STRICT_DATE} as well. An identity that is actually forged is refused whatever you pick here.`}
+ control={
+ <Select
+ aria-label="Require verified node identity"
+ value={identityChoice(settings.hookIdentityStrict)}
+ onChange={(e) =>
+ update({ hookIdentityStrict: identityValue(e.target.value as IdentityChoice) })
+ }
+ >
+ {IDENTITY_CHOICES.map((c) => (
+ <option key={c} value={c}>
+ {IDENTITY_LABELS[c]}
+ </option>
+ ))}
+ </Select>
+ }
+ />
+ </SearchableRow>
<SearchableRow {...ROWS.hibernation}>
<FieldRow
label="Hibernate idle agents"
diff --git a/src/shared/node-identity.ts b/src/shared/node-identity.ts
new file mode 100644
index 000000000..4f2b6a8d1
--- /dev/null
+++ b/src/shared/node-identity.ts
@@ -0,0 +1,17 @@
+/**
+ * The one place the per-node identity cutoff DATE is written down.
+ *
+ * It lives in `@shared` rather than in the policy module because three parties have to agree on it
+ * and only one of them can import `src/core`: the policy itself
+ * (`src/core/agents/node-identity-policy.ts`, which builds the instant and the refusal sentences
+ * from it), the routes that apply it, and the **Settings row** in the renderer — and the renderer
+ * must never import the service core.
+ *
+ * A date the user reads in Settings that disagrees with the date the server enforces is the worst
+ * possible version of this feature, so there is exactly one string and everything else derives.
+ *
+ * The value is the owner's rule — *the second minor release or 60 days after the shipping release,
+ * whichever is later* — resolved to a concrete day. Resolved, not computed: a rule that has to be
+ * re-derived from a release calendar is a rule that quietly never fires. See docs/node-identity.md.
+ */
+export const NODE_IDENTITY_STRICT_DATE = '2026-10-13'