tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

63 lignes · 3529 octetsBrut · Historique

ADR 0006: Incremental analysis model

Status: Accepted — 2026-10-08, reviewed and accepted by the project owner (issue #2).

Context

The LSP re-analyses code on every keystroke. The batch compiler (louise check/build) analyses whole packages once.

Both should share one analysis pipeline:

parse → resolve → infer → (later) lower.

The LSP needs to stay responsive, around 100 ms on the v0 demo project, and to keep working on broken code.

The main option is a query framework such as salsa, which gives fine-grained memoization and dependency tracking. Its costs are an extra dependency with its own macros and lifecycle rules, and a learning curve for every contributor.

Decision

An AnalysisDb with coarse, explicit caching

There is no query framework in v0.

Inputs: file texts, keyed by FileId, plus a revision counter.

Cached per file:

  • the Parse,
  • the module's interface: the resolved signatures of its pub and private items,
  • the body results of each item: types of expressions and diagnostics.

Invalidation on an edit:

  1. Re-parse the file.
  2. Recompute its interface.
  3. If the interface hash is unchanged, re-check only that file's bodies.
  4. Otherwise, also re-check the files that import it, transitively.

Interfaces stay stable while bodies are edited

pub fn requires a full signature (ADR 0001). So editing a body never changes the module's public interface, and dependents never need re-checking.

Stable item IDs

Each item is identified by ItemId { module, namespace, name }, plus a disambiguator for impls. IDs never use a source position, so inserting text does not shift them, and caches keyed by ItemId survive edits elsewhere.

Results are positional data keyed by ID

Expression types and other per-body results live in side tables, keyed by syntax pointers that are relative to the item. The tree itself is never mutated. Every phase is error-tolerant:

  • unresolved names and ill-typed expressions get Ty::Error,
  • Ty::Error unifies with anything and silences follow-on errors,
  • inference continues with the next item.

Implementation status (M2)

louise_db::Db caches parses per file. Resolution and type checking re-run over the whole package on each analysis; at v0 scale that costs milliseconds. Interface hashing and per-item caching come when the revisit criteria are met. The Db API does not change when they do.

Note — 2026-11-01: only the std a program reaches (issue #411)

Status: Proposed; needs engineering review (#44).

Resolution and type checking run over the package and the std modules it reaches, not over all of std: ADR 0074. What is reached is found from the parse trees on every analysis.

When to revisit

Move to salsa (or similar) if either holds on the v0 demo project:

  • p95 keystroke-to-diagnostics latency exceeds 100 ms,
  • the hand-written dependency tracking needs more than whole-file granularity.

Consequences

  • The pipeline stays plain functions over plain data, so it is easy to test and debug.
  • Re-checking granularity is a whole file, not a function. That is acceptable at v0 scale.
  • Callers see only Db (add or edit a file, then analyze), so a later migration to salsa-like queries replaces its internals rather than its callers. (The query-shaped API first planned here, parse(file), interface(module), check_item(item), was not built; see "Implementation status".)