Skip to content

Commit b39023f

Browse files
committed
clawdbot-9c3: tighten lifecycle archive regression
1 parent 9d55ffd commit b39023f

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1fc413736b1320d11981317535e791cd40cb7b5ac14d6beef50cc032b4e28afb plugin-sdk-api-baseline.json
2-
7a375996b95a8fd4fb4eade436497ea7153faf7061f65a4e4b16b54ed6690561 plugin-sdk-api-baseline.jsonl
1+
3783a464b7d054abbe393a6fc826cabcdf5468de8db2a1407e3d76f7badf059d plugin-sdk-api-baseline.json
2+
26dcaaf21d56ab9d5ad801cd5133e617d6e6c3f6bb34fa13918eef66efd07609 plugin-sdk-api-baseline.jsonl

src/config/sessions/session-accessor.test.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -270,18 +270,21 @@ describe("session accessor file-backed seam", () => {
270270
it("cleans scoped lifecycle entries and unreferenced transcript artifacts", async () => {
271271
const nowMs = Date.now();
272272
const oldDate = new Date(nowMs - 600_000);
273-
const removedTranscriptPath = path.join(tempDir, "removed-lifecycle.jsonl");
274-
const customTranscriptPath = path.join(tempDir, "custom-lifecycle-old.jsonl");
275-
const freshDefaultTranscriptPath = path.join(tempDir, "custom-lifecycle.jsonl");
276-
const freshTranscriptPath = path.join(tempDir, "fresh-lifecycle.jsonl");
277-
const referencedTranscriptPath = path.join(tempDir, "referenced.jsonl");
278-
const orphanTranscriptPath = path.join(tempDir, "orphan-lifecycle.jsonl");
279-
const siblingDir = `${tempDir}-sibling-sessions`;
273+
const lifecycleSessionsDir = path.join(tempDir, "state", "agents", "main", "sessions");
274+
const lifecycleStorePath = path.join(lifecycleSessionsDir, "sessions.json");
275+
const removedTranscriptPath = path.join(lifecycleSessionsDir, "removed-lifecycle.jsonl");
276+
const customTranscriptPath = path.join(lifecycleSessionsDir, "custom-lifecycle-old.jsonl");
277+
const freshDefaultTranscriptPath = path.join(lifecycleSessionsDir, "custom-lifecycle.jsonl");
278+
const freshTranscriptPath = path.join(lifecycleSessionsDir, "fresh-lifecycle.jsonl");
279+
const referencedTranscriptPath = path.join(lifecycleSessionsDir, "referenced.jsonl");
280+
const orphanTranscriptPath = path.join(lifecycleSessionsDir, "orphan-lifecycle.jsonl");
281+
const siblingDir = path.join(tempDir, "state", "agents", "sibling", "sessions");
280282
const siblingTranscriptPath = path.join(siblingDir, "sibling-lifecycle.jsonl");
283+
fs.mkdirSync(lifecycleSessionsDir, { recursive: true });
281284
fs.mkdirSync(siblingDir, { recursive: true });
282285

283286
fs.writeFileSync(
284-
storePath,
287+
lifecycleStorePath,
285288
JSON.stringify({
286289
"agent:main:lifecycle-cleanup-removed": {
287290
sessionId: "removed-lifecycle",
@@ -324,22 +327,22 @@ describe("session accessor file-backed seam", () => {
324327
fs.utimesSync(orphanTranscriptPath, oldDate, oldDate);
325328

326329
const result = await cleanupSessionLifecycleArtifacts({
327-
storePath,
330+
storePath: lifecycleStorePath,
328331
sessionKeySegmentPrefix: "lifecycle-cleanup-",
329332
transcriptContentMarker: "lifecycle-marker-",
330333
orphanTranscriptMinAgeMs: 300_000,
331334
nowMs,
332335
});
333336

334337
expect(result).toEqual({ removedEntries: 3, archivedTranscriptArtifacts: 3 });
335-
const loaded = loadSessionStore(storePath, { skipCache: true });
338+
const loaded = loadSessionStore(lifecycleStorePath, { skipCache: true });
336339
expect(loaded).not.toHaveProperty("agent:main:lifecycle-cleanup-removed");
337340
expect(loaded).not.toHaveProperty("agent:main:lifecycle-cleanup-custom");
338341
expect(loaded).not.toHaveProperty("agent:main:lifecycle-cleanup-sibling");
339342
expect(loaded).toHaveProperty("agent:main:lifecycle-cleanup-fresh");
340343
expect(loaded).toHaveProperty("agent:main:telegram:group:lifecycle-cleanup-room");
341344
expect(loaded).toHaveProperty("agent:main:regular");
342-
const files = fs.readdirSync(tempDir);
345+
const files = fs.readdirSync(lifecycleSessionsDir);
343346
expect(
344347
files.filter((file) => file.startsWith("removed-lifecycle.jsonl.deleted.")),
345348
).toHaveLength(1);

0 commit comments

Comments
 (0)