From 4287d29bbac394b6f432ed5e34ac87eca7dbb2e7 Mon Sep 17 00:00:00 2001 From: dawn <90008@klbr.net> Date: Wed, 2 Sep 2026 16:55:54 +0900 Subject: [PATCH] fix: expose snapcompact worker failures --- index.ts | 11 ++++++++++- test/integration.mjs | 15 +++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/index.ts b/index.ts index 968a9ec..265bc86 100644 --- a/index.ts +++ b/index.ts @@ -147,6 +147,12 @@ export function runWorker(payload: unknown, signal: AbortSignal): Promise ({ settings: { enabled: true, reserveTokens: 16384, keepRecentTokens: 20000 }, }); const controller = new AbortController(); +const notifications = []; let branch = []; const ctx = { cwd: process.cwd(), - hasUI: false, - ui: { notify() {} }, + hasUI: true, + ui: { notify(message, level) { notifications.push({ message, level }); } }, model: { ...model }, modelRegistry: { async getApiKeyAndHeaders() { throw new Error("auth should not be needed in this test"); } }, sessionManager: { @@ -231,6 +232,16 @@ console.warn = () => {}; const workerFailureWithArchive = await before({ type: "session_before_compact", preparation: prep(nextMessages, first.compaction.summary), branchEntries: branch, customInstructions: undefined, signal: controller.signal }, ctx); console.warn = originalWarn; if (workerFailureWithArchive?.cancel !== true) throw new Error("worker failure with an existing archive did not cancel safely"); +const retainedNotice = notifications.at(-1); +if ( + retainedNotice?.level !== "error" || + !retainedNotice.message.includes("SnapCompact visual compaction failed: SnapCompact worker failed") || + !retainedNotice.message.includes("maxArchiveTokens must be positive") || + !retainedNotice.message.includes("text fallback also failed") || + !retainedNotice.message.includes("existing archive was retained") +) { + throw new Error(`worker failure notice hid the primary error: ${JSON.stringify(retainedNotice)}`); +} ctx.model = { ...model, input: ["text"], contextWindow: 20000, maxTokens: 4096 }; console.warn = () => {}; const manual = await before({ type: "session_before_compact", preparation: prep(nextMessages, first.compaction.summary), branchEntries: branch, customInstructions: "focus on tests", signal: controller.signal }, ctx); -- knotmirror 0.0.1