fix (memory/qmd): verify qmd index artifact after manual reindex

This commit is contained in:
Vignesh Natarajan
2026-02-14 20:16:28 -08:00
parent 93dd9f697e
commit 17b6809517
2 changed files with 99 additions and 0 deletions

View File

@@ -215,6 +215,34 @@ async function scanMemoryFiles(
return { source: "memory", totalFiles, issues };
}
async function summarizeQmdIndexArtifact(manager: MemoryManager): Promise<string | null> {
const status = manager.status?.();
if (!status || status.backend !== "qmd") {
return null;
}
const dbPath = status.dbPath?.trim();
if (!dbPath) {
return null;
}
let stat: fsSync.Stats;
try {
stat = await fs.stat(dbPath);
} catch (err) {
const code = (err as NodeJS.ErrnoException).code;
if (code === "ENOENT") {
throw new Error(`QMD index file not found: ${shortenHomePath(dbPath)}`, { cause: err });
}
throw new Error(
`QMD index file check failed: ${shortenHomePath(dbPath)} (${code ?? "error"})`,
{ cause: err },
);
}
if (!stat.isFile() || stat.size <= 0) {
throw new Error(`QMD index file is empty: ${shortenHomePath(dbPath)}`);
}
return `QMD index: ${shortenHomePath(dbPath)} (${stat.size} bytes)`;
}
async function scanMemorySources(params: {
workspaceDir: string;
agentId: string;
@@ -633,6 +661,10 @@ export function registerMemoryCli(program: Command) {
}
},
);
const qmdIndexSummary = await summarizeQmdIndexArtifact(manager);
if (qmdIndexSummary) {
defaultRuntime.log(qmdIndexSummary);
}
defaultRuntime.log(`Memory index updated (${agentId}).`);
} catch (err) {
const message = formatErrorMessage(err);