Repository navigation
Fix: semantic search service-layer filtering and skill pipeline (retroactive #1064) - #1073
Conversation
…roactive review #1064) The original PR #1064 (closes #1059) implemented node_types and property_filters filtering only at the MCP handler layer. The acceptance criteria required the service-layer signature to be extended so any caller benefits from the filtering without duplicating logic. Changes: - Add SearchNodeFilters struct to services/mod.rs with matches() helper and comprehensive unit tests (13 tests covering all filter combinations) - Extend NodeEmbeddingService::semantic_search_nodes() to accept Option<&SearchNodeFilters> — when filters are active, fetch 3x results to compensate for post-filter attrition, then apply and truncate - Update handle_search_semantic() MCP handler to build SearchNodeFilters from params and pass it to the service instead of filtering post-hoc; remove the duplicate filter blocks from the handler's post-filter pass - Update search_ops.rs caller to pass None (no behavior change for that path) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
## PR #1063/#1065 findings — Metal crash fix (merged without review) ### tools.rs: Incomplete get_tool_schemas refactor (compile error) PR #1065 changed callers to pass Vec<SchemaNode> but never updated the get_tool_schemas function signature (still &[String]) or defined tool_desc and node_type_desc variables referenced in the json! macro. Fix: Update signature to &[SchemaNode], define tool_desc and node_type_desc dynamically from schema data. When user-defined schemas are present, their IDs and descriptions appear in the create_node tool description. ### context_assembly.rs: Missing filters arg (compile error) semantic_search_nodes gained a 4th filters: Option<&SearchNodeFilters> parameter (from e3a28fa). context_assembly.rs was missed. Fix: Pass None (no filter needed for general context assembly queries). ### tools_test.rs: Tests still use Vec<String> Two unit tests for get_tool_schemas still passed Vec<String> after the signature change. Fix: Construct minimal SchemaNode instances. ## PR #1069 finding — Per-turn context refresh (merged without review) ### initialize.rs: Dead function build_workspace_context_for_prompt build_workspace_context_for_prompt was added but is never called. The actual code uses build_workspace_context directly from context_ops. Fix: Remove the unused public function entirely. ## Non-functional changes - ollama_inference.rs: rustfmt alignment only - agent_e2e.rs: rustfmt alignment only Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…oactive #1059) The skill pipeline still used semantic_search() with limit*3 over-fetch and manual post-filtering by node_type == "skill". This is exactly the acceptance criterion that was not addressed by PR #1064. Use semantic_search_nodes() with SearchNodeFilters{node_types: Some(["skill"])} so filtering is applied at the service layer — no more over-fetching. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ing_logic Clippy -D warnings flags vec!["a", "b"] in a context where an array literal suffices. Switch to array to satisfy the lint. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review — Initial ReviewReview Type: Initial Review Requirements Check (Issue #1059)
Code Review Findings🟡 Important: Compounding 9× over-fetch when node_type and collection filters both active📁 When a caller passes both // handler: has_post_filters=true (collection), effective_limit = limit * 3
let effective_limit = if has_post_filters { limit * 3 } else { limit };
// passes effective_limit to service:
.semantic_search_nodes(¶ms.query, effective_limit, threshold, search_filters.as_ref())
// service: has_filters=true (node_types), fetch_limit = effective_limit * 3 = limit * 9
let fetch_limit = if has_filters { limit * 3 } else { limit };A Recommendation: Document this interaction with a comment, or cap 🟡 Important: Database-level filtering acceptance criterion not met📁 Issue #1059 acceptance criterion: "Filters are applied at the database level where possible (not just post-filter)". The current implementation calls The issue wording "where possible" acknowledges this may be complex. The HNSW/KNN index query ( Given the issue's "where possible" qualifier and that the PR description doesn't mention DB-level filtering as a gap, this is correctly punted as out of scope for now. However the AC should be closed with a note documenting why DB-level filtering wasn't implemented. Recommendation: Add a 🟢 Suggestion: Uncommitted indentation-only change to skill_ops.rs📁 There is an uncommitted change to Recommendation: Commit the unstaged indentation fix ( 🟢 Suggestion: tools_test.rs SchemaNode construction is verbose — consider a test helper📁 Both test functions construct identical Recommendation: Extract a ✅ Positive findings worth noting
RecommendationCOMMENT — The code is functionally correct and the primary acceptance criteria are satisfied. Two items need attention before merging:
The DB-level filtering gap is an acknowledged limitation — adding a TODO comment would close the loop on that AC. |
malibio
left a comment
There was a problem hiding this comment.
Automated review posted. See comment above for findings. Two action items before merge: (1) commit unstaged skill_ops.rs indentation fix, (2) consider a comment on the 9× over-fetch interaction when both node_type and collection filters are active.
…ver-fetch compounding and DB filter TODO - Commit the unstaged skill_ops.rs indentation cleanup (loop body was indented one extra level after the if-let wrapper was removed in commit 6b2c7c4) - Add comments to embedding_service.rs documenting: - The 9× over-fetch compounding that occurs when both service-layer filters (node_types) and handler-layer filters (collection/scope) are active - A TODO for future DB-level node_type filtering (requires embedding table schema change to add node_type column to vector index WHERE clause) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Re-Review: All Findings Addressed ✅Reviewing commits since initial review at Latest commit: Previous findings status:
No new issues found in the addressing commits. Recommendation: APPROVE — Ready to merge. |
malibio
left a comment
There was a problem hiding this comment.
All findings addressed. Service-layer filtering implementation is correct and well-documented. Ready to merge.
Summary
Retroactive review of PR #1064 (closes #1059). The original PR implemented
node_typesandproperty_filtersparams at the MCP handler layer but missed acceptance criteria requiring service-layer filtering. Additionally PR #1065 introduced a compilation error.Changes
Commit 1 (
e3a28fad): Service-layerSearchNodeFiltersstruct +semantic_search_nodes4-arg APISearchNodeFiltersstruct inservices/mod.rswith.matches()helper (13 unit tests)NodeEmbeddingService::semantic_search_nodes()to acceptOption<&SearchNodeFilters>handle_search_semantic()to buildSearchNodeFiltersfrom params; removed duplicate inline filter blockssearch_ops.rsto passNoneCommit 2 (
4879182a): Fix PR #1065 compilation error + related callerstools.rsget_tool_schemassignature&[String]→&[SchemaNode]with dynamic descriptionscontext_assembly.rsmissing 4thfiltersarg after signature changetools_test.rsto useSchemaNodeinstancesCommit 3 (
6b2c7c42): Fix skill pipelineskill_ops.rs: replaced over-fetch + manual node_type post-filter withsemantic_search_nodes(filters=SearchNodeFilters{node_types:["skill"]})Test Results
test_handle_query_nodes_filters_unsupported_operator_ignored) — fails on main before these changesAcceptance Criteria
semantic_search_nodesacceptsnode_typefilter viaSearchNodeFilterssemantic_search_nodesaccepts property-based filtersSearchNodeFiltersinstead of over-fetch + post-filternode_typesparameter (from Semantic search: add node_type and property-based filtering #1064)SearchNodeFiltersunit tests cover filtered and unfiltered paths🤖 Generated with Claude Code