feat(eph): make src/core/*.eph genuinely linear — verified by ephapax (gossamer#82)#101
Merged
Merged
Conversation
… (gossamer#82)
The 13 Ephapax bindings to the libgossamer C ABI were __ffi passthroughs
over raw I64 handles with comments CLAIMING linearity but zero `let!`
bindings — and, because __ffi is typed I64 while the wrappers declared
`: I32` / `: ()` / `String` returns, not one of them type-checked.
`ephapax check` rejected all 13. A comment is not a proof.
Rewritten so the Ephapax compiler is the oracle:
- 13/13 now type-check under `ephapax check` (--mode linear), up from 0/13.
- 8 handle-owning modules are genuinely linear via `extern` opaque handle
types + `let!`: Bridge (Channel), Shell (Webview), Tray (Tray),
Capabilities (CapToken), Conf (Conf), ClosureConversion (Closure),
ShellExec (Child), Dialog (DialogPath). The resource is minted linear,
borrowed via &Handle for mid-lifetime ops, and consumed exactly once by
its retire op — so leaking a handle is a compile error ("Linear variable
not consumed"), adversarially verified on the real files by deleting each
consume and confirming rejection.
- 5 compute modules (Platform, Module, Filesystem, SSG, Groove) own no
linear handle and are correctly-typed extern surfaces. Groove is
registry-indexed at the .eph layer; its connection linearity stays proved
in Idris2 (GrooveLinearity / GrooveResidue). Only real C symbols are
declared — no phantom FFI.
Enforcement:
- scripts/check-eph-linearity.sh — positive (all .eph type-check) + negative
(drop each handle's consume, assert rejection) gate; shellcheck-clean.
- .github/workflows/eph-linearity.yml — builds ephapax from source as the
oracle, degrades to a notice if unreachable (estate sibling-tool pattern).
- just eph-check added; just check now covers all 13 modules (was 5).
Docs: CHANGELOG + PROOF-NEEDS updated.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Zg1kEsjSRpcf1wFBZyeNj
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.
Summary
Closes the Ephapax half of gossamer#82. The 13
src/core/*.ephbindings to the libgossamer C ABI were__ffi(...)passthroughs over rawI64handles with comments claiming linearity but zerolet!bindings — and, because__ffiis typedI64while the wrappers declared: I32/: ()/Stringreturns, not one of them type-checked.ephapax checkrejected all 13. A comment is not a proof. This PR rewrites them so the Ephapax compiler is the oracle, and adds a CI gate that re-runs the linearity proof every run.Refs gossamer#82. Complements the Idris2 ABI↔FFI cleave work (#98/#99/#100).
Changes
.ephfiles now type-check underephapax check(--mode linear), up from 0/13.externopaque handle types +let!:Bridge(Channel),Shell(Webview),Tray(Tray),Capabilities(CapToken),Conf(Conf),ClosureConversion(Closure),ShellExec(Child),Dialog(DialogPath). The resource is minted linear, borrowed via&Handlefor mid-lifetime ops, and CONSUMED exactly once by its retire op — so leaking a handle is a compile-time error (Linear variable not consumed).Platform,Module,Filesystem,SSG,Groove) own no linear handle and are correctly-typedexternsurfaces.Grooveis registry-indexed at the.ephlayer, so its connection linearity stays proved in Idris2 (GrooveLinearity.idr/GrooveResidue.idr). Only real C symbols are declared — no phantom FFI.scripts/check-eph-linearity.sh— positive gate (all.ephtype-check) + negative gate (drop each handle's consume, assertephapax checkrejects it). Shellcheck-clean..github/workflows/eph-linearity.yml— builds Ephapax (hyperpolymath/ephapax, pinned) from source as the oracle; degrades to a notice if unreachable (estate sibling-tool convention).just eph-checkadded;just checknow covers all 13 modules (was 5).CHANGELOG.md+PROOF-NEEDS.mdupdated.RSR Quality Checklist
Required
./scripts/check-eph-linearity.sh). The.ephlayer is not part of the Idris2 147-test suite, which is unaffected..ephformatter exists in-tree; files follow the surrounding style.shellcheck scripts/check-eph-linearity.shclean.unsafeblocks without// SAFETY:comments — none introduced.believe_me,unsafeCoerce,Obj.magic,Admitted,sorry) — none in the.ephlayer..eph, the script, and the workflow..envfiles included.As Applicable
PROOF-NEEDS.md.CHANGELOGor release notes updated.externdeclares a realgossamer_*(or Idris2 RTS) symbol; no phantom FFI, mirroring the Idris2 cleave gate.Testing
Local, against the Ephapax compiler built from
hyperpolymath/ephapax@55d6a24:The negative half deletes each module's consuming call on the real file and confirms the compiler rejects the leak — so a silent de-linearisation (opaque type reverted to
I64, orlet!downgraded tolet) fails the gate.🤖 Generated with Claude Code
https://claude.ai/code/session_013Zg1kEsjSRpcf1wFBZyeNj
Generated by Claude Code