← Back to PRs

#9624: fix(memory): resolve QMD search returning empty results [AI-assisted]

by kowshik24 open 2026-02-05 13:44 View on GitHub →
stale
## Summary Fixes #9000 - memory_search returns empty when memory.backend=qmd, but qmd CLI works. ## Root Cause The resolveDocLocation method only used docid (a 6-char hash) to look up documents in the SQLite database. When QMD CLI returns JSON results, it includes both: - docid (e.g., #abc123) - file (e.g., qmd://collection/path/to/file.md) If the docid lookup failed (e.g., DB timing, hash mismatch), all results were silently filtered out. ## Fix 1. Updated resolveDocLocation to accept both docid and file parameters 2. Added fallback logic: if docid lookup fails, parse the qmd:// URI from the file field 3. Added parseQmdPath helper to extract collection name and path from qmd://collection/path format 4. Updated search call to pass both entry.docid and entry.file ## Testing - [x] pnpm build passes - [x] pnpm check passes (lint + format) - [x] pnpm test src/memory/qmd-manager.test.ts passes - [x] Added unit test for parseQmdPath helper ## AI Disclosure This PR was AI-assisted (Claude). The code changes have been reviewed and I understand what they do. The fix is straightforward: add a fallback path resolution when the primary docid lookup fails. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR updates `QmdMemoryManager`’s search result resolution to accept both `docid` and `file` from QMD JSON results, attempting a SQLite `docid` lookup first and falling back to parsing `qmd://<collection>/<path>` from the `file` field. It also adds a unit test around the new path parsing helper. In the current state, the fallback path parsing logic has an off-by-one bug that prevents `qmd://` URIs from being parsed correctly, so the intended fix for “empty results” won’t actually take effect when the DB lookup fails. <h3>Confidence Score: 2/5</h3> - This PR is not safe to merge as-is due to a functional bug in the new fallback path parsing. - The core change is meant to prevent QMD searches from returning empty results by parsing `qmd://` URIs when the SQLite lookup fails, but `parseQmdPath` currently slices the prefix incorrectly, causing valid `qmd://` inputs to return null and making the fallback ineffective. The added test also doesn’t exercise the full fallback wiring, so it wouldn’t catch this regression. - src/memory/qmd-manager.ts (parseQmdPath/resolveDocLocation), src/memory/qmd-manager.test.ts (coverage of fallback behavior) <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs