Skip to content

Commit 7d6edd2

Browse files
Alix-007steipetevincentkoc
authored andcommitted
fix(memory-core): keep daily ingestion outside session repair (openclaw#93389)
* fix(memory-core): clear daily-ingestion sqlite namespace on dreaming repair repairDreamingArtifacts() cleared the dreaming-session-ingestion-files and dreaming-session-ingestion-seen namespaces but not the migrated dreaming-daily-ingestion namespace. After openclaw#92020 taught auditDreamingArtifacts() to treat all three ingestion namespaces as ingestion state, the repair path became asymmetric: the memory status --fix re-audit still reported sessionIngestionExists=true from the surviving daily rows, and the daily ingestion bookkeeping leaked past repair so daily memory files were not re-ingested on the next sweep. Clear DREAMING_DAILY_INGESTION_NAMESPACE alongside the session files/seen namespaces so repair fully resets dreaming ingestion state, matching the audit. * chore: retrigger CI for real behavior proof check * fix(memory-core): keep daily ingestion outside session repair Co-authored-by: Vincent Koc <vincentkoc@ieee.org> Co-authored-by: Alix-007 <li.long15@xydigit.com> --------- Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
1 parent 89645be commit 7d6edd2

2 files changed

Lines changed: 43 additions & 4 deletions

File tree

extensions/memory-core/src/dreaming-repair.test.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ describe("dreaming artifact repair", () => {
199199
}),
200200
]);
201201

202+
await expect(
203+
auditDreamingArtifacts({ workspaceDir }).then((audit) => audit.sessionIngestionExists),
204+
).resolves.toBe(true);
205+
202206
const repair = await repairDreamingArtifacts({ workspaceDir });
203207

204208
expect(repair.archivedSessionCorpus).toBe(true);
@@ -214,6 +218,41 @@ describe("dreaming artifact repair", () => {
214218
workspaceDir,
215219
}),
216220
).resolves.toEqual([]);
221+
await expect(
222+
auditDreamingArtifacts({ workspaceDir }).then((audit) => audit.sessionIngestionExists),
223+
).resolves.toBe(false);
224+
});
225+
226+
it("preserves sqlite daily ingestion state when archiving session corpus", async () => {
227+
const workspaceDir = await createWorkspace();
228+
const sessionCorpusDir = path.join(workspaceDir, "memory", ".dreams", "session-corpus");
229+
await fs.mkdir(sessionCorpusDir, { recursive: true });
230+
await fs.writeFile(path.join(sessionCorpusDir, "2026-04-11.txt"), "corpus\n", "utf-8");
231+
await writeMemoryCoreWorkspaceEntries({
232+
namespace: DREAMING_DAILY_INGESTION_NAMESPACE,
233+
workspaceDir,
234+
entries: [
235+
{
236+
key: "2026-06-10",
237+
value: { ingestedAt: 1_000, lastDreamingDayIngested: "2026-06-10" },
238+
},
239+
],
240+
});
241+
242+
const repair = await repairDreamingArtifacts({ workspaceDir });
243+
244+
expect(repair.archivedSessionCorpus).toBe(true);
245+
await expect(
246+
readMemoryCoreWorkspaceEntries({
247+
namespace: DREAMING_DAILY_INGESTION_NAMESPACE,
248+
workspaceDir,
249+
}),
250+
).resolves.toEqual([
251+
{
252+
key: "2026-06-10",
253+
value: { ingestedAt: 1_000, lastDreamingDayIngested: "2026-06-10" },
254+
},
255+
]);
217256
});
218257

219258
it("reports ingestion state present from SQLite when legacy JSON is absent", async () => {
@@ -235,7 +274,7 @@ describe("dreaming artifact repair", () => {
235274
expect(audit.sessionIngestionExists).toBe(true);
236275
});
237276

238-
it("reports ingestion state present from SQLite daily namespace", async () => {
277+
it("does not report session ingestion from the SQLite daily namespace", async () => {
239278
const workspaceDir = await createWorkspace();
240279
// Only daily ingestion namespace has rows
241280
await writeMemoryCoreWorkspaceEntries({
@@ -251,6 +290,6 @@ describe("dreaming artifact repair", () => {
251290

252291
const audit = await auditDreamingArtifacts({ workspaceDir });
253292

254-
expect(audit.sessionIngestionExists).toBe(true);
293+
expect(audit.sessionIngestionExists).toBe(false);
255294
});
256295
});

extensions/memory-core/src/dreaming-repair.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import path from "node:path";
55
import { extractErrorCode } from "openclaw/plugin-sdk/error-runtime";
66
import {
77
clearMemoryCoreWorkspaceNamespace,
8-
DREAMING_DAILY_INGESTION_NAMESPACE,
98
DREAMING_SESSION_INGESTION_FILES_NAMESPACE,
109
DREAMING_SESSION_INGESTION_SEEN_NAMESPACE,
1110
readMemoryCoreWorkspaceEntries,
@@ -213,10 +212,11 @@ export async function auditDreamingArtifacts(params: {
213212
// Fall back to SQLite plugin state when the legacy JSON file was archived by migration.
214213
if (!sessionIngestionExists) {
215214
try {
215+
// Daily ingestion tracks memory/*.md independently; session repair must not
216+
// report or clear that healthy bookkeeping when rebuilding the session corpus.
216217
const ingestionNamespaces = [
217218
DREAMING_SESSION_INGESTION_FILES_NAMESPACE,
218219
DREAMING_SESSION_INGESTION_SEEN_NAMESPACE,
219-
DREAMING_DAILY_INGESTION_NAMESPACE,
220220
] as const;
221221
for (const namespace of ingestionNamespaces) {
222222
const entries = await readMemoryCoreWorkspaceEntries({

0 commit comments

Comments
 (0)