feat(research): cut over canonical runtime and enforce agent budgets
This commit is contained in:
parent
ab08db82fd
commit
bbf0dd4453
103 changed files with 6138 additions and 3112 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
type BacktestRequest,
|
||||
} from '../../apps/stock/web-api/src/services/backtest-v2.service';
|
||||
import { DatasetCatalogService } from '../../apps/stock/web-api/src/services/dataset-catalog.service';
|
||||
import { seedHistoricalRun } from '../fixtures/historical-run';
|
||||
|
||||
setLoggerConfig({ logLevel: 'fatal', logConsole: false });
|
||||
const logger = getLogger('dataset-catalog-test');
|
||||
|
|
@ -200,7 +201,7 @@ describe.skipIf(!url)('dataset catalog and selected-run submission on real Postg
|
|||
}
|
||||
});
|
||||
|
||||
test('missing, inconsistent, malformed and unsupported selected snapshots reject before any run/outbox is inserted', async () => {
|
||||
test('legacy admission refuses missing, inconsistent, malformed and unsupported snapshots before any run/outbox is inserted', async () => {
|
||||
const f = await fixture();
|
||||
const saved = await f.api.createBacktest(
|
||||
{ ...request(), config: { fastPeriod: 2, slowPeriod: 3 } },
|
||||
|
|
@ -230,7 +231,9 @@ describe.skipIf(!url)('dataset catalog and selected-run submission on real Postg
|
|||
saved.id,
|
||||
{ ...request().config, datasetHash: 'e'.repeat(64) },
|
||||
]);
|
||||
await expect(f.api.createRun({ backtestId: saved.id })).rejects.toThrow('not found');
|
||||
await expect(f.api.createRun({ backtestId: saved.id })).rejects.toThrow(
|
||||
'Legacy backtest execution is retired'
|
||||
);
|
||||
expect((await f.pool.query('SELECT count(*)::int AS n FROM runs')).rows[0].n).toBe(0);
|
||||
expect((await f.pool.query('SELECT count(*)::int AS n FROM backtest_dispatch')).rows[0].n).toBe(
|
||||
0
|
||||
|
|
@ -288,23 +291,20 @@ describe.skipIf(!url)('dataset catalog and selected-run submission on real Postg
|
|||
const retained = await f.api.getBacktest(saved.id);
|
||||
expect(retained!.endDate.toISOString()).toBe(manifest().endDate);
|
||||
expect(retained!.config.datasetHash).toBe(hash);
|
||||
expect((await f.api.createRun({ backtestId: saved.id })).dataset.requestedHash).toBe(hash);
|
||||
expect(
|
||||
(await seedHistoricalRun(f.pool, f.api, { backtestId: saved.id })).dataset.requestedHash
|
||||
).toBe(hash);
|
||||
await expect(f.api.createRun({ backtestId: saved.id })).rejects.toThrow(
|
||||
'Legacy backtest execution is retired'
|
||||
);
|
||||
});
|
||||
|
||||
test('selected run snapshots commit atomically and same-key retry returns its original receipt before mutable definition validation', async () => {
|
||||
test('historical selected snapshots and original receipts survive retired admission and later definition edits', async () => {
|
||||
const f = await fixture();
|
||||
await f.insert(hash, { manifest: manifest(), bars: [{}] });
|
||||
const saved = await f.api.createBacktest(request(), { autoStart: false });
|
||||
await f.pool.query(
|
||||
`CREATE FUNCTION reject_dataset_outbox() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN RAISE EXCEPTION 'injected outbox failure'; END $$; CREATE TRIGGER reject_dataset_outbox BEFORE INSERT ON backtest_dispatch FOR EACH ROW EXECUTE FUNCTION reject_dataset_outbox()`
|
||||
);
|
||||
await expect(f.api.createRun({ backtestId: saved.id })).rejects.toThrow(
|
||||
'injected outbox failure'
|
||||
);
|
||||
expect((await f.pool.query('SELECT count(*)::int AS n FROM runs')).rows[0].n).toBe(0);
|
||||
await f.pool.query('DROP TRIGGER reject_dataset_outbox ON backtest_dispatch');
|
||||
const submission = { principal: 'operator' as const, key: 'dataset-retry' };
|
||||
const first = await f.api.createRun({ backtestId: saved.id }, submission);
|
||||
const first = await seedHistoricalRun(f.pool, f.api, { backtestId: saved.id }, submission);
|
||||
expect(first.dataset).toEqual({
|
||||
requestedHash: hash,
|
||||
pinnedHash: null,
|
||||
|
|
@ -334,7 +334,7 @@ describe.skipIf(!url)('dataset catalog and selected-run submission on real Postg
|
|||
{ ...request(), config: { dataSource: 'eod' } },
|
||||
{ autoStart: false }
|
||||
);
|
||||
const run = await f.api.createRun({ backtestId: saved.id });
|
||||
const run = await seedHistoricalRun(f.pool, f.api, { backtestId: saved.id });
|
||||
expect(run.dataset).toEqual({
|
||||
requestedHash: null,
|
||||
pinnedHash: null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue