diff --git a/src/main/runtime/rpc/methods/orchestration/runs/run-receipt.test.ts b/src/main/runtime/rpc/methods/orchestration/runs/run-receipt.test.ts new file mode 100644 index 00000000000..83434c63119 --- /dev/null +++ b/src/main/runtime/rpc/methods/orchestration/runs/run-receipt.test.ts @@ -0,0 +1,61 @@ +import { describe, expect, it } from 'vitest' +import { exposeRun } from './run-receipt' +import type { RunRow } from '../../../../orchestration/types' + +// Why: typecheck cannot see the strip because the RPC return types are loose. +const RUN_ROW: RunRow = { + id: 'run_1', + objective: 'Coordinate reviews', + home_database: '/tmp/orca/orchestration.db', + coordinator_handle: 'term_coord', + coordinator_pane_key: 'tab_coord:11111111-1111-4111-8111-111111111111', + consumer_generation: 3, + legacy: 0, + created_at: '2026-09-04T18:53:07Z', + updated_at: '2026-09-04T18:53:09Z' +} + +describe('exposeRun', () => { + it('drops exactly the internal routing columns', () => { + const exposed = exposeRun(RUN_ROW) + + expect(Object.keys(exposed).sort()).toEqual([ + 'consumer_generation', + 'coordinator_handle', + 'created_at', + 'id', + 'legacy', + 'objective', + 'updated_at' + ]) + expect(exposed).not.toHaveProperty('home_database') + expect(exposed).not.toHaveProperty('coordinator_pane_key') + }) + + it('preserves every published column by value', () => { + const exposed = exposeRun(RUN_ROW) + + expect(exposed).toEqual({ + id: 'run_1', + objective: 'Coordinate reviews', + coordinator_handle: 'term_coord', + consumer_generation: 3, + legacy: 0, + created_at: '2026-09-04T18:53:07Z', + updated_at: '2026-09-04T18:53:09Z' + }) + }) + + it('does not mutate the source row', () => { + const row = { ...RUN_ROW } + exposeRun(row) + + expect(row).toEqual(RUN_ROW) + }) + + it('strips the columns even when they are null', () => { + const exposed = exposeRun({ ...RUN_ROW, coordinator_pane_key: null }) + + expect(exposed).not.toHaveProperty('coordinator_pane_key') + }) +}) diff --git a/src/main/runtime/rpc/methods/orchestration/runs/runs.test.ts b/src/main/runtime/rpc/methods/orchestration/runs/runs.test.ts index 0d4d5ef6a96..a037a1d473d 100644 --- a/src/main/runtime/rpc/methods/orchestration/runs/runs.test.ts +++ b/src/main/runtime/rpc/methods/orchestration/runs/runs.test.ts @@ -90,6 +90,22 @@ describe('orchestration RPC methods', () => { expect(current.run?.id).toBe(created.run.id) }) + it('publishes a run receipt without internal routing columns', async () => { + setup(false) + vi.spyOn(runtime, 'getTerminalPaneKey').mockReturnValue( + 'tab_coord:11111111-1111-4111-8111-111111111111' + ) + + const created = (await call('orchestration.runCreate', { + objective: 'Coordinate reviews', + from: 'term_coord' + })) as { run: Record } + + expect(created.run).not.toHaveProperty('coordinator_pane_key') + expect(created.run).not.toHaveProperty('home_database') + expect(created.run.consumer_generation).toBe(1) + }) + it('requires runtime-observed stable pane identity for binding', async () => { setup(false) vi.spyOn(runtime, 'getTerminalPaneKey').mockReturnValue(null)