Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(hook,doctor): E-N1 follow-ups from the full gate

time-attack09e0613bc0cf
diff --git a/src/commands/doctor/checks/memory-writeback.ts b/src/commands/doctor/checks/memory-writeback.ts
index d643e58c78..aa0c6a8ce5 100644
--- a/src/commands/doctor/checks/memory-writeback.ts
+++ b/src/commands/doctor/checks/memory-writeback.ts
@@ -176,8 +176,6 @@ export async function buildMemoryWritebackCheck(engine: BrainEngine | null): Pro
details.near_duplicates_shadow_7d = dedup.reduce((n, e) => n + (e.near_duplicate ?? 0), 0);
} catch { /* heartbeat unreadable — counters stay absent */ }
- const corpusProblem = await corpusBacklogProblem(engine, fileCfg, details).catch(() => null);
-
// Plane comparison (the dual-write design's promised surfacing): the DB
// row is authoritative at runtime; a disagreeing file mirror means a
// failed dual-write, a foreign writer, or another machine's `config set`
@@ -237,6 +235,7 @@ export async function buildMemoryWritebackCheck(engine: BrainEngine | null): Pro
}
const problems: string[] = [];
+ const corpusProblem = await corpusBacklogProblem(engine, fileCfg, details).catch(() => null);
if (corpusProblem) problems.push(corpusProblem);
if (!wb.ttl_valid) {
problems.push(`memory.auto_writeback_transient_ttl is invalid — using '${wb.transient_ttl}'`);
diff --git a/test/hook-command.serial.test.ts b/test/hook-command.serial.test.ts
index ea62fc0fea..6f73744403 100644
--- a/test/hook-command.serial.test.ts
+++ b/test/hook-command.serial.test.ts
@@ -842,11 +842,14 @@ describe('session-end', () => {
expect(readdirSync(corpusDir).filter((f) => f.includes('.tmp-'))).toEqual([]);
});
- test('retention prune: corpus files past the default 30d window are removed [G15]', async () => {
+ test('retention prune: extracted corpus files past the default 30d window are removed [G15]', async () => {
const corpusDir = join(home(), 'transcripts', 'corpus');
mkdirSync(corpusDir, { recursive: true });
const oldFile = join(corpusDir, 'ancient.txt');
writeFileSync(oldFile, 'old corpus\n');
+ // E-N1 (D16): only an extracted file goes at plain retention; an
+ // unextracted one is kept to 3x (test/corpus-retention-uningested.serial.test.ts).
+ writeFileSync(oldFile + '.ingested', '{}\n');
const old = (Date.now() - 40 * 24 * 3600 * 1000) / 1000;
utimesSync(oldFile, old, old);
const freshFile = join(corpusDir, 'fresh.txt');