iseriser: codegen emits verified, compiling Idris2 ABI (P2)#69
Merged
Conversation
The scaffold generator still emitted the old flat, never-compiled ABI
template: files at `src/interface/abi/{Types,Layout,Foreign}.idr` with a
namespace they didn't match, a `Layout.idr` whose `modNatNZ ... == 0`
proof does not reduce at the type level, no `Proofs.idr`, and no `.ipkg`.
Every newly-generated -iser therefore started with a broken ABI — exactly
the bug a prior session hand-fixed across the family.
Rewrite the Idris2 ABI generators to emit the verified reference pattern,
proven to compile clean under Idris2 0.7.0 (zero warnings, no
believe_me/postulate/holes):
- Nested modules at `src/interface/abi/<Mod>/ABI/{Types,Layout,Foreign,
Proofs}.idr` so each file's path matches its namespace, plus
`src/interface/abi/<iser>-abi.ipkg` (sourcedir=".", lists all four).
- Types: `Result` with a complete `DecEq` (explicit off-diagonals, not
`No absurd`), a non-null `Handle` built via `choose`, and a primitive
enum with a tag-based `Eq` that is warning-free for any arity.
- Layout: real `Divides`/`StructLayout`/`FieldsAligned` machinery and one
concrete, provably C-ABI-compliant context layout.
- Proofs: a non-vacuous `CABICompliant` theorem (each offset pinned by
`DivideBy k Refl`, qualified layout name so it doesn't auto-bind), the
result-code round-trip, and a Nat-level negative control. Verified:
perturbing a field offset makes the proof fail to typecheck.
Tests: assert the generated tree is self-consistent (every ipkg module
present at its namespace path, no leftover template tokens, old flat path
gone) and add an end-to-end test that runs `idris2 --build` on the
generated ABI when the toolchain is present (no-op otherwise, so CI
without idris2 stays green). Update the integration tests for the new
paths and the real proof module.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xMKB3T4Vo5FYC7Czx3JSH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
iseriser's scaffold generator still emitted the old flat, never-compiled ABI for every new -iser:src/interface/abi/{Types,Layout,Foreign}.idrwhose path did not match their<Mod>.ABI.*namespace,Layout.idrwhoseSo (modNatNZ contextSize 8 SIsNonZero == 0)proof does not reduce at the type level,Proofs.idrand no.ipkgat all.So every freshly-generated -iser started life with the exact broken ABI a prior session had to hand-fix across the whole family. This closes that regression source (kickoff P2).
Change
Rewrote the Idris2 ABI generators to emit the verified reference pattern (the form proven to compile clean under Idris2 0.7.0, zero warnings, no
believe_me/postulate/holes):src/interface/abi/<Mod>/ABI/{Types,Layout,Foreign,Proofs}.idr(path matches namespace) +src/interface/abi/<iser>-abi.ipkg(sourcedir=".", lists all four modules).Resultwith a completeDecEq(explicit off-diagonals, notNo absurd); a non-nullHandleconstructed viachoose; a primitive enum with a tag-basedEqthat stays warning-free for any number of primitives.Divides/StructLayout/FieldsAlignedmachinery and one concrete, provably C-ABI-compliant context layout.CABIComplianttheorem (each field offset pinned byDivideBy k Refl; qualified layout name so it doesn't auto-bind as an implicit), the result-code round-trip, and a Nat-level negative control.Verification
cargo testgreen (lib + integration).idris2 --buildon a freshly-generated repo's ABI and asserts a clean, warning-free build (no-ops whereidris2isn't installed, so CI without the toolchain stays green).Idris2iser/1 primitive) — allidris2 --buildexit 0, zero warnings.DivideBy 4 Reflfail to typecheck atProofs.idr, confirming the headline theorem genuinely pins the offsets rather than passing vacuously.believe_me/postulate/ holes.Scope / not included
DeepProofstub.🤖 Generated with Claude Code
https://claude.ai/code/session_019xMKB3T4Vo5FYC7Czx3JSH
Generated by Claude Code