Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions mobile/src/tasks/agent-launch-mobile-replay.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
} from '../../../src/shared/agent-session-host-authority'
import { setStructuredAgentSessionHost } from '../../../src/main/native-chat/agent-session-wire/structured-agent-session-registry'
import type { StructuredAgentSessionHost } from '../../../src/main/native-chat/agent-session-wire/structured-agent-session-host'
import { AgentSessionRecordStore } from '../../../src/main/runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../../../src/main/runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../../src/main/runtime/agent-session-record-store-test-harness'
import type { OrcaRuntimeService } from '../../../src/main/runtime/orca-runtime'
import { RpcDispatcher } from '../../../src/main/runtime/rpc/dispatcher'
import { runtimeStub } from '../../../src/main/runtime/rpc/methods/agent-launch.test-fixture'
Expand All @@ -30,7 +31,7 @@ beforeEach(async () => {
createStructuredSession.mockReset()
createStructuredSession.mockResolvedValue({ ok: true, value: { sessionId: 'session-1' } })
directory = await mkdtemp(join(tmpdir(), 'orca-mobile-launch-replay-'))
store = await AgentSessionRecordStore.open({ directory, hostId: 'local' })
store = await openTestAgentSessionRecordStore(directory)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the launch reads only deps.store; structured session creation is the injected boundary above.
setStructuredAgentSessionHost({ deps: { store } } as unknown as StructuredAgentSessionHost)
})
Expand Down
9 changes: 5 additions & 4 deletions mobile/src/tasks/mobile-agent-launch-architecture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { AgentSessionRecordStore } from '../../../src/main/runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../../../src/main/runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../../src/main/runtime/agent-session-record-store-test-harness'
import { OrcaRuntimeRpcServer } from '../../../src/main/runtime/runtime-rpc'
import { DeviceRegistry } from '../../../src/main/runtime/device-registry'
import type { AuthenticatedMobileSocket } from '../../../src/main/runtime/rpc/mobile-socket-wiring'
Expand Down Expand Up @@ -37,7 +38,7 @@ beforeEach(async () => {
createStructuredSession.mockReset()
createStructuredSession.mockResolvedValue({ ok: true, value: { sessionId: 'session-1' } })
directory = await mkdtemp(join(tmpdir(), 'orca-launch-architecture-'))
store = await AgentSessionRecordStore.open({ directory, hostId: 'local' })
store = await openTestAgentSessionRecordStore(directory)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the launch reads deps.store; session creation is injected above.
setStructuredAgentSessionHost({ deps: { store } } as unknown as StructuredAgentSessionHost)
})
Expand Down Expand Up @@ -241,7 +242,7 @@ describe('mobile launch retry authority', () => {
}
const first = await dispatcher.dispatch(request)
expect(first.ok).toBe(true)
store = await AgentSessionRecordStore.open({ directory, hostId: 'local' })
store = await openTestAgentSessionRecordStore(directory)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: launch admission reads only deps.store from the installed host.
setStructuredAgentSessionHost({ deps: { store } } as unknown as StructuredAgentSessionHost)
await expect(
Expand Down Expand Up @@ -291,7 +292,7 @@ describe('mobile launch retry authority', () => {
message: 'Branch "otter" already exists locally.'
}
})
store = await AgentSessionRecordStore.open({ directory, hostId: 'local' })
store = await openTestAgentSessionRecordStore(directory)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: launch admission reads only deps.store from the installed host.
setStructuredAgentSessionHost({ deps: { store } } as unknown as StructuredAgentSessionHost)
await expect(dispatcher.dispatch(request)).resolves.toMatchObject({
Expand Down
7 changes: 2 additions & 5 deletions src/main/claude/claude-api-retry-idle-sweep.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { mkdtemp, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from 'vitest'
import { AgentSessionRecordStore } from '../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../runtime/agent-session-record-store-test-harness'
import type { StructuredAgentSessionAdapter } from '../native-chat/agent-session-wire/structured-agent-session-adapter'
import type { StructuredAgentSessionEventSink } from '../native-chat/agent-session-wire/structured-agent-session-event-sink'
import { StructuredAgentSessionHost } from '../native-chat/agent-session-wire/structured-agent-session-host'
Expand Down Expand Up @@ -53,10 +53,7 @@ beforeEach(async () => {
sink = null
clock = NOW
closeSession = vi.fn(async () => true)
const store = await AgentSessionRecordStore.open({
directory: join(root, 'store'),
hostId: 'local'
})
const store = await openTestAgentSessionRecordStore(root)
const adapter: StructuredAgentSessionAdapter = {
acquire: async ({ fence, spawnToken, events }) => {
sink = events ?? null
Expand Down
5 changes: 3 additions & 2 deletions src/main/codex/codex-structured-question-order.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
} from '../../shared/structured-agent-session-reducer'
import { projectStructuredAgentSessionMessages } from '../../shared/structured-agent-session-message-projection'
import { projectNativeChatTranscriptMessages } from '../../shared/native-chat-transcript-projection'
import { AgentSessionRecordStore } from '../runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../runtime/agent-session-record-store-test-harness'
import { CodexJournalPrompts } from './codex-structured-journal-prompts'
import { CODEX_USER_INPUT_METHOD } from './codex-structured-prompt-replies'
import type { StructuredAgentSessionAdapter } from '../native-chat/agent-session-wire/structured-agent-session-adapter'
Expand Down Expand Up @@ -90,7 +91,7 @@ beforeEach(async () => {
answerPrompt: vi.fn(async ({ commit }) => commit()),
setOption: vi.fn(async () => undefined)
}
store = await AgentSessionRecordStore.open({ directory: join(root, 'store'), hostId: 'local' })
store = await openTestAgentSessionRecordStore(root)
host = new StructuredAgentSessionHost({
store,
adapter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
DISPATCH_REJECTED_CANCELLED
} from '../../../shared/structured-agent-session-dispatch-rejection'
import { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../runtime/agent-session-record-store-test-harness'
import type { AgentSessionJournal } from '../agent-session-journal/journal-store'
import { openAgentSessionJournal } from '../agent-session-journal/journal-store-factory'
import {
Expand Down Expand Up @@ -109,7 +110,7 @@ beforeEach(async () => {
ordinal: dispatch.mock.calls.length
}
}))
store = await AgentSessionRecordStore.open({ directory: join(root, 'store'), hostId: 'local' })
store = await openTestAgentSessionRecordStore(root)
await startHost()
expect(await host.attach(CALLER, hostTestAttachParams(null))).toMatchObject({ ok: true })
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
import { computeAgentSessionPayloadFingerprint } from '../../../shared/agent-session-mutation-envelope'
import type { AgentSessionOptionsResult } from '../../../shared/agent-session-wire'
import type { AgentJournalMessageItem } from '../../../shared/agent-session-journal-types'
import { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../runtime/agent-session-record-store-test-harness'
import type { AgentSessionRecord } from '../../../shared/agent-session-record'
import type { StructuredAgentSessionAdapter } from './structured-agent-session-adapter'
import { digestPayload } from '../agent-session-journal/journal-payload-bounds'
Expand Down Expand Up @@ -116,10 +117,7 @@ function expectSettledAttachLease(record: AgentSessionRecord | null): void {
describe('structured session acquisition options', () => {
it('samples provider history before acquiring a replacement child', async () => {
root = await mkdtemp(join(tmpdir(), 'orca-history-before-acquire-'))
const initialStore = await AgentSessionRecordStore.open({
directory: join(root, 'store'),
hostId: 'local'
})
const initialStore = await openTestAgentSessionRecordStore(root)
let childAcquired = false
const historyWindow = (): ProviderHistoryWindow => ({
items: [],
Expand Down Expand Up @@ -181,10 +179,7 @@ describe('structured session acquisition options', () => {
fence: 1
})
await firstJournal!.close()
const store = await AgentSessionRecordStore.open({
directory: join(root, 'store'),
hostId: 'local'
})
const store = await openTestAgentSessionRecordStore(root)
await store.reconcileOnRestart({
probe: async () => ({ outcome: 'pid-absent' }),
now: NOW + 1
Expand Down Expand Up @@ -218,10 +213,7 @@ describe('structured session acquisition options', () => {

it('persists create defaults before the first provider acquisition', async () => {
root = await mkdtemp(join(tmpdir(), 'orca-create-options-'))
const store = await AgentSessionRecordStore.open({
directory: join(root, 'store'),
hostId: 'local'
})
const store = await openTestAgentSessionRecordStore(root)
const sessionAdapter = adapter({ origin: 'created' })
const options = { model: 'gpt-5.6-sol', effort: 'medium', fastMode: 'false' }
const recordPhase = vi.fn<AgentSessionCreatePhaseRecorder>()
Expand Down Expand Up @@ -252,10 +244,7 @@ describe('structured session acquisition options', () => {

it('replays a create retried after the host re-resolved different options', async () => {
root = await mkdtemp(join(tmpdir(), 'orca-create-retry-'))
const store = await AgentSessionRecordStore.open({
directory: join(root, 'store'),
hostId: 'local'
})
const store = await openTestAgentSessionRecordStore(root)
const sessionAdapter = adapter({ origin: 'created' })
const attempt = async (options: Readonly<Record<string, string>>, spawnToken: string) =>
performAttach({
Expand Down Expand Up @@ -286,8 +275,7 @@ describe('structured session acquisition options', () => {

it('persists provider options before proving a resumed legacy record', async () => {
root = await mkdtemp(join(tmpdir(), 'orca-acquisition-options-'))
const storeDir = join(root, 'store')
const store = await AgentSessionRecordStore.open({ directory: storeDir, hostId: 'local' })
const store = await openTestAgentSessionRecordStore(root)

const created = await performAttach({
store,
Expand All @@ -313,10 +301,7 @@ describe('structured session acquisition options', () => {
now: NOW
})

const resumedStore = await AgentSessionRecordStore.open({
directory: storeDir,
hostId: 'local'
})
const resumedStore = await openTestAgentSessionRecordStore(root)
await resumedStore.reconcileOnRestart({
probe: async () => ({ outcome: 'pid-absent' }),
now: NOW + 1
Expand Down Expand Up @@ -345,7 +330,7 @@ describe('structured session acquisition options', () => {
})

expect(resumed).toMatchObject({ ok: true })
const reopened = await AgentSessionRecordStore.open({ directory: storeDir, hostId: 'local' })
const reopened = await openTestAgentSessionRecordStore(root)
expect(reopened.getRecord(SESSION)?.options).toEqual({
approvalPolicy: 'on-request',
personality: 'concise',
Expand All @@ -357,10 +342,7 @@ describe('structured session acquisition options', () => {

it('clears a rejected Fast restore instead of retaining the prior encoded value', async () => {
root = await mkdtemp(join(tmpdir(), 'orca-acquisition-fast-restore-'))
const store = await AgentSessionRecordStore.open({
directory: join(root, 'store'),
hostId: 'local'
})
const store = await openTestAgentSessionRecordStore(root)
const sessionAdapter = adapter({
origin: 'created',
options: { current: { model: 'gpt-standard' }, models: [] },
Expand Down Expand Up @@ -392,10 +374,7 @@ describe('structured session acquisition options', () => {

it('releases an acquisition when provider options cannot be read', async () => {
root = await mkdtemp(join(tmpdir(), 'orca-acquisition-options-failure-'))
const store = await AgentSessionRecordStore.open({
directory: join(root, 'store'),
hostId: 'local'
})
const store = await openTestAgentSessionRecordStore(root)
const releaseAcquisition = vi.fn(async () => true)
const failingAdapter: StructuredAgentSessionAdapter = {
...adapter({ origin: 'created' }),
Expand Down Expand Up @@ -446,8 +425,7 @@ describe('structured session acquisition options', () => {
] as const)('atomically settles the lease and operation after %s', async (_case, cleanup) => {
const exitProven = cleanup === true
root = await mkdtemp(join(tmpdir(), `orca-acquisition-${failurePoint}-`))
const storeDir = join(root, 'store')
const store = await AgentSessionRecordStore.open({ directory: storeDir, hostId: 'local' })
const store = await openTestAgentSessionRecordStore(root)
const base = adapter({
origin: 'created',
options: { current: { model: 'gpt-5.6-terra' }, models: [] }
Expand Down Expand Up @@ -534,10 +512,7 @@ describe('structured session acquisition options', () => {
exitProven ? injected.message : 'agent_session_acquisition_exit_unproven'
))

const reopened = await AgentSessionRecordStore.open({
directory: storeDir,
hostId: 'local'
})
const reopened = await openTestAgentSessionRecordStore(root)
const failedRecord = reopened.getRecord(SESSION)
expectSettledAttachLease(failedRecord)
expect(
Expand Down Expand Up @@ -600,7 +575,7 @@ describe('structured session acquisition options', () => {
describe('the tab a create reserves', () => {
async function openStore() {
root = await mkdtemp(join(tmpdir(), 'orca-surface-tab-id-'))
return AgentSessionRecordStore.open({ directory: join(root, 'store'), hostId: 'local' })
return openTestAgentSessionRecordStore(root)
}

function attachWith(store: AgentSessionRecordStore, surfaceTabId?: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { computeAgentSessionPayloadFingerprint } from '../../../shared/agent-session-mutation-envelope'
import { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../runtime/agent-session-record-store-test-harness'
import type { StructuredAgentSessionAdapter } from './structured-agent-session-adapter'
import {
attachFingerprintFields,
Expand Down Expand Up @@ -119,7 +120,7 @@ async function attach(
sessionAdapter: StructuredAgentSessionAdapter,
onAttached: AttachFlowInput['onAttached'] = () => {}
) {
store ??= await AgentSessionRecordStore.open({ directory: join(root!, 'store'), hostId: 'local' })
store ??= await openTestAgentSessionRecordStore(root!)
return performAttach({
store,
adapter: sessionAdapter,
Expand Down Expand Up @@ -230,7 +231,7 @@ describe('adopting a provider conversation on create', () => {
root = await mkdtemp(join(tmpdir(), 'orca-adopt-host-failure-'))
const transcriptPath = join(root, 'rollout.jsonl')
await writeCodexRollout(transcriptPath, 'valid source')
store = await AgentSessionRecordStore.open({ directory: join(root, 'store'), hostId: 'local' })
store = await openTestAgentSessionRecordStore(root)
const host = new StructuredAgentSessionHost({
store,
adapter: adapter(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import type {
AgentJournalSubmission
} from '../../../shared/agent-session-journal-types'
import type { AgentSessionSubscribeEvent } from '../../../shared/agent-session-wire'
import { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../runtime/agent-session-record-store-test-harness'
import type { StructuredAgentSessionAdapter } from './structured-agent-session-adapter'
import { StructuredAgentSessionHost } from './structured-agent-session-host'
import {
Expand Down Expand Up @@ -125,7 +126,7 @@ beforeEach(async () => {
acquisitionGeneration: `generation-${++generation}`,
providerChildPhase: 'starting' as const
}))
store = await AgentSessionRecordStore.open({ directory: join(root, 'store'), hostId: 'local' })
store = await openTestAgentSessionRecordStore(root)
host = new StructuredAgentSessionHost({
store,
adapter: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
PROVIDER_SESSION_ID,
type FakeConnection
} from '../../claude/claude-structured-session-test-support'
import { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../runtime/agent-session-record-store-test-harness'
import { structuredClaudeLifecycleEvent } from '../../runtime/structured-claude-runtime-adapter'
import { structuredAgentSessionCommandTurn } from './structured-agent-session-command-turn'
import { StructuredAgentSessionHost } from './structured-agent-session-host'
Expand Down Expand Up @@ -67,7 +68,7 @@ beforeEach(async () => {
readProcessStartTime: async () => 1_700_000_000_000,
now: () => adapterNow
})
store = await AgentSessionRecordStore.open({ directory: join(root, 'store'), hostId: 'local' })
store = await openTestAgentSessionRecordStore(root)
host = new StructuredAgentSessionHost({
store,
// The production router is what declares create support; the bare adapter only knows locations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
fakeClaude,
PROVIDER_SESSION_ID
} from '../../claude/claude-structured-session-test-support'
import { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import type { AgentSessionRecordStore } from '../../runtime/agent-session-record-store'
import { openTestAgentSessionRecordStore } from '../../runtime/agent-session-record-store-test-harness'
import { structuredClaudeLifecycleEvent } from '../../runtime/structured-claude-runtime-adapter'
import { StructuredAgentSessionHost } from './structured-agent-session-host'
import {
Expand Down Expand Up @@ -63,7 +64,7 @@ beforeEach(async () => {
readProcessStartTime: async () => 1_700_000_000_000,
now: () => NOW
})
store = await AgentSessionRecordStore.open({ directory: join(root, 'store'), hostId: 'local' })
store = await openTestAgentSessionRecordStore(root)
host = new StructuredAgentSessionHost({
store,
adapter: Object.assign(adapter, { supportsCreate: () => true }),
Expand Down
Loading
Loading