feat(memory): adaptive retrieval dispatch by query type (#1629)#1789
Merged
feat(memory): adaptive retrieval dispatch by query type (#1629)#1789
Conversation
- README.md, zeph-llm, zeph-mcp, zeph-memory, zeph-tools: reflect tool overflow SQLite migration, graph memory temporal versioning, Gemini Phase 4 SSE tool use, cascade cost_tiers, MCP sanitization - docs/src/advanced/tools.md: update overflow storage section (disk path → SQLite-backed, portable, auto-cleanup on session end) - docs/src/reference/configuration.md: document temporal_decay_rate validation ([0.0, 10.0] clamp) and cost_tiers cascade config field
- graph-memory.md: document temporal edge validity (valid_from/valid_until, edges_at_timestamp, edge_history, bfs_at_timestamp, temporal_decay_rate) - providers.md: add Gemini Phase 4 SSE streaming tool use - adaptive-inference.md: document cascade cost_tiers config - observability.md: minor updates - security/mcp.md: document tools/list_changed sanitization
Add a lightweight query classifier to zeph-memory that routes recall queries to the optimal retrieval path based on temporal cues: - Episodic queries (temporal keywords: "yesterday", "last week", etc.) route to SQLite FTS5 + optional created_at timestamp range filter - Semantic queries continue through the existing BM25+RRF+MMR pipeline Implementation details: - `has_temporal_cue()`: word-boundary heuristic (no regex, no allocs) checked first in HeuristicRouter::route() before relationship patterns - `strip_temporal_keywords()`: LazyLock sorted patterns, single-pass span removal, single lowercase allocation — ~18x fewer allocs vs naive impl - `resolve_temporal_range(now)`: injectable clock for deterministic tests, covers 12 temporal expressions with explicit branches - `keyword_search_with_time_range()`: parameterized sqlx queries, no schema changes, same access control predicates as existing path - Add chrono `clock` feature to workspace dep for isolated crate builds 45 new tests: routing (temporal + false-positive guards), resolver (deterministic with injected time), strip (edge cases + all-occurrence removal), SQL filter (bounds, conversation isolation), Episodic dispatch integration.
This was referenced Mar 15, 2026
Closed
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
has_temporal_cue()heuristic classifier (word-boundary matching, zero heap allocs) checked first inHeuristicRouter::route()before relationship patternscreated_attimestamp range filter; semantic queries continue through existing BM25+RRF+MMR pipelinestrip_temporal_keywords()removes temporal tokens from the FTS5 query usingLazyLocksorted patterns and a single-pass span merge (~18x fewer allocations vs naive approach)resolve_temporal_range(now: DateTime<Utc>)converts temporal expressions to ISO 8601 bounds with injectable clock for deterministic testskeyword_search_with_time_range()uses parameterized sqlx queries; no schema changes; sameagent_visible/deleted_at/conversation access controls as existing pathclockfeature to workspacechronodep to fix isolatedzeph-memorybuildTest plan
--features fullcargo +nightly fmt --check: PASScargo clippy --workspace --features full -- -D warnings: PASSCloses #1629