refactor: share research domain and simplify application workflows
This commit is contained in:
parent
805a9f8fd4
commit
8c39ccf7ea
58 changed files with 3805 additions and 3081 deletions
|
|
@ -93,6 +93,7 @@ describe('orchestrator architecture boundaries', () => {
|
|||
'@stock-bot/stock-config/paper-deployments',
|
||||
'@stock-bot/calculations/analytics',
|
||||
'@stock-bot/calculations/returns',
|
||||
'@stock-bot/research/results',
|
||||
].includes(specifier)
|
||||
).toBe(true);
|
||||
}
|
||||
|
|
@ -417,3 +418,36 @@ describe('orchestrator architecture boundaries', () => {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('shared research boundary', () => {
|
||||
const repository = fileURLToPath(new URL('../../', import.meta.url));
|
||||
const research = join(repository, 'libs/research/src');
|
||||
it('shared domain files have no application implementation or service imports', () => {
|
||||
for (const name of new Bun.Glob('**/*.ts').scanSync({ cwd: research })) {
|
||||
const source = readFileSync(join(research, name), 'utf8');
|
||||
const sourceFile = ts.createSourceFile(name, source, ts.ScriptTarget.Latest, true);
|
||||
for (const statement of sourceFile.statements) {
|
||||
if ((ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) && statement.moduleSpecifier && ts.isStringLiteral(statement.moduleSpecifier)) {
|
||||
const dependency = statement.moduleSpecifier.text;
|
||||
expect(dependency).not.toMatch(/apps\/|orchestrator|@stock-bot\/(?:di|postgres|mongodb|questdb|engine|queue)(?:\/|$)/);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
it('the shared response contract bundles for browsers without server dependencies', async () => {
|
||||
const result = await Bun.build({ entrypoints: [join(research, 'dataset-contracts.ts')], target: 'browser', write: false });
|
||||
expect(result.success).toBe(true);
|
||||
expect(await result.outputs[0]!.text()).not.toMatch(/node:crypto|node:fs|engine\.node/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canonical admission boundary', () => {
|
||||
it('new run operations cannot construct legacy snapshots or invoke legacy execution', () => {
|
||||
const path = fileURLToPath(new URL('../../apps/stock/web-api/src/services/backtests/runs.ts', import.meta.url));
|
||||
const dependencies = runtimeImports(path);
|
||||
expect(dependencies.some(value => /execution-engine|BacktestRunner|strategy-manager/.test(value))).toBe(false);
|
||||
const source = readFileSync(path, 'utf8');
|
||||
expect(source).not.toContain('backtestRequestFromDefinition');
|
||||
expect(source).not.toContain('legacyDefinition');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue