From 85b379c4caea70ec3c77ff37fbfe18915fd93085 Mon Sep 17 00:00:00 2001 From: Kaoru0822 Date: Tue, 20 Oct 2026 10:01:56 -0700 Subject: [PATCH] test(evidence): assert the exact cancellation reason after staging cleanup fails (#5601) 52d1a72af made a cancelled write whose staging cleanup also fails carry the caller's exact abort reason as its cause, with the cancellation retained as cleanupPrimary and the staging directory as cleanup state. The boundary test still expected the old wrapped cause, so it failed on main and in every PR built on it; its finally block then masked the assertion with a cleanup error. Assert the current contract. Co-authored-by: Claude Opus 5.5 --- tests/boundary/filesystem/jsonOutputOwnership.test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/boundary/filesystem/jsonOutputOwnership.test.ts b/tests/boundary/filesystem/jsonOutputOwnership.test.ts index 18928cf71a..9f25d9ef33 100644 --- a/tests/boundary/filesystem/jsonOutputOwnership.test.ts +++ b/tests/boundary/filesystem/jsonOutputOwnership.test.ts @@ -208,10 +208,13 @@ it("preserves cancellation when staging cleanup also fails", async () => { if (result.ok) throw new Error("Expected cancellation"); expect(result.error).toBeInstanceOf(AnalysisCancelledError); expect(result.error.cleanupIncomplete).toBe(true); - expect(result.error.cause).toMatchObject({ - cause: expect.any(AnalysisCancelledError), - owner: { directory: expect.stringContaining(".rea-write-") }, - }); + // The caller's exact abort reason stays the cause; the retained staging + // directory is reported as cleanup state, not as the cancellation cause. + expect(result.error.cause).toBe(controller.signal.reason); + expect(result.error.cleanupPrimary).toBeInstanceOf(AnalysisCancelledError); + expect(result.error.cleanupResources).toEqual([ + expect.stringContaining(".rea-write-"), + ]); await expect(fs.access(join(root, "cancelled.json"))).rejects.toThrow(); const stage = requireStages(root)[0]; if (stage !== undefined) await fs.rm(join(root, stage, "unexpected"));