Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

feat(doctor): memory_writeback reports the last successful harvest (E-N3)

time-attack3cf6b7742b23
diff --git a/src/commands/doctor/checks/memory-writeback.ts b/src/commands/doctor/checks/memory-writeback.ts
index 4d160ef2ae..d643e58c78 100644
--- a/src/commands/doctor/checks/memory-writeback.ts
+++ b/src/commands/doctor/checks/memory-writeback.ts
@@ -349,6 +349,7 @@ export async function buildMemoryWritebackCheck(engine: BrainEngine | null): Pro
// flush_skip_* = the turn IS banked; only the prompt-harvest enqueue
// was declined (cap/queue policy) — the sweep extracts it later.
turns_banked: bank.filter((e) => e.reason === 'wb_scheduled' || e.reason === 'wb_banked' || e.reason?.startsWith('flush_skip_')).length,
+ last_ok_at: harvest.filter((e) => e.outcome === 'ok').map((e) => e.ts).sort().at(-1) ?? null,
};
const failures = harvest.filter((e) => e.outcome === 'error');
const finished = failures.length + harvest.filter((e) => e.outcome === 'ok').length;
diff --git a/test/doctor-memory-writeback.test.ts b/test/doctor-memory-writeback.test.ts
index 71336b711d..6926fe3ed0 100644
--- a/test/doctor-memory-writeback.test.ts
+++ b/test/doctor-memory-writeback.test.ts
@@ -293,7 +293,7 @@ describe('memory_writeback doctor check', () => {
];
for (const entry of entries) await writeHeartbeat(entry, { trim: false });
const check = await buildMemoryWritebackCheck(engine);
- expect(check.details?.backstop_7d).toMatchObject({ failed: c.errors.length });
+ expect(check.details?.backstop_7d).toMatchObject({ failed: c.errors.length, last_ok_at: ts });
if (c.warn) {
expect(check.status).toBe('warn');
expect(check.message).toContain(c.warn);