11# CLAUDE.md
22
3- Vectorless is a reasoning-native document intelligence engine written in Rust.
3+ Vectorless is a Document Understanding Engine for AI written in Rust.
44
55## Principles
66
@@ -10,32 +10,56 @@ Vectorless is a reasoning-native document intelligence engine written in Rust.
1010
1111## Project Structure
1212
13- - ` rust/ ` - Rust core engine
14- - ` src/client/ ` - Client API (EngineBuilder, Engine) - facade layer, no business logic
15- - ` src/document/ ` - Document data structures (DocumentTree, NavigationIndex, ReasoningIndex)
16- - ` src/index/ ` - Compile pipeline (8-stage, checkpointing, incremental update)
17- - ` src/retrieval/ ` - Retrieval dispatch layer (preprocessing, dispatch, postprocessing, cache, streaming)
18- - ` src/query/ ` - Query understanding and planning (intent classification, rewrite, decomposition)
19- - ` src/agent/ ` - Retrieval execution (Worker: doc navigation, Orchestrator: supervisor loop + multi-doc fusion)
20- - ` src/rerank/ ` - Result reranking and answer synthesis (dedup, scoring, fusion, synthesis)
21- - ` src/scoring/ ` - Scoring and ranking strategies (BM25, relevance scoring, score combination)
22- - ` src/llm/ ` - LLM client (connection pool, memo/caching, throttle/rate-limiting, fallback)
23- - ` src/storage/ ` - Persistence (Workspace, LRU cache, backend abstraction file/memory)
24- - ` src/graph/ ` - Cross-document relationship graph
25- - ` src/metrics/ ` - Metrics collection and reporting
26- - ` src/events/ ` - Event system for progress monitoring
27- - ` src/config/ ` - Configuration types and validation
28- - ` src/error.rs ` - Unified error types
29- - ` src/utils/ ` - Utility functions (token counting, fingerprinting, validation)
30- - ` examples/ ` - Rust examples (flow, indexing, pdf, batch, etc.)
31- - ` python/ ` - Python SDK (PyO3 bindings) + CLI
13+ Cargo workspace with 17 fine-grained Rust crates + pure Python SDK:
14+
15+ ```
16+ vectorless-core/
17+ ├── vectorless-error/ # Error types (Result, Error enum)
18+ ├── vectorless-document/ # Document types (Document, Tree, NavigationIndex, ReasoningIndex)
19+ ├── vectorless-config/ # Configuration hub (aggregates all config types)
20+ ├── vectorless-utils/ # Utilities (fingerprinting, token counting, validation)
21+ ├── vectorless-scoring/ # Scoring (BM25, keyword extraction)
22+ ├── vectorless-graph/ # Cross-document relationship graph
23+ ├── vectorless-events/ # Event system for progress monitoring
24+ ├── vectorless-metrics/ # Metrics collection and reporting
25+ ├── vectorless-llm/ # LLM client (pool, memo/cache, throttle, fallback)
26+ ├── vectorless-storage/ # Persistence (Workspace, LRU cache, file/memory backends)
27+ ├── vectorless-query/ # Query understanding (intent classification, rewrite)
28+ ├── vectorless-index/ # Compile pipeline (10-stage, checkpointing, incremental update)
29+ ├── vectorless-agent/ # Retrieval execution (Worker navigation + Orchestrator fusion)
30+ ├── vectorless-retrieval/ # Retrieval dispatch layer (dispatcher, cache, streaming)
31+ ├── vectorless-rerank/ # Result reranking (dedup, BM25 scoring, fusion)
32+ ├── vectorless-engine/ # Facade (Engine, EngineBuilder) — re-exports public API
33+ └── vectorless-py/ # PyO3 bindings (compiled into Python native module)
34+ ```
35+
36+ - ` vectorless/ ` - Pure Python SDK (high-level wrappers, CLI, config loading, integrations)
37+ - ` examples/ ` - Python examples (primary, for Python ecosystem)
3238- ` docs/ ` - Docusaurus documentation site
33- - ` samples/ ` - Sample files
39+
40+ ### Dependency Layers
41+
42+ ```
43+ Layer 0: error · document · utils · scoring (no workspace deps)
44+ Layer 1: graph · events · config · metrics (depends on Layer 0)
45+ Layer 2: llm · storage (depends on Layer 0–1)
46+ Layer 3: query (depends on Layer 0–2)
47+ Layer 4: index · agent (depends on Layer 0–3)
48+ Layer 5: retrieval · rerank (depends on Layer 0–4)
49+ Layer 6: engine (facade) · vectorless-py (bindings) (depends on all)
50+ ```
51+
52+ ### Compilation Isolation
53+
54+ 改一个模块只重编译该 crate + 上游 facade:
55+ - 改 ` agent ` → agent, retrieval, rerank, engine, py 重编译;index/llm/storage 不动
56+ - 改 ` llm ` → llm 及其上层重编译;index/agent/stage 不重编译
57+ - 改 ` document ` → 全部重编译(核心类型,预期行为)
3458
3559### Retrieval Call Flow
3660
3761```
38- Engine.query ()
62+ Engine.ask ()
3963 → retrieval/dispatcher
4064 → query/understand() → QueryPlan (LLM intent + concepts + strategy)
4165 → Orchestrator (always, single or multi-doc)
@@ -49,16 +73,17 @@ Engine.query()
4973## Build Commands
5074
5175``` bash
52- # Rust core
53- cd rust
54- cargo build # Build
55- cargo test # Run tests
76+ # Build (workspace)
77+ cargo build # Build all crates
78+ cargo test # Run tests (488 tests across all crates)
5679cargo clippy # Lint
5780cargo fmt # Format code
5881
82+ # Build specific crate (fast — only that crate + dependents)
83+ cargo build -p vectorless-agent
84+
5985# Python SDK
60- cd python
61- pip install -e . # Install in editable mode
86+ pip install -e . # Install in editable mode (from project root, uses maturin)
6287
6388# Docs site
6489cd docs
@@ -145,7 +170,9 @@ When uncertain whether an operation is safe, **default to asking user confirmati
145170
146171## Common Development Workflow
147172
148- 1 . ** Adding features** : Implement in appropriate ` rust/src /` module , add tests
173+ 1 . ** Adding features** : Implement in the appropriate ` vectorless-core/vectorless-* /` crate , add tests
1491742 . ** Fixing bugs** : Add failing test case first, fix and ensure tests pass
150- 3 . ** Python bindings** : Update ` python/src/lib.rs ` (PyO3) when Rust APIs change
151- 4 . ** Committing code** : Use semantic commit messages, format: ` type(scope): description `
175+ 3 . ** Adding crates** : New modules get their own crate under ` vectorless-core/ ` , add to workspace Cargo.toml
176+ 4 . ** Python bindings** : Update ` vectorless-core/vectorless-py/src/lib.rs ` (PyO3) when Rust APIs change
177+ 5 . ** Python SDK** : Update ` vectorless/ ` when API surface changes
178+ 6 . ** Committing code** : Use semantic commit messages, format: ` type(scope): description `
0 commit comments