perf: query workers skip the extraction and resolution stacks
Item 1E. §5.45 found each query worker holding ~96 MB of anonymous memory. Most of it was code the worker never runs.
Cause. Loading the library through src/index.ts pulled 187 modules (4.5 MB of JavaScript: the tree-sitter extractors, the callback synthesizer, the name matcher, the resolver). Every open also built an extraction orchestrator and a resolver. A query worker only reads the graph.
Change:
- The
CodeGraphclass moved tosrc/codegraph.ts.src/index.tsstays the public entry with every export unchanged, and hands the extraction, resolution and watcher modules to the class throughprovideStacks. - A caller that loads
codegraph.tsdirectly loads those modules on first use. That means the query worker, the MCP engine and the ToolHandler's cross-project open, which now require../codegraphinstead of../index. - The orchestrator and resolver are built on first use and reset when the layers are rewired after a reopen.
Measured (the bloc corpus, daemon mode, the same 8-way explore burst as §5.45):
| before | after | |
|---|---|---|
| modules a worker loads | 187 | 60 |
| RSS added by that load | +44 MB | +25 MB |
| idle daemon, anonymous | 148 MB | 109 MB |
| after the burst, anonymous | 531 MB (5 workers) | 303 MB (6 workers) |
| per extra worker | ~96 MB | ~32 MB |
AGENTS.md is updated for the new file layout, and the ledger has §5.46 and a CHANGELOG Fixes entry. One test sampled a call line from the engine's own src/index.ts; it now reads src/codegraph.ts, as its comment asked for when the file moved.
Gate: full suite, 305 files and 5,190 tests.