Remove dataset input caps and simplify preparation

This commit is contained in:
Boki 2026-10-21 23:34:10 -04:00
parent 6bd671d92a
commit 007e35c747
17 changed files with 175 additions and 620 deletions

View file

@ -13,7 +13,6 @@ import { BacktestCancelledError } from '../../apps/stock/orchestrator/src/backte
import { PostgresBacktestRunRepository } from '../../apps/stock/orchestrator/src/backtest/PostgresBacktestRunRepository';
import { BacktestLeaseLostError } from '../../apps/stock/orchestrator/src/backtest/run-repository';
import { RustBacktestAdapter } from '../../apps/stock/orchestrator/src/backtest/RustBacktestAdapter';
import { DatasetLimitError } from '../../apps/stock/orchestrator/src/data/dataset-limits';
import { loadDataset } from '../../apps/stock/orchestrator/src/data/historical-dataset';
import { StorageService } from '../../apps/stock/orchestrator/src/services/StorageService';
import { BacktestConfigSchema } from '../../apps/stock/orchestrator/src/types';
@ -295,36 +294,6 @@ describe.skipIf(!url || !redisUrl)('durable backtests on real PostgreSQL and Red
);
});
test('oversized snapshots fail before pinning and persisted JSONB size is checked before transfer', async () => {
const f = await fixture();
const run = await f.api.createRun({ backtestId: f.definition.id });
const config = await f.snapshot(run.id);
const claim = await f.repository.start(config);
const dataset = await loadDataset(f.storage, config);
const small = new PostgresBacktestRunRepository(f.postgres, 2000, { maxBars: 1 });
await expect(small.freezeDataset(run.id, claim.attemptId, dataset)).rejects.toBeInstanceOf(
DatasetLimitError
);
expect((await f.pool.query('SELECT * FROM backtest_datasets')).rows).toHaveLength(0);
expect(
(await f.pool.query('SELECT dataset_hash FROM runs WHERE id = $1', [run.id])).rows[0]
.dataset_hash
).toBeNull();
// A stored-text overflow during freeze must roll back both insertion and pinning too.
const storedBudget = new PostgresBacktestRunRepository(f.postgres, 2000, { maxStoredBytes: 1 });
await expect(
storedBudget.freezeDataset(run.id, claim.attemptId, dataset)
).rejects.toBeInstanceOf(DatasetLimitError);
expect((await f.pool.query('SELECT * FROM backtest_datasets')).rows).toHaveLength(0);
await f.repository.freezeDataset(run.id, claim.attemptId, dataset);
await expect(storedBudget.loadDataset(run.id, claim.attemptId)).rejects.toBeInstanceOf(
DatasetLimitError
);
expect((await f.repository.loadDataset(run.id, claim.attemptId))?.manifest.hash).toBe(
dataset.manifest.hash
);
});
test('cancellation after snapshot insertion aborts preparation and rolls back the run pointer and payload', async () => {
const f = await fixture();
const run = await f.api.createRun({ backtestId: f.definition.id });