Skip to content

Commit 2212ea0

Browse files
committed
test(memory): add regression test for status-purpose dirty detection (fixes #97814)
Adds a regression test that exercises the actual purpose:'status' manager flow: create a session file without index row, create status manager, verify status().dirty is true. This addresses the ClawSweeper P1 finding requesting a test that exercises the real status path, not only the protected helper. Also fixes the timing issue: move dirty detection from constructor (void) to create() factory (await), guaranteeing sessionsDirty is set before any caller reads manager.status().
1 parent 42168dd commit 2212ea0

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

extensions/memory-core/src/memory/index.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,4 +2290,26 @@ describe("memory index", () => {
22902290
restoreMemoryIndexStateDir();
22912291
}
22922292
});
2293+
it("status-purpose manager detects unindexed session transcripts as dirty", async () => {
2294+
// Regression test for #97814: plain openclaw memory status (purpose: status)
2295+
// must report dirty=true when session files exist without index rows.
2296+
const cfg = createCfg({ sources: ["sessions"], sessionMemory: true });
2297+
const stateDirName = ".state-status-dirty-test";
2298+
setMemoryIndexStateDir(path.join(workspaceDir, stateDirName));
2299+
try {
2300+
const sessionsDir = resolveSessionTranscriptsDirForAgent("main");
2301+
await fs.mkdir(sessionsDir, { recursive: true });
2302+
const transcriptPath = path.join(sessionsDir, "status-dirty-test.jsonl");
2303+
await fs.writeFile(transcriptPath, JSON.stringify({ type: "test", ts: 1 }) + "\n");
2304+
2305+
const manager = await getFreshManager(cfg, "status");
2306+
managersForCleanup.add(manager);
2307+
2308+
const result = manager.status();
2309+
expect(result.dirty).toBe(true);
2310+
} finally {
2311+
restoreMemoryIndexStateDir();
2312+
}
2313+
});
2314+
22932315
});

0 commit comments

Comments
 (0)