From c343cfc6dc018e5536046b27200f943e1fddf42c Mon Sep 17 00:00:00 2001 From: Josh Lehman Date: Tue, 2 Jun 2026 16:11:27 -0700 Subject: [PATCH] clawdbot-9c3: tighten lifecycle archive regression --- .../.generated/plugin-sdk-api-baseline.sha256 | 4 +-- src/config/sessions/session-accessor.test.ts | 25 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/.generated/plugin-sdk-api-baseline.sha256 b/docs/.generated/plugin-sdk-api-baseline.sha256 index 1e2d7de8c172..4be195e6dd7e 100644 --- a/docs/.generated/plugin-sdk-api-baseline.sha256 +++ b/docs/.generated/plugin-sdk-api-baseline.sha256 @@ -1,2 +1,2 @@ -1fc413736b1320d11981317535e791cd40cb7b5ac14d6beef50cc032b4e28afb plugin-sdk-api-baseline.json -7a375996b95a8fd4fb4eade436497ea7153faf7061f65a4e4b16b54ed6690561 plugin-sdk-api-baseline.jsonl +3783a464b7d054abbe393a6fc826cabcdf5468de8db2a1407e3d76f7badf059d plugin-sdk-api-baseline.json +26dcaaf21d56ab9d5ad801cd5133e617d6e6c3f6bb34fa13918eef66efd07609 plugin-sdk-api-baseline.jsonl diff --git a/src/config/sessions/session-accessor.test.ts b/src/config/sessions/session-accessor.test.ts index 9f8512968e4c..9a1d674d66bf 100644 --- a/src/config/sessions/session-accessor.test.ts +++ b/src/config/sessions/session-accessor.test.ts @@ -270,18 +270,21 @@ describe("session accessor file-backed seam", () => { it("cleans scoped lifecycle entries and unreferenced transcript artifacts", async () => { const nowMs = Date.now(); const oldDate = new Date(nowMs - 600_000); - const removedTranscriptPath = path.join(tempDir, "removed-lifecycle.jsonl"); - const customTranscriptPath = path.join(tempDir, "custom-lifecycle-old.jsonl"); - const freshDefaultTranscriptPath = path.join(tempDir, "custom-lifecycle.jsonl"); - const freshTranscriptPath = path.join(tempDir, "fresh-lifecycle.jsonl"); - const referencedTranscriptPath = path.join(tempDir, "referenced.jsonl"); - const orphanTranscriptPath = path.join(tempDir, "orphan-lifecycle.jsonl"); - const siblingDir = `${tempDir}-sibling-sessions`; + const lifecycleSessionsDir = path.join(tempDir, "state", "agents", "main", "sessions"); + const lifecycleStorePath = path.join(lifecycleSessionsDir, "sessions.json"); + const removedTranscriptPath = path.join(lifecycleSessionsDir, "removed-lifecycle.jsonl"); + const customTranscriptPath = path.join(lifecycleSessionsDir, "custom-lifecycle-old.jsonl"); + const freshDefaultTranscriptPath = path.join(lifecycleSessionsDir, "custom-lifecycle.jsonl"); + const freshTranscriptPath = path.join(lifecycleSessionsDir, "fresh-lifecycle.jsonl"); + const referencedTranscriptPath = path.join(lifecycleSessionsDir, "referenced.jsonl"); + const orphanTranscriptPath = path.join(lifecycleSessionsDir, "orphan-lifecycle.jsonl"); + const siblingDir = path.join(tempDir, "state", "agents", "sibling", "sessions"); const siblingTranscriptPath = path.join(siblingDir, "sibling-lifecycle.jsonl"); + fs.mkdirSync(lifecycleSessionsDir, { recursive: true }); fs.mkdirSync(siblingDir, { recursive: true }); fs.writeFileSync( - storePath, + lifecycleStorePath, JSON.stringify({ "agent:main:lifecycle-cleanup-removed": { sessionId: "removed-lifecycle", @@ -324,7 +327,7 @@ describe("session accessor file-backed seam", () => { fs.utimesSync(orphanTranscriptPath, oldDate, oldDate); const result = await cleanupSessionLifecycleArtifacts({ - storePath, + storePath: lifecycleStorePath, sessionKeySegmentPrefix: "lifecycle-cleanup-", transcriptContentMarker: "lifecycle-marker-", orphanTranscriptMinAgeMs: 300_000, @@ -332,14 +335,14 @@ describe("session accessor file-backed seam", () => { }); expect(result).toEqual({ removedEntries: 3, archivedTranscriptArtifacts: 3 }); - const loaded = loadSessionStore(storePath, { skipCache: true }); + const loaded = loadSessionStore(lifecycleStorePath, { skipCache: true }); expect(loaded).not.toHaveProperty("agent:main:lifecycle-cleanup-removed"); expect(loaded).not.toHaveProperty("agent:main:lifecycle-cleanup-custom"); expect(loaded).not.toHaveProperty("agent:main:lifecycle-cleanup-sibling"); expect(loaded).toHaveProperty("agent:main:lifecycle-cleanup-fresh"); expect(loaded).toHaveProperty("agent:main:telegram:group:lifecycle-cleanup-room"); expect(loaded).toHaveProperty("agent:main:regular"); - const files = fs.readdirSync(tempDir); + const files = fs.readdirSync(lifecycleSessionsDir); expect( files.filter((file) => file.startsWith("removed-lifecycle.jsonl.deleted.")), ).toHaveLength(1);