mirror of
https://github.com/stablyai/orca.git
synced 2026-11-17 19:34:29 +00:00
* refactor: group structured session modules by owner * test: retire status history work-count oracle suite * refactor(main): organize journal storage and projection owners * Consolidate restart recovery fixture imports * Consolidate concrete session option model imports
60 lines
2.5 KiB
TypeScript
60 lines
2.5 KiB
TypeScript
import { mkdtempSync, rmSync } from 'node:fs'
|
|
import { tmpdir } from 'node:os'
|
|
import { join } from 'node:path'
|
|
import { expect, test } from 'vitest'
|
|
import { structuredAgentSessionWorkingAtStop } from '../../../src/main/native-chat/agent-session-wire/termination/structured-agent-session-working-at-teardown'
|
|
import {
|
|
journal,
|
|
NOW,
|
|
record,
|
|
SESSION,
|
|
TEARDOWN_CURRENT,
|
|
turnItem
|
|
} from '../../../src/main/native-chat/agent-session-wire/recovery/testing/structured-agent-session-restart-resume-test-harness'
|
|
import { AgentSessionRecoveryCapsule } from '../../../src/main/runtime/agent-session/records/agent-session-recovery-capsule'
|
|
import { importReleaseCheckoutModule, materializeReleaseCheckout } from './release-checkout'
|
|
import { prepareReleaseFixtures } from './release-fixture-setup'
|
|
|
|
// A release whose marker parser still requires the chat's newest message id.
|
|
const BASELINE_REF = 'v1.4.211'
|
|
const releaseCapsule = prepareReleaseFixtures([BASELINE_REF], async (ref) =>
|
|
importReleaseCheckoutModule(
|
|
await materializeReleaseCheckout(ref),
|
|
'src/main/runtime/agent-session-recovery-capsule.ts'
|
|
)
|
|
)
|
|
|
|
test('an older build reads the restart offer this build records at quit', async () => {
|
|
const directory = mkdtempSync(join(tmpdir(), 'orca-resume-marker-downgrade-'))
|
|
try {
|
|
// This build: the offer teardown takes for a chat whose turn was running.
|
|
const marker = structuredAgentSessionWorkingAtStop({
|
|
sessionId: SESSION,
|
|
session: {
|
|
journal: journal([turnItem('turn-1', 'running')]),
|
|
child: { fence: 1, phase: 'ready' }
|
|
},
|
|
getRecord: () => record(),
|
|
childWork: () => undefined,
|
|
childWorkOpen: () => false,
|
|
trigger: 'quit',
|
|
teardownId: TEARDOWN_CURRENT,
|
|
now: NOW
|
|
})
|
|
if (!marker) {
|
|
throw new Error('this build recorded no offer for a running turn')
|
|
}
|
|
await new AgentSessionRecoveryCapsule(directory).record([marker], NOW)
|
|
|
|
// The older build, after a downgrade, still lists it.
|
|
const baseline = releaseCapsule(BASELINE_REF)
|
|
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the pinned release exports this class with the constructor and `list` called below; a missing one fails the test.
|
|
const OldCapsule = baseline.AgentSessionRecoveryCapsule as new (directory: string) => {
|
|
list: (now: number) => Promise<{ sessionId: string }[]>
|
|
}
|
|
expect(await new OldCapsule(directory).list(NOW)).toMatchObject([{ sessionId: SESSION }])
|
|
} finally {
|
|
rmSync(directory, { recursive: true, force: true })
|
|
}
|
|
})
|