refactor(FN-2126): align memory handling with canonical .fusion/memory paths

- Update memory docs and contracts to reference canonical .fusion/memory files while treating the legacy top-level memory file as compatibility-only
- Tighten memory backend path normalization messaging and map stale qmd legacy top-level memory results back to .fusion/memory/MEMORY.md
- Remove legacy memory read/write fallback branches from backend initialization paths and rely on ensureOpenClawMemoryFiles() migration behavior
- Preserve migration-seeded legacy content during ensureMemoryFile() bootstrap and add regression coverage for seeded long-term memory creation
This commit is contained in:
Fusion
2026-04-19 05:04:30 -07:00
committed by gsxdsm
parent 3472c122d4
commit a956ce5a4f
7 changed files with 41 additions and 40 deletions

View File

@@ -654,7 +654,7 @@ function normalizeMemoryRequestPath(rawPath: string): string {
}
throw new MemoryBackendError(
"UNSUPPORTED",
`Memory path '${rawPath}' is outside allowed files: MEMORY.md, DREAMS.md, memory/YYYY-MM-DD.md`,
`Memory path '${rawPath}' is outside allowed files: .fusion/memory/MEMORY.md, .fusion/memory/DREAMS.md, .fusion/memory/YYYY-MM-DD.md`,
"memory",
);
}
@@ -789,12 +789,14 @@ function normalizeQmdSearchResultPath(rootDir: string, rawPath: unknown): string
}
const lowerCandidate = candidate.toLowerCase();
const legacyLower = LEGACY_MEMORY_FILE_PATH.toLowerCase();
if (lowerCandidate === legacyLower || lowerCandidate.endsWith(`/${legacyLower}`)) {
return LEGACY_MEMORY_FILE_PATH;
}
const normalizedBaseName = basename(candidate).toLowerCase();
const normalizedDirName = dirname(lowerCandidate).replace(/\\/g, "/");
// Map legacy top-level memory paths from stale qmd indexes to the canonical
// layered long-term path without exposing legacy paths to callers.
if (normalizedBaseName === "memory.md" && (normalizedDirName === ".fusion" || normalizedDirName.endsWith("/.fusion"))) {
return `${MEMORY_WORKSPACE_PATH}/${MEMORY_LONG_TERM_FILENAME}`;
}
if (normalizedBaseName === MEMORY_LONG_TERM_FILENAME.toLowerCase()) {
return `${MEMORY_WORKSPACE_PATH}/${MEMORY_LONG_TERM_FILENAME}`;
}