feat: add auto-context recall to UserPromptSubmit hook#5
Merged
blackaxgit merged 11 commits intomainfrom Mar 13, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…udget overflow - Use floor_char_boundary for all string slicing in format_recall_context - Weight all hybrid_merge hits consistently (0.6 semantic, 0.4 FTS) - Clamp FTS scores to [0.0, 1.0] before weighting - Add budget overflow protection in format_recall_context - Add CLX_AUTO_RECALL_MIN_PROMPT_LEN env override in config - Derive Storage and EmbeddingStore from same db_path in hook - Add MCP threshold divergence comment - Add tests for multibyte UTF-8, budget overflow, single-source weighting
Reorder RecallEngine::query() to execute FTS5 search first (<10ms) before the potentially slow Ollama embedding for semantic search. This ensures results are available within the default 500ms timeout.
Set 5-second busy_timeout on all SQLite connection open paths (Storage and EmbeddingStore) to prevent SQLITE_BUSY errors when multiple CLX processes share the database concurrently.
Cover AutoRecallConfig defaults, YAML parsing (all 8 fields), missing-section serde(default) behaviour, partial YAML field defaults, serialization roundtrip, and apply_f32_override for valid/boundary/ out-of-range/invalid inputs.
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.
Summary
UserPromptSubmithook — on every user prompt, the hook runs hybrid search (semantic + FTS5) against stored snapshots and injects top-K relevant results asadditionalContextRecallEngineinclx-coreused by both MCPclx_recalltool and the hook, eliminating code duplicationAutoRecallConfigwith 8 tuneable fields, env var overrides, and dashboard Settings UI (9th section)busy_timeout(5s)for safe multi-session concurrencyChanges
clx-core/src/config.rsAutoRecallConfigstruct, defaults,apply_f32_override, 8 env overridesclx-core/src/recall.rsRecallEngine,RecallHit,RecallQueryConfig,hybrid_merge,format_recall_contextclx-core/src/lib.rspub mod recallclx-core/src/storage/migration.rsbusy_timeout(5s)inconfigure_pragmas()clx-core/src/embeddings.rsbusy_timeout(5s)inEmbeddingStore::new()andwith_dimension()clx-core/src/storage/tests.rstest_busy_timeout_is_setclx-core/tests/integration.rstest_concurrent_storage_access(multi-thread write test)clx-hook/src/types.rsprompt: Option<String>field onHookInputclx-hook/src/hooks/subagent.rsbuild_recall_context+do_recallwith timeout, graceful degradationclx-mcp/src/tools/recall.rsRecallEngineclx/src/dashboard/settings/README.mdKey design decisions
floor_char_boundary()for all string truncationbusy_timeout(5s)on all SQLite connections preventsSQLITE_BUSYerrorsTest plan
cargo test --workspace— all tests pass (597 total)cargo clippy --workspace -- -D warnings— zero warningstest_busy_timeout_is_setverifies PRAGMA returns 5000mstest_concurrent_storage_access— 2 threads, 20 writes each, zero SQLITE_BUSY🤖 Generated with Claude Code