Skip to content

Commit fb0dc51

Browse files
committed
test(daemon): bound values in idle cleanup evidence
1 parent 3c6673a commit fb0dc51

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎src/daemon-entrypoint.test.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import fs from 'node:fs';
55
import http from 'node:http';
66
import path from 'node:path';
77
import { test } from 'vitest';
8+
import { KNOWN_APP_ERROR_CODES } from '@agent-device/kernel/errors';
89
import { resolveDaemonPaths } from '@agent-device/daemon-contracts/daemon-resolution';
910
import { readRegisteredDaemonIdentity } from '@agent-device/daemon-contracts/daemon-registration';
1011
import { startDaemonRuntime, type DaemonRuntimeController } from '@agent-device/daemon';
@@ -309,15 +310,21 @@ test('daemon entrypoint reaps itself when idle: exits cleanly, releases its regi
309310
(line) =>
310311
JSON.parse(line) as {
311312
phase: string;
312-
data?: { reason?: string; error?: { code?: string } };
313+
data?: { reason?: unknown; error?: { code?: unknown } };
313314
},
314315
)
315316
.filter(
316317
({ phase }) =>
317318
phase === 'daemon_info_removal_declined' ||
318319
phase === 'daemon_registration_finish_failed',
319320
)
320-
.map(({ phase, data }) => ({ phase, reason: data?.reason, code: data?.error?.code }));
321+
.map(({ phase, data }) => ({
322+
phase,
323+
reason: ['retained', 'replaced', 'unproven', 'unreadable', 'ownerless'].find(
324+
(reason) => reason === data?.reason,
325+
),
326+
code: KNOWN_APP_ERROR_CODES.find((code) => code === data?.error?.code),
327+
}));
321328
} catch {
322329
diagnostics = 'unavailable';
323330
}

0 commit comments

Comments
 (0)