System Architecture
Canontra v0.4.0.0 is built as a zero-FFI, zero-network compiler pipeline in pure Haskell (GHC 9.6.6). Version 0.4.0 combines AST normalization into a single-pass CanonicalProgram and keeps hot-path data in compact unboxed vectors rather than pointer-heavy heap trees.
Eight-Phase Pipeline (v0.4.0.0)
Section titled “Eight-Phase Pipeline (v0.4.0.0)”[ Raw Source Bytes ] | vPhase 1: Ingestion & 256-Bit SIMD/SWAR FastScan (Canontra.Canonical.SIMDScan) - UTF-8 validation, 32 bytes/cycle CRLF -> LF conversion, Unicode NFC | vPhase 2: Polyglot ByteString/SIMD Direct-to-IR Parsing (Canontra.Parser.*) - Recursive descent (Python, FastPython, JS, Go, Rust) via flatparse - Flat Linear Arena vectors + 16-way SwissTable symbol interning | vPhase 3: Single-Pass CanonicalProgram & Normalization (Canontra.Normalize.*) - Comment/docstring/dead-statement stripping - Language-specific alpha-renaming (canonicalizeAlphaModuleForLang) - Purity & IEEE-754 guarded Algebraic Normal Form + pure function sorting | vPhase 4: Graph & ABI Type Contract Extraction (Canontra.Analysis.*) - Call Graph, Lengauer-Tarjan Dominator / Frontier RPO CFG, SSA DFG - ABI-precise Type Contract (F_T: Mutability, scalar widths, ordered TypeTuple) - Go package dir merging, TS/JS barrel resolution, Unboxed CSR matrices | vPhase 5: Canonical Binary Serialization (Canontra.Canonical.Serialize) - Strict Big-Endian lengths, 1-byte tags, IEEE-754 -0.0/NaN normalization | vPhase 6: Multi-Tier SHA-256 Hashing (Canontra.Fingerprint.*) - F0, F1, F2, F3, F_CG, F_CF, F_DF, F_T -> F4; F_R folds composite F4 | vPhase 7: CNTR\x07 Incremental Slab Caching (Canontra.Cache.SlabV7) - 256-way L1 radix jump table, 64-byte CacheRecordV6, 4KB CRC-32C pages - Per-file FileGraphSummary payloads + transparent CNTR\x06/CNTR\x05 upgrade | vPhase 8: Impact Slicing, Interchange & AI Harness Snaps (BatchImpact, Harness.*, Export.*) - CSR backward reachability cones (--pr-base), SARIF v2.1.0, Graphviz DOT - Stateless canontra snap checkpoints (0.1-alpha) under .canontra/snaps/Core Memory Layouts & Runtime Primitives
Section titled “Core Memory Layouts & Runtime Primitives”- Single-Pass
CanonicalProgram(Canontra.Normalize.Normalize): Runs normalization once per file viatoCanonicalProgram, avoiding double parses and repeated AST walks incomputeManifest. - Flat Linear Arena (
Canontra.IR.Arena): Stores AST nodes in four parallel unboxed arrays (astTags,astFirstChild,astNextSibling,astPayloads) with zero intermediate CST heap allocations. - SwissTable Symbol Interning (
Canontra.Parser.SwissTable): Open-addressing hash table with 16-way 8-bith2control-byte probing for O(1) symbol deduplication. - Unboxed CSR Graph (
Canontra.Analysis.CSRGraph): Stores cross-file call and data-flow edges in flatVector Word32(csrRowOffsets,csrColIndices) andVector Word16(csrEdgeFlags) arrays usingSet/IntMapdeduplication. - Mutable
MV.IOVectorChase-Lev Scheduler (Canontra.Repository.Parallel): Lock-freeChaseLevDequebacked by mutableMV.IOVectorcircular buffers for multi-core file scanning (+RTS -N). - Stateless AI Harness (
Canontra.Harness.{Store,SubVersion,Guard}): Content-addressed.canontra/snaps/storage with zero background daemon, zero IPC, and preflight SHA-256 + path-containment checks.
Exposed Haskell Module Map (v0.4.0.0)
Section titled “Exposed Haskell Module Map (v0.4.0.0)”| Layer | Modules |
|---|---|
| IR & Canonical Primitives | Canontra.Types, Canontra.IR.{Program,Declaration,Expression,Dependency,Arena}, Canontra.Canonical.{Float,Unicode,FastScan,SIMDScan,StreamingHash,FusedStream,Serialize} |
| Polyglot Frontends | Canontra.Parser.{Python,FastPython,JS,Go,Rust,Polyglot,Outline,Ingest,SymbolTable,SwissTable} |
| Normalization | Canontra.Normalize.{Alpha,Algebraic,Normalize,Fused,Rules} |
| Graphs & Impact | Canontra.Analysis.{Scope,Symbol,CallGraph,CFG,CFGCanonical,DFG,CompactGraph,CSRGraph,WholeRepoGraph,Impact,BatchImpact,TypeContract} |
| Fingerprints | Canontra.Fingerprint.{Source,Structural,Declaration,Dependency,CallGraph,ControlFlow,DataFlow,TypeContract,Composite,Bundle,WholeRepoCallGraph,WholeRepoDataFlow} |
| Cache, Repo & Security | Canontra.Cache.{Common,Inode,MerkleCache,PagedCache,SlabV6,SlabV7}, Canontra.Repository.{Parallel,Repository,MerkleDAG,Watcher,Git}, Canontra.Security.Path |
| Harness (Alpha), CLI & Verification | Canontra.Harness.{Store,SubVersion,Guard}, Canontra.CLI.{Commands,Cache,Completions}, Canontra.Comparison.{Compare,Diff}, Canontra.Export.{SARIF,Graph}, Canontra.Verification.{Determinism,Metamorphic} |