This commit is contained in:
Boki 2026-10-22 09:46:29 -04:00
parent e4925ecdfe
commit b7aeca4888
20 changed files with 490 additions and 248 deletions

View file

@ -76,7 +76,7 @@ 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 });
const bundle = await Bun.build({ entrypoints: [entry], target: 'browser' });
expect(bundle.success).toBe(true);
const code = await bundle.outputs[0]?.text();
expect(code).toBeDefined();
@ -123,6 +123,29 @@ describe('orchestrator architecture boundaries', () => {
).toEqual(['contracts/strategy-names.ts', 'strategies/StrategyRegistry.ts']);
});
it('backtest and strategy lifecycle collaborators are injected, not located or constructed internally', () => {
for (const file of [
'backtest/BacktestEngine.ts',
'backtest/RustBacktestAdapter.ts',
'strategies/StrategyManager.ts',
'core/ModeManager.ts',
'services/MarketDataService.ts',
]) {
const source = readFileSync(join(root, file), 'utf8');
expect(source).not.toMatch(/\b(OrchestratorServices|IServiceContainer)\b/);
const tree = ts.createSourceFile(file, source, ts.ScriptTarget.Latest, true);
function visit(node: ts.Node) {
if (ts.isPropertyAccessExpression(node)) expect(node.name.text).not.toBe('custom');
if (ts.isElementAccessExpression(node) && ts.isStringLiteral(node.argumentExpression)) {
expect(node.argumentExpression.text).not.toBe('custom');
}
if (ts.isNewExpression(node)) expect(node.expression.getText(tree)).not.toBe('StorageService');
ts.forEachChild(node, visit);
}
visit(tree);
}
});
it('concrete strategies can only be loaded by the registry or other strategy implementations', () => {
for (const [file, dependencies] of graph) {
const owner = relative(root, file);