feat(research): select and reuse frozen datasets in workbench

This commit is contained in:
Boki 2026-10-23 18:13:37 -04:00
parent 6a67ae8683
commit b106c1ca85
29 changed files with 2295 additions and 426 deletions

View file

@ -40,8 +40,11 @@ function memoryStore() {
const index = documents.findIndex(
old => old.date === row.date && old.eodSearchCode === row.eodSearchCode
);
if (index >= 0) documents[index] = row;
else documents.push(row);
if (index >= 0) {
documents[index] = row;
} else {
documents.push(row);
}
}
return {
insertedCount: rows.length,
@ -175,6 +178,30 @@ describe('deterministic ingestion → storage → native backtest', () => {
expect(a.manifest.hash).not.toBe(b.manifest.hash);
});
test('explicit source requests reach storage and cannot silently reuse another provider', async () => {
const { mongodb } = memoryStore();
await persistEodPrices(mongodb, identity, fixture);
const storage = new StorageService({ logger }, mongodb, null, null);
const providers: unknown[] = [];
const selected = await loadDataset(
{
getHistoricalBars: (...args: Parameters<StorageService['getHistoricalBars']>) => {
providers.push(args[6]);
return storage.getHistoricalBars(...args);
},
},
{ ...datasetConfig(), dataSource: 'eod' }
);
expect(providers).toEqual(['eod']);
expect(selected.manifest.sources.map(source => source.provider)).toEqual(['eod']);
expect(() => validateDataset(selected, { ...datasetConfig(), dataSource: 'questdb' })).toThrow(
'does not match'
);
await expect(
loadDataset(storage, { ...datasetConfig(), dataSource: 'questdb' })
).rejects.toThrow();
});
test('missing provider factors cannot silently turn adjusted requests into raw data', async () => {
const { mongodb } = memoryStore();
await persistEodPrices(mongodb, identity, [fixture[0]!]);