@@ -58,49 +58,95 @@ Planned improvements for CodexA, organized by priority.
5858
5959> Phases redesigned after self-analysis with CodexA tools and competitive
6060> comparison with [ ck] ( https://github.com/BeaconBay/ck ) (Rust-based semantic
61- > search, v0.7.4). Priorities: close visible UX/performance gaps first, then
62- > double down on CodexA's unique AI-powered strengths.
61+ > search, v0.7.4). ** Strategy: replace the Python search/indexing core with
62+ > Rust first (Phase 32), then build every subsequent feature on the fast
63+ > native foundation.** Old Phase 34 (Performance & Smart Indexing) is fully
64+ > absorbed into the Rust core.
6365
64- ### Phase 32 — Search UX & Output Modes
66+ ### Phase 32 — Rust Search Engine Core ( ` codexa-core ` )
6567
66- Close the biggest visible gaps in search ergonomics:
68+ Replace the Python search/indexing hot paths with a native Rust library,
69+ exposed to Python via PyO3. This is the single largest performance leap —
70+ every phase after this builds on the Rust foundation.
71+
72+ ** Crate structure** (` codexa-core/ ` ):
73+
74+ - ` codexa-core ` — top-level PyO3 module exporting Python classes
75+ - ` codexa-ann ` — HNSW vector index (replaces FAISS ` IndexFlatIP ` / ` IndexIVFFlat ` )
76+ - ` codexa-index ` — Tantivy full-text search (replaces Python BM25)
77+ - ` codexa-chunk ` — tree-sitter AST chunking (Rust-native grammars)
78+ - ` codexa-embed ` — ONNX embedding inference via ` ort ` crate (CPU + GPU)
79+ - ` codexa-scan ` — parallel file scanner with ` rayon ` , blake3 content hashing
80+
81+ ** What moves to Rust:**
82+
83+ - Vector store: HNSW index with memory-mapped persistence (replaces FAISS)
84+ - Full-text search: Tantivy inverted index (replaces Python BM25)
85+ - Hybrid search: RRF fusion computed in Rust
86+ - Chunking: Rust-native tree-sitter grammars (12+ languages)
87+ - File scanning: ` rayon ` -parallel walk, blake3 hashing, smart binary detection
88+ - Embedding: ` ort ` (ONNX Runtime) for model inference, batched
89+ - Content hashing: blake3 replaces SHA-256 for incremental indexing
90+
91+ ** What stays in Python:**
92+
93+ - CLI (Click), LLM integration, RAG pipeline, MCP/bridge server
94+ - Web UI, quality analysis, plugin system, CI tools
95+
96+ ** Python API** (drop-in replacements via PyO3):
97+
98+ ``` python
99+ from codexa_core import VectorStore, TextIndex, Chunker, Scanner, Embedder
100+
101+ store = VectorStore(dimension = 384 ) # HNSW, not FAISS
102+ store.add(embeddings, metadata)
103+ results = store.search(query_vec, top_k = 10 )
104+
105+ index = TextIndex.load(path) # Tantivy, not BM25
106+ results = index.search(" query" , top_k = 10 )
107+
108+ chunks = Chunker.chunk(content, language) # Rust tree-sitter
109+ files = Scanner.scan(root, ignore_patterns) # rayon + blake3
110+ embeddings = Embedder.encode(texts, model) # ort ONNX
111+ ```
112+
113+ ** Performance targets:**
114+
115+ - Indexing: 1M LOC in < 2 min (vs current ~ 8 min Python)
116+ - Search: sub-100ms queries at 100K vectors
117+ - Memory: 50% reduction via memory-mapped indices
118+ - Startup: near-instant index loading (mmap, no deserialization)
119+
120+ ### Phase 33 — Search UX & Output Modes
121+
122+ Build on the Rust core to close the biggest visible UX gaps:
67123
68124- ` --scores ` flag to display similarity scores with color highlighting
69125- ` --full-section ` flag to return complete function/class bodies, not just chunk snippets
70126- ` --threshold ` flag to filter results below a minimum similarity score
71127- JSONL streaming output mode (` --jsonl ` ) for piping into downstream tools
72- - ` codexa search --inspect <file> ` to visualize chunks, token counts, and embeddings for a file
128+ - ` codexa search --inspect <file> ` to visualize chunks, token counts, and embeddings
73129- ` .codexaignore ` auto-generation from detected binary/vendored/generated files
74- - Smart binary detection to skip non-text files during indexing
130+ - ` codexa index --diff ` to index only git-changed files
75131
76- ### Phase 33 — Precise Token Management
132+ ### Phase 34 — Precise Token Management
77133
78- Replace rough token estimation with model-specific counting (ck already ships exact tokenization) :
134+ Leverage the Rust ` tokenizers ` crate for exact model-specific counting:
79135
80- - ` tiktoken ` for OpenAI models, HuggingFace ` tokenizers ` for local/Ollama models
136+ - HuggingFace ` tokenizers ` in Rust (exposed via PyO3) for local models
137+ - ` tiktoken ` integration for OpenAI models
81138- Accurate context window budgeting with overflow protection in RAG pipeline
82139- Token usage reporting and cost estimation per query
83140- Smart context truncation preserving semantic boundaries (function/class edges)
84141- ` codexa search --tokens ` to show token count per result
85142
86- ### Phase 34 — Performance & Smart Indexing
87-
88- Content-aware incremental indexing to close the speed gap:
89-
90- - Content-hash (blake3) per chunk — skip re-embedding unchanged code
91- - Parallel embedding with configurable worker count
92- - Batch FAISS insertion instead of one-by-one vector adds
93- - Memory-mapped FAISS indices for low-RAM machines
94- - ` codexa index --diff ` to index only git-changed files
95- - Indexing progress bar with ETA and throughput stats
96-
97143### Phase 35 — Advanced Embedding & Model Selection
98144
99- Multiple embedding models and smarter search infrastructure :
145+ Multi-model support powered by the Rust ONNX backend :
100146
101147- Support BGE, mxbai-embed, nomic-embed, jina-code-v2 alongside current MiniLM
102148- Model switching at query time without full re-index (dual-index mode)
103- - GPU-accelerated FAISS with IVF-PQ indices for million-file repos
149+ - IVF-PQ indices in Rust for million-file repos
104150- Field-scoped search filters (` --lang ` , ` --symbol-type ` , ` --file ` )
105151- Configurable RRF weights for hybrid search tuning
106152- ` codexa models compare ` to benchmark models on the user's actual codebase
0 commit comments