All checks were successful
deploy / deploy (push) Successful in 1m13s
Proof: Raw NEAR Intents quote retention now keeps only a 30 minute raw firehose window and drains up to 10M stale unlinked raw rows per pass. Targeted raw retention tests, full npm test, and operator dashboard bundle build pass. Assumptions: raw quote firehose rows are debug evidence, while normalized quote demand, decisions, commands, executor results, outcomes, inventory, pricing, and DB config remain the durable trading evidence. Still fake: venue-native terminal fill ids and fee-complete realized PnL remain unavailable; raw quote firehose rows truncated during emergency recovery are intentionally no longer readable.
36 lines
2.2 KiB
JavaScript
36 lines
2.2 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const source = readFileSync(new URL('../src/apps/history-writer.mjs', import.meta.url), 'utf8');
|
|
|
|
test('history writer replays durable topics but joins the raw quote firehose live', () => {
|
|
assert.match(source, /durableHistoryConsumerCount\s*=\s*3/);
|
|
assert.match(source, /durableConsumers\.push\(await createConsumer/);
|
|
assert.match(source, /liveEvidenceConsumerCount\s*=\s*2/);
|
|
assert.match(source, /groupId:\s*`\$\{config\.kafkaConsumerGroupHistory\}-live`/);
|
|
assert.match(source, /groupId:\s*`\$\{config\.kafkaConsumerGroupHistory\}-raw`/);
|
|
assert.match(source, /liveEvidenceTopics\s*=\s*\[[\s\S]+config\.kafkaTopicNormSwapDemand[\s\S]+config\.kafkaTopicDecisionTradeDecision/);
|
|
assert.match(source, /current quote\/decision truth visible/);
|
|
assert.match(source, /rawQuoteConsumer\.subscribe\(\{[\s\S]+fromBeginning:\s*false/);
|
|
assert.match(source, /historyConsumer\.subscribe\(\{[\s\S]+fromBeginning:\s*true/);
|
|
assert.match(source, /liveEvidenceTopics[\s\S]+fromBeginning:\s*false/);
|
|
assert.match(source, /Raw quote volume is a live firehose/);
|
|
assert.match(source, /runHistoryConsumer\(historyConsumer\)/);
|
|
assert.match(source, /runHistoryConsumer\(rawQuoteConsumer\)/);
|
|
assert.match(source, /eachBatch/);
|
|
assert.match(source, /insertHistoryEvents/);
|
|
assert.match(source, /rawQuoteHistoryPruneIntervalMs\s*=\s*60 \* 1000/);
|
|
assert.match(source, /rawQuoteHistoryRetainRecentMs\s*=\s*30 \* 60 \* 1000/);
|
|
assert.match(source, /rawQuoteHistoryPruneBatchSize\s*=\s*500_000/);
|
|
assert.match(source, /rawQuoteHistoryPruneMaxBatches\s*=\s*20/);
|
|
assert.match(source, /pruneRawNearIntentsQuoteHistory/);
|
|
assert.match(source, /maxBatches:\s*rawQuoteHistoryPruneMaxBatches/);
|
|
assert.match(source, /batch\.topic === config\.kafkaTopicRawNearIntentsQuote/);
|
|
});
|
|
|
|
test('history writer passes tracked assets into portfolio valuation', () => {
|
|
assert.match(source, /trackedAssets:\s*tradingConfig\.trackedAssets/);
|
|
assert.match(source, /valuationAssets:\s*inputs\.valuationAssets \|\| \[\]/);
|
|
assert.match(source, /inputs\.valuationAssets[\s\S]+asset\.priceId/);
|
|
});
|