Some checks failed
deploy / deploy (push) Failing after 43s
Proof: Pair-native trade semantics and multi-asset outcome truth; strategy, request preflight, outcome attribution, valuation visibility, dashboard labels, alerts, and ops watch paths now use DB pair/asset/route metadata with nBTC/EURe compatibility and nBTC/USDC regressions covered. Assumptions: Postgres asset, pair, strategy config, and price route rows remain canonical; supported reference adapters remain BTC/EUR and BTC/USDC; deployment is push-driven through the existing Forgejo workflow. Still fake: Arbitrary multi-hop valuation, new execution venues, fee-complete realized PnL, venue-native terminal fill ingestion, and autonomous optimization remain unbuilt.
79 lines
2.2 KiB
JavaScript
79 lines
2.2 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
deriveServiceHealth,
|
|
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);
|
|
});
|
|
|
|
test('armed service treats critical truth alerts for any active pair as critical', () => {
|
|
const health = deriveServiceHealth({
|
|
service: 'strategy-engine',
|
|
snapshot: {
|
|
reachable: true,
|
|
state: {
|
|
armed: true,
|
|
},
|
|
health: {
|
|
ok: true,
|
|
},
|
|
},
|
|
activePairs: [
|
|
'btc->eure',
|
|
'btc->usdc',
|
|
],
|
|
activeAlerts: [{
|
|
alert_code: 'reference_price_stale',
|
|
severity: 'critical',
|
|
service_scope: 'strategy-engine',
|
|
pair: 'btc->usdc',
|
|
}],
|
|
now: '2026-05-18T10:00:00.000Z',
|
|
});
|
|
|
|
assert.equal(health.status, 'critical');
|
|
assert.equal(health.label, 'armed on stale truth');
|
|
});
|