Skip to content

Verify Ephapax string ABI against real .wasm output #215

Closed

Description

@hyperpolymath

Follow-up to #196 / #212.

src/ui/gossamer/loader.js (readString) currently assumes the Ephapax wasm string ABI is:

ptr -> [ i32 length (little-endian) | bytes... ]

This matches the AffineScript convention and the project receipts that describe Ephapax strings as {ptr, len} pairs, but the wasm-level packing has never been verified against a real Ephapax-emitted binary — there isn't one yet (gated on hyperpolymath/ephapax#36).

The loader's readString now bounds-checks length and ptr, so a mismatch surfaces as a RangeError rather than a silent garble — but the actual fix would be a one-line update to readString if Ephapax emits something else (e.g. multi-value return, separate _get_len/_get_bytes calls, length-as-second-export).

Definition of done

  • Once ephapax#36 lands and the Build Gossamer GUI workflow produces a hypatia_gui.wasm artifact, instantiate it locally (or in CI via a tiny node script) and call hypatia_view against an hypatia_init model. Confirm the returned bytes decode to the expected view string.
  • If the ABI differs from the assumed convention, update readString accordingly and adjust the gossamer.bytes_to_string / JSON-helper stubs that share the same assumption.
  • Update the ABI documentation block at the top of loader.js with the verified convention.

Scope

Out of scope for #196 — that DoD allows the ABI assumption to be documented with bounds-checking until a real wasm exists.

Activity

  1. hyperpolymath commented on May 11, 2026

    @hyperpolymath
    OwnerAuthor

    Status update from #219:

    The new Node smoke harness (test/gossamer/loader_smoke.test.mjs) instantiates a hand-built minimal .wasm against loader.js's gossamer host imports and verifies the {ptr, i32-len} string ABI round-trips through real wasm memory. That confirms the loader side of the convention is internally consistent and decodes correctly when wasm produces strings in the assumed shape.

    What it does not confirm — and what this issue still tracks — is whether Ephapax-emitted wasm actually packs strings that way, or whether it uses multi-value returns / separate _get_len/_get_bytes calls / length-as-second-export / etc. That requires a real Ephapax-emitted artifact, which is gated on hyperpolymath/ephapax#36.

    Plan once ephapax#36 lands and the workflow promotes the compile step:

    1. Build Gossamer GUI produces a real hypatia_gui.wasm.
    2. Extend the smoke harness to additionally instantiate the produced artifact (already wired byte-for-byte against the same import object), call hypatia_view(hypatia_init()), and assert the decoded view string matches the expected initial content.
    3. If the ABI differs from the assumed convention, update readEphapaxString (single point of change per the loader doc block) and the gossamer.bytes_to_string / JSON-helper stubs.
    4. Update the ABI documentation block at the top of loader.js with the verified convention.

    Holding open until ephapax#36 is mergeable — there's no hypatia-side action I can take to close this issue before then.


    Generated by Claude Code

  2. added a commit that references this issue on May 11, 2026
    8bee15c
  3. hyperpolymath commented on May 11, 2026

    @hyperpolymath
    OwnerAuthor

    After inspecting hyperpolymath/[email protected] to attempt the integration: the upstream gate isn't actually a CLI subcommand wrapper — it's the v2 grammar.

    What I found:

    • The v1.0.0 binary is named ephapax (not ephapax-cli) and already ships ephapax compile <file> -o <out> (see src/ephapax-cli/src/main.rs:65).
    • But v1.0.0's parser grammar (src/ephapax-parser/src/ephapax.pest) only accepts top-level fn and type declarations.
    • Running it locally: ephapax compile src/ui/gossamer/bridge.eph -o /tmp/hypatia_gui.wasm → Parse error at line 18: expected EOI or declaration at "module hypatia/ui/bridge".
    • bridge.eph and hypatia_gui.eph use v2 constructs (module, import, extern "gossamer" { ... }, data Msg = Navigate(Department) | PopState, match, let!) — none of which v1.0.0's parser accepts.

    So hyperpolymath/ephapax#36 (the "compile-eph CLI subcommand" tracker) is really blocked on the v2 grammar landing in ephapax-parser. Once the parser accepts v2, the existing ephapax compile subcommand will start producing real wasm and this issue becomes verifiable in one CI cycle.

    Latest commit on #219 updates the workflow to probe ephapax compile (the real v1.0.0 subcommand) and surface a clear warning if the parse fails, plus corrects this issue's mental model in the loader/README comments. Doesn't close #215 — the verification still requires upstream parser support — but means the moment that lands we're one CI cycle away from a real artifact rather than two.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions