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

@ipiton

ipiton commented Aug 11, 2026

Copy link
Copy Markdown
Owner

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 main in b052f2d / bd00d87, before this PR arrived; the .md branch now returns docs unconditionally. That is what makes this PR conflict: it changes the same lines. The fix has not shipped in a release yet, which is why v0.9.1 still reproduces it. Your two regression cases are worth keeping and have been picked up.

Recall filter (#18) — a real bug, still present on main, and your fix is the right shape. It landed in #20 with one correction: the successor is now looked up in the cache rather than trusted, because Delete does not clear superseded_by on predecessors. With an unconditional continue, deleting a successor buries its predecessor permanently — an archived entry beats no entry at all. #20 also updates TestMarkOutdatedDownranksMemory, which pinned the opposite contract and would have failed CI here, and adds coverage for the recall path itself (this PR only touched the RAG tests).

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

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

2 participants