- 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.
18 lines
911 B
TypeScript
18 lines
911 B
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { buildQueueWaitTiming, decideRetryAction } from '../../src/jobs/worker-loop-policy';
|
|
|
|
describe('worker loop policy', () => {
|
|
test('returns queue wait timing with non-negative clamped duration', () => {
|
|
expect(buildQueueWaitTiming(1000, 1300)).toEqual({ queueWaitMs: 300 });
|
|
expect(buildQueueWaitTiming(1500, 1300)).toEqual({ queueWaitMs: 0 });
|
|
});
|
|
|
|
test('retry policy: layout jobs can retry until max attempts', () => {
|
|
expect(decideRetryAction({ kind: 'pdf_layout', deliveryCount: 1, pdfAttempts: 3 })).toBe('nak_retry');
|
|
expect(decideRetryAction({ kind: 'pdf_layout', deliveryCount: 3, pdfAttempts: 3 })).toBe('term_fail');
|
|
});
|
|
|
|
test('retry policy: whisper jobs terminate immediately by default', () => {
|
|
expect(decideRetryAction({ kind: 'whisper_align', deliveryCount: 1, pdfAttempts: 10 })).toBe('term_fail');
|
|
});
|
|
});
|