feat: v0.4a deterministic retrieval core#91
Merged
Conversation
Add file index, symbol index, context retriever, and budget manager for repo-aware code intelligence. Includes symbol_lookup tool and optional ContextRetriever integration in CodingAgent ANALYZE phase. New modules: - src/index/ (file-index, symbol-index, indexer) - src/context/ (budget-manager, context-retriever) - src/tools/definitions/symbol-lookup.ts Config additions (schema.ts + locode.yaml): - index: enabled, ignore, languages, chunk_size, storage_dir, auto_update - context_retrieval: max_files, max_tokens_per_file, max_total_tokens, strategy, confidence_threshold 60 new tests, all 398 pass. Build and lint clean.
Merged
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
Implements v0.4 phase A — deterministic retrieval core from the v0.4 codebase intelligence design.
Adds a persistent codebase index (file tree + symbols) and a deterministic context retriever that runs before the LLM-driven ANALYZE phase, reducing token usage and latency for file/symbol lookups.
What's new
src/index/— codebase indexingFileIndex— scans the repo respecting.gitignore+ config ignore patterns; records path, language, size, SHA-256 hash. Supports incremental updates (add/remove/change via hash comparison) and save/load to.locode/index/.SymbolIndex+RegexSymbolExtractor— extracts functions, classes, methods, interfaces, types, and enums from TypeScript, JavaScript, and Python. Uses a swappableSymbolExtractorinterface soweb-tree-sittercan replace the regex extractor later without API changes.CodebaseIndexer— orchestrates file + symbol indexes, handles full builds and incremental updates, persists/loads from disk.src/context/— smart context retrievalBudgetManager— priority-weighted token allocation across files (direct_match > symbol_match > semantic_match > dependency > git_context). Respectsmax_total_tokens,max_tokens_per_file, andmax_files.ContextRetriever— deterministic pipeline: mentioned-file resolution → symbol search → sibling-test discovery → recent-file injection → rank → truncate to budget. ReturnsRetrievedContextwith confidence score and strategies used.src/tools/definitions/symbol-lookup.tssymbol_lookuptool (factory function, registered when index is available). Searches the symbol index by name + optional type filter.Config additions (
src/config/schema.ts+locode.yaml)Orchestrator + CodingAgent integration
.locode/index/on startup (non-blocking, falls back gracefully if absent).symbol_lookuptool registered when index is available.ContextRetrieveroptionally injected intoCodingAgent— when confidence ≥ 0.7, ANALYZE skips the LLM entirely (zero tokens for context gathering). Low confidence falls through to the existing LLM-driven ANALYZE.orchestrator.buildCodebaseIndex()method for a futurelocode indexCLI command.Design decisions
SymbolExtractorinterface means tree-sitter is a drop-in replacement later.find_referencesdeferred to v0.4b: Depends on the dependency graph (import tracking), which is v0.4b scope.Findings documented
See
docs/plans/2026-06-20-v04a-impl-progress.mdfor implementation decisions and findings:.default({})does not recursively apply inner defaults — must use pre-parsed constantsCONFIG_TEMPLATEduplication risk (known, noted in misc-todos.md)CodingAgent.analyzefast-path is ripe for delegating toContextRetriever(deferred to avoid changing working behavior)Test plan
npm test)npm run buildsucceedsnpm run lintpasses