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(control): flat run refusal; pin run's cross-project gate (#925)

reviewaedf793bdf00
diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.ts
index 8c7acc1c4..57247389b 100644
--- a/src/core/agents/hook-server.ts
+++ b/src/core/agents/hook-server.ts
@@ -265,8 +265,9 @@ export const OPEN_PROJECT_CONTROL_REFUSAL = 'Project open refused.'
export const SETTINGS_CONTROL_REFUSAL = 'Settings access refused.'
/** One sentence, names what was refused, no diagnosis — house style for every refusal here. */
export const REPORT_ISSUE_CONTROL_REFUSAL = 'Issue reporting refused.'
-const RUN_CONTROL_REFUSAL =
- 'Run refused: starting a queued session the user is not watching needs verified node identity.'
+/** Same posture for `run` (#925): it starts a queued session the user is not watching, and the
+ * refusal says only that the run was refused. */
+export const RUN_CONTROL_REFUSAL = 'Run refused.'
/** The verified-only refusal, worded for the verb that was refused. */
export function verifiedRefusalFor(verb: string): string {
diff --git a/src/core/agents/messaging-verified-only.test.ts b/src/core/agents/messaging-verified-only.test.ts
index cd845d341..a5ca6add4 100644
--- a/src/core/agents/messaging-verified-only.test.ts
+++ b/src/core/agents/messaging-verified-only.test.ts
@@ -16,7 +16,13 @@ import os from 'os'
import path from 'path'
import { initPlatform, resetPlatformForTests } from '../platform'
import { fakePlatform } from '../platform-fake'
-import { hookServer, MESSAGING_CONTROL_REFUSAL, requiresVerified, verifiedRefusalFor } from './hook-server'
+import {
+ hookServer,
+ MESSAGING_CONTROL_REFUSAL,
+ RUN_CONTROL_REFUSAL,
+ requiresVerified,
+ verifiedRefusalFor
+} from './hook-server'
import { nodeAuthToken } from './node-auth-token'
import { TOLERANT_CONTROL_VERBS } from './node-identity-policy'
import { DESTRUCTIVE_VERBS } from '../../shared/control-verbs'
@@ -96,13 +102,20 @@ describe('send/reply require `verified` — and controlPolicy is NOT the decider
it('tells a text/plain caller the same refusal, without token or restart advice', async () => {
hookServer.setIdentityStrictOverride(() => undefined)
- const res = await post('send', 'n-src', undefined, 'text/plain')
- expect(res.status).toBe(403)
- const text = (await res.text()).trim()
- expect(text).toBe(MESSAGING_CONTROL_REFUSAL)
- // No diagnosis and no hint: advice here is advice to an attacker and a lie to nobody else.
- for (const hint of ['token', 'Restart', 'restart', 'identity']) {
- expect(text).not.toContain(hint)
+ // `run` (#925) is held to the same posture: its refusal names what was refused and nothing
+ // else, even though it has its own sentence.
+ for (const [verb, refusal] of [
+ ['send', MESSAGING_CONTROL_REFUSAL],
+ ['run', RUN_CONTROL_REFUSAL]
+ ] as const) {
+ const res = await post(verb, 'n-src', undefined, 'text/plain')
+ expect(res.status, verb).toBe(403)
+ const text = (await res.text()).trim()
+ expect(text, verb).toBe(refusal)
+ // No diagnosis and no hint: advice here is advice to an attacker and a lie to nobody else.
+ for (const hint of ['token', 'Restart', 'restart', 'identity']) {
+ expect(text, verb).not.toContain(hint)
+ }
}
expect(handled).toEqual([])
})
@@ -167,10 +180,8 @@ describe('where the verbs sit in the routing tables', () => {
])
})
- it('the run refusal is its own sentence, not the messaging one (#925)', () => {
- expect(verifiedRefusalFor('run')).toBe(
- 'Run refused: starting a queued session the user is not watching needs verified node identity.'
- )
+ it('the run refusal is its own flat sentence, not the messaging one (#925)', () => {
+ expect(verifiedRefusalFor('run')).toBe(RUN_CONTROL_REFUSAL)
expect(verifiedRefusalFor('run')).not.toBe(MESSAGING_CONTROL_REFUSAL)
})
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.ts
index ae8ef4716..fbc3e1d90 100644
--- a/src/main/canvas-control-core.test.ts
+++ b/src/main/canvas-control-core.test.ts
@@ -345,6 +345,8 @@ describe('parseControlRequest', () => {
args: { node: 'n1', text: '' }
})
expect(isDestructiveVerb('sticky')).toBe(false)
+ // #925: `run` starts a queued launch; it is verified-only, not confirm-gated.
+ expect(isDestructiveVerb('run')).toBe(false)
})
it('both agent-facing texts warn that --prompt is one line and must not start with a slash', () => {
diff --git a/src/main/project-grants.test.ts b/src/main/project-grants.test.ts
index d7844ada9..19105856c 100644
--- a/src/main/project-grants.test.ts
+++ b/src/main/project-grants.test.ts
@@ -111,10 +111,19 @@ describe('gateProjectTarget (spec §3/§5) — every branch, fail closed', () =>
expect(PROJECT_TARGETABLE_VERBS.has('open-claude')).toBe(true)
expect(PROJECT_TARGETABLE_VERBS.has('open-terminal')).toBe(true)
expect(PROJECT_TARGETABLE_VERBS.has('open-agent')).toBe(true)
+ // #925: `run` reaches a node in another project only through this gate. Dropping it from the
+ // set would make `gateProjectTarget` answer 'allow' for any --project, ungating the verb.
+ expect(PROJECT_TARGETABLE_VERBS.has('run')).toBe(true)
expect(PROJECT_TARGETABLE_VERBS.has('show-image')).toBe(false)
expect(gateProjectTarget({ ...base, verb: 'list' })).toBe('allow')
})
+ it('refuses `run --project <foreign, ungranted>` like any stranger id (#925)', () => {
+ expect(gateProjectTarget({ ...base, verb: 'run', targetProjectId: 'proj-foreign' })).toEqual({
+ refuse: PROJECT_TARGET_REFUSED
+ })
+ })
+
it('is a no-op when no --project is present', () => {
expect(gateProjectTarget({ ...base, targetProjectId: undefined })).toBe('allow')
})