fix(memory): keep qmd session paths roundtrip-safe#57560
Conversation
2cc6077 to
85b4192
Compare
Greptile SummaryThis PR fixes a roundtrip safety bug in Key changes:
Confidence Score: 5/5Safe to merge — targeted one-line guard in a single private method, a clear regression test, and no unrelated behaviour changed. The fix is minimal and correctly scoped: it only triggers when relativeToWorkspace is exactly qmd or starts with qmd/, which is the exact reserved namespace that readFile() already handles specially. The fallback for non-workspace files is unchanged, normal workspace-relative paths below other directories are untouched, the sanitized variable move is purely mechanical, and the new test traces the full search→readFile roundtrip through the collision path. No P0/P1 issues found. No files require special attention.
|
| Filename | Overview |
|---|---|
| extensions/memory-core/src/memory/qmd-manager.ts | Minimal targeted guard added to buildSearchPath: moves sanitized declaration before the isInsideWorkspace branch and returns the explicit collection-scoped virtual path when relativeToWorkspace collides with the reserved qmd/ namespace. |
| extensions/memory-core/src/memory/qmd-manager.test.ts | Adds regression test covering the full search→readFile roundtrip for session exports under the workspace qmd/ directory, plus adds agents.defaults to the shared cfg fixture. |
| CHANGELOG.md | Changelog entry added for the QMD session-hit path roundtrip fix. |
Reviews (1): Last reviewed commit: "Merge branch 'main' into fix/qmd-binary-..." | Re-trigger Greptile
Summary
qmd/directory,memory_searchreturned that workspace-relative path, butmemory_gettreatsqmd/<collection>/...as a reserved virtual namespace and therefore rejected the genericqmd/sessions/...alias.memory_searchintomemory_get, which broke normal session-backed recall flows.qmd/virtual namespace; in that collision case it returns the collection-scoped virtual path instead.qmd/prefix collision case.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
extensions/memory-core/src/memory/qmd-manager.tspreferred workspace-relative paths for hits inside the workspace, butreadFile()reserves theqmd/<collection>/...prefix for virtual QMD collection reads. Session exports under${workspace}/qmd/...therefore serialized to an ambiguous path thatmemory_getinterpreted as the wrong collection.qmd/directory and the returned path must still be roundtrip-safe.git blame, prior PR, issue, or refactor if known): fix: keep QMD session search paths roundtrip-safe #43523 identified the same failure mode on older code.qmd://collection/...file resolution already worked; the breakage is specifically in OpenClaw's search-hit path formatting layer.Regression Test Plan (if applicable)
extensions/memory-core/src/memory/qmd-manager.test.tsqmd/directory,memory_searchreturnsqmd/<real-collection>/...andreadFile()succeeds with that exact path.QmdMemoryManager, and the existing manager test harness already covers both search-hit formatting and read-path resolution.qmd://file URIs and QMD path read safety, but not the reserved-prefix collision case.User-visible / Behavior Changes
memory_getcan now read the exact QMD session-hit path returned bymemory_searcheven when exported session markdown lives under the workspaceqmd/directory.Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Environment
memory.backend=qmdwith session indexing enabled and a workspace under the agent state dirSteps
qmd/directory.qmd://sessions-main/....memory_get.Expected
Actual
qmd/sessions/...alias, whichmemory_getrejected as an unknown collection.Evidence
Human Verification (required)
qmd/collision case plus adjacentqmd://URI and read-path safety tests.qmd://collection/...URI resolution still works and non-markdown / symlink reads remain blocked.Review Conversations
Compatibility / Migration
Risks and Mitigations
qmd/directory now serialize differently than other workspace-relative files.qmd/namespace thatreadFile()already treats specially, so it restores roundtrip safety without changing unrelated workspace paths.