0023: Deterministic predictive debugging per language provider
- Status: Proposed (implemented in Phase 2, task 016)
- Date: 2026-12-05
Context
While paused, users want to know what the next lines will do before stepping. Asking the debugger to evaluate expressions would answer that, but evaluation runs program code: it can change state, call getters, block or crash the program. An AI guess would not be deterministic and could be wrong while looking certain. Each language's semantics differ in exactly the places that matter (integer width and overflow, division rounding, null).
Decision
- A prediction role in the provider contract (contract version 3).
LanguageProvider::predicttakes aPredictInput(stop identity, source, paused line, typed locals, build facts, limits) and a cancel token;prediction_valueturns a debugger-reported local into an exact value for a given adapter. Shared code (ide_languages::predict) is limited to the value and result types, budgets and parsing helpers. - One interpreter per language, over the existing Tree-sitter grammars, in the language's provider: Rust, C# and Python. Each starts at the paused statement, stays in the current function, and stops with a reason at anything it does not model. An unknown condition stops the prediction; nothing speculative is shown as certain.
- Checked host arithmetic in
i128, with each language's rules modelled explicitly. Where the outcome depends on a setting that is not known (overflow checks), the result is unknown. - The core schedules: one worker thread at a time, a single coalescing slot, a cache keyed by the whole context, and results kept only while their context is current. The worker verifies the source against the launch evidence before predicting. Edits, resume, frame change, stop and disabling hide results at once.
- No debugger traffic from prediction. It uses only values already fetched. The core lists the frame's locals itself only when the debug provider's
LaunchPlan::locals_without_side_effectssays listing runs no program code (lldb-dap); otherwise the user opens Locals. - On by default, independent of AI, with a global switch and per-language overrides in
[prediction].
Alternatives considered
- Debugger evaluation. Precise, but runs program code and needs adapter round trips; rejected for an always-on feature.
- Compiler metadata (rustc MIR, Roslyn, CPython bytecode). More exact types, but needs the toolchain at runtime or a build-time step, and running tools from the workspace. Tree-sitter is already loaded and runs nothing.
- One shared interpreter with language flags. Less code, but the semantics differ in most operators; separate interpreters keep each language's rules readable and testable.
- Merging both branches of an unknown condition. Allowed only for identical proven outcomes; stopping is simpler and never misleading, so it was chosen for now.
Consequences
- Provider contract version 3; bundled manifests declare
predictionproviders. - Predictions cover a small, documented subset; most real functions stop at the first call. The subset can grow per language without changing the contract.
- Build settings (Rust
overflow-checks, C#CheckForOverflowUnderflow) are not read yet, so overflow outside explicit contexts is unknown. - ADR 0022's rule that no variables are fetched before the user opens a scope now has one exception: locals of adapters whose provider guarantees listing them runs no program code.