feat(search): add containment-style tags filter for multi-user scoping (#368) - #402
Closed
RerankerGuo wants to merge 1 commit into
Closed
feat(search): add containment-style tags filter for multi-user scoping (#368)#402RerankerGuo wants to merge 1 commit into
RerankerGuo wants to merge 1 commit into
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
RerankerGuo
force-pushed
the
feat/issue-368-tag-filter-search
branch
from
July 30, 2026 00:54
4de7e79 to
047c1f3
Compare
6 tasks
RerankerGuo
force-pushed
the
feat/issue-368-tag-filter-search
branch
from
August 6, 2026 08:16
047c1f3 to
c84bdf1
Compare
#368) Closes #368 - Add containment-style tags filter to LocalFileStore._matches_search_filter with AND semantics (chunk must contain every expected tag). Matches the design note in the issue: frontmatter tags: [user:alice] plus the markdown chunker include_frontmatter_in_metadata=true lets multi-agent deployments scope recalls to a single user without per-user workspaces. - Promote tags context parameter in SearchStep and SearchV2Step to search_filter[tags], mirroring the existing start_date/end_date promotion. Accept both list[str] and comma-separated strings (trimmed). Explicit search_filter.tags takes precedence. - Add _tag_contains helper on LocalFileStore (covers list/set/tuple, scalar, and None inputs) and move the final two early-returns of _matches_search_filter to a combined boolean so pylint keeps the function's return-count under the limit. - Unit tests: containment semantics at the filter layer, list+CSV promotion in both SearchStep and SearchV2Step, precedence over top-level context. - The v0.4.x user-facing change removed an explicit user-scoping parameter. The documented workaround (separate workspaces per user) is heavyweight; the maintainer suggestion (store user:<name> in frontmatter tags) needed the corresponding search-side filter to be actionable in practice. - Using containment (AND) rather than exact equality keeps the frontmatter format natural: mix of user:<name>, project:<proj>, domain tags still works without calling multiple filters. - Using a reserved top-level tags key keeps the behavior explicit and the metadata semantics stable (metadata keys still use exact equality, which is what callers need for conversation_date style filters). - Does NOT flip include_frontmatter_in_metadata default to true — that's a deploy-time config decision and changes memory usage. Docs update to note the knob is tracked separately. - No vector or keyword index changes; filtering stays post-hoc consistent with date/path/metadata filters today. - [x] New unit tests (4) for filter semantics, list and CSV promotion, precedence, SearchV2Step — all PASS - [x] Existing search step test suite — 36/36 PASS (no regressions) - [x] Pre-commit: check-ast, black, flake8, pylint, pyroma, add-trailing-comma, whitespace, private-key — all PASS
RerankerGuo
force-pushed
the
feat/issue-368-tag-filter-search
branch
from
August 6, 2026 08:16
c84bdf1 to
c210995
Compare
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.
🎯 背景 (Background)
Closes #368
问题摘要:Issue 作者报告 v0.4.x 版本不再支持显式的用户维度检索。Maintainer 在 评论 中明确给出了推荐方案:在 Markdown frontmatter 中写入
并在 search 上扩展支持 containment-style tag filter。但当时 search 侧只支持 metadata 的精确相等匹配,不支持对 list 类型的 tags 做包含匹配,因此该方案实际上不可落地。本 PR 补齐这一能力,并把
tags作为顶级 context 参数暴露,与 start_date/end_date 对齐。📝 改动内容 (What & Why)
做了什么
tags作为保留 key,避免走默认的 exact equality,保证其他 metadata key(如 conversation_date)行为不变;同时把末尾两个 early-return 合并为 passes_tags & passes_metadata,把 return 数量控制在 pylint 阈值内为什么这么做
user:alice + project:foo,调用方只需要传其中一个就做用户维度隔离,需要更严格就同时传两个tags参数即可明确不做什么(边界)
include_frontmatter_in_metadata默认值(仍为 false):开启它会放大内存占用,属于部署配置决策,调用方按 maintainer 的方案需要自行打开,或单独开 PR 补配置文档✅ 验证方式 (Verification)
本地测试
手动(集成侧)验证步骤
对部署方而言,落地用户维度隔离需要同时做两件事:
Markdown chunker 打开 frontmatter 到 metadata(config YAML 中):
搜索传 tags 参数:
或者等价 MCP 调用:tools/call with name=search, params={query, limit, tags:["user:alice"]}。
🌊 影响范围 (Impact)
include_frontmatter_in_metadata配置建议建议在下一个独立文档 PR 补入 MCP / 集成指南📋 Checklist