unrip/test/runtime-health.test.mjs
philipp f5ee95b325
All checks were successful
deploy / deploy (push) Successful in 31s
Stop false publish-stale containment
Proof: Sentinel no longer raises publish-stale before any matching quote exists, preventing false executor auto-disarm during quiet or pre-match periods; regression tests cover both the false case and the real stalled-after-match case.

Assumptions: A publish-path failure is only meaningful after at least one matching quote has been observed for the active pair.

Still fake: The dashboard still lacks deep ingest diagnostics for why quotes are filtered, so pair-filter mismatch analysis is not yet visible at a glance.
2026-04-08 23:21:51 +02:00

49 lines
1.5 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
shouldContainExecutorForAlerts,
shouldRaiseIngestPublishStale,
} from '../src/core/runtime-health.mjs';
test('publish stale does not raise before any matching quote exists', () => {
assert.equal(shouldRaiseIngestPublishStale({
lastMatchingQuoteAt: null,
lastPublishedAt: null,
matchingQuoteAgeMs: null,
publishedAgeMs: null,
publishStaleMs: 30_000,
}), false);
});
test('publish stale raises after a matching quote exists but no publish follows', () => {
assert.equal(shouldRaiseIngestPublishStale({
lastMatchingQuoteAt: '2026-04-08T20:45:00.000Z',
lastPublishedAt: null,
matchingQuoteAgeMs: 10_000,
publishedAgeMs: null,
publishStaleMs: 30_000,
}), true);
});
test('executor containment ignores quote-stale-only conditions', () => {
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'near_intents_quotes_stale',
severity: 'critical',
}]), false);
});
test('executor containment still triggers on broken truth path alerts', () => {
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'near_intents_ingest_disconnected',
severity: 'critical',
}]), true);
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'near_intents_publish_stale',
severity: 'critical',
}]), true);
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'history_writer_stalled',
severity: 'critical',
}]), true);
});