- Remove legacy compute-worker monolith under `src/compute/`, including PDF and Whisper inference, control-plane, and runtime orchestration - Move PDF and Whisper inference logic to new `src/inference/` module - Move control-plane, orchestrator, and state machine logic to `src/operations/` - Move NATS/JetStream adapters to `src/infrastructure/` - Move job orchestration, progress, and artifact persistence to `src/jobs/` - Update imports throughout tests and main app to reference new module structure - Update Dockerfile and scripts to use new asset paths - Add new entrypoints: `src/api/app.ts` and `src/api/contracts.ts` - Remove obsolete files and update `.gitignore` for new dev artifacts This refactor modularizes the compute-worker, improving maintainability and separation of concerns. No functional changes to inference or orchestration logic. BREAKING CHANGE: compute-worker internal APIs, directory structure, and imports have changed; downstream code must update imports and integration points.
59 lines
1.8 KiB
TypeScript
59 lines
1.8 KiB
TypeScript
import { afterEach, describe, expect, test, vi } from 'vitest';
|
|
import { recoverOrphanedOperations } from '../../src/operations/recovery';
|
|
import { FakeControlPlane } from '../fixtures/fake-control-plane';
|
|
|
|
describe('orphan recovery', () => {
|
|
afterEach(() => {
|
|
vi.useRealTimers();
|
|
});
|
|
|
|
test('recovers a running whisper op when a later sweep crosses the timeout in the same session', async () => {
|
|
vi.useFakeTimers();
|
|
vi.setSystemTime(new Date('2026-06-03T08:00:00.000Z'));
|
|
|
|
const fake = new FakeControlPlane();
|
|
const startedAt = Date.now();
|
|
fake.seedState({
|
|
opId: 'op-whisper-running',
|
|
opKey: 'k-whisper-running',
|
|
kind: 'whisper_align',
|
|
jobId: 'job-op-whisper-running',
|
|
status: 'running',
|
|
queuedAt: startedAt,
|
|
updatedAt: startedAt,
|
|
});
|
|
|
|
const firstSweep = await recoverOrphanedOperations({
|
|
operationStateStore: fake.deps.operationStateStore,
|
|
orchestrator: fake.deps.orchestrator,
|
|
whisperTimeoutMs: 30_000,
|
|
pdfTimeoutMs: 300_000,
|
|
opStaleMs: 1_800_000,
|
|
});
|
|
expect(firstSweep).toEqual([]);
|
|
expect(fake.getState('op-whisper-running')).toMatchObject({
|
|
status: 'running',
|
|
});
|
|
|
|
vi.advanceTimersByTime(31_000);
|
|
|
|
const secondSweep = await recoverOrphanedOperations({
|
|
operationStateStore: fake.deps.operationStateStore,
|
|
orchestrator: fake.deps.orchestrator,
|
|
whisperTimeoutMs: 30_000,
|
|
pdfTimeoutMs: 300_000,
|
|
opStaleMs: 1_800_000,
|
|
});
|
|
expect(secondSweep).toEqual([{
|
|
opId: 'op-whisper-running',
|
|
kind: 'whisper_align',
|
|
status: 'running',
|
|
}]);
|
|
expect(fake.getState('op-whisper-running')).toMatchObject({
|
|
status: 'failed',
|
|
error: {
|
|
code: 'WORKER_ORPHANED_OP',
|
|
},
|
|
});
|
|
});
|
|
});
|