Repository navigation
Conversation
The memory_search MCP tool advertises search over "titles, content, and tags", but content_tsv (migration 068) only covered title + content — so searching a tag (e.g. `planning-doc-migration`) returned zero rows despite matching artifacts. Migration 127 rebuilds content_tsv to fold in `array_to_string(tags, ' ')`. A generated column's expression can't be ALTERed in place, so it drops the GIN index, drops + re-adds the column, and recreates the index; re-adding the STORED generated column recomputes it for every existing row, so all current artifacts become tag-searchable immediately (memory_artifact is small — quick rewrite). No query change: SearchMemoryArtifacts already selects on content_tsv. The sqlc regen is a benign reorder — re-adding the column moves content_tsv (an opaque tsvector, name-scanned) to the end of the RETURNING/SELECT column lists. Verified: `make sqlc` clean, `go build` ok. The FTS expression is correct by construction (to_tsvector folds the tag tokens in; websearch_to_tsquery tokenizes the query identically). Live end-to-end proof runs on `make migrate-up` / CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
memory_search(theSearchMemoryArtifactsquery) is advertised as searching "titles, content, and tags", butcontent_tsv(migration 068) is generated from onlytitle + content. So a full-text search for a tag returns nothing — e.g. searchingplanning-doc-migrationfound 0 rows even though many artifacts carry that tag. (Discovered while bulk-migrating planning docs with a shared tag and finding them unsearchable by it.)Fix — migration 127
Rebuild
content_tsvto foldtagsinto the vector:A generated column's expression can't be
ALTERed in place, so the migration drops theidx_memory_tsvGIN index, drops + re-addscontent_tsvwith the new expression, and recreates the index. Re-adding the STORED generated column recomputes it for every existing row, so all current artifacts become tag-searchable immediately (memory_artifactis small — the rewrite is quick)..down.sqlreverts to title+content only.No behavior change beyond the fix
SearchMemoryArtifacts/CountSearchMemoryArtifactsalready match oncontent_tsv; they now match tag terms too.content_tsv(an opaquetsvector, scanned by name) to the end of theRETURNING */SELECT *column lists. That's the entire generated diff.Verification
make sqlcclean ·go build ./pkg/db/... ./cmd/multica/ok.to_tsvectorfolds the tag lexemes in, andwebsearch_to_tsquerytokenizes the query the same way, so@@matches. (Couldn't run a live DB proof locally — no Docker here — so the end-to-end check happens onmake migrate-up/ CI.)Note for reviewer
Applying this on deploy (
make migrate-up) rewrites thecontent_tsvfor existing rows once. If you'd rather keep tags out of relevance weighting, an alternative issetweight(...)with a low weight for the tags portion — happy to switch to that if preferred.🤖 Generated with Claude Code