The novacoder/indexing/ package is the incremental indexing pipeline for Nova Coder. It is consumed by WorkspaceService to build project understanding.
Status: IMPLEMENTED ✅
The indexing pipeline supports:
- File scanning with hash-based change detection
- Language detection from file extensions
- Symbol extraction for Python, JavaScript, and TypeScript
- Generic symbol extraction via regex for unsupported languages (imports, classes, functions)
- Tree-sitter extraction (optional), accurate multi-language parsing with incremental re-parsing when the
treesitterextra is installed (pip install "novacoder[treesitter]").SymbolExtractorprefersTreeSitterExtractorper language and falls back to the built-in extractors when a grammar is unavailable or parsing fails. - Incremental scanning, only changed and deleted files are reprocessed
- Symbol index for fast lookup
- Import extraction for dependency graph building
Package Layout
novacoder/indexing/
├── __init__.py # Public re-exports
├── languages.py # LanguageDetector
├── scanner.py # ProjectScanner, FileEntry
├── symbols.py # Symbol, SymbolExtractor, SymbolIndex
└── extractors/
├── __init__.py # EXTRACTORS registry
├── base.py # LanguageExtractor ABC
├── generic.py
├── javascript.py
├── python.py
└── typescript.py
ProjectScanner
ProjectScanner discovers files and returns only changed files on incremental scans.
from novacoder.indexing import ProjectScanner
scanner = ProjectScanner("/path/to/project")
files = scanner.scan()
# Incremental re-scan
changed = scanner.scan(incremental=True)
deleted = scanner.last_deleted
Performance semantics (post-Report 34)
- Metadata fast-path:
scan()stats each file and skipsread_bytes+ sha256 + symbol extraction when(mtime, size)match the stored entry, in both incremental and non-incremental modes. A no-change rescan of this repo (~1800 indexed files) went from ~15–48s to ~0.5s. - Pruned traversal: the scanner walks with
os.walkand prunes excluded directories (node_modules,.venv,.git, …) before descending, dependency trees are never entered.Path.rglobused to stat all ~30k excluded files first. - Single extraction:
_index_fileextracts symbols once; consumers reuseentry.symbols(WorkspaceService.scan,_run_scan) instead of re-extracting. entry.contentis transient: set only for changed/new files and released by consumers after use. Callers must not assume content persists.- Lazy graphs:
WorkspaceServicemarks its four symbol graphs dirty on changes and rebuilds them on first property access, not per scan. - Change key caveat: mtime+size is the fast-path key; a same-size same-mtime edit is the accepted edge case (hash check catches mtime-only touches cheaply).
See backups/reports_archive_2026-10-13/ai-chat-performance/34_large_project_performance.md for
measurements and scripts/bench_indexing.py for the benchmark harness.
Symbol Extraction
SymbolExtractor dispatches to a language-specific extractor.
from novacoder.indexing import SymbolExtractor, SymbolIndex
result = SymbolExtractor().extract("main.py")
print(result["classes"])
print(result["functions"])
print(result["imports"])
index = SymbolIndex()
index.add(result["symbols"])
print(index.find(kind="class"))
Language Detection
LanguageDetector maps file extensions to language identifiers.
from novacoder.indexing import LanguageDetector
print(LanguageDetector.detect("main.py")) # python
print(LanguageDetector.detect("app.js")) # javascript
print(LanguageDetector.detect("app.ts")) # typescript
Integration with WorkspaceService
WorkspaceService uses ProjectScanner and SymbolExtractor from novacoder/indexing/ to maintain the project index. It publishes WorkspaceScanned, WorkspaceFileChanged, and WorkspaceSymbolsUpdated events.
The FileWatcher debounces filesystem events (default 1s quiet period,
one trailing run if changes arrive during a scan) and its polling fallback
prunes the scanner's literal exclude dirs. IndexingService.ingest() runs
the scan + graph builds in a threadpool and bounds embedding concurrency
(asyncio.Semaphore(8)); VectorMemoryStore is capacity-bounded
(max_entries=50_000, FIFO) and skips re-embedding identical text.
Development Instructions
Adding a New Language
- Edit
LanguageDetector.EXTENSIONSinnovacoder/indexing/languages.py. - Add a new extractor in
novacoder/indexing/extractors/if needed. - Register the extractor in
novacoder/indexing/extractors/__init__.py.
Adding a New Extractor
- Create a class extending
LanguageExtractor. - Implement
extract(path, content) -> dict[str, Any]returningimports,classes,functions,symbols. - Register it in
EXTRACTORSunder the language identifier. - Add tests in
tests/test_indexing.py.