All computation happens in Idris2. No exceptions.
src/Proven/ Idris2 with dependent types — THE TRUTH
|
| idris2 --codegen refc
v
build/refc/ Generated C code (RefC backend)
|
| zig build (links RefC output + Idris2 runtime)
v
ffi/zig/zig-out/lib/ libproven.so / libproven.dylib / libproven.dll
|
| Language-specific FFI calls
v
bindings/*/ Thin wrappers — data marshaling ONLY
The proven.ipkg declares 258 modules. Key categories:
Core.idr— Fundamental types,ProvenResult,SafeNat,BoundedIntAxioms.idr— Axioms (should be empty — everything proved)
Pattern: src/Proven/Safe<Domain>.idr
SafeArith.idr— Overflow-proof arithmeticSafeString.idr— Length-bounded string operationsSafeCrypto.idr— Cryptographic primitivesSafeBuffer.idr— Bounds-checked buffersSafeParse.idr— Total parsing (always terminates)SafeNet.idr— Network operationsSafeFS.idr— Filesystem operations- etc.
Each Safe* module exports functions with dependent type signatures that make invalid states unrepresentable. For example:
safeAdd : (a : Int) -> (b : Int) -> {auto prf : NoOverflow a b} -> IntThese declare the C-ABI-compatible function signatures that Zig exports.
Pattern: src/Proven/FFI/<Domain>FFI.idr
Neurosymbolic proof validation hooks for the echidna theorem prover.
ffi/zig/build.zig accepts these build options:
-Didris-refc=<path>— Path to RefC output directory-Didris-refc-runtime=<path>— Path to Idris2 RefC runtime headers-Didris-c-support=<path>— Path to Idris2 C support headers-Didris-support-lib=<path>— Path to libidris2_support
ffi/zig/src/main.zig exports C-ABI functions that:
- Accept C-compatible arguments
- Call the corresponding Idris2 RefC compiled function
- Return C-compatible results
The Zig layer adds NO safety logic. It is purely structural bridging.
- Call
libprovenfunctions via FFI - Marshal data between language types and C types
- Propagate errors from C return codes
- Include SPDX headers and author attribution
- Reimplement any algorithm (even "simple" ones)
- Use unsafe patterns:
unwrap(),getExn,Obj.magic,panic!() - Claim "formally verified" for code that does not call Idris2
./hypatia-v2 . --severity=critical --severity=high --exclude=bindings/*/tests
# Must show 0 findings130 unsafe patterns found in bindings (5 CRITICAL, 124 HIGH). ReScript used
getExn, Rust used unwrap(). This blocked opam publication. Never again.
just build # Full pipeline (2-5 min)
just build-refc # Step 1: Idris2 → RefC C code
just build-ffi # Step 2: Zig links RefC → libproven.so
just typecheck # Typecheck all 258 modules
just typecheck-ffi # Typecheck FFI-only package
just verify-totality # Run totality checker
just test # All tests (Idris2 + Zig FFI)
just test-idris # Idris2 tests only
just test-ffi # Zig FFI integration tests
just scan # hypatia security scan
just env-info # Show Idris2/Zig/pack versions
just doctor # Check prerequisites
just heal # Install instructions| File | Purpose |
|---|---|
proven.ipkg |
Full library (258 modules) |
proven-ffi.ipkg |
FFI-only subset |
core-only.ipkg |
Core types only |
test-simple.ipkg |
Test suite |
test-ffi.ipkg |
FFI integration tests |
All in .machine_readable/6a2/:
STATE.a2ml— Current progress, blockers, next actionsMETA.a2ml— Architecture decisions (ADR-008: FFI-only bindings)ECOSYSTEM.a2ml— Ecosystem position and relationshipsAGENTIC.a2ml— AI agent interaction patternsNEUROSYM.a2ml— Neurosymbolic configPLAYBOOK.a2ml— Operational runbook
NEVER create these files in the root directory.
- Create
src/Proven/SafeNewDomain.idrwith total functions - Add FFI signatures in
src/Proven/FFI/NewDomainFFI.idr - Add module to
proven.ipkgandproven-ffi.ipkg - Run
just typecheck— must pass with zero warnings - Add Zig export in
ffi/zig/src/main.zig - Run
just build && just test - Add bindings in
bindings/*/(thin wrappers only) - Run hypatia scan before committing
- Create directory
bindings/<lang>/ - Add package metadata (Cargo.toml, package.json, etc.)
- Write FFI calls to
libproven— NO reimplementation - Add tests that verify FFI calls work
- Run
./hypatia-v2 bindings/<lang>/ --severity=critical --severity=high - Must show 0 findings before PR
In Idris2:
believe_me— BANNED (breaks proofs)assert_total— BANNED (hides partiality)unsafePerformIO— BANNED
In bindings:
- Rust:
unwrap(),expect(),panic!(),unsafe(except FFI boundary) - ReScript:
getExn,Obj.magic - Any pattern hypatia flags as HIGH or CRITICAL
17 workflows in .github/workflows/. Key ones:
hypatia-scan.yml— Security scanningcodeql.yml— Code analysisquality.yml— TruffleHog, EditorConfigmirror.yml— GitLab/Bitbucket mirroring
MPL-2.0 throughout. Author: Jonathan D.A. Jewell j.d.a.jewell@open.ac.uk Git: 6759885+hyperpolymath@users.noreply.github.com