Skip to content
BANG

Core implementation — current architecture

Summary: BANG has one graded-CBPV semantic core observed through several representations. The source oracle defines behavior; the calculated machine is the executable compiler specification; Wasm 3.0 is the target; each arrow carries its own proof or differential-test status.

Read this page to answer three questions:

  1. Which representation or engine am I looking at?
  2. What evidence connects it to the source meaning?
  3. Which tier owns a change, and what may that tier import?

Architecture decisions remain authoritative: ADR-0016 fixes the two-hop shape, ADR-0059 revises the product target to Wasm 3.0, ADR-0110 preserves the abstract-model to concrete-emitter evidence boundary, and ADR-0035 separates source equivalence from compilation simulation.

1. One meaning, several representations

diagram

Reading the diagram: each edge label is the serialized evidence label followed by the serialized method; labels do not imply a stronger status.

RepresentationKindSourcesOutgoing boundaries
Project Wasm-oriented abstract machine executionabstract-target-executionBang/Backend/Wasm.lean, docs/decisions/0110-wasm-proof-model-concrete-emitter-boundary.md
CalcVM compile + execmachineBang/Backend/AbstractMachine.lean
Graded-CBPV Compcore-irBang/Core/IR.leanWasmGC text emission → WasmGC / WAT (implemented); kernel interpretation → Source.eval oracle (implemented)
WasmGC / WATemitted-watBang/Backend/WasmEmit.leanreal-engine execution → Wasmtime (differential-tested)
evalE default engineenvironment-machineBang/Backend/EnvMachine.lean, Main.lean
evalDstate-semanticsBang/Backend/AbstractMachine.leancalculation → CalcVM compile + exec (proven); environment evaluation and readback → evalE default engine (differential-tested); state reification → Source.eval oracle (proven)
Source.eval oraclesource-semanticsBang/Core/Semantics/Eval.lean
Source executionsource-executionBang/Spec.leanannotated forward simulation → Project Wasm-oriented abstract machine execution (proven)
Source texttextBang/Frontend/Surface.leanfrontend lowering → Graded-CBPV Comp (differential-tested)
Wasmtimeruntimetools/emit-rung4-diff.sh

The namespace Wasmfx survives in the formal Lean model for historical reasons. The model is a project-defined Wasm-oriented abstract machine: the checked compile_forward_sim theorem targets its Wasmfx.run, not the concrete WAT emitter or official Wasm semantics. Wasmfx.run returns Option Wasmfx.Val: only a singleton successful final value is some, and its neutral none does not classify fuel, stack-shape, handler-state, or unhandled-operation non-values using the source evaluator's Result. ADR-0059 separately makes stock Wasm 3.0 the product target through the concrete emitter, whose real-engine edge is differentially tested. A formal correspondence between those two target layers remains open; WasmFX is only a future fast path for the post-v1 general-resumption slot.

Architecture assertions

Generated from validated committed architecture and proof facts. The JSON is the consumer seam; source checks remain in the fact producers.

FactCurrent valueSource/evidence
Compiler targetWasm 3.0, grade-directed pluggable backend; WasmFX: future general-case fast pathdocs/decisions/0016-two-hop-architecture-calcvm-and-wasmfx.md, docs/decisions/0059-wasm3-grade-directed-pluggable-backend.md, docs/decisions/0110-wasm-proof-model-concrete-emitter-boundary.md
Source equivalencebinary biorthogonal LR: Bang.lr_fundamental, Bang.lr_soundimplemented; flagged support: Bang.lr_fundamental, Bang.lr_sound; Bang/Spec.lean, Bang/Meta/LR.lean, Bang/Meta/BinaryLR.lean, Bang/Audit.lean; validate: lake env lean Bang/Audit.lean
Compilation correctnessannotated forward simulation: Bang.compile_forward_simproven; Bang/Spec.lean, Bang/Backend/Wasm.lean, Bang/Audit.lean, docs/decisions/0059-wasm3-grade-directed-pluggable-backend.md, docs/decisions/0110-wasm-proof-model-concrete-emitter-boundary.md; validate: lake env lean Bang/Audit.lean
CLI enginesoracle, compiled, env; default env; --compiled aliases compiledBang/Backend/EnvMachine.lean, Main.lean, docs/decisions/0094-env-semantics-in-the-machine-layer.md
Module graph58 modules · 117 internal edges · Apex 4 · Backend 6 · Core 12 · Frontend 12 · Meta 2 · Reify 3 · Witness 1958 serialized module records in docfacts/architecture.json
Architecture lineageADR-0016 two-hop shape; product target refined by ADR-0059; evidence boundary amended by ADR-0110ADR-0016 (Accepted; implemented), ADR-0059 (Accepted; implemented), ADR-0110 (Accepted; implemented)

