|
| 1 | +// SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | += src/abi/ — Idris2 ABI Declarations (formal interface contracts) |
| 3 | + |
| 4 | +Idris2 dependent-type-checked ABI declarations for the valence-shell |
| 5 | +foreign-function interface. Per the **CLAUDE.md ABI/FFI Universal |
| 6 | +Standard**: |
| 7 | + |
| 8 | +> Idris2 for ABI: Dependent types prove interface correctness at |
| 9 | +> compile-time; formal verification of memory layout; platform-specific |
| 10 | +> ABIs with compile-time selection; provable backward compatibility. |
| 11 | + |
| 12 | +This tree provides the formal contract that `../../ffi/zig/` (and any |
| 13 | +future per-language FFI binding) must satisfy. |
| 14 | + |
| 15 | +Per the 2026-04-18 audit (`../../docs/governance/CRG-AUDIT-2026-04-18.adoc`): |
| 16 | +"minimal stubs; primary proof work is in proofs/{coq,lean4,...} not in |
| 17 | +the Idris2 ABI layer". The three-file shape below is the |
| 18 | +template-required minimum; deeper proofs live in the `proofs/` tree. |
| 19 | + |
| 20 | +== Files |
| 21 | + |
| 22 | +[cols="2,4"] |
| 23 | +|=== |
| 24 | +| File | Role |
| 25 | + |
| 26 | +| `Types.idr` | Type-level encoding of the FFI value domain |
| 27 | + (file descriptors, paths, error codes, etc.). |
| 28 | +| `Layout.idr` | Memory-layout proofs (alignment, size, padding) — |
| 29 | + the dependent-type guarantee that Zig structs match |
| 30 | + the Idris2 contract. |
| 31 | +| `Foreign.idr` | `%foreign` declarations: the actual function |
| 32 | + signatures exposed across the ABI boundary. |
| 33 | +|=== |
| 34 | + |
| 35 | +== Build / typecheck |
| 36 | + |
| 37 | +```bash |
| 38 | +cd src/abi |
| 39 | +idris2 --check Types.idr # single module |
| 40 | +idris2 --check Foreign.idr # transitive (imports Types + Layout) |
| 41 | +``` |
| 42 | + |
| 43 | +== Generated headers |
| 44 | + |
| 45 | +C headers derived from these declarations would be emitted under |
| 46 | +`../generated/abi/` per the standard layout (currently absent — this |
| 47 | +tree is at the stub stage; the audit's "minimal stubs" finding stands). |
| 48 | + |
| 49 | +== See also |
| 50 | + |
| 51 | +* `../../ffi/zig/README.adoc` — Zig implementation that conforms to |
| 52 | + these contracts |
| 53 | +* `../../ffi/rust/README.adoc` — Rust FFI library (separate; does not |
| 54 | + currently consume these Idris2 declarations) |
| 55 | +* `../../CLAUDE.md` — global ABI/FFI Universal Standard |
| 56 | +* `../../alkahest-shell-transmuter/src/abi/` — sibling sub-project |
| 57 | + carrying its own (also-stub) ABI tree |
0 commit comments