Commit 9bcde6c
authored
feat(abi): add Rust/SPARK ABI seam + abi-verify CI gate (Refs standards#134) (#95)
## Summary
Estate language policy
(`standards/rhodium-standard-repositories/spec/LANGUAGE-POLICY.adoc`
§Terminology) requires Rust projects to be *"designed to admit SPARK/Ada
modules across a stable Idris2-typed boundary, with Zig as the FFI
layer."* Ephapax has a Coq `formal/` metatheory and an Idris2
`src/formal/` region/linearity metatheory but no named SPARK admission
seam — **standards#134 flags this as residual proof debt**.
This PR is the **scaffolding pass**: name the obligations, give them a
machine-checked file, gate them in CI. **No new discharges** — existing
ones (`splitLinearCoverage`, `noEscapeTheorem`) are CITED from the seam;
the vacuous-wrapper problem in `regionSafetyExtract` / `noGCExtract` is
FLAGGED honestly (it's vacuous: body is the input unchanged, ROADMAP
claiming them "complete" is misleading).
## What's added
| File | Role |
|------|------|
| `src/abi/Ephapax/ABI/Types.idr` | Boundary types: `Qual`, `Ty`,
`Term`, `CtxEntry`/`TypeCtx`, `SExpr`, `WasmExpr`, `RegionId`.
Constructor order ABI-significant, matches Rust enums in
`src/ephapax-{syntax,typing,ir,wasm}/`. |
| `src/abi/Ephapax/ABI/Invariants.idr` | E1–E6 register (see table
below). |
| `src/abi/Ephapax/ABI/Foreign.idr` | Zig/WASM-FFI boundary:
`InU32`/`InI32Magnitude` (Integer-bounded, not Nat — carries the
proof-of-work#63 unhang lesson), `CompileResult` C-ABI codes with
round-trip discharge, and `compileOkImpliesWasmTyped` tying CompileOk to
an E5 certificate. |
| `src/abi/ephapax-abi.ipkg` | Idris2 package for the `Ephapax.ABI.*`
namespace. |
| `.github/workflows/abi-verify.yml` | HARD GATE — rebuilds the seam on
every PR/push touching `src/abi/**` (snazzybucket/idris2 container).
Mirrors proof-of-work's `abi-verify.yml`. |
| `RUST-SPARK-STANCE.adoc` | Top-level stance doc, structurally
identical to proof-of-work's. |
## Invariant register
| ID | Property | Status |
|----|----------|--------|
| E1 | Type preservation | **OWED** — Coq `preservation` `Admitted`
(ephapax#92) |
| E2 | Linear consumption | **PARTIAL** — head form DISCHARGED via
`splitLinearCoverage` (PR#85); control-flow form OWED |
| E3 | Region no-escape | **PARTIAL** — narrow form DISCHARGED via
`noEscapeTheorem`; operational form OWED |
| E4 | No-runtime-GC | **OWED** — `noGCExtract` is vacuous (returns
input pair) |
| E5 | WASM compilation correctness | **OWED** — no formalisation today
|
| E6 | IR lowering correctness | **OWED** — no formalisation today |
## Verification (local, Idris2 0.8.0)
```
cd src/abi && idris2 --build ephapax-abi.ipkg
# → EXIT 0, 3/3 modules built
```
## Honest gaps surfaced by this audit
- `regionSafetyExtract` / `noGCExtract` in
`src/formal/Ephapax/Formal/RegionLinear.idr` are **vacuous** — bodies
are `= ne` and `= (ne, lc)` (return inputs unchanged). The proofs are
sound (no escape hatches) but content-free. ROADMAP citing them as
"regionSafetyTheorem" / "noGCTheorem" complete is therefore overstated —
flagged in seam (E3, E4) and stance doc.
- No WASM compilation formalisation exists anywhere in the repo. E5 is
the highest-leverage compiler-correctness gap.
- `ephapax-parse-tests.ipkg` fails on origin/main
(`testLexPositions`/`parseWithBuf` undefined) — independent of the seam,
flagged for awareness.
## Bounds encoding (Integer not Nat)
`Foreign.idr` uses `Integer` for the u32/i32 bounds, not `Nat`,
deliberately carrying the proof-of-work#63 lesson: a `Nat` constant of
`2^32` under `LT n bound` in a constructor type forces the Idris2 0.8.0
elaborator to reduce the literal (~4×10⁹ `S` ctors) and hangs `--build`.
The boundary predicate is `So (natToInteger n < bound)` instead —
propositionally equivalent, no unary expansion. Don't rewrite back.
## Refs
Refs standards#134 (**NOT Closes** — joint-close on agreement). #134
also has:
- ephapax#88 OPEN — 14 `idris2/src/*.idr` SPDX headers
- ephapax#92 OPEN — `Qed.` → `Admitted.` on `preservation` (honesty fix;
this stance doc cites it)
Both are independent of this seam.
## Test plan
- [x] `cd src/abi && idris2 --build ephapax-abi.ipkg` → exit 0 locally
(3/3 modules)
- [ ] `abi-verify.yml` green on this PR's CI run
- [ ] Existing Rust CI unaffected (`src/abi/` is independent of
`src/ephapax-*/` crates)
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 69a0d29 commit 9bcde6c
6 files changed
Lines changed: 757 additions & 0 deletions
File tree
- .github/workflows
- src/abi
- Ephapax/ABI
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
0 commit comments