unrip/test/runtime-health.test.mjs
philipp 65d3cff595
All checks were successful
deploy / deploy (push) Successful in 32s
Disable automatic executor containment
Proof: Remove repo-owned automatic safety disarms and operator alert severity surfaces so arming state is no longer silently reverted by stale-quote alerts.

Assumptions: The operator now wants arming to remain explicit and durable even when quote-truth checks are stale or noisy, and simple reachability/state is a better surface than derived alert severity for now.

Still fake: The upstream quote-truth and health heuristics remain unreliable; this change removes their automatic containment effect instead of fixing their underlying accuracy.
2026-04-09 23:42:22 +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 stays disabled for quote-stale-only conditions', () => {
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'near_intents_quotes_stale',
severity: 'critical',
}]), false);
});
test('executor containment stays disabled even for broken truth path alerts', () => {
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'near_intents_ingest_disconnected',
severity: 'critical',
}]), false);
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'near_intents_publish_stale',
severity: 'critical',
}]), false);
assert.equal(shouldContainExecutorForAlerts([{
alert_code: 'history_writer_stalled',
severity: 'critical',
}]), false);
});