refactor(orchestrator): narrow historical storage to reads (CL17)
This commit is contained in:
parent
03518c8ae4
commit
984dc1a9cc
17 changed files with 88 additions and 232 deletions
|
|
@ -126,7 +126,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
recordsSaved: 78,
|
||||
recordsFetched: 78,
|
||||
});
|
||||
const storage = new StorageService({ logger }, store.mongodb, null, null);
|
||||
const storage = new StorageService(logger, store.mongodb, null);
|
||||
const bars = await storage.getHistoricalBars(identity.eodSearchCode, start, end, '5m');
|
||||
const economicRows = bars.map(({ timestamp, open, high, low, close, volume }) => ({
|
||||
timestamp: timestamp.getTime(),
|
||||
|
|
@ -157,6 +157,10 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
});
|
||||
const dataset = freeze(economicRows);
|
||||
expect(dataset.manifest.hash).toBe(freeze(expected).manifest.hash);
|
||||
// Pinned before CL17: dropping write/lifecycle responsibilities cannot alter retained bytes.
|
||||
expect(dataset.manifest.hash).toBe(
|
||||
'828cff0ac7ac555f82e69540b90f529ed237de07bab4bbd96a734068d75cfed1'
|
||||
);
|
||||
expect(dataset.manifest.barCount).toBe(response.length);
|
||||
expect(dataset.manifest.eligibility).toBe('exploratory');
|
||||
expect(dataset.bars[0]?.intervalStart).toBe(start.getTime());
|
||||
|
|
@ -168,6 +172,9 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
|
||||
// Historical V1 payloads remain readable; production execution requires V2 admission.
|
||||
const legacy = await loadDataset(storage, config());
|
||||
expect(legacy.manifest.hash).toBe(
|
||||
'094e1002f551d4a9ec31d7f89afae5cb32ca82b4b6ff1ca6778c8c281f5392eb'
|
||||
);
|
||||
expect(
|
||||
legacy.bars.map(({ timestamp, open, high, low, close, volume }) => ({
|
||||
timestamp,
|
||||
|
|
@ -196,7 +203,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
.slice(0, 3)
|
||||
.map(row => ({ ...row, gmtoffset: -14_400, datetime: 'untrusted local label' }))
|
||||
);
|
||||
const storage = new StorageService({ logger }, store.mongodb, null, null);
|
||||
const storage = new StorageService(logger, store.mongodb, null);
|
||||
for (const [interval, collection] of [
|
||||
['1m', 'eodIntraday1M'],
|
||||
['5m', 'eodIntraday5M'],
|
||||
|
|
@ -219,7 +226,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
|
||||
test('capabilities report configured connectivity and supported intervals, never stored coverage', () => {
|
||||
const store = memoryStore();
|
||||
const storage = new StorageService({ logger }, store.mongodb, null, {
|
||||
const storage = new StorageService(logger, store.mongodb, {
|
||||
connected: false,
|
||||
} as QuestDBClient);
|
||||
expect(storage.getHistoricalCapabilities()).toEqual([
|
||||
|
|
@ -232,7 +239,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
{ provider: 'eod', configured: true, connected: true, intervals: ['1m', '5m', '1h', '1d'] },
|
||||
]);
|
||||
expect(
|
||||
new StorageService({ logger }, null, null, null)
|
||||
new StorageService(logger, null, null)
|
||||
.getHistoricalCapabilities()
|
||||
.every(capability => !capability.configured && !capability.connected)
|
||||
).toBe(true);
|
||||
|
|
@ -240,7 +247,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
|
||||
test('unsupported_interval and provider reject explicitly without queries or synthetic fallback', async () => {
|
||||
const store = memoryStore();
|
||||
const storage = new StorageService({ logger }, store.mongodb, null, null, {
|
||||
const storage = new StorageService(logger, store.mongodb, null, {
|
||||
allowSyntheticData: true,
|
||||
});
|
||||
for (const interval of ['15m', '2m']) {
|
||||
|
|
@ -260,7 +267,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
)
|
||||
).rejects.toMatchObject({ code: 'unsupported-provider' });
|
||||
expect(store.reads).toHaveLength(0);
|
||||
const absent = new StorageService({ logger }, null, null, null, { allowSyntheticData: true });
|
||||
const absent = new StorageService(logger, null, null, { allowSyntheticData: true });
|
||||
for (const provider of ['eod', 'questdb'] as const) {
|
||||
await expect(
|
||||
absent.getHistoricalBars(
|
||||
|
|
@ -278,7 +285,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
|
||||
test('missing_range is typed; selecting a real provider never falls back to synthetic data', async () => {
|
||||
const store = memoryStore();
|
||||
const storage = new StorageService({ logger }, store.mongodb, null, null, {
|
||||
const storage = new StorageService(logger, store.mongodb, null, {
|
||||
allowSyntheticData: true,
|
||||
});
|
||||
try {
|
||||
|
|
@ -306,7 +313,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
return { rows: [] };
|
||||
},
|
||||
} as unknown as QuestDBClient;
|
||||
const storage = new StorageService({ logger }, store.mongodb, null, questdb);
|
||||
const storage = new StorageService(logger, store.mongodb, questdb);
|
||||
await expect(
|
||||
storage.getHistoricalBars(identity.eodSearchCode, start, end, '5m')
|
||||
).rejects.toMatchObject({ code: 'missing-range', provider: 'questdb' });
|
||||
|
|
@ -337,7 +344,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
return records;
|
||||
},
|
||||
} as unknown as MongoDBClient;
|
||||
const storage = new StorageService({ logger }, mongodb, null, null);
|
||||
const storage = new StorageService(logger, mongodb, null);
|
||||
for (const timestamp of [
|
||||
String(row.timestamp),
|
||||
row.timestamp + 0.5,
|
||||
|
|
@ -362,6 +369,12 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
storage.getHistoricalBars(identity.eodSearchCode, start, end, '5m')
|
||||
).rejects.toThrow('identity mismatch');
|
||||
}
|
||||
for (const volume of [null, undefined, '', ' ', NaN, Infinity, -1]) {
|
||||
records = [{ ...row, volume }];
|
||||
await expect(
|
||||
storage.getHistoricalBars(identity.eodSearchCode, start, end, '5m')
|
||||
).rejects.toThrow('Invalid historical OHLCV');
|
||||
}
|
||||
records = [{ ...row, low: -1 }];
|
||||
await expect(
|
||||
storage.getHistoricalBars(identity.eodSearchCode, start, end, '5m')
|
||||
|
|
@ -394,7 +407,7 @@ describe('EOD intraday ingestion → research storage', () => {
|
|||
return [{ ...intradayResponse()[0]!, ...identity }];
|
||||
},
|
||||
} as unknown as MongoDBClient;
|
||||
const storage = new StorageService({ logger }, mongodb, null, null);
|
||||
const storage = new StorageService(logger, mongodb, null);
|
||||
await expect(
|
||||
storage.getHistoricalBars(identity.eodSearchCode, start, end, '5m', undefined, before.signal)
|
||||
).rejects.toThrow('cancelled before query');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue