Skip to content

fix: exclude superseded memories from recall and classify all markdown as docs - #17

Open
ch405canova-sudo wants to merge 1 commit into
ipiton:mainfrom
ch405canova-sudo:fix/recall-superseded-and-markdown-classification
Open

fix: exclude superseded memories from recall and classify all markdown as docs#17
ch405canova-sudo wants to merge 1 commit into
ipiton:mainfrom
ch405canova-sudo:fix/recall-superseded-and-markdown-classification

Conversation

@ch405canova-sudo

@ch405canova-sudo ch405canova-sudo commented Aug 4, 2026

Copy link
Copy Markdown

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 — the Recall loop never filtered entries whose superseded_by column is set (e.g. after a merge via MarkOutdated/merge flow). A merged duplicate kept ranking as a top result.

Fix: skip entries with m.SupersededBy != "" in the recall loop. They remain visible to List/ListLightweight so maintenance tools can still see the temporal history.

2. Plain markdown files silently dropped from the RAG index

internal/rag/documents.goclassifySourceType was called with empty content (classifySourceType(relPath, "", "")), so the .md heuristic relying on strings.Contains(contentLower, "# ") never matched. A normal .md file (not named readme.md, not under a docs/ path) classified as "" → 0 chunks, silently ignored.

Fix: every .md file classifies as "docs". Added regression cases to TestClassifySourceType.

Verification

  • go test ./internal/rag/ passes (incl. new cases)
  • End-to-end: a non-README .md file now produces a chunk in the vector store; recall no longer returns the superseded duplicate

Files changed

  • internal/memory/read.go
  • internal/rag/documents.go
  • internal/rag/rag_test.go
  • .gitignore

Fixes #18
Fixes #19

…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.
@ch405canova-sudo

Copy link
Copy Markdown
Author

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: plain markdown files silently dropped from RAG index (0 chunks) Bug: merged/superseded memories still surface as top recall results

1 participant