Share backtest request contracts and isolate stored result mapping

This commit is contained in:
Boki 2026-10-21 23:57:48 -04:00
parent 007e35c747
commit 420c47704e
21 changed files with 777 additions and 244 deletions

View file

@ -65,7 +65,7 @@ describe('orchestrator architecture boundaries', () => {
path === 'backtest/native-worker-protocol.ts'
).toBe(true);
for (const specifier of imports.get(file) ?? []) {
expect(specifier.startsWith('.') || ['zod', '@stock-bot/types'].includes(specifier)).toBe(
expect(specifier.startsWith('.') || ['zod', '@stock-bot/types', '@stock-bot/stock-config/backtest'].includes(specifier)).toBe(
true
);
}
@ -73,6 +73,18 @@ describe('orchestrator architecture boundaries', () => {
}
});
it('the shared backtest contract loads no configuration manager, services or application runtime', async () => {
const entry = resolve(root, '../../config/src/contracts/backtest.ts');
expect(runtimeImports(entry).sort()).toEqual(['@stock-bot/types', 'zod']);
const bundle = await Bun.build({ entrypoints: [entry], target: 'browser', write: false });
expect(bundle.success).toBe(true);
const code = await bundle.outputs[0]?.text();
expect(code).toBeDefined();
expect(code).not.toContain('config-instance');
expect(code).not.toContain('PostgresClient');
expect(code).not.toContain('engine.node');
});
it('recovery and the ledger port do not depend on concrete adapters, strategies or the service container', () => {
for (const entry of [
'execution/SimulationExecution.ts',