Programming Language

Nocter

A self-contained systems language built around simplicity, encapsulation, and foolproof design.

/development/reviews/v0.20.0-phase-1.md

v0.20.0 Phase 1 Incremental Semantic Computation Review

Result: passed (2026-08-29). Phase 1 replaces workspace-owned eager semantic continuation with a revision-pinned demand graph. The final review covered the computation kernel, workspace input publication, declaration and body queries, recovery, whole-program finalization, session handoff, analysis capabilities, and language-server dependency boundary.

Review Criteria

The review traced:

  • every source input from accepted workspace revision through parse, module surface, semantic scope, body input, and final analysis demand;
  • source-neutral versus exact-current fingerprints and every retained syntax/source/symbol identity;
  • declaration, preparation, lexical, typed-body, finalization, and incomplete-syntax rejection;
  • warm single-body edits versus fresh analysis of the same final source;
  • compiler-stage calls outside their owning composition boundary;
  • unavailable-product handling, fallback entry points, repeated projection/finalization, duplicate source authority, manual invalidation, and consumer-selected phase order;
  • architecture dependencies and editor behavior through complete workspace tests.

Final Model

Workspace analysis publishes one immutable DiscoveredUnit through two scope inputs. The declaration input fingerprints source-neutral topology and public declaration surfaces. The current input additionally fingerprints normalized source bytes and the complete current SourceId layout. Stable per-body inputs use canonical path plus declaration locator and exact body bytes.

The semantic demand graph is:

source text -> parse -> declaration surface -> module surface
                                      |             |
                                      +--> semantic scope inputs
                                                   |
declarations -> program preparation -> body names -> typed bodies -> finalization
       |                 |                 |              |             |
       +-----------------+-----------------+--------------+-------------+
                                      top-level program analysis

Accepted declaration, preparation, lexical, and typed-body products are source-neutral where their contracts permit reuse. Authored rejection, source projection, incomplete syntax, canonical replay, and final program analysis remain exact-current. Generation-local NodeId, SourceId, syntax token, span, frontend binding, and symbol identities never become stable query keys or source-neutral products.

One body query opens from the immutable prepared-program prefix. It owns body-local lexical, type, closure, and source recipes. Finalization replays successful recipes once in canonical BodyId order, then runs ownership, provenance, loans, opaque witnesses, and semantic completion once. Neither workspace nor session can invoke this replay.

One top-level exact-current program-analysis query selects checked completion or declaration, preparation, lexical, or body rejection. Workspace demands only that product. Session validates its paired discovery snapshot and translates the closed branch into semantic capabilities and target construction. Branch-specific session consumers and intermediate query transport were removed.

Syntax-invalid input uses a separate exact-current incomplete-analysis query. Semantic computation owns its sole declaration/preparation/body recovery traversal. Direct session analysis delegates to the same pure recovery composer, so editor and direct compilation do not implement separate recovery meanings. An incomplete outcome cannot authorize target construction.

Findings Corrected During Qualification

Authored rejection was represented as absence

Typed, lexical, and program-preparation authored failures initially collapsed to unavailable products. That forced a consumer to rerun compiler stages to reconstruct diagnostics and recovery. Each authored failure is now a first-class exact-current query outcome with an owned branchable recovery contract.

Canonical finalization remained outside the graph

Per-body queries originally ended before canonical type/closure replay, ownership, provenance, loans, opaque witnesses, and semantic completion. Session could therefore repeat whole-program work. One exact-current finalization query now owns that sequence and shares the sole current declaration projection with body queries.

Unavailable products selected an eager fallback

Workspace previously treated missing declaration, preparation, lexical, typed, or finalization authority as permission to restart from an earlier session entry point. This concealed missing query edges and duplicated dependency selection. Source-complete unavailable outcomes are now explicit integrity failures; all intermediate continuation entry points were deleted.

Incomplete syntax had a second semantic pipeline

Editor-only incomplete syntax ran directly in session and was not memoized. The traversal gained an exact-current query product in Phase 1. Phase 2 subsequently deleted the direct session entry; the traversal is now private to the compiler-computation query graph.

Declaration rejection escaped the closed outcome boundary

After the first fallback cleanup, declaration lowering was query-owned but its deeper recovery continuation still started when session consumed the rejection. The top-level analysis query now materializes that continuation. Session cannot invoke a compiler stage when opening a query result.

Intermediate outcomes duplicated current source authority

Declaration, preparation, lexical, and finalization wrappers retained separate DiscoveredUnit references for branch-specific validation. Once the top-level product became the sole public consumer boundary, those references represented duplicate authority. They were removed; complete and incomplete top-level products now own the exact source pairing once.

Boundary Audit

  • nocter-computation remains compiler-domain independent.
  • The semantic query subsystem depends only on declaration/checking/input/discovery/syntax contracts; after Phase 2 it is private to nocter-compiler-computation and does not depend on workspace, session, analysis, LSP, target, MIR, or machine layers.
  • workspace analysis publishes inputs and demands either the complete or incomplete top-level query; it does not inspect intermediate semantic products.
  • session opens closed semantic branches, constructs target programs, and publishes capability views; it does not rerun query-owned compiler stages.
  • analysis and language-server crates depend on semantic capabilities rather than phase ordinals or compiler storage.
  • architecture tests freeze these dependency edges and Clippy restrictions freeze the compiler-stage composition call sites.

Qualification Evidence

The completed implementation passes:

  • cargo test --workspace --quiet;
  • cargo clippy --workspace --all-targets -- -D warnings;
  • cargo fmt --all --check;
  • node docs/build-docs.js;
  • git diff --check;
  • architecture dependency tests;
  • incremental instrumentation for source text, parsing, module surfaces, declarations, preparation, lexical bodies, typed bodies, finalization, top-level analysis, and incomplete analysis;
  • warm-versus-fresh semantic signatures for accepted and rejected edits.

No unresolved Phase 1 correctness or responsibility-boundary finding remains. Background execution, cancellation, persistent caches, remote indexes, parallel backend work, hashing APIs, and associative collections remain outside this phase.