feat(core): add default_search_type config setting#676
feat(core): add default_search_type config setting#676phernandez wants to merge 2 commits intomainfrom
Conversation
Add default_search_type to config.json to let users set their preferred search mode (text, vector, hybrid) without specifying search_type on every query. When unset (None), preserves existing auto-detection: hybrid if semantic search is enabled, text otherwise. Closes #671 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 2m 25s —— View job PR Review: feat(config): add default_search_type setting
SummaryThe feature design is clean and well-scoped — adding a Bug: Existing stub configs break after refactorSeverity: High — this will cause existing tests to fail with The refactored # search.py:38
if config.default_search_type:
return config.default_search_type
return "hybrid" if config.semantic_search_enabled else "text"But the pre-existing stub config objects in four existing tests don't have a
Accessing Missing literate-programming comment (CLAUDE.md requirement)The old # Before (old code had this):
except RuntimeError:
# Trigger: MCP container is not initialized (e.g., `bm tool search-notes` direct call).
# Why: CLI path still needs the same semantic-default behavior as MCP server path.
# Outcome: load config directly and keep text-mode retrieval behavior consistent.
return ConfigManager().config.semantic_search_enabledThe new code has the same branch with no comment. Per CLAUDE.md's literate programming style, non-obvious branches need Trigger/Why/Outcome comments. Minor: Broad exception type in test# tests/test_config.py — overly broad
def test_default_search_type_rejects_invalid_values(self):
with pytest.raises(Exception):
BasicMemoryConfig(default_search_type="invalid")Should use Minor: Imports inside test function bodiesThe three new tests in Team Checklist
|
Existing tests used stub config objects missing the new default_search_type field, causing AttributeError in CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task in 4m 20s —— View job PR Review: feat(config): add default_search_type setting
Changes made
except RuntimeError:
# Trigger: MCP container is not initialized (e.g., CLI `bm tool search-notes` direct call).
# Why: CLI invocation bypasses the MCP server startup, so get_container() is unavailable.
# We still need the same default-type resolution as the MCP server path.
# Outcome: Load config directly from disk; downstream logic proceeds identically.
config = ConfigManager().config
def test_default_search_type_rejects_invalid_values(self):
with pytest.raises(ValidationError): # was: Exception
BasicMemoryConfig(default_search_type="invalid")
|
Summary
default_search_typeconfig option (text,vector, orhybrid) so users can set their preferred search mode globallynull), preserves existing auto-detection behavior:hybridif semantic search is enabled,textotherwisesearch_typeparameter onsearch_notesExample config:
{ "default_search_type": "vector" }Closes #671
Test plan
🤖 Generated with Claude Code