Overview
Located atsrc/athena/tools/search.py, this module provides:
- Parallel collection from 8+ data sources
- Weighted RRF score fusion
- Optional cross-encoder reranking
- Exact and semantic caching
- Confidence-based filtering
Function Signature
Parameters
query- Search query stringlimit- Maximum number of results to return (default: 10)strict- Filter out low-confidence results belowCONFIDENCE_MEDthresholdrerank- Enable semantic reranking with cross-encoderdebug- Show detailed signal informationjson_output- Output results as JSON instead of human-readable formatinclude_personal- Include results from personal domain (default: excluded)skills_only- Restrict search to.agent/skills/directory
Data Sources
Search collects from the following sources in parallel:1. Canonical (collect_canonical)
Searches CANONICAL.md for keyword matches. Requires 2+ keyword hits per line.
2. Tags (collect_tags)
Searches sharded tag indexes using grep for exact matches.
3. Vectors (collect_vectors)
Semantic search across multiple vector collections in Supabase:
case_study(weight: 3.0)session(weight: 3.0)protocol(weight: 2.8)capability(weight: 1.8)playbook(weight: 1.8)workflow(weight: 1.8)entity(weight: 1.8)reference(weight: 1.8)framework(weight: 2.3)user_profile(weight: 2.5)system_doc(weight: 1.8)
4. GraphRAG (collect_graphrag)
Searches knowledge graph entities and communities via query_graphrag.py subprocess.
5. Filenames (collect_filenames)
Searches project files by name using find command.
6. Framework Docs (collect_framework_docs)
Searches .framework/ and .context/memory_bank/ directories.
Weight: 2.5
7. SQLite (collect_sqlite)
Fallback search in local athena.db index.
Weight: 1.5
8. Exocortex (collect_exocortex)
Searches Wikipedia abstracts via FTS5 index.
Weight: 1.5
RRF Fusion Algorithm
Weighted Reciprocal Rank Fusion combines rankings from multiple sources:RRF Formula
For each document:k = 60(RRF constant)score_mod = 0.5 + original_score(dynamic boost)weight_source= source-specific weight fromWEIGHTSdict
Caching
Exact Cache
Matches query string + parameters:Semantic Cache
Matches by embedding similarity (fallback when exact miss):Optimization Features
God Mode
Aggressive latency optimization enabled by default:Low Entropy Detection
Skips deep vector retrieval for short, generic queries:Parallel Collection
All sources collected concurrently with timeout:Reranking
Optional semantic reranking with cross-encoder:Confidence Filtering
Results are tagged with confidence badges:CLI Usage
Basic Search
With Reranking
Strict Mode
JSON Output
Debug Mode
Output Format
Human-Readable
JSON
Performance
- Cold start: ~800ms (vector embedding fetch)
- Warm (exact cache hit): ~5ms
- Warm (semantic cache hit): ~200ms
- Collection timeout: 5s (God Mode) / 8s (normal)
- GraphRAG timeout: 5s
Related
Agentic Search
Multi-step query decomposition
Search Models
SearchResult data structure