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
feat(canvas-control): `verify` — a review panel over one node's work
enes7d299612a883
diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.tsindex b58188f97..adb5e7850 100644--- a/src/main/canvas-control-core.test.ts+++ b/src/main/canvas-control-core.test.ts@@ -78,6 +78,15 @@ describe('parseControlRequest', () => {expect(isDestructiveVerb('link')).toBe(false)})+ it('verify requires --node and is not destructive (it only opens read-only reviewers)', () => {+ expect(parseControlRequest('verify', {})).toEqual({ error: 'verify requires --node <id>' })+ expect(parseControlRequest('verify', { node: 'n1', lenses: 'security,tests' })).toEqual({+ verb: 'verify',+ args: { node: 'n1', lenses: 'security,tests' }+ })+ expect(isDestructiveVerb('verify')).toBe(false)+ })+it('open-agent requires --agent, and is not destructive', () => {expect(parseControlRequest('open-agent', {})).toEqual({ error: 'open-agent requires --agent <id>' })expect(parseControlRequest('open-agent', { agent: 'codex' })).toEqual({diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.tsindex 01667e4c2..6cc0cf2ca 100644--- a/src/main/canvas-control-core.ts+++ b/src/main/canvas-control-core.ts@@ -15,6 +15,7 @@ export type ControlVerb =| 'arrange'| 'align'| 'link'+ | 'verify'| 'spawn-team'| 'open-worktree'| 'close-worktree'@@ -41,6 +42,7 @@ const VERBS: ControlVerb[] = ['arrange','align','link',+ 'verify','spawn-team','open-worktree','close-worktree',@@ -78,6 +80,7 @@ export function parseControlRequest(if (v === 'align' && !args.nodes) return { error: 'align requires --nodes <id,id>' }if (v === 'align' && !args.edge) return { error: 'align requires --edge' }if (v === 'link' && !args.to) return { error: 'link requires --to <id,id>' }+ if (v === 'verify' && !args.node) return { error: 'verify requires --node <id>' }if (v === 'spawn-team' && !args.team) return { error: 'spawn-team requires --team <json>' }if (v === 'open-worktree' && !args.branch) return { error: 'open-worktree requires --branch <name>' }if (v === 'close-worktree' && !args.group) return { error: 'close-worktree requires --group <id>' }@@ -143,6 +146,10 @@ export function buildCanvasControlInstructions(shimPath: string): string {' on demand (nodeterm linked-context CLI). `--from` defaults to you; nothing is pushed into the',' linked sessions. Agent sessions you open are linked to you automatically — use `link` for nodes',' you did not open, or to link two OTHER nodes together.',+ '- `verify --node <id> [--lenses correctness,security,tests] [--focus "..."] [--synthesis off]` — open a',+ ' review panel over that node\'s work: one reviewer per lens, each armed behind the target and linked',+ ' to it, plus a judge armed behind the panel that merges the findings into one verdict. Reviewers are',+ ' told not to change files. Prefer this over asking one agent to double-check itself.','- `spawn-team --label L --team \'[{"title":"UI","prompt":"...","agent":"claude"}]\'` — one agent per',' role (max 8), arranged in a grid, wrapped in a labeled group, each connected + context-linked to you.','- `open-worktree --branch <name> [--base <ref>] [--path P] [--group <id>]` — create a git worktree',@@ -307,6 +314,15 @@ Verbs:pushed into the linked sessions — reading is on demand, so linking never interrupts anyone.Agent sessions you open (\`open-claude\`/\`open-agent\`/\`spawn-team\`) are linked to youautomatically; use \`link\` for nodes you did not open, or to link two OTHER nodes together.+- \`verify --node <id> [--lenses correctness,security,tests] [--focus "..."] [--agent <id>] [--synthesis off] [--label L]\` —+ open a review PANEL over that node's work: one reviewer per lens, each armed behind the target+ (they start when it goes idle) and linked to it so they can read what it actually did, plus a+ judge armed behind the whole panel that merges their findings into one verdict+ (\`--synthesis off\` skips the judge). Default lenses are correctness, security, tests; any word+ works as a lens, known ones just get a sharper brief. Reviewers are told NOT to change files —+ they share one checkout, and finding is a separate job from fixing. Use this instead of asking+ one agent "are you sure?": several INDEPENDENT looks from different angles catch what one pass,+ or several identical passes, cannot.- \`spawn-team --label "Frontend Team" --team '[{"title":"UI","prompt":"...","agent":"claude"}]'\` —open one agent per role (each prompt starts that member working), arrange them in a grid,wrap them in a labeled group, and connect + context-link each to you. Max 8 roles per call.@@ -367,7 +383,12 @@ across Nodeterm sessions), be the orchestration chef — plan the kitchen, thenother, name the conflicts and the leftovers, and report ONE synthesis. A station you neverread is a station whose work you cannot vouch for — say so rather than assuming it wentfine. Stations you did not open are not linked; \`link --to <id>\` them first.-6. Hand back: the user merges from the group's chip (never merge for them); release a finished+6. Verify before you report. When a station's work matters — anything touching money, auth, data+ migration or a public API — run \`verify --node <stationId>\` instead of re-reading it yourself.+ You cannot independently check work you were part of planning; a panel of reviewers who each+ look through ONE lens, and who did not watch it being written, can. Fold their verdict into+ your synthesis, and say which findings you accepted and which you dismissed and why.+7. Hand back: the user merges from the group's chip (never merge for them); release a finishedstation with \`close-worktree --group <id>\` (unbind keeps the directory).`}diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex 3e72fdd9a..8fd5c8ebd 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -179,6 +179,7 @@ import {} from '../session/relay-tab'import { buildBackgroundLinkMaps, buildContextLinkNote, buildLinkMap, buildNotePushMessage, classifyLink, planBridges, type LinkEndpoint } from '../lib/noteLink'import { dependencyEdges, launchesToFire, unmetDeps, type ArmedNode } from '../lib/pendingLaunch'+import { parseLenses, verifyLensPrompt, verifySynthesisPrompt } from '../lib/verifyPanel'import { useSettings } from '../state/settings'import { activePermissionMode } from '../state/permissionMode'import { useContextWindow } from '../state/contextWindow'@@ -4794,7 +4795,10 @@ export function Canvas() {// Hold a freshly-built node's launch instead of running it on open. The factories already// composed the exact command (agent CLI + permission-mode flag + prompt, or --cmd), so it// is MOVED rather than rebuilt — a second construction site is how the two drift apart.- const armAfter = (node: CanvasNode, after: string[]): CanvasNode => {+ // `extraLive` names nodes being created in this same tick — `verify` arms its judge on+ // reviewers that are not on the canvas yet, and without this they would look DELETED,+ // which counts as satisfied, and the judge would fire before a single review existed.+ const armAfter = (node: CanvasNode, after: string[], extraLive?: Iterable<string>): CanvasNode => {const command = node.data.initialCommand as string | undefinedif (!after.length || !command) return node// If the wait is ALREADY over, don't arm at all — leave the command as the node's@@ -4802,7 +4806,7 @@ export function Canvas() {// (which waits for the shell prompt and echo-verifies). Arming would instead hand// delivery to the canvas effect, which would race the node's PTY into existence and// could fire into a session that does not exist yet.- const live = new Set(nodesRef.current.map((nd) => nd.id))+ const live = new Set([...nodesRef.current.map((nd) => nd.id), ...(extraLive ?? [])])const unmet = unmetDeps({ id: node.id, data: { pendingLaunch: { after, command } } },useAgentStatus.getState().byId,@@ -5105,6 +5109,136 @@ export function Canvas() {})return}+ case 'verify': {+ // A review PANEL over one node's work: one reviewer per lens, each armed behind the+ // target (so they start when it goes idle) and linked to it (so they can read what it+ // actually did), plus an optional judge armed behind the whole panel. Everything here+ // is composed from the two primitives already built — `--after` and the context+ // bridge; `verify` is the shape, not new machinery.+ const targetId = (args.node ?? '').trim()+ const target = nodesRef.current.find((nd) => nd.id === targetId)+ if (!target) {+ reply({ ok: false, error: `verify: --node names no existing node (${targetId})` })+ return+ }+ const targetAgent = agentIdOf(targetId)+ if (!targetAgent || !canContextLink(targetAgent)) {+ reply({+ ok: false,+ error: `verify: ${targetId} is not an agent session whose work can be read — the reviewers would have nothing to look at`+ })+ return+ }+ const reviewAgent = ((args.agent as AgentId | undefined) || targetAgent) as AgentId+ if (!canContextLink(reviewAgent)) {+ reply({+ ok: false,+ error: `verify: --agent ${reviewAgent} cannot read linked context, so it cannot review anything`+ })+ return+ }+ const lenses = parseLenses(args.lenses)+ const wantJudge = (args.synthesis ?? 'on').trim().toLowerCase() !== 'off'+ const { shimPath: vShim } = await window.nodeTerminal.contextLink.info()+ const targetTitle = (target.data.title as string) || targetId+ const targetCwd = target.data.cwd as string | undefined+ const live = nodesRef.current as CanvasNode[]+ const vStore = useProjects.getState()+ // Reviewers inherit the TARGET's account, not the caller's: they read that node's+ // transcript, which is resolved inside its own account dir.+ const vAccount = resolveNewNodeAccount(+ target.data.accountId as string | undefined,+ vStore.getProject(vStore.activeProjectId ?? ''),+ useSettings.getState().settings.claudeAccounts+ )+ const vMode = activePermissionMode()+ const reviewers = lenses.map((lens, i) => {+ const node = createAgentNode(+ reviewAgent,+ live.length + i,+ targetCwd,+ placeBelow(i),+ verifyLensPrompt({+ lens,+ targetTitle,+ targetId,+ agentId: reviewAgent,+ shimPath: vShim,+ focus: args.focus+ }),+ undefined,+ vAccount,+ vMode+ )+ return armAfter(+ { ...node, data: { ...node.data, title: `Verify: ${lens}`, titleAuto: false } },+ [targetId]+ )+ })+ const reviewerIds = reviewers.map((r) => r.id)+ const judge = wantJudge+ ? armAfter(+ (() => {+ const j = createAgentNode(+ reviewAgent,+ live.length + lenses.length,+ targetCwd,+ placeBelow(lenses.length),+ verifySynthesisPrompt({+ lenses,+ targetTitle,+ agentId: reviewAgent,+ shimPath: vShim+ }),+ undefined,+ vAccount,+ vMode+ )+ return { ...j, data: { ...j.data, title: 'Verify: verdict', titleAuto: false } }+ })(),+ reviewerIds,+ reviewerIds // the reviewers exist only in this tick — see armAfter+ )+ : null+ const panelIds = [...reviewerIds, ...(judge ? [judge.id] : [])]+ let next: CanvasNode[] = [...live, ...reviewers, ...(judge ? [judge] : [])]+ next = arrangeNodes(next, panelIds, { layout: 'grid', origin: placeBelow(0) })+ const vGroupCount = next.filter((nd) => nd.type === 'group').length+ next = groupSelectedNodes(next, panelIds, vGroupCount)+ const vGroup = next[0]+ next = next.map((nd) =>+ nd.id === vGroup.id+ ? { ...nd, data: { ...nd.data, title: args.label || `Verify: ${targetTitle}` } }+ : nd+ )+ setNodes(next)+ panelIds.forEach((pid) => connect(pid))+ // Same-tick lookup: the panel is not on the canvas yet (setNodes is async).+ const panelEndpoint = (id: string): LinkEndpoint | null =>+ panelIds.includes(id)+ ? { kind: 'terminal', contextCapable: canContextLink(reviewAgent) }+ : linkEndpointOf(id)+ for (const rid of reviewerIds) bridgeTo(rid, [targetId], panelEndpoint)+ bridgeTo(sourceNodeId, panelIds, panelEndpoint)+ if (judge) bridgeTo(judge.id, reviewerIds, panelEndpoint)+ markDirty()+ reply({+ ok: true,+ message:+ `verifying ${targetTitle} (${targetId}) with ${lenses.length} lens(es): ${lenses.join(', ')}` ++ `\nreviewers: ${reviewerIds.join(', ')}` ++ (judge ? `\nverdict node (runs after all reviewers): ${judge.id}` : '') ++ `\nthey start when ${targetId} goes idle`,+ result: {+ groupId: vGroup.id,+ targetId,+ lenses,+ reviewerIds,+ judgeId: judge?.id ?? null+ }+ })+ return+ }case 'spawn-team': {let roles: { title?: string; prompt?: string; agent?: string }[]try {diff --git a/src/renderer/lib/verifyPanel.test.ts b/src/renderer/lib/verifyPanel.test.tsnew file mode 100644index 000000000..be6db0039--- /dev/null+++ b/src/renderer/lib/verifyPanel.test.ts@@ -0,0 +1,91 @@+import { describe, it, expect } from 'vitest'+import {+ DEFAULT_LENSES,+ MAX_LENSES,+ parseLenses,+ verifyLensPrompt,+ verifySynthesisPrompt+} from './verifyPanel'++describe('parseLenses', () => {+ it('falls back to the default panel when nothing is given', () => {+ expect(parseLenses(undefined)).toEqual(DEFAULT_LENSES)+ expect(parseLenses('')).toEqual(DEFAULT_LENSES)+ expect(parseLenses(' , ,')).toEqual(DEFAULT_LENSES)+ })++ it('normalizes case and whitespace, and drops duplicates', () => {+ expect(parseLenses(' Security , security ,TESTS ')).toEqual(['security', 'tests'])+ })++ it('keeps lens words it does not know — an unanticipated angle is still a valid review', () => {+ expect(parseLenses('accessibility,i18n')).toEqual(['accessibility', 'i18n'])+ })++ it('caps the panel size', () => {+ const many = parseLenses('a,b,c,d,e,f,g,h')+ expect(many).toHaveLength(MAX_LENSES)+ })+})++describe('verifyLensPrompt', () => {+ const base = { targetTitle: 'Migration', targetId: 'term-7', shimPath: '/x/nodeterm.sh' }++ it('names the lens, the target, and a known lens brief', () => {+ const p = verifyLensPrompt({ ...base, lens: 'security', agentId: 'claude' })+ expect(p).toContain('single lens: security')+ expect(p).toContain('"Migration" (term-7)')+ expect(p).toContain('injection')+ })++ it('points claude at the skill and other agents at the CLI shim', () => {+ expect(verifyLensPrompt({ ...base, lens: 'tests', agentId: 'claude' })).toContain(+ 'get-linked-context skill'+ )+ const codex = verifyLensPrompt({ ...base, lens: 'tests', agentId: 'codex' })+ expect(codex).toContain('/x/nodeterm.sh')+ expect(codex).not.toContain('get-linked-context skill')+ })++ it('gives an unknown lens a generic brief instead of dropping it', () => {+ expect(verifyLensPrompt({ ...base, lens: 'accessibility' })).toContain(+ 'problems of this kind: accessibility'+ )+ })++ it('always forbids editing — a panel shares one checkout', () => {+ for (const lens of ['correctness', 'security', 'whatever']) {+ expect(verifyLensPrompt({ ...base, lens })).toMatch(/Do NOT change any files/)+ }+ })++ it('always licenses an empty finding, so reviewers do not invent one', () => {+ expect(verifyLensPrompt({ ...base, lens: 'correctness' })).toContain('nothing found')+ })++ it('folds in --focus when given, and omits the clause when not', () => {+ expect(verifyLensPrompt({ ...base, lens: 'tests', focus: 'the SSH retry path' })).toContain(+ 'specifically about: the SSH retry path'+ )+ expect(verifyLensPrompt({ ...base, lens: 'tests' })).not.toContain('specifically about')+ expect(verifyLensPrompt({ ...base, lens: 'tests', focus: ' ' })).not.toContain(+ 'specifically about'+ )+ })+})++describe('verifySynthesisPrompt', () => {+ const base = { targetTitle: 'Migration', shimPath: '/x/nodeterm.sh' }++ it('names every lens on the panel and the count', () => {+ const p = verifySynthesisPrompt({ ...base, lenses: ['correctness', 'security'] })+ expect(p).toContain('2 reviewers')+ expect(p).toContain('correctness, security')+ })++ it('makes an empty verdict an acceptable outcome', () => {+ expect(verifySynthesisPrompt({ ...base, lenses: ['correctness'] })).toContain(+ 'an empty verdict is a real result'+ )+ })+})diff --git a/src/renderer/lib/verifyPanel.ts b/src/renderer/lib/verifyPanel.tsnew file mode 100644index 000000000..6aba438a1--- /dev/null+++ b/src/renderer/lib/verifyPanel.ts@@ -0,0 +1,101 @@+// Pure prompt/lens logic for the canvas-control `verify` verb: a panel of independent reviewers,+// one per LENS, each reading the same target node's work and looking for a different class of+// problem. Diversity is the point — N identical reviewers correlate their mistakes and mostly+// agree with each other, which reads as confirmation while adding no evidence.+//+// Kept free of React/store imports so the lens table and the prompt wording are unit-testable.++/** Lens id → what that reviewer is told to hunt for. */+const LENS_BRIEFS: Record<string, string> = {+ correctness:+ 'logic that is wrong or incomplete — bad assumptions, unhandled inputs, off-by-one and boundary cases, error paths that silently swallow failure',+ security:+ 'unsafe handling — injection through interpolated shell/SQL/paths, missing authorization, secrets or tokens that leak into logs, args or files, and input trusted because of where it came from',+ tests:+ 'whether the tests actually prove what they claim — assertions that would still pass if the code were broken, missing cases for the paths that matter, and behaviour covered only by its own mock',+ performance:+ 'work that will not scale — accidental quadratic loops, per-item queries or subprocesses, blocking calls on a hot path, and unbounded growth',+ regression:+ 'existing behaviour this could break — callers and call sites that were not updated, persisted data written in a shape older readers cannot parse, and defaults that silently changed',+ repro:+ 'whether the claimed result is real — actually run it, and report exactly what you observed versus what was claimed'+}++/** The panel used when `--lenses` is not given. */+export const DEFAULT_LENSES = ['correctness', 'security', 'tests']++/** Hard cap on panel size (matches spawn-team's role cap). */+export const MAX_LENSES = 6++/**+ * Parse and clean a `--lenses a,b,c` list. Unknown lens words are KEPT (they get a generic+ * brief) rather than rejected: "does this work offline", "accessibility" and "i18n" are+ * perfectly good review angles, and a table that only accepts what it already knows would+ * make the verb useless for the reviews nobody anticipated.+ */+export function parseLenses(raw: string | undefined): string[] {+ const list = (raw ?? '')+ .split(',')+ .map((s) => s.trim().toLowerCase())+ .filter(Boolean)+ const seen = new Set<string>()+ const out: string[] = []+ for (const l of list.length ? list : DEFAULT_LENSES) {+ if (seen.has(l)) continue+ seen.add(l)+ out.push(l)+ if (out.length >= MAX_LENSES) break+ }+ return out+}++/** How a given agent is told to read a linked node's work. */+function readInstruction(agentId: string | undefined, shimPath: string): string {+ return !agentId || agentId === 'claude'+ ? 'read its work with the get-linked-context skill (summary first, then transcript if you need detail)'+ : `read its work by running: sh "${shimPath}" summary --node <id> (then transcript --node <id> for detail) — see the get-linked-context section of your global agent instructions`+}++/**+ * The starting prompt for one lens reviewer.+ *+ * Two guardrails are deliberate. **Read-only**: a panel is several agents pointed at one+ * checkout, so a reviewer that "just fixes it" races the others into the same files — review+ * and repair are separate jobs, and only the repair one needs isolation. **Permission to find+ * nothing**: a reviewer under implicit pressure to produce findings invents them, and invented+ * findings are worse than none because they cost someone else the time to disprove.+ */+export function verifyLensPrompt(opts: {+ lens: string+ targetTitle: string+ targetId: string+ agentId?: string+ shimPath: string+ focus?: string+}): string {+ const brief = LENS_BRIEFS[opts.lens] ?? `problems of this kind: ${opts.lens}`+ const focus = opts.focus?.trim() ? ` The work under review is specifically about: ${opts.focus.trim()}.` : ''+ return [+ `You are one reviewer on a verification panel, looking at the work of the linked node "${opts.targetTitle}" (${opts.targetId}) through a single lens: ${opts.lens}.`,+ `First ${readInstruction(opts.agentId, opts.shimPath)}, and read enough of the actual code it touched to judge it for yourself rather than trusting its summary.${focus}`,+ `Then hunt specifically for ${brief}.`,+ `Report only what you can point at — a file:line, a concrete input that breaks it, or a command you ran and its output. If this lens turns up nothing real, say "nothing found" and stop; do not pad the report to look thorough.`,+ `Do NOT change any files and do NOT fix anything — other reviewers are reading the same checkout right now, and repairing is a separate job from finding.`+ ].join(' ')+}++/** The starting prompt for the panel's judge, which runs once every reviewer has gone idle. */+export function verifySynthesisPrompt(opts: {+ lenses: string[]+ targetTitle: string+ agentId?: string+ shimPath: string+}): string {+ return [+ `You are the judge of a verification panel on the work of "${opts.targetTitle}". ${opts.lenses.length} reviewers each examined it through one lens: ${opts.lenses.join(', ')}.`,+ `Each reviewer is linked to you — ${readInstruction(opts.agentId, opts.shimPath)} for each of them.`,+ `Then produce ONE verdict: drop every finding the reviewer could not point at concretely, merge the duplicates that several lenses reported, and rank what survives by what it would actually cost to ship.`,+ `Say plainly which lenses found nothing, and say plainly if nothing survived at all — an empty verdict is a real result, not a failed one.`,+ `Do NOT fix anything; report.`+ ].join(' ')+}