Fix semantic search MCP tool leaking embedding vectors into results - #1553
Conversation
The tool's result mapping spread the full row, including every embedding field's vector and metadata, into each search result — a real cost in context tokens and a leak of a column that may carry its own read access restriction. Strip embedding-typed fields out of each match before spreading. Closes #1297 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NZ2pqay76RJhiaV76BUi9a
🦋 Changeset detectedLatest commit: 0c7a219 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
The Both files already exist at No fix for it exists yet on Generated by Claude Code |
Code Review SummaryReviewed the diff in this PR (branch What I checked:
Verdict: Approve — ready to merge as-is. No correctness bugs or reuse/simplification/efficiency issues found at medium review effort. Generated by Claude Code |
Coverage Report for Core Package Coverage (./packages/core)
File CoverageNo changed files found. |
Coverage Report for UI Package Coverage (./packages/ui)
File CoverageNo changed files found. |
Coverage Report for CLI Package Coverage (./packages/cli)
File CoverageNo changed files found. |
Coverage Report for Auth Package Coverage (./packages/auth)
File CoverageNo changed files found. |
Coverage Report for Storage Package Coverage (./packages/storage)
File CoverageNo changed files found. |
Coverage Report for RAG Package Coverage (./packages/rag)
File Coverage
|
||||||||||||||||||||||||||||||||||||||
Coverage Report for Storage S3 Package Coverage (./packages/storage-s3)
File CoverageNo changed files found. |
Coverage Report for Storage Vercel Package Coverage (./packages/storage-vercel)
File CoverageNo changed files found. |
Summary
semantic_search_<list>MCP tool built its result by spreading the whole matched row ({ ...match.item, _similarity: match.score }), which included every embedding field's stored vector — 1,536 floats per result on the default OpenAI provider — plus that field's metadata sibling.access.readrule was meant to restrict.semanticSearch,findSimilarinruntime/search.ts) — neither spreads a row itself; they returnSearchResult<TRow>[]and leave projection to the caller, so no equivalent fix was needed there.Test plan
plugin.test.ts) with anearest()double returning a row carrying two embedding fields, asserting the tool's result keeps the plain fields and_similaritybut drops both embedding columns and their metadata.plugin.ts) and passes with it.pnpm buildinpackages/core,packages/ui,packages/ragpnpm testinpackages/rag— 258/258 passingpnpm lint,pnpm manypkg fix,pnpm formatat the repo root.changeset/thirty-otters-search.md, patch on@opensaas/stack-rag)Closes #1297
🤖 Generated with Claude Code
https://claude.ai/code/session_01NZ2pqay76RJhiaV76BUi9a
Generated by Claude Code