@@ -483,48 +483,63 @@ After each session: run `idris2 --check` on every file in
483483adjacent code (no new unsafe code should land), update this file's
484484inventory table, commit.
485485
486- ## Outstanding infrastructure work — Layout module fix (added 2026-04-18)
487-
488- ` Layout/Types.idr ` was never compiling cleanly under this Idris2 0.8
489- build. The directory rename ` layout/ ` → ` Layout/ ` (filesystem case
490- matching the ` Layout.* ` module names) and the ` import layout.Types `
491- → ` import Layout.Types ` typo fix in ` TypedWasm/ABI/Layout.idr ` were
492- made on 2026-04-18, which surfaced the underlying issues:
493-
494- 1 . ** Mutual recursion not declared.** ` WasmHeapType ` references
495- ` WasmValType ` (line 65) but ` WasmValType ` is declared later
496- (line 73). Wrapping both in ` mutual ` is needed.
497- 2 . ** Visibility annotations missing.** ` data WasmPrimitive ` /
498- ` WasmHeapType ` / ` WasmValType ` and the layout values
499- (` stringLayout ` , ` optionLayout ` , ` resultLayout ` , ` enumLayout ` ,
500- ` recordLayout ` ) all lack ` public export ` , so downstream
501- constructors are not visible and ` Refl ` -based proofs do not
502- unify.
503- 3 . ** Imports missing.** ` Decidable.Equality ` is used (` DecEq ` ,
504- ` Yes ` , ` No ` , ` decEq ` ) but never imported; ` Data.List ` similarly.
505- 4 . ** Nested ` with ` block patterns** in the ` DecEq WasmHeapType `
506- instance (lines 178-234) trigger pattern-variable unification
507- errors under this Idris2 build.
508- 5 . ** Refl-impossible patterns** (`stringOptionDistinct _ Refl
509- impossible` etc.) need the layout values to reduce at unification
510- time — even with ` public export ` the reduction does not happen
511- under this build, so a different proof strategy is needed
512- (probably explicit ` case ... of ` with constructor mismatch).
513-
514- ** Current gating (2026-04-18):** the four ` Layout.* ` modules are
515- commented out of ` typed-wasm.ipkg ` and the ` import TypedWasm.ABI.Layout `
516- line in ` TypedWasm/ABI/Proofs.idr ` is gated. This unblocks the full
517- ipkg build for the typed-wasm core (TypedWasm.ABI.* modules) — which
518- is the primary purpose of typed-wasm. The aggregate-library Layout
519- contracts remain in the tree for restoration once the issues above
520- are addressed.
521-
522- ** Remediation plan:** add ` public export ` to every Layout type/value;
523- add ` import Decidable.Equality, Data.List ` ; rewrite the `DecEq
524- WasmHeapType` and ` DecEq WasmValType` instances without nested ` with`
525- (use case-of or explicit witness construction); replace the
526- Refl-impossible patterns with ` case ... of ` + constructor analysis.
527- Estimated effort: one focused session.
486+ ## Outstanding infrastructure work — Layout module fix ✅ DONE 2026-04-18
487+
488+ ** Status:** resolved in the same session it was identified. All four
489+ ` Layout.* ` modules plus the ` TypedWasm.ABI.Layout ` bridge are back in
490+ ` typed-wasm.ipkg ` , the ` import TypedWasm.ABI.Layout ` is restored in
491+ ` TypedWasm/ABI/Proofs.idr ` , and the full 21-module ipkg builds cleanly
492+ under Idris2 0.8.0-712523a89.
493+
494+ ** Fixes applied, by issue:**
495+
496+ 1 . ** Mutual recursion not declared** — wrapped ` WasmHeapType ` and
497+ ` WasmValType ` in a single ` mutual ` block (and separately
498+ ` WasmValTypeValid ` / ` WasmGCLayoutValid ` in ` TypedWasm.ABI.Layout ` ).
499+ 2 . ** Visibility annotations missing** — added ` public export ` to every
500+ data type, constructor, function, layout value, and ` DecEq ` / data
501+ instance in ` Layout/Types.idr ` , ` Layout/ABI.idr ` , ` Layout/Stdlib.idr ` ,
502+ ` Layout/AirborneSubmarineSquadron.idr ` , and ` TypedWasm/ABI/Layout.idr ` .
503+ 3 . ** Imports missing** — added ` Decidable.Equality ` + ` Data.List ` to
504+ ` Layout/Types.idr ` ; ` Data.List.Quantifiers ` to ` TypedWasm.ABI.Layout ` ;
505+ ` Data.List ` to ` Layout/AirborneSubmarineSquadron.idr ` .
506+ 4 . ** Nested ` with ` block patterns** — rewrote the ` DecEq WasmHeapType `
507+ and ` DecEq WasmValType ` instances as four plain mutual functions
508+ (` decEqHT ` , ` decEqVT ` , ` decEqVTList ` , ` decEqFields ` ) with thin
509+ non-mutual interface wrappers. This sidesteps Idris2 0.8's
510+ interface-resolution chain through ` List (String, WasmValType) ` .
511+ 5 . ** Refl-impossible patterns** — replaced ` LHS impossible ` clauses
512+ with ` prf = case prf of Refl impossible ` . The scope change lets
513+ Idris2 reduce the layout values after they see ` public export ` .
514+ 6 . ** Auto-bound implicit shadowing** — lowercase references to
515+ ` stringLayout ` , ` resultLayout ` , etc. inside type signatures were
516+ being treated as implicit pattern variables that shadowed the real
517+ definitions. Fully qualifying as ` Layout.Types.stringLayout ` (and
518+ friends) suppresses the auto-bind and lets the definitions reduce.
519+ 7 . ** ` (x y : T) ` binder syntax** — Idris2 0.8 prefers comma-separated
520+ ` (x, y : T) ` ; updated all affected binders.
521+ 8 . ** ` prefix ` is reserved** — renamed ` SubStruct ` 's ` prefix ` argument
522+ to ` pre ` (operator fixity keyword in Idris2 0.8).
523+ 9 . ** Non-linear SubStruct transitivity pattern** — rewrote
524+ ` data Subtype ` 's ` SubStruct ` constructor to carry an explicit
525+ equality witness ` prf : fs = pre ++ rest ` , then proved
526+ ` subTrans ` for the SubStruct/SubStruct case using ` trans ` , ` cong ` ,
527+ and ` sym appendAssociative ` . (The direction of
528+ ` appendAssociative : l ++ (c ++ r) = (l ++ c) ++ r ` needs ` sym ` to
529+ rearrange ` (pre ++ rest1) ++ rest2 ` into ` pre ++ (rest1 ++ rest2) ` .)
530+ 10 . ** ` WasmGCLayoutValid ` struct-field predicate** — replaced the
531+ ` case vt of … => True ` predicate (which mixed ` Bool ` with ` Type ` )
532+ with a proper ` WasmValTypeValid ` inductive in a mutual block.
533+ 11 . ** ` WasmGCEq ` constructor** — replaced the over-strong
534+ ` MkGCEq : decEq h1 h2 = Yes Refl -> WasmGCEq h1 h2 ` with the
535+ simpler propositional form ` MkGCEq : h1 = h2 -> WasmGCEq h1 h2 ` .
536+ The original encoding required a non-trivial theorem about ` decEq `
537+ to construct a reflexive witness.
538+
539+ ** Net result:** the aggregate-library Layout contracts (the secondary
540+ purpose of typed-wasm, per ADR-004) are back in the ipkg alongside
541+ the typed-wasm core, with zero ` believe_me ` / ` assert_total ` /
542+ ` postulate ` / ` sorry ` . ` %default total ` preserved throughout.
528543
529544## Pre-existing notes (preserved from prior revision)
530545
0 commit comments