Architecture
wdpkr is a Rust CLI (Edition 2024, Rust 1.96+) that maintains a vector-search index of LLM-generated code summaries. This page maps the source tree and the patterns that recur across it.
Module map
Section titled “Module map”src/├── cli/ # Clap parsing + subcommand dispatch├── config/ # 4-layer resolution: defaults → file → env → CLI flags├── chunk/ # tree-sitter AST chunking (8 languages)├── summarize/ # Anthropic adapter + prompt templates + big-file rollup├── embed/ # Voyage / Ollama / OpenAI adapters├── store/ # VectorStore trait + Turbopuffer adapter├── search/ # Search orchestration + JSON/pretty output├── indexer/ # Full pipeline: git diff → walk → chunk → summarize → embed → upsert└── testing/ # Mocks (store, embedder, summarizer) + fixturesDesign conventions
Section titled “Design conventions”- Trait-first design.
VectorStore,Embedder,Summarizer, andChunkerare each a trait with both a mock and a real implementation. The pipeline depends on the traits, never the concrete providers — that’s what makes backends swappable. - The
env_orconfig pattern. Every field resolves throughenv_or_resolved(KEY, file_or_resolved(file_value, default))— so each setting has a known environment variable, a file key, and a hardcoded default. See Configuration. - Shared adapter shape. All external API adapters use the same pattern: a
reqwestHTTP client, bounded exponential-backoff retry on 429/5xx, and a configurable base URL so tests never hit the network. - Errors.
anyhowat the binary boundary; traits returnanyhow::Result. - Async runtime.
tokio—current_threadfor search (fast cold start),multi_threadfor indexing (parallel summarize/embed).
Testing
Section titled “Testing”The test suite is mock-based — no live API calls. Integration tests create
temporary git repos with fixture source files and exercise the real pipeline
against MockEmbedder, MockVectorStore, and MockSummarizer.
The suite also runs under Miri to catch
undefined behavior. Tests that cross an FFI boundary — tree-sitter, spawned
processes, system TLS, or the tokio reactor — are marked
#[cfg_attr(miri, ignore)]; pure-Rust tests using the mocks run under Miri
unchanged.
Building from source
Section titled “Building from source”just test # run all testsjust ci # fmt-check + clippy (-D warnings) + testjust build # debug buildjust release # optimized release buildjust run <args> # run from sourceThe toolchain is pinned via rust-toolchain.toml.