fix: keep QMD session search paths roundtrip-safe#43523
fix: keep QMD session search paths roundtrip-safe#43523holgergruenhagen wants to merge 2 commits into
Conversation
Greptile SummaryThis PR fixes a roundtrip-safety bug where The fix is minimal and targeted:
No logic errors or security concerns were found. The change is well-scoped, correct, and the accompanying test directly covers the reported failure mode. Confidence Score: 5/5
Last reviewed commit: 8543f21 |
|
Follow-up on the earlier red CI:
This looks like transient CI / setup-install flakiness rather than something caused by the QMD roundtrip fix itself. |
|
Thanks for the original fix attempt here, @holgergruenhagen. I reworked this on top of current Closing this as superseded by #57560 to keep the queue clean while preserving attribution. |
|
Thanks for the rework in #57560, @vincentkoc! Makes total sense to port it fresh given the code path has moved since. Appreciate you confirming the root cause and keeping the fix alive — looking forward to seeing it land. 🙌 |
Summary
Closes #43519.
When an agent workspace lives under the OpenClaw state directory, exported QMD session markdown files can end up inside the workspace under
qmd/sessions/....In that case,
memory_searchwas returning the workspace-relative path:qmd/sessions/<file>.mdBut
memory_gettreats theqmd/<collection>/...prefix as a virtual QMD path and therefore expects a real collection name such as:qmd/sessions-coder/<file>.mdThat made
memory_search -> memory_getnon-roundtrip-safe for session hits.Fix
If a workspace-relative QMD hit would serialize to the reserved
qmd/prefix, return the collection-scoped virtual path instead:qmd/<real-collection>/<file>.mdThis preserves roundtrip safety while keeping normal in-workspace paths unchanged.
Tests
Added a regression test covering the exact case where session exports live under the workspace
qmd/directory and verifying that:qmd/sessions-<agentId>/...Verification
pnpm -s exec vitest run src/memory/qmd-manager.test.ts -t 'returns collection-scoped qmd paths when session exports live under the workspace qmd directory'pnpm -s exec vitest run src/memory/qmd-manager.test.ts -t 'returns collection-scoped qmd paths when session exports live under the workspace qmd directory|diversifies mixed session and memory search results so memory hits are retained|blocks non-markdown or symlink reads for qmd paths'