From 37ded8ea5bcbb797a62e8b2adc031f26250e29a4 Mon Sep 17 00:00:00 2001 From: OrcaWin <293788423+OrcaWin@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:27:02 -0800 Subject: [PATCH] test: remove synthetic mailbox and admission pipeline cases --- ...creation-and-orchestration-part-03.spec.ts | 116 +----------------- ...session-tabs-targeted-agent-resume.spec.ts | 72 +---------- 2 files changed, 2 insertions(+), 186 deletions(-) diff --git a/src/main/runtime/orca-runtime-tests/mobile-creation-and-orchestration-part-03.spec.ts b/src/main/runtime/orca-runtime-tests/mobile-creation-and-orchestration-part-03.spec.ts index 7456f981a34..de8ebeff271 100644 --- a/src/main/runtime/orca-runtime-tests/mobile-creation-and-orchestration-part-03.spec.ts +++ b/src/main/runtime/orca-runtime-tests/mobile-creation-and-orchestration-part-03.spec.ts @@ -1,124 +1,10 @@ -import { settledWriteStub } from '../../providers/testing/settled-pty-write-stub' import { describe, expect, it, vi } from 'vitest' import './runtime-test-module-registration.spec' import { OrcaRuntimeService } from '../orca-runtime' -import { - bindSinglePtyRun, - setInMemoryOrchestrationMessages, - store, - syncSinglePty -} from './orca-runtime-test-fixtures.spec' -import { InMemoryOrchestrationMessages } from '../orchestration/mailbox/terminal-pointer/in-memory-orchestration-messages.spec' -import { MessageWake } from '../orchestration/mailbox/runtime-message-waiters' +import { store } from './orca-runtime-test-fixtures.spec' describe('OrcaRuntimeService', () => { - it('leaves rows a live filtered waiter reserved out of the pushed batch', async () => { - vi.useFakeTimers() - try { - const runtime = new OrcaRuntimeService(store) - const db = new InMemoryOrchestrationMessages() - const write = vi.fn().mockReturnValue(true) - setInMemoryOrchestrationMessages(runtime, db) - runtime.setPtyController({ - write, - writeWithSettlement: settledWriteStub(write), - kill: vi.fn(), - getForegroundProcess: async () => null - }) - syncSinglePty(runtime) - - const [terminal] = (await runtime.listTerminals()).terminals - const mailbox = bindSinglePtyRun(db, terminal.handle) - runtime.onPtyData('pty-1', '\x1b]0;Codex working\x07', 100) - runtime.onPtyData('pty-1', '\x1b]0;Codex done\x07', 101) - await runtime.waitForTerminal(terminal.handle, { condition: 'tui-idle' }) - write.mockClear() - - // Push scans all pending rows; exclude worker_done owned by the blocked check or it delivers twice. - const waitPromise = runtime.waitForMessage(mailbox, { - typeFilter: ['worker_done'], - timeoutMs: 5_000 - }) - const status = db.insertMessage({ - from: 'sender', - to: terminal.handle, - subject: 'unclaimed status', - type: 'status' - }) - runtime.notifyMessageArrived(terminal.handle, 'status') - const done = db.insertMessage({ - from: 'sender', - to: terminal.handle, - subject: 'reserved completion', - type: 'worker_done' - }) - runtime.notifyMessageArrived(terminal.handle, 'worker_done') - - await expect(waitPromise).resolves.toBeInstanceOf(MessageWake) - await vi.advanceTimersByTimeAsync(600) - const payloads = write.mock.calls - .map(([, data]) => data) - .filter((data): data is string => typeof data === 'string') - expect(payloads).toContain( - '\nYou have 1 orchestration message. Run `orca-dev orchestration check --run run_test`.\n' - ) - expect(payloads.some((data) => data.includes('reserved completion'))).toBe(false) - expect(status.delivered_at).toEqual(expect.any(String)) - expect(done.delivered_at).toBeNull() - db.close() - } finally { - vi.useRealTimers() - } - }) - - it('skips rows claimed by a waiter that registered after the notify', async () => { - vi.useFakeTimers() - try { - const runtime = new OrcaRuntimeService(store) - const db = new InMemoryOrchestrationMessages() - const write = vi.fn().mockReturnValue(true) - setInMemoryOrchestrationMessages(runtime, db) - runtime.setPtyController({ - write, - writeWithSettlement: settledWriteStub(write), - kill: vi.fn(), - getForegroundProcess: async () => null - }) - syncSinglePty(runtime) - - const [terminal] = (await runtime.listTerminals()).terminals - const mailbox = bindSinglePtyRun(db, terminal.handle) - runtime.onPtyData('pty-1', '\x1b]0;Codex working\x07', 100) - runtime.onPtyData('pty-1', '\x1b]0;Codex done\x07', 101) - await runtime.waitForTerminal(terminal.handle, { condition: 'tui-idle' }) - write.mockClear() - - const message = db.insertMessage({ - from: 'sender', - to: terminal.handle, - subject: 'claimed late', - type: 'status' - }) - // A waiter arriving after notify still owns rows before deferred push; consult live waiters at push time. - runtime.notifyMessageArrived(terminal.handle, 'status') - const waitPromise = runtime.waitForMessage(mailbox, { - typeFilter: ['status'], - timeoutMs: 5_000 - }) - await Promise.resolve() - - expect(write).not.toHaveBeenCalled() - expect(message.delivered_at).toBeNull() - - await vi.advanceTimersByTimeAsync(5_000) - await expect(waitPromise).resolves.toBe('timed_out') - db.close() - } finally { - vi.useRealTimers() - } - }) - it('rejects leaf PTY waits when the request signal aborts', async () => { vi.useFakeTimers() try { diff --git a/src/main/runtime/orca-runtime-tests/mobile-session-tabs-targeted-agent-resume.spec.ts b/src/main/runtime/orca-runtime-tests/mobile-session-tabs-targeted-agent-resume.spec.ts index 03572fefd51..3f8ef42d770 100644 --- a/src/main/runtime/orca-runtime-tests/mobile-session-tabs-targeted-agent-resume.spec.ts +++ b/src/main/runtime/orca-runtime-tests/mobile-session-tabs-targeted-agent-resume.spec.ts @@ -19,16 +19,7 @@ import type { PtyProcessInfo } from '../../providers/pty/process-info' import { deterministicAgentSessionUuid } from '../terminal/launch/runtime-agent-launch-resolution' import { deriveRemoteRuntimeTerminalCreateHandle } from '../terminal/identity/remote-runtime-terminal-create-identity' import type { RuntimePtyController } from '../terminal/lifecycle/runtime-pty-controller-contract' -import { agentSessionConversationView } from '../../../shared/agent-session/lifecycle/agent-session-conversation-view' -import { AgentSessionRecordStore } from '../agent-session/records/agent-session-record-store' -import { - agentSessionLeaseFixture, - agentSessionRecordFixture -} from '../../../shared/agent-session/lifecycle/agent-session-record.test-fixture' -import { - chooseSavedResumeFreshLaunch, - savedResumeResult -} from '../../ipc/pty/host-env/saved-resume-admission' +import { savedResumeResult } from '../../ipc/pty/host-env/saved-resume-admission' import { spawnedCommands, resumeSpawns } from './agent-resume-spawn-commands.test-fixture' const PANE_KEY = `host-tab:${HEADLESS_LEAF_ID}` @@ -131,67 +122,6 @@ function storedRecord(fixture: Fixture) { } describe('resumeAgentSessionInWorkspace', () => { - it.each(['live', 'worktree-sleep'] as const)( - 'releases a %s saved resume claim when actual admission creates a plain shell', - async (origin) => { - const fixture = makeSleptWorkspace() - const saved = storedRecord(fixture) - if (!saved) { - throw new Error('missing saved conversation') - } - saved.origin = origin - const chat = agentSessionRecordFixture( - agentSessionLeaseFixture({ - claimStatus: 'released', - ownerProcess: null, - reservedSpawnToken: null, - deathEvidence: { kind: 'exit-observed', detail: 'closed', observedAt: 1 } - }) - ) - chat.providerHandleChain[0]!.handle.nativeId = SESSION.id - let nativeOpen = true - const store: AgentSessionRecordStore = Object.create(AgentSessionRecordStore.prototype) - store.listConversations = () => [agentSessionConversationView(chat)] - store.getVisibleSessionTabIndex = () => ({ - present: true, - sessionIds: nativeOpen ? [chat.sessionId] : [] - }) - const effectiveCommands: (string | undefined)[] = [] - const { runtime, spawn, openOldPane, resume } = makeRuntime(fixture, { - spawn: async (args) => { - const admission = await chooseSavedResumeFreshLaunch( - { openAgentSessionRecordStore: async () => store }, - args, - null, - args - ) - effectiveCommands.push(args.command) - return { - id: effectiveCommands.length === 1 ? 'refused-shell' : 'resumed-C', - launchAgent: args.launchAgent, - launchConfig: args.launchConfig, - ...savedResumeResult(admission) - } - } - }) - await openOldPane() - expect(runtime.getTerminalLaunchResult('refused-shell')).toMatchObject({ - agentResumeRefused: 'chat-home', - savedResumeDecision: { agent: 'claude', providerSession: SESSION, verdict: 'chat-home' } - }) - expect(runtime.getTerminalLaunchResult('refused-shell')?.launchAgent).toBeUndefined() - expect(effectiveCommands).toEqual([undefined]) - nativeOpen = false - await expect(resume({ mutationId: 'after-native-close' })).resolves.toMatchObject({ - ok: true, - ptyId: 'resumed-C' - }) - expect(effectiveCommands[1]).toContain(SESSION.id) - expect(spawn).toHaveBeenCalledTimes(2) - expect(runtime.getTerminalLaunchResult('refused-shell')).toBeDefined() - } - ) - it('settles only fresh matching saved results and binds unproven or observed results until exit', async () => { for (const kind of [ 'matching',