fix: exclude superseded memories from recall and classify all markdown as docs - #17
Conversation
…n as docs Two bugs in the memory and RAG indexers: 1. recall (internal/memory/read.go): entries marked as superseded_by (e.g. after a merge) were still returned as top semantic matches. They now stay invisible to recall while remaining visible to List/ListLightweight for maintenance tools. 2. markdown classification (internal/rag/documents.go): classifySourceType received empty content, so a plain .md file (not README, not under docs/) fell through and was silently skipped with 0 chunks. Every .md file is now classified as 'docs'. Adds regression test cases.
|
This work is a joint effort by chaos (@ch405canova-sudo) and opencode — found and fixed together on a live llama.cpp + agent-memory-mcp stack (August 2026). |
|
Thank you for this — both reports were accurate, and the root-cause analysis in #18 and #19 pointed straight at the right lines. Status of each half: Markdown classification (#19) — already fixed on Recall filter (#18) — a real bug, still present on #20 supersedes both halves, so there is nothing left to rebase here — feel free to close this PR. The credit is yours, and the report quality is genuinely appreciated. Happy to take further PRs. |
Summary
Two real bugs found while operating the server against a live memory store:
1. Superseded entries still surfaced in semantic recall
internal/memory/read.go— theRecallloop never filtered entries whosesuperseded_bycolumn is set (e.g. after a merge viaMarkOutdated/merge flow). A merged duplicate kept ranking as a top result.Fix: skip entries with
m.SupersededBy != ""in the recall loop. They remain visible toList/ListLightweightso maintenance tools can still see the temporal history.2. Plain markdown files silently dropped from the RAG index
internal/rag/documents.go—classifySourceTypewas called with empty content (classifySourceType(relPath, "", "")), so the.mdheuristic relying onstrings.Contains(contentLower, "# ")never matched. A normal.mdfile (not namedreadme.md, not under adocs/path) classified as""→ 0 chunks, silently ignored.Fix: every
.mdfile classifies as"docs". Added regression cases toTestClassifySourceType.Verification
go test ./internal/rag/passes (incl. new cases).mdfile now produces a chunk in the vector store; recall no longer returns the superseded duplicateFiles changed
internal/memory/read.gointernal/rag/documents.gointernal/rag/rag_test.go.gitignoreFixes #18
Fixes #19