import test from 'node:test'; import assert from 'node:assert/strict'; import { summarizeServiceSnapshotForSentinel, summarizeServiceState, } from '../src/core/service-snapshot-summary.mjs'; test('sentinel snapshot summary keeps trade-executor health fields and drops retained command maps', () => { const summary = summarizeServiceSnapshotForSentinel({ service: 'trade-executor', label: 'Trade Executor', base_url: 'http://trade-executor', reachable: true, health: { ok: true }, state: { service: 'trade-executor', namespace: 'unrip', paused: false, armed: true, relay: { connected: true, last_message_at: '2026-05-06T15:00:00.000Z' }, last_result: { status: 'submitted' }, submitted_count: 100, processed_idempotency_keys: Object.fromEntries(Array.from({ length: 100 }, (_, index) => [`quote:${index}`, true])), submitted_commands: { 'cmd-1': { quote_id: 'quote-1', raw_response: { large: true } }, }, }, }); assert.equal(summary.state.armed, true); assert.deepEqual(summary.state.relay, { connected: true, last_message_at: '2026-05-06T15:00:00.000Z' }); assert.equal(summary.state.processed_idempotency_keys, undefined); assert.equal(summary.state.submitted_commands, undefined); }); test('sentinel snapshot summary keeps near-intents ingest truth fields', () => { const state = summarizeServiceState('near-intents-ingest', { service: 'near-intents-ingest', namespace: 'unrip', pair_filter: { pair: 'btc->eure' }, ingest: { connected: true, last_message_at: '2026-05-06T15:00:00.000Z', last_matching_quote_at: '2026-05-06T09:56:42.742Z', last_published_at: '2026-05-06T09:56:42.744Z', filtered_count: 10, }, bulky_unused_field: Object.fromEntries(Array.from({ length: 100 }, (_, index) => [index, index])), }); assert.equal(state.ingest.connected, true); assert.equal(state.ingest.last_matching_quote_at, '2026-05-06T09:56:42.742Z'); assert.equal(state.bulky_unused_field, undefined); });