2. Proof arrows are different claims

diagram

Question / endpoint typeDirectionMethod and theorem refsEvidence status
source-programs: Source program PSource program Qbidirectional-contextualbinary biorthogonal LR; Bang.lr_fundamental, Bang.lr_soundimplemented; flagged support: Bang.lr_fundamental, Bang.lr_sound; validate: lake env lean Bang/Audit.lean
source-to-target-executions: Source executionProject Wasm-oriented abstract machine executionforwardannotated forward simulation; Bang.compile_forward_simproven; validate: lake env lean Bang/Audit.lean

Do not describe compiler correctness as “the Benton–Hur LR.” The LR and simulation are complementary, not interchangeable; ADR-0035 is the decision record.

Audited theorem census

Census: 33 enrolled theorems · 27 trusted · 6 flagged · 2 with no axioms.

Semantic inventory: 17 strong scoped claims · 3 structural · 2 bounded · 3 partial · 1 conjectural · 1 placeholder · 6 aliases. Alias and placeholder rows never increase the strong count.

Strong, precisely scoped claims: Bang.seq_unit, Bang.compile_forward_sim, Bang.compile_forward_sim_pure, Bang.source_eval_to_exec, Bang.Rung5ProofGrade.s5_exec_wexec_lockstep, Bang.subst_value, Bang.preservation, Bang.progress, Bang.type_safety, Bang.no_accidental_handling, Bang.no_accidental_handling_custom, Bang.closed_fully_handled_program_no_unclassified_stuck, Bang.CalcVM.compile_correct, Bang.CalcVM.evalD_agrees_source, Bang.CalcVM.sim, Bang.CalcVM.run_evalD, Bang.EnvMachine.evalE_agrees_evalD.

Live validator: python3 tools/docfacts_proof.py --live-check.

Axiom trust and semantic strength are independent axes. trusted means only that the kernel-reported axiom set is within the reviewed trusted set; it is not a generic product-level proven badge.

