Run quote lifecycle retention on a timer
All checks were successful
deploy / deploy (push) Successful in 41s

Proof: History writer now runs quote lifecycle retention immediately and on a repo-owned timer independent of Kafka batch traffic, with regression coverage for the timer and shutdown cleanup.
Assumptions: A one-minute maintenance cadence remains the approved bounded retention cadence for this turn.
Still fake: Retention remains aggregate rollup evidence for pruned non-success detail; already-pruned historical detail cannot be reconstructed.
This commit is contained in:
philipp 2026-06-06 15:55:41 +02:00
parent 2d329c9b2f
commit aa42fccbd4
2 changed files with 10 additions and 0 deletions

View file

@ -229,6 +229,12 @@ await refreshQuoteLifecycleRetentionState().catch((error) => {
state.retention_error = serializeError(error);
});
const quoteLifecycleRetentionMaintenanceTimer = setInterval(() => {
void maybeRunQuoteLifecycleRetentionMaintenance();
}, quoteLifecycleRetentionMaintenanceIntervalMs);
quoteLifecycleRetentionMaintenanceTimer.unref?.();
await maybeRunQuoteLifecycleRetentionMaintenance({ force: true });
for (const historyConsumer of durableConsumers) {
await runHistoryConsumer(historyConsumer);
}
@ -770,6 +776,7 @@ function resumeConsumers() {
}
async function shutdown() {
clearInterval(quoteLifecycleRetentionMaintenanceTimer);
await controlApi.close().catch(() => {});
await Promise.allSettled([
...durableConsumers.map((historyConsumer) => historyConsumer.disconnect()),

View file

@ -24,6 +24,9 @@ test('history writer replays durable topics but joins the raw quote firehose liv
assert.match(source, /runQuoteLifecycleRetentionMaintenance/);
assert.match(source, /loadQuoteLifecycleRetentionSummary/);
assert.match(source, /maybeRunQuoteLifecycleRetentionMaintenance/);
assert.match(source, /quoteLifecycleRetentionMaintenanceTimer\s*=\s*setInterval/);
assert.match(source, /maybeRunQuoteLifecycleRetentionMaintenance\(\{\s*force:\s*true\s*\}\)/);
assert.match(source, /clearInterval\(quoteLifecycleRetentionMaintenanceTimer\)/);
assert.match(source, /retention_mode/);
assert.match(source, /storage_pressure/);
assert.doesNotMatch(source, /RetainRecentMs/);