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.

docs(identity): say plainly that the strict bucket is pre-positioned, and stop guessing a surface

Claude Code9f678d47f27a
diff --git a/docs/node-identity.md b/docs/node-identity.md
index b29854c26..7d0e52081 100644
--- a/docs/node-identity.md
+++ b/docs/node-identity.md
@@ -295,11 +295,14 @@ around. Anyone who can set the header can present an unjudgeable one, and the ap
it takes to set the header. So: the latch is a good bug-catcher and worth keeping; it is not a
boundary, and neither is the dated cutoff (the same probe walks past both).
-**The one place the probe stops.** A verb in `STRICT_CONTROL_VERBS` admits `verified` and nothing
-else, so a foreign kid — `legacy` by invariant 3 — is refused there with a flat sentence and no
-diagnosis. That is the only route in this document where the invented-kid escape does not apply, and
-it is affordable exactly because those verbs are new: there is no legacy population to strand, so
-nothing has to fail open. It buys nothing for the routes above, which keep the posture they have.
+**The one place the probe will stop — once there is anything in it.** A verb in
+`STRICT_CONTROL_VERBS` admits `verified` and nothing else, so a foreign kid — `legacy` by invariant
+3 — is refused there with a flat sentence and no diagnosis. That will be the only route in this
+document where the invented-kid escape does not apply, and it is affordable exactly because the
+verbs it is for are new: no legacy population to strand, so nothing has to fail open. **Today the
+set names a verb that does not exist yet** (see [The escape hatch](#the-escape-hatch)), so this
+changes nothing for any route currently reachable — every claim above still holds in full, and the
+probe still reaches `/control/list` and every `/context-link/*` verb.
**The real hardening, if it is ever wanted.** Scope the remote token dir as
`node-tokens/<kid>/<nodeId>` (already sketched in `writeNodeTokens`' own doc comment). The *only*
@@ -336,13 +339,29 @@ because it is a tri-state:
| `false` | Not required | Keep the warning window open past the date **and** release the latch. |
`false` is for a user whose upgrade strands a live session: it gets the canvas back without
-downgrading the app. Neither value ever admits a `forged` token, and neither releases a verb in
-**`STRICT_CONTROL_VERBS`** (today: `browser`) — that bucket is decided one line below the `forged`
-check, above every branch the hatch or the dated window can reach, and it admits `verified` only.
-The hatch exists to rescue a session that cannot present an identity; it must not double as a grant
-of the one capability where identity *is* the admission control. The cost is named rather than
-hidden: cross-instance failover loses those verbs, because another instance's token is a foreign
-kid and therefore `legacy`. Both shells wire it as a **live
+downgrading the app. Neither value ever admits a `forged` token.
+
+Neither releases a verb in **`STRICT_CONTROL_VERBS`** either — but **that set is pre-positioned and
+gates nothing today, and nobody's hatch has narrowed.** It contains one name, `browser`, which is
+**not a verb this app has**: `ControlVerb` lists 24 and the browser one is `open-browser`, which is
+deliberately *not* in the set. Measured over the real verb list, the set of verbs the hatch stops
+releasing is empty. What exists now is the ORDERING: the bucket is decided one line below the
+`forged` check, above every branch the hatch or the dated window can reach, and it admits `verified`
+only — so the verb it is for cannot arrive through the `override === false` branch, which returns
+`allow-with-warning` for every non-tolerant verb. The user-visible change begins in the PR that
+creates the verb, not here.
+
+`open-browser` stays out on purpose, and the distinction is worth stating because the sentence above
+says "browser": **opening a node is not driving one.** The threat is an agent acting inside a page
+the user is logged into (cookies, typing, script); `open-browser` only creates the surface and
+navigates it, like `show-web`. It is also a shipped verb with a live legacy population, and a strict
+gate would leave a pre-token session — or an SSH host whose project has not reconnected — unable to
+open a browser node with no way back, since the hatch by design cannot reach into this bucket. The
+residual is named rather than hidden: an unverified caller can open a node onto a logged-in page and
+the page's title then shows up in `list`. That is `list`'s tolerance, unchanged by this bucket.
+
+The cost, when the verb does land: cross-instance failover loses it, because another instance's
+token is a foreign kid and therefore `legacy`. Both shells wire it as a **live
getter** (`setIdentityStrictOverride`), so a change takes effect on the next request, not the next
launch — a stranded user must not have to restart the thing that is already broken.
diff --git a/src/core/agents/node-identity-policy.ts b/src/core/agents/node-identity-policy.ts
index 46cde479b..db85ea59b 100644
--- a/src/core/agents/node-identity-policy.ts
+++ b/src/core/agents/node-identity-policy.ts
@@ -183,10 +183,37 @@ export const TOLERANT_CONTROL_VERBS = new Set(['list'])
/**
* Control verbs that admit ONLY a `verified` caller — no window, no latch, no override.
*
- * `browser` is the whole bucket. It is a route through which an agent acts as the user on the
- * internet, inside a session jar that may hold real logins, and it is NEW — so unlike every verb
- * the two-move rollout was built for, there is no legacy population to strand and nothing to fail
- * open FOR. Same posture `/codex-thread/{start,bind}` already holds, for the same reason.
+ * ⚠ **PRE-POSITIONED, AND INERT TODAY.** `browser` is the whole bucket, and `browser` is **not a
+ * verb this app has**: `ControlVerb` (`src/main/canvas-control-core.ts`) lists 24 and the browser
+ * one is `open-browser`, which is deliberately NOT in here (see below). So measured over the real
+ * verb list, this set changes nothing for anybody: no request that succeeds today starts failing,
+ * and `hookIdentityStrict: false` releases exactly what it released before. What it does is make
+ * the ordering correct BEFORE the verb exists, so the verb cannot arrive through the hole. The
+ * hole was real — the `override === false` branch below returns `allow-with-warning` for every
+ * non-tolerant verb — and a route that acts as the user on the internet must not be the thing that
+ * discovers it.
+ *
+ * The verb it is for is a route through which an agent acts as the user on the internet, inside a
+ * session jar that may hold real logins, and it is NEW — so unlike every verb the two-move rollout
+ * was built for, there is no legacy population to strand and nothing to fail open FOR. Same posture
+ * `/codex-thread/{start,bind}` already holds, for the same reason.
+ *
+ * **Why `open-browser` is NOT in here, deliberately.** OPENING a node is not DRIVING one. The
+ * threat this bucket answers is an agent acting *inside* a page the user is logged into — reading
+ * cookies, typing, evaluating script; `open-browser` only creates the surface and navigates it to
+ * a URL the caller supplied, which is the same class of act as `show-web`. And it is a SHIPPED
+ * verb with a live legacy population: adding it would mean an agent session that has not picked up
+ * a token (a pre-token tmux session, or an SSH host whose project has not reconnected) loses the
+ * ability to open a browser node with no way back — the hatch cannot rescue it, because the whole
+ * point of this bucket is that the hatch does not reach it. That is precisely the stranding the
+ * dated window exists to prevent, paid to defend a surface that holds nothing yet. The residual is
+ * named rather than hidden: an unverified caller can open a node onto a logged-in page, and the
+ * page's TITLE then appears in `list`. That leak belongs to `list`'s tolerance, is unchanged by
+ * this file, and is the pre-existing trade documented on TOLERANT_CONTROL_VERBS.
+ *
+ * So: this doc comment claims a gate on DRIVING a browser, never on opening one. When the real
+ * verb lands it joins this set in the PR that creates it, and that PR — not this one — is where a
+ * user-visible behaviour change begins.
*
* Checked BEFORE the `override === false` branch, deliberately. That branch returns
* `allow-with-warning` for any non-tolerant verb, so `settings.hookIdentityStrict: false` — the
diff --git a/src/main/browser-guest-registry.test.ts b/src/main/browser-guest-registry.test.ts
index b555dee11..4304cd24e 100644
--- a/src/main/browser-guest-registry.test.ts
+++ b/src/main/browser-guest-registry.test.ts
@@ -78,10 +78,10 @@ describe('registerBrowserGuest', () => {
expect(m.size).toBe(0)
})
- it('refuses an unknown surface value', () => {
+ it('refuses a surface value that is present and unrecognised', () => {
const m = new Map<number, BrowserGuest>()
// The renderer is the more attackable half; `surface` is what selects a debugger target later.
- for (const bad of ['modal ', 'CANVAS', '', undefined, null, 1]) {
+ for (const bad of ['modal ', 'CANVAS', '', null, 1]) {
expect(
registerBrowserGuest(m, 7, 'browser-1', bad as unknown as BrowserSurfaceKind, lookup({ 7: 'webview' })),
String(bad)
@@ -90,6 +90,19 @@ describe('registerBrowserGuest', () => {
expect(m.size).toBe(0)
})
+ it('records an ABSENT surface as unknown — never as canvas', () => {
+ // Both mount sites still call the 2-argument preload, so this is what every registration in
+ // the app looks like today. Defaulting to 'canvas' would file the kanban modal's guest as a
+ // canvas guest: a false claim, indistinguishable from the real thing, and two 'canvas' entries
+ // for one node id — the exact collision the field exists to prevent.
+ const m = new Map<number, BrowserGuest>()
+ expect(registerBrowserGuest(m, 7, 'browser-1', undefined, lookup({ 7: 'webview' }))).toBe(true)
+ const guest = m.get(7)
+ expect(guest?.nodeId).toBe('browser-1')
+ expect(guest?.surface).toBeUndefined()
+ expect(Object.prototype.hasOwnProperty.call(guest, 'surface')).toBe(false)
+ })
+
it('accepts the modal surface, and keeps both of a node`s guests apart', () => {
const m = new Map<number, BrowserGuest>()
expect(registerBrowserGuest(m, 11, 'browser-3', 'modal', lookup({ 11: 'webview' }))).toBe(true)
@@ -127,4 +140,12 @@ describe('the IPC handler is wired through it', () => {
// `.set(` anywhere on this map would be a second, unguarded door.
expect(src).not.toContain('browserGuests.set(')
})
+
+ it('passes the surface through, absent and all — no default at the boundary either', () => {
+ // The unit test above pins the registry; this pins the caller. A `surface ?? 'canvas'` here
+ // would reintroduce the false claim one layer up, where no unit test can see it.
+ const src = readFileSync(resolve(__dirname, 'index.ts'), 'utf8')
+ expect(src).toContain('nodeId, surface, (id)')
+ expect(src).not.toMatch(/surface\s*(\?\?|\|\|)/)
+ })
})
diff --git a/src/main/browser-guest-registry.ts b/src/main/browser-guest-registry.ts
index 9cdf3be01..2d5b256fa 100644
--- a/src/main/browser-guest-registry.ts
+++ b/src/main/browser-guest-registry.ts
@@ -11,14 +11,24 @@ import { isSafeNodeId } from '../core/remote-safety'
*
* One node id can have TWO live guests — the canvas one (`BrowserNode`) and the kanban card modal
* one (`CardModal`) — both mounting `BrowserSurface` with the SAME nodeId, so a reverse lookup by
- * node id picks arbitrarily. The field is recorded here first; threading it from both mount sites
- * is its own change.
+ * node id picks arbitrarily.
*/
export type BrowserSurfaceKind = 'canvas' | 'modal'
export interface BrowserGuest {
nodeId: string
- surface: BrowserSurfaceKind
+ /**
+ * ABSENT until both mount sites are threaded, and absent is the only honest value: neither of
+ * them sends a surface yet, so this field is `undefined` for every registration the app makes
+ * today.
+ *
+ * It is deliberately NOT defaulted to `'canvas'`. Defaulting would record the kanban card
+ * modal's guest as a canvas guest — a positive false claim, indistinguishable from the real
+ * thing, producing two `'canvas'` entries for one node id: exactly the bug the field exists to
+ * prevent. `undefined` is detectable, so a future reverse lookup can refuse to guess. A consumer
+ * must treat it as "unknown", never as "canvas".
+ */
+ surface?: BrowserSurfaceKind
}
/** The minimum of Electron's `webContents` this module needs, injected so the guard is testable
@@ -46,12 +56,14 @@ export function registerBrowserGuest(
guests: Map<number, BrowserGuest>,
webContentsId: number,
nodeId: string,
- surface: BrowserSurfaceKind,
+ /** `undefined` = the caller does not know which surface this is; see {@link BrowserGuest.surface}.
+ * A value that is PRESENT and unrecognised is refused rather than treated as unknown. */
+ surface: BrowserSurfaceKind | undefined,
lookup: WebContentsLookup
): boolean {
if (!Number.isInteger(webContentsId) || webContentsId <= 0) return false
if (!isSafeNodeId(nodeId)) return false
- if (surface !== 'canvas' && surface !== 'modal') return false
+ if (surface !== undefined && surface !== 'canvas' && surface !== 'modal') return false
// The lookup can throw for a destroyed id (Electron's own accessors do); a guest that cannot be
// looked at is not a guest.
let contents: { getType(): string } | null = null
@@ -61,7 +73,10 @@ export function registerBrowserGuest(
return false
}
if (!contents || contents.getType() !== 'webview') return false
- guests.set(webContentsId, { nodeId, surface })
+ // The key is only written when it is known: an entry with no `surface` says "unknown", an entry
+ // with `surface: undefined` written explicitly says the same thing, and neither ever says
+ // "canvas" on a guess.
+ guests.set(webContentsId, surface === undefined ? { nodeId } : { nodeId, surface })
return true
}
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.ts
index 47b65ed58..14e994998 100644
--- a/src/main/canvas-control-core.test.ts
+++ b/src/main/canvas-control-core.test.ts
@@ -6,6 +6,7 @@ import {
buildCanvasControlInstructions,
buildCanvasSkillBody
} from './canvas-control-core'
+import { STRICT_CONTROL_VERBS } from '../core/agents/node-identity-policy'
describe('parseControlRequest', () => {
it('accepts known verbs', () => {
@@ -207,3 +208,29 @@ describe('parseControlRequest', () => {
}
})
})
+
+/**
+ * The claim `node-identity-policy.ts` makes about itself, checked against the real verb model.
+ *
+ * `STRICT_CONTROL_VERBS` is pre-positioned: the ordering is fixed before the verb it is for
+ * exists, so the verb cannot arrive through the `override === false` hole. These two tests are
+ * what stop that from quietly becoming a false claim in either direction — the first FAILS on the
+ * day the real `browser` verb lands, which is exactly when the PR body, the changelog and the
+ * Settings copy all have to stop saying "nothing changes for anyone".
+ */
+describe('the strict identity bucket is pre-positioned, not live', () => {
+ it('`browser` is not a verb this app has, so the bucket gates nothing today', () => {
+ expect(STRICT_CONTROL_VERBS.has('browser')).toBe(true)
+ expect(parseControlRequest('browser', {})).toEqual({ error: 'Unknown verb: browser' })
+ })
+
+ it('`open-browser` IS a real verb and is deliberately NOT in the bucket', () => {
+ // Opening a node is not driving one, and open-browser has a live legacy population that a
+ // strict gate would strand with no way back. See STRICT_CONTROL_VERBS' doc comment.
+ expect(parseControlRequest('open-browser', { url: 'https://example.com' })).toEqual({
+ verb: 'open-browser',
+ args: { url: 'https://example.com' }
+ })
+ expect(STRICT_CONTROL_VERBS.has('open-browser')).toBe(false)
+ })
+})
diff --git a/src/main/index.ts b/src/main/index.ts
index 2dae3c816..6c62f43d8 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -580,12 +580,12 @@ app.whenReady().then(async () => {
ipcMain.on(
IPC.browserRegister,
(_e, webContentsId: number, nodeId: string, surface?: BrowserSurfaceKind) => {
- // `surface` is optional ON THE WIRE only: both mount sites still send two arguments, so an
- // absent value means "the canvas one", which is what every registration was taken to be
- // before the field existed. A value that is present and wrong is refused, not defaulted.
- const kind = surface === undefined ? 'canvas' : surface
+ // `surface` is passed through UNCHANGED, including when it is absent. Both mount sites
+ // (BrowserNode and the kanban CardModal) still send two arguments, so today it is always
+ // absent — and defaulting it to 'canvas' here would record every modal guest as a canvas
+ // guest, which is a false claim a later reverse lookup cannot detect. See `BrowserGuest`.
if (
- !registerBrowserGuest(browserGuests, webContentsId, nodeId, kind, (id) =>
+ !registerBrowserGuest(browserGuests, webContentsId, nodeId, surface, (id) =>
webContents.fromId(id) ?? null
)
) {
diff --git a/src/renderer/components/settings/sections/AgentsSection.tsx b/src/renderer/components/settings/sections/AgentsSection.tsx
index bf3ac98c6..377ed6bda 100644
--- a/src/renderer/components/settings/sections/AgentsSection.tsx
+++ b/src/renderer/components/settings/sections/AgentsSection.tsx
@@ -265,7 +265,7 @@ export function AgentsSection({ isActive }: { isActive: boolean }): React.JSX.El
<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. It does not release browser control, which always requires a verified identity.`}
+ 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"