From 01f5557520ce4131c7ac3ad22f7bb975a4a66b82 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Tue, 7 Apr 2026 14:04:14 -0500 Subject: [PATCH] test(gsd): update audit tests for expanded SAFE_KEYS allowlist --- .../extensions/gsd/tests/workflow-logger-audit.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/resources/extensions/gsd/tests/workflow-logger-audit.test.ts b/src/resources/extensions/gsd/tests/workflow-logger-audit.test.ts index 1859bf1d8..1c63b60bd 100644 --- a/src/resources/extensions/gsd/tests/workflow-logger-audit.test.ts +++ b/src/resources/extensions/gsd/tests/workflow-logger-audit.test.ts @@ -90,18 +90,21 @@ describe("workflow-logger audit persistence", () => { assert.ok(ctx, "context should exist"); assert.equal(ctx.fn, "saveDecisionToDb"); assert.equal(ctx.tool, "gsd_decision_save"); - assert.equal(ctx.error, undefined, "error key must be stripped from persisted context"); + assert.equal(ctx.error, "SQLITE_BUSY: database is locked", "error key should be preserved in persisted context"); assert.equal(ctx.file, undefined, "file key must be stripped from persisted context"); }); - test("persisted errors omit context when no safe keys present", () => { + test("persisted errors preserve error key but strip other unsafe keys", () => { logError("bootstrap", "ensureDbOpen failed", { error: "ENOENT", cwd: "/home/user/project", }); const lines = readAuditLines(tmp); assert.equal(lines.length, 1); - assert.equal(lines[0].context, undefined, "context should be omitted when no safe keys match"); + const ctx = lines[0].context as Record; + assert.ok(ctx, "context should exist when error key is present"); + assert.equal(ctx.error, "ENOENT", "error key should be preserved"); + assert.equal(ctx.cwd, undefined, "cwd key must be stripped"); }); test("mixed warnings and errors only persist errors", () => {