Theorem / sourceAxiom trustSemantic evidenceTarget / premise usageExact guarantee and boundary
Bang.lr_sound<br>Bang/Spec.lean:267flagged<br>Classical.choice, Quot.sound, propext, sorryAxpartial · logical-relation · partial-kernel-declaration · role canonicaltyped-contextual-semantics<br>load-bearing: step-indexed Crel premise; unused: nonePartial logical-relation adequacy from related computations to typed contextual approximation. Scope: Typed source computations at one effect and computation type. Limitations: Depends on sorryAx at the documented capability-reshape observation bridge. Statement: (forall n, Crel n B e c1 c2) -> ctxApprox c1 c2
Bang.lr_fundamental<br>Bang/Spec.lean:298flagged<br>Classical.choice, Quot.sound, propext, sorryAxpartial · logical-relation · partial-kernel-declaration · role canonicaltyped-contextual-semantics<br>load-bearing: source typing, related closing environments; unused: nonePartial fundamental theorem for related closures of a typed open computation. Scope: Step-indexed binary logical relation over typed source terms. Limitations: Depends on sorryAx in the handler and up compatibility spine. Statement: HasCTy gamma Gamma c e B -> forall n delta1 delta2, EnvRel n Gamma delta1 delta2 -> Crel n B e (closeC delta1 c) (closeC delta2 c)
Bang.lr_fundamental_closed<br>Bang/Spec.lean:308flagged<br>Classical.choice, Quot.sound, propext, sorryAxpartial · logical-relation · partial-kernel-declaration · role supportingtyped-contextual-semantics<br>load-bearing: closed source typing; unused: noneClosed-program specialization of the partial logical-relation fundamental theorem. Scope: Closed typed source computations. Limitations: Inherits the sorryAx dependencies of lr_fundamental and is not independent evidence. Statement: HasCTy gamma [] c e B -> forall n, Crel n B e c c
Bang.seq_unit<br>Bang/Spec.lean:324trusted<br>Classical.choice, Quot.sound, propextstrong · contextual-equivalence-law · kernel-checked-theorem · role canonicaltyped-contextual-semantics<br>load-bearing: none; unused: noneReturning a value and then sequencing is contextually equivalent to the continuation. Scope: Every typed observation effect and computation type. Limitations: A single sequencing law, not a complete equational theory. Statement: ctxEquiv (seqComp (ret v) c) c
Bang.compile_forward_sim<br>Bang/Spec.lean:365trusted<br>Classical.choice, Quot.sound, propextstrong · forward-simulation · kernel-checked-theorem · role canonicalsource-to-project-wasm-oriented-abstract-machine<br>load-bearing: literal-capability freedom, successful source evaluation; unused: noneA successful source run has a value-preserving run in the project Wasm-oriented abstract machine. Scope: Literal-capability-free programs and terminating-success executions. Limitations: One-way only.; Does not target the concrete WAT emitter or official Wasm semantics.; Excludes ambient host IO represented by literal capabilities. Statement: VcapFree c -> Source.eval fuel c = done v -> exists fuel', Wasmfx.run fuel' (compileC c) = some (compileV v)
Bang.compile_forward_sim_pure<br>Bang/Backend/Wasm.lean:2763trusted<br>Classical.choice, Quot.sound, propextstrong · forward-simulation · kernel-checked-specialization · role supportingsource-to-project-wasm-oriented-abstract-machine<br>load-bearing: pure-fragment premise, successful source evaluation; unused: nonePure successful source runs have matching abstract-target runs. Scope: Pure source fragment and terminating-success executions. Limitations: One-way only.; Does not target concrete emitted Wasm. Statement: Pure c -> Source.eval fuel c = done v -> exists fuel', Wasmfx.run fuel' (compileC c) = some (compileV v)
Bang.source_eval_to_exec<br>Bang/Backend/Wasm.lean:2751trusted<br>Classical.choice, Quot.sound, propextstrong · forward-simulation · kernel-checked-theorem · role supportingsource-to-calcvm<br>load-bearing: pure-fragment premise, successful source evaluation; unused: nonePure successful source evaluation is reproduced by compiled CalcVM code. Scope: Pure source programs with successful terminating runs. Limitations: Does not cover non-pure programs or non-success outcomes. Statement: Pure c -> Source.eval fuel c = done v -> exists F, CalcVM.exec F 0 (compile c []) [] [] = some [ret v]
Bang.Rung5ProofGrade.s5_effectful_forward_sim<br>Bang/Backend/Rung5ProofGrade.lean:101trusted<br>Classical.choice, Quot.sound, propextalias · compatibility-alias · theorem-alias · role alias of compile_forward_simsource-to-project-wasm-oriented-abstract-machine<br>load-bearing: literal-capability freedom, successful source evaluation; unused: noneNamed re-export of compile_forward_sim for the rung-5 census. Scope: Exactly the scope of compile_forward_sim. Limitations: Provides no independent proof evidence. Statement: Same proposition as compile_forward_sim
Bang.Rung5ProofGrade.s5_exec_wexec_lockstep<br>Bang/Backend/Rung5ProofGrade.lean:110trusted<br>Quot.sound, propextstrong · machine-correspondence · kernel-checked-theorem · role supportingcalcvm-to-project-wasm-oriented-abstract-machine<br>load-bearing: code well-formedness, handler-stack well-formedness, successful CalcVM execution; unused: noneSuccessful CalcVM execution is preserved by the project abstract target executor. Scope: Well-formed code and handler stacks on successful executions. Limitations: One-way success correspondence between two in-repo abstract machines. Statement: CodeOk code -> HStackOk hs -> exec ... = some s' -> wexec ... = some (injStack s')
Bang.compileC_satisfies_current_instrWF<br>Bang/Spec.lean:340trusted<br>propextstructural · structural-invariant · kernel-checked-theorem · role canonicalproject-wasm-oriented-abstract-machine<br>load-bearing: compileC output shape; unused: noneEvery compileC instruction satisfies the current project-defined InstrWF predicate. Scope: All source computations lowered to the project abstract instruction list. Limitations: InstrWF only rejects local get/set today.; Not source type preservation, official Wasm validation, or concrete-emitter validation. Statement: Wasmfx.WellTyped (compileC c)
Bang.compile_well_typed<br>Bang/Spec.lean:347trusted<br>propextalias · compatibility-alias · deprecated-theorem-alias · role deprecated-alias of compileC_satisfies_current_instrWFproject-wasm-oriented-abstract-machine<br>load-bearing: none; unused: source typingCompatibility form of the current structural InstrWF invariant. Scope: Typed closed source programs, although the structural conclusion holds for every input. Limitations: Name overstates the current predicate and must not be presented as target validation. Statement: HasCTy [] [] c e (F q A) -> Wasmfx.WellTyped (compileC c)
Bang.handler_lowering_placeholder<br>Bang/Spec.lean:374flagged<br>sorryAxplaceholder · placeholder · placeholder-kernel-declaration · role placeholderhandler-lowering-placeholder<br>load-bearing: none; unused: HandlerLawful hTracks the intended future handler-lowering proposition only. Scope: Roadmap placeholder over an empty compiled module and True predicates. Limitations: Depends on sorryAx.; Current premise and conclusion are True placeholders and constrain no behavior. Statement: HandlerLawful h -> Wasmfx.HandlerEquiv (compileHandler h) h
Bang.handler_compiles<br>Bang/Spec.lean:379flagged<br>sorryAxalias · compatibility-alias · deprecated-theorem-alias · role deprecated-alias of handler_lowering_placeholderhandler-lowering-placeholder<br>load-bearing: none; unused: HandlerLawful hCompatibility name for the handler-lowering roadmap placeholder. Scope: No product-evidence scope. Limitations: Depends on the placeholder and provides no independent evidence. Statement: Same proposition as handler_lowering_placeholder
Bang.compileC_emits_no_locals<br>Bang/Spec.lean:386trusted<br>propextstructural · structural-invariant · kernel-checked-theorem · role canonicalproject-wasm-oriented-abstract-machine<br>load-bearing: compileC output shape; unused: noneThe substitution-based abstract lowering emits no local get/set instruction at any index. Scope: Every source computation and every local index in the abstract instruction list. Limitations: Not grade-directed erasure.; Does not inspect the concrete Wasm emitter or source computations embedded in abstract instructions. Statement: not Wasmfx.MentionsLocal (compileC c) k
Bang.zero_grade_no_code<br>Bang/Spec.lean:392trusted<br>propextalias · compatibility-alias · deprecated-theorem-alias · role deprecated-alias of compileC_emits_no_localsproject-wasm-oriented-abstract-machine<br>load-bearing: none; unused: grade-zero source typingCompatibility specialization of compileC_emits_no_locals at local index zero. Scope: Grade-zero-typed inputs, although the structural conclusion holds for every input. Limitations: Not evidence that grade zero directs erasure or that the concrete emitter omits code. Statement: HasCTy (0 :: gamma) (A :: Gamma) c e B -> not Wasmfx.MentionsLocal (compileC c) 0
Bang.subst_value<br>Bang/Spec.lean:109trusted<br>Classical.choice, Quot.sound, propextstrong · typing-metatheorem · kernel-checked-theorem · role canonicalsource-type-system<br>load-bearing: value typing, computation typing, binder grade rho; unused: noneCapture-avoiding value substitution preserves typing with graded context arithmetic. Scope: Core graded source typing. Limitations: A syntactic typing theorem, not observational grade erasure. Statement: HasVTy gammaV Gamma v A -> HasCTy (rho :: gamma) (A :: Gamma) c e B -> HasCTy (gamma + rho * gammaV) Gamma (subst v c) e B
Bang.preservation<br>Bang/Spec.lean:124trusted<br>Classical.choice, Quot.sound, propextstrong · typing-metatheorem · kernel-checked-theorem · role canonicalsource-ck-machine<br>load-bearing: configuration typing and NonEscape, concrete step equality; unused: noneOne source CK step preserves the whole-program type while the running effect may shrink. Scope: Configurations satisfying the stronger HasConfig invariant. Limitations: One-step preservation only; it does not establish termination. Statement: HasConfig cfg eo Co -> step cfg = some cfg' -> exists eo', eo' <= eo and HasConfig cfg' eo' Co
Bang.progress<br>Bang/Spec.lean:139trusted<br>Quot.sound, propextstrong · machine-safety · kernel-checked-theorem · role canonicalsource-ck-machine<br>load-bearing: configuration typing at bottom effect and returner type; unused: tautological NonEscape' conjunctA fully handled typed configuration returns, steps, or reaches the classified capability-escape terminal. Scope: Bottom-effect configurations with returner type. Limitations: Defined capability escape is allowed.; Not a return-or-step-only theorem or termination proof. Statement: HasConfig' cfg bottom (F q A) -> isReturnConfig cfg or (exists cfg', step cfg = some cfg') or IsDefinedEscape cfg
Bang.type_safety<br>Bang/Spec.lean:161trusted<br>Classical.choice, Quot.sound, propextstrong · machine-safety · kernel-checked-theorem · role canonicalsource-ck-machine<br>load-bearing: initial configuration typing at bottom effect; unused: tautological NonEscape' conjunctA fully handled well-typed source program cannot produce the unclassified stuck result. Scope: Fuel-bounded Source.eval from a fresh empty configuration. Limitations: Defined capability escape and the outOfFuel outcome remain allowed.; Does not prove termination. Statement: HasConfig' (0, [], c) bottom (F q A) -> forall fuel, Source.eval fuel c != stuck
Bang.no_accidental_handling<br>Bang/Spec.lean:60trusted<br>—strong · dispatch-isolation · kernel-checked-theorem · role canonicaleffect-dispatch-predicate<br>load-bearing: handler label containment, row disjointness, foreign-label membership; unused: noneA handler scoped to one row cannot report that it handles an operation in a disjoint row. Scope: The label-indexed handlesOp dispatch predicate. Limitations: Not by itself a whole-run noninterference theorem. Statement: HandlesWithin l h -> Disjoint l e -> labelEff l' <= e -> handlesOp h l' op = false
Bang.no_accidental_handling_custom<br>Bang/Spec.lean:71trusted<br>propextstrong · dispatch-isolation · kernel-checked-specialization · role supportingeffect-dispatch-predicate<br>load-bearing: row disjointness, foreign-label membership; unused: custom handler parameter and clausesA custom handler cannot report that it handles a foreign label. Scope: Custom-handler specialization of dispatch isolation. Limitations: Constrains label matching only, not arbitrary handler behavior. Statement: Disjoint (labelEff l) e -> labelEff l' <= e -> handlesOp (custom l p cl) l' op = false
Bang.closed_fully_handled_program_no_unclassified_stuck<br>Bang/Spec.lean:81trusted<br>Classical.choice, Quot.sound, propextstrong · machine-safety · kernel-checked-corollary · role canonicalsource-ck-machine<br>load-bearing: closed bottom-effect source typing; unused: noneEvery closed, fully handled, well-typed program avoids the unclassified stuck result. Scope: All closed bottom-effect programs, including but not requiring custom handlers. Limitations: Defined capability escape and the outOfFuel outcome remain allowed.; Does not identify or isolate a custom-handler fragment. Statement: HasCTy [] [] c bottom (F q A) -> forall fuel, Source.eval fuel c != stuck
Bang.custom_program_safe<br>Bang/Spec.lean:89trusted<br>Classical.choice, Quot.sound, propextalias · compatibility-alias · deprecated-theorem-alias · role deprecated-alias of closed_fully_handled_program_no_unclassified_stucksource-ck-machine<br>load-bearing: closed bottom-effect source typing; unused: noneCompatibility name for generic closed-program no-unclassified-stuck safety. Scope: Exactly the scope of closed_fully_handled_program_no_unclassified_stuck. Limitations: The name does not establish that a program contains or exercises a custom handler. Statement: Same proposition as closed_fully_handled_program_no_unclassified_stuck
Bang.rowinst_requires_disjoint<br>Bang/Spec.lean:49trusted<br>—structural · definition-projection · kernel-checked-definition-projection · role canonicalrow-instantiation-judgment<br>load-bearing: WfInst record proposition; unused: noneWell-formed row instantiation includes its required disjointness condition. Scope: The project WfInst definition. Limitations: A projection from the definition, not an independently derived metatheorem. Statement: WfInst q L epsilon -> Disjoint epsilon L
Bang.evalTrace_dispatches_within_recorded_live_bound<br>Bang/Spec.lean:207trusted<br>Quot.sound, propextbounded · runtime-invariant · kernel-checked-theorem · role canonicalsource-trace-runtime<br>load-bearing: successful instrumented run; unused: source typingEvery recorded dispatch label lies within the runtime live bound recorded beside that dispatch. Scope: Successful runs of the instrumented source CK trace evaluator. Limitations: Not static effect soundness.; The checked bound is runtime instrumentation stored in each trace event. Statement: HasCTy [] [] c e (F q A) -> evalTrace fuel c e = done (v, t) -> traceWithin t
Bang.effect_sound<br>Bang/Spec.lean:220trusted<br>Quot.sound, propextalias · compatibility-alias · deprecated-theorem-alias · role deprecated-alias of evalTrace_dispatches_within_recorded_live_boundsource-trace-runtime<br>load-bearing: successful instrumented run; unused: source typingCompatibility name for the runtime-recorded-live-bound invariant. Scope: Exactly the scope of evalTrace_dispatches_within_recorded_live_bound. Limitations: Must not be described as static effect soundness. Statement: Same proposition as evalTrace_dispatches_within_recorded_live_bound
Bang.zero_usage_erasable<br>Bang/Spec.lean:170flagged<br>propext, sorryAxconjectural · conjecture · conjectural-kernel-declaration · role canonicaltyped-contextual-semantics<br>load-bearing: intended grade-zero source typing premise; unused: noneConjectures observational irrelevance of substitutions for a zero-graded binder. Scope: Typed contextual equivalence at every observation type. Limitations: The proof body is sorry and depends on sorryAx.; Must not be presented as established grade erasure. Statement: HasCTy (0 :: gamma) (A :: Gamma) c e B -> NotEvaluated 0 c
Bang.Surface.cell_reflects_latest<br>Bang/Frontend/Surface.lean:2837trusted<br>propextbounded · example-law · kernel-checked-theorem · role supportingsurface-example<br>load-bearing: none; unused: noneThe canonical cell example returns the latest written integer under the fixed evaluator bound. Scope: One fixed cellComp program family at fuel 80. Limitations: Example-level regression law, not a universal theorem about reactive cells. Statement: forall s0 v, Source.eval 80 (cellComp s0 v) = done (vint v)
Bang.CalcVM.compile_correct<br>Bang/Backend/AbstractMachine.lean:3456trusted<br>Classical.choice, Quot.sound, propextstrong · machine-correspondence · kernel-checked-theorem · role canonicalcalcvm<br>load-bearing: terminating evalD term result; unused: noneA terminating evalD term result is reproduced by compiled CalcVM code. Scope: Successful term outcomes from empty initial machine state. Limitations: One-way convergent result theorem and does not directly mention Source.eval. Statement: evalD n 0 [] [] [] M = some (term t, ...) -> exists F, exec F 0 (compile M []) [] [] = some [t]
Bang.CalcVM.evalD_agrees_source<br>Bang/Backend/AbstractMachine.lean:6843trusted<br>Classical.choice, Quot.sound, propextstrong · machine-correspondence · kernel-checked-theorem · role canonicalcalcvm-to-source-ck-machine<br>load-bearing: literal-capability freedom, successful evalD return; unused: noneA literal-capability-free terminating evalD return is reproduced by Source.eval. Scope: Successful returned values from empty initial state. Limitations: One-way success correspondence and excludes literal capabilities. Statement: VcapFree M -> evalD f 0 [] [] [] M = some (term (ret v), ...) -> exists F, Source.eval F M = done v
Bang.CalcVM.sim<br>Bang/Backend/AbstractMachine.lean:2296trusted<br>Classical.choice, Quot.sound, propextstrong · machine-correspondence · kernel-checked-theorem · role supportingcalcvm<br>load-bearing: evalD result, store correspondence, handler-stack correspondence, freshness and disjointness invariants; unused: noneThe invariant-rich calculation theorem relates evalD outcomes to CalcVM execution. Scope: Term and raised outcomes under the stated machine invariants. Limitations: Internal proof infrastructure rather than a direct end-user compiler equation. Statement: evalD result plus store and handler-stack invariants -> matching exec behavior and preserved invariants
Bang.CalcVM.run_evalD<br>Bang/Backend/AbstractMachine.lean:5494trusted<br>Classical.choice, Quot.sound, propextstrong · machine-correspondence · kernel-checked-theorem · role supportingcalcvm-to-source-config-run<br>load-bearing: evalD result, store and context correspondence, capability-label coherence, freshness, NoResume for raised results; unused: noneRelates evalD term and raised outcomes to source configuration execution under explicit invariants. Scope: Invariant-rich internal bridge to the source CK configuration runner. Limitations: Not a premise-free whole-program evaluator equality. Statement: evalD term or raised result plus correspondence, coherence, freshness, and NoResume premises -> matching Config.run behavior
Bang.EnvMachine.evalE_agrees_evalD<br>Bang/Backend/EnvMachine.lean:3147trusted<br>Classical.choice, Quot.sound, propextstrong · machine-correspondence · kernel-checked-theorem · role canonicalenvironment-machine-to-calcvm<br>load-bearing: environment agreement, environment well-formedness, closure well-formedness, source scoping, handler well-formedness, successful empty-store evalE return; unused: noneA successful default environment-machine return is reproduced by evalD after closing the source term and reading back the value. Scope: Empty input stores, agreeing well-formed environments, scoped handler-well-formed source terms, and successful returned outcomes. Limitations: Concludes evalD correspondence, not direct Source.eval agreement.; Does not cover non-success outcomes or arbitrary initial stores. Statement: EnvAgrees rho gamma -> MEnv.WF rho -> MEnv.WFClos rho -> ScopedC gamma.length M -> HandlerWF gamma.length M -> evalE f 0 [] [] [] rho M = some (mterm (mret mv), g', eSigma', eTau', eKappa') -> exists g'' sigma' tau' kappa', evalD f 0 [] [] [] (substEnv gamma M) = some (term (ret (readback mv)), g'', sigma', tau', kappa')

3. C4 component dependencies

The useful architecture zoom is the component level: repository tiers such as Frontend, Core, and Backend. Individual Lean modules are code-level detail—kept exact in the serialized fact, but intentionally omitted from the visual.

The dependency V still points inward at Core even though program data flows Frontend → Core → Backend. tools/import_facts.py is the single parser/classifier; tools/arch-check.py enforces the V. Unknown tiers and missing internal imports fail rather than silently falling into a default component.

BANG uses the C4 abstraction hierarchy to choose a useful zoom level for this page:

C4 abstractionBANG mappingThis view
Software systemBANG implementation and toolchainShown as the outer boundary
ContainerLean compiler/reference toolchainShown as the application boundary
Component7 repository tiers (Frontend, Core, …)Dependency nodes below
Code58 Lean modules and 117 direct importsSerialized in docfacts/architecture.json; intentionally not drawn

A C4 component is related functionality behind a defined interface and is not separately deployable. That matches these tiers better than C4's application/data-store container term.

diagram

Reading the diagram: arrows are dependencies between C4 components; edge labels aggregate the 69 code-level imports that cross a component boundary. Internal module-to-module imports are deliberately omitted from the visual.

Component (repository tier)ResponsibilityModulesLOCDepends on
Frontendtext → typed core1217278Core (4)
CoreIR · typing · semantics · soundness128162
Backendcalculated + abstract target machines · separate WasmGC emitter616995Core (8)
Metacontextual-equivalence metatheory23852Core (7)
Witnessexecutable evidence and counterexamples193685Frontend (5), Core (27), Backend (4)
Reifycalculated-machine proof laboratory31883
Apexpublic theorem façade · audit · distribution41060Frontend (3), Core (4), Backend (5), Meta (2)

The generated graph reports aggregate direct imports that cross component boundaries. It shows coupling pressure; it does not by itself prove semantic correctness or justify moving code.

4. Contributor routing

ChangeStart atRequired cross-check
Syntax, inference, modules, diagnosticsBang/Frontend/Follow every relevant surface traversal; run structured CLI/corpus gates
Kernel behavior or typing ruleBang/Core/Preserve the five-primitive boundary; run proof and axiom gates
Calculated machine or formal targetBang/Backend/AbstractMachine.lean, Bang/Backend/Wasm.leanTie execution back to Source.eval; preserve simulation statements
Concrete WasmGC emissionBang/Backend/WasmEmit.leanRun the real Wasmtime differential harness, not only Lean tests
Contextual equivalenceBang/Meta/Keep LR claims separate from compilation simulation
Public theorem or trust claimBang/Spec.lean, Bang/Audit.lean#print axioms; trusted set must remain within {propext, Classical.choice, Quot.sound}
Evidence/counterexampleBang/Witness/State whether it is a regression, refutation, fuzz pole, or tested law

5. Current boundary versus horizon

  • Current: v1 handlers are abortive or one-shot tail-resumptive; stock Wasm 3.0 exceptions, tail calls, GC values, and the tested concrete emitter are sufficient for the shipped path.
  • Post-v1 horizon: general/multishot resumptions may use the GC-frame-chain slot, with WasmFX as a swappable fast path once standardized and deployed.
  • Separate laboratory: Bang/Reify/ studies calculated handler machines; it is not another production execution path.
  • Volatile project position: read repository-local CONTEXT.md in a checkout. This page intentionally contains no active-branch, checkpoint, or issue-status narrative.

6. Gates

python3 tools/import_facts.py --self-test
python3 tools/arch-check.py
python3 tools/gen-import-graph.py --check
python3 tools/check-architecture-assertions.py --check
just fitness

For theorem trust, run just axioms; for the full repository gate, run just verify from the Nix development shell.