feat(research): isolate candidates and add reviewed paper promotion

This commit is contained in:
Boki 2026-10-24 18:46:55 -04:00
parent 26b97265c6
commit 25b5cbf481
128 changed files with 13038 additions and 1388 deletions

View file

@ -2,10 +2,10 @@ import { ServiceContainerBuilder } from '@stock-bot/di';
import type { StockAppConfig } from '@stock-bot/stock-config';
import { assertResearchConcurrency } from './backtest/ResearchBacktestPool';
import { paperConfigurationSchema } from './contracts/paper-runtime';
import { validatePaperConfiguration } from './paper/feed';
import {
assertSupportedComposition,
registerOrchestratorServices,
resolvePaperComposition,
type OrchestratorRole,
} from './container';
import type { OrchestratorServices } from './types';
@ -32,21 +32,17 @@ export async function createContainer(
const maxConcurrent =
settings?.backtesting?.maxConcurrent === undefined ? 1 : settings.backtesting.maxConcurrent;
assertResearchConcurrency(maxConcurrent);
if (settings?.canonicalPaper !== undefined && role !== 'paper') {
throw new Error('Canonical paper configuration requires a paper composition');
}
const canonicalPaper =
const { canonicalPaper, paperDeploymentHost } = resolvePaperComposition(
role,
settings?.canonicalPaper === undefined
? undefined
: validatePaperConfiguration(paperConfigurationSchema.parse(settings.canonicalPaper));
if (role === 'paper' && !canonicalPaper) {
throw new Error(
'Paper composition requires explicit canonicalPaper configuration; accounts are never migrated automatically'
);
}
if (canonicalPaper && !config.database?.postgres?.enabled) {
: paperConfigurationSchema.parse(settings.canonicalPaper),
settings?.paperDeploymentHost
);
if ((canonicalPaper || paperDeploymentHost) && !config.database?.postgres?.enabled) {
throw new Error('Canonical paper requires durable PostgreSQL custody');
}
const container = await new ServiceContainerBuilder()
.withConfig(config)
.withOptions({
@ -67,6 +63,7 @@ export async function createContainer(
syntheticSeed: config.services?.orchestrator?.backtesting?.syntheticSeed ?? 42,
nativeExecutionTimeoutMs: config.services?.orchestrator?.backtesting?.executionTimeoutMs,
canonicalPaper,
paperDeploymentHost,
});
return container.resolve('serviceContainer') as OrchestratorServices;
}