refactor(orchestrator): require canonical research contracts (CL14)
This commit is contained in:
parent
bc2b8a89da
commit
21666242f4
37 changed files with 151 additions and 319 deletions
3
test/fixtures/backtest-crash-owner.ts
vendored
3
test/fixtures/backtest-crash-owner.ts
vendored
|
|
@ -5,7 +5,6 @@ import { PostgreSQLClient } from '@stock-bot/postgres';
|
|||
import { BacktestRunner } from '../../apps/stock/orchestrator/src/backtest/BacktestRunner';
|
||||
import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository';
|
||||
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
|
||||
import { StorageService } from '../../apps/stock/orchestrator/src/services/StorageService';
|
||||
|
||||
setLoggerConfig({ logLevel: 'fatal', logConsole: false });
|
||||
const url = process.env.PIPELINE_TEST_DATABASE_URL;
|
||||
|
|
@ -35,9 +34,7 @@ repository.loadCanonicalDataset = async () => {
|
|||
const runner = new BacktestRunner({
|
||||
engine: new RustBacktestAdapter({
|
||||
logger,
|
||||
storage: new StorageService({ logger }, null, null, null),
|
||||
}),
|
||||
engineName: 'native',
|
||||
repository,
|
||||
logger,
|
||||
heartbeatMs: 50,
|
||||
|
|
|
|||
20
test/fixtures/canonical-runner.ts
vendored
20
test/fixtures/canonical-runner.ts
vendored
|
|
@ -68,9 +68,6 @@ export function canonicalRunnerFixture() {
|
|||
let heartbeatFailure = false;
|
||||
let status = 'pending';
|
||||
const repo: BacktestRunRepository = {
|
||||
async start() {
|
||||
throw new Error('legacy claim must not run');
|
||||
},
|
||||
async startCanonical(input) {
|
||||
events.push('claim');
|
||||
status = 'running';
|
||||
|
|
@ -95,20 +92,11 @@ export function canonicalRunnerFixture() {
|
|||
}
|
||||
return { cancelRequested: false };
|
||||
},
|
||||
async loadDataset() {
|
||||
throw new Error('v1 data must not run');
|
||||
},
|
||||
async freezeDataset() {
|
||||
throw new Error('provider freeze must not run');
|
||||
},
|
||||
async loadCanonicalDataset(_id, _attempt, hash) {
|
||||
expect(hash).toBe(dataset.manifest.hash);
|
||||
events.push('dataset');
|
||||
return dataset;
|
||||
},
|
||||
async complete() {
|
||||
throw new Error('legacy completion must not run');
|
||||
},
|
||||
async completeCanonical(input) {
|
||||
events.push('complete');
|
||||
result = input;
|
||||
|
|
@ -125,12 +113,8 @@ export function canonicalRunnerFixture() {
|
|||
events.push('cancel');
|
||||
status = 'cancelled';
|
||||
},
|
||||
async updateControl() {},
|
||||
};
|
||||
const engine = Object.assign(new EventEmitter(), {
|
||||
async runBacktest(): Promise<never> {
|
||||
throw new Error('legacy simulator must not run');
|
||||
},
|
||||
async runCanonical(
|
||||
_input: typeof request,
|
||||
resolve: (signal: AbortSignal) => Promise<HistoricalDatasetV2>
|
||||
|
|
@ -146,9 +130,6 @@ export function canonicalRunnerFixture() {
|
|||
async stopBacktest() {
|
||||
events.push('stop');
|
||||
},
|
||||
async pauseBacktest() {},
|
||||
async resumeBacktest() {},
|
||||
setSpeedMultiplier() {},
|
||||
getStatus() {
|
||||
return { isRunning: false, isPaused: false, progress: 0, currentTime: 0 };
|
||||
},
|
||||
|
|
@ -157,7 +138,6 @@ export function canonicalRunnerFixture() {
|
|||
const runner = new BacktestRunner({
|
||||
engine,
|
||||
repository: repo,
|
||||
engineName: 'native',
|
||||
logger,
|
||||
heartbeatMs: 5,
|
||||
heartbeatTimeoutMs: 50,
|
||||
|
|
|
|||
6
test/fixtures/research-pool.ts
vendored
6
test/fixtures/research-pool.ts
vendored
|
|
@ -148,11 +148,6 @@ export async function researchPoolFixture(dataset?: HistoricalDatasetV2) {
|
|||
const engines = repositories.map((_repository, slot) => {
|
||||
const engine = new RustBacktestAdapter({
|
||||
logger,
|
||||
storage: {
|
||||
async getHistoricalBars(): Promise<never> {
|
||||
throw new Error('Retained trials must not read a provider');
|
||||
},
|
||||
},
|
||||
});
|
||||
if (options.beforeExecute) {
|
||||
const execute = engine.runCanonical.bind(engine);
|
||||
|
|
@ -168,7 +163,6 @@ export async function researchPoolFixture(dataset?: HistoricalDatasetV2) {
|
|||
new BacktestRunner({
|
||||
engine,
|
||||
repository: repositories[i]!,
|
||||
engineName: 'native',
|
||||
logger,
|
||||
heartbeatMs: options.heartbeatMs ?? 5000,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue