## Summary Replace the push-based compilation model with a pull-based (lazy) model where compilation is driven entirely by feature requests. ### Server core (`master_server.cpp/h`) - **Remove** `schedule_build()`, `run_build_drain()`, debounce timers, and `DocumentState` flags (`build_running`, `build_requested`, `drain_scheduled`) - **Remove** `debounce_ms` config field - `didOpen`/`didChange` only update `DocumentState` and mark `ast_dirty` — no compilation triggered - `didSave` marks dependent docs dirty via `CompileGraph::update()`, invalidates PCH hashes, marks **all** open documents `ast_dirty` (header saves), and queues background indexing - **Implement** `ensure_compiled(path_id)` — the pull-based entry point called by `forward_stateful()`/`forward_stateless()` before every feature request: 1. Fast-path if `!ast_dirty` 2. Compile C++20 module deps via `compile_graph->compile_deps()` 3. Build/reuse PCH via `ensure_pch()` (only attach on success) 4. Send `CompileParams` to stateful worker 5. Publish diagnostics, clear dirty, schedule indexing 6. Generation mismatch → return `false`, keep dirty for retry - `forward_stateless()` now also calls `compile_graph->compile_deps()` before stateless requests (completion/signatureHelp) - Move module-implementation-unit implicit dependency handling into `resolve_fn` (was duplicated in `run_build_drain` and `ensure_compiled`) ### CompileGraph (`compile_graph.cpp/h`) - **Add** `compile_deps(path_id)` — compiles all transitive module dependencies but NOT the file itself (used for plain .cpp files that `import` modules) - Unify `compile`/`compile_deps` via `compile_impl(path_id, ancestors, dispatch_self)` parameter - `compile_deps` compiles dependencies concurrently via `when_all` - Extract `finish()` lambda to deduplicate `compiling=false; completion->set()` cleanup across all exit paths - Use `std::ranges::remove` instead of legacy `std::remove` ### Test infrastructure (`conftest.py`) - `open_and_wait()` now sends a hover request to trigger `ensure_compiled()` (pull-based model requires a feature request to compile) - Fix URI handling: send percent-encoded URI on the wire, normalize for internal lookups, store diagnostics under both raw and normalized URI keys - Add `_normalize_uri()` helper using `urllib.parse.unquote` ### Integration tests - Update all tests for pull-based model: no more waiting on `didOpen` diagnostics - `_wait_for_index()` sends hover to trigger compilation before polling `workspace/symbol` - `test_hover_save_close` simplified — hover directly triggers compilation - `test_save_recompile` and `test_pch_*` wait for fresh diagnostics after hover-triggered recompilation ### Unit tests (`compile_graph_tests.cpp`) - Extract `compiled`/`graph` as TEST_SUITE members with `std::optional<CompileGraph>` - Extract `execute(callback)` helper to deduplicate event_loop boilerplate - Add 8 new `compile_deps` tests: no-deps, single dep, chain, diamond, failure, plain-cpp, concurrent dedup, resolve-once - Remove redundant `inline` on file-scope helpers ## Test plan - [x] Unit tests: 426 passed, 5 skipped - [x] Smoke tests: 1/1 passed - [x] Integration tests: 69 passed, 0 failed, no hangs 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
22 KiB
22 KiB