Expand description
v2.76.0 — Phase 0 of the Epistemic Module System: dependency discovery.
Builds the module dependency DAG for a multi-file AXON project and
topologically sorts it (Kahn), refusing cycles (axon-T955).
§Design
- In-memory-first. The resolver operates over a
ModuleSet— a deterministic map fromModulePathto source text. The filesystem walk (ModuleSet::from_entry_file) is one constructor on top; the enterprise bundle path and the LSP feed sources directly (ModuleSet::from_memory) and never touch a disk. - Lexer-true scanning.
scan_importstokenizes with the real AXON lexer and walks tokens — no AST, and crucially no regex: discovery can never recognize a different import grammar than the parser does (the drift class the retired Python EMS’s regex scanner invited). - Lenient scan, authoritative parse. A malformed import statement is skipped by the scanner — the parser owns the canonical diagnostic. The scanner’s only job is to know which files to load.
- Deterministic everywhere.
BTreeMap/BTreeSetordering, and the Kahn ready-queue pops the smallest module path first, so the topological order is a pure function of the module set (section 4.4 of the EMS paper — the property the enterpriseir_sha256dedupe anchor relies on).
§Refusal posture
Two import forms parse but are refused downstream (axon-T953, in
the type-checker’s module mode): the non-selective import a.b (name
pollution — #include wearing a module system’s clothes) and the
@scope-prefixed form (reserved for a future package registry). The
resolver records them (so the diagnostics can fire with real locations)
but neither loads files nor contributes DAG edges for them.
Structs§
- Loaded
Module - One loaded module: its display origin (path or bundle key) + source.
- Module
Error - A Phase-0 resolution failure. Rendered by the CLI in the house
error [line N]:shape against the importing file. - Module
Graph - The resolved dependency graph: every module’s scanned imports plus the deterministic topological order (dependencies first, entry last).
- Module
Path - A dotted module path:
axon.security⇔["axon", "security"]⇔<modules-root>/axon/security.axon. - Module
Set - The complete, deterministic set of modules for one compilation: the entry plus every transitively imported module.
- Scanned
Import - One
importstatement as seen by the Phase-0 token scan.
Constants§
- MAX_
MODULES - Hard ceiling on the number of modules a single project may load. Fail-closed guard against runaway transitive graphs; generous by an order of magnitude over any real deployment seen to date.
Functions§
- scan_
imports - Extract every
importstatement fromsourcevia the real lexer.