Skip to content

M19: verisim-nif real implementation (host-side, replaces nif_placeholder) [hypatia#294 unlock] #61

Closed as not planned

Description

@hyperpolymath

Context

hypatia#294 ruled Option A (split) on 2026-05-27. The architecture pins VCL parse + typecheck inside a wasm32-freestanding SNIF (zero imports), while the VCL → DB hop runs host-side via this NIF. This issue tracks the real implementation of verisim-nif, which today returns {"status":"nif_placeholder"}.

References:

  • hypatia#294 (boundary ruling, A — split)
  • hypatia#273 (parent architecture-reconciliation epic, Gap 2)
  • hypatia/docs/architecture/boundary-design-options.adoc (design memo)
  • hypatia/docs/operations/issue-294-boundary-recommendation.adoc (recommendation memo, committed 2026-05-24)
  • Current Elixir reference: hypatia/lib/vcl/file_executor.ex (the VCL query subset hypatia actually exercises)

Current state

verisim-nif is a placeholder. It returns a constant {"status":"nif_placeholder"} regardless of input. No real query execution, no storage backend wiring, no error model, no timeouts.

Acceptance

  • Replace placeholder with real query execution against verisimdb's storage backend (octad-store)
  • Support the VCL query subset hypatia uses (mirror behaviour of lib/vcl/file_executor.ex in hypatia for current-art reference)
  • Structured error model across the NIF boundary — no panics into BEAM, all faults returned as {:error, reason}-shaped terms
  • Host-side timeout enforcement (caller-provided budget, hard cancel)
  • Documented contract for the wasm SNIF caller (i.e. the shape of the call from hypatia's M20 port: query AST in, result rows / error out)
  • Integration smoke from Elixir side: real query → real rows from octad-store

Estimated effort

~3 person-weeks (per the recommendation memo, verisim-nif portion).

Companion

hypatia# tracks the Idris2 → Zig SNIF parser port; together M19 + M20 close hypatia#294 + hypatia#273 Gap 2.

Activity

  1. added
    enhancement
    rust
    elixir
    on May 27, 2026
  2. hyperpolymath commented on May 27, 2026

    @hyperpolymath
    OwnerAuthor

    Companion: hypatia#367 (Zig SNIF parser port). Together close hypatia#294 + hypatia#273 Gap 2.

  3. added a commit that references this issue on Jun 5, 2026
  4. hyperpolymath commented on Jul 21, 2026

    @hyperpolymath
    OwnerAuthor

    Status 2026-07-21 — do not start this until #86 is ruled on

    Two things have changed since this was filed.

    1. The placeholder no longer lies. This issue opens by noting verisim-nif "returns a constant {"status":"nif_placeholder"} regardless of input". That is no longer true. Every entry point now calls not_implemented() and returns a typed failure; delete_octad carries the comment that it "previously returned {"status":"deleted"} without deleting anything — the silent-data-loss bug this stub exists to prevent."

    That removes the urgency. Callers get a loud, honest error instead of silently dropped results, so there is no correctness pressure forcing this work to start before the architecture is settled.

    2. #86 would subsume most of this issue's acceptance list. #86 Option A compiles verisim-core to WASM and wraps it with a SNIF. Under that design:

    • "Structured error model across the NIF boundary — no panics into BEAM" is what SNIFs provide by construction (WASM guest faults become BEAM error tuples).
    • "Documented contract for the wasm SNIF caller" becomes the SNIF wrapper's own interface rather than a separate artefact.
    • The "~3 person-weeks (per the recommendation memo)" estimate was made against the hand-written-NIF design and does not carry over unchanged.

    Only the storage-backend wiring and host-side timeout budget survive both designs intact.

    Recommendation: hold this issue until the #86 A/B ruling lands, then re-scope the acceptance list against whichever option is chosen. Starting now risks building against an architecture that is about to be replaced. Also note the companion this issue names — hypatia#367, the Zig SNIF parser port — is itself SNIF-shaped, which is further reason to settle the SNIF boundary first.

    No code in #185 touches verisim-nif. It remains 0 tests / 204 LOC (see #79); writing tests against a deliberate fail-loudly stub would also be premature for the same reason.

  5. hyperpolymath commented on Jul 28, 2026

    @hyperpolymath
    OwnerAuthor

    Closing as subsumed by the #86 ruling (Option A + VCL-wire-codec contract).

    verisim-core compiles to WASM and is wrapped by SNIFs, so the hand-written
    Rustler NIF this issue specifies is replaced rather than deferred, and the ~3
    person-weeks estimated here is not spent. The P1 spike is already green: a real
    kernel builds to wasm32-unknown-unknown with zero link-time imports — see
    #86 for the measurement.

    How this issue's acceptance criteria are met under that ruling:

    #61 criterion Under #86 Option A
    Real execution against the octad store Kernels operate on buffers; the store stays Rust-native/BEAM-side — see the correction below
    Structured error model, no panics into the BEAM Free from the sandbox: a guest trap becomes {:error, reason} and the caller survives
    Host-side timeout enforcement fuel_per_call (ADR-004 liveness guard) plus the pool receive-timeout
    Documented contract for the caller The VCL wire codec — VCLT/VCLW/VCLS today, plus VCLR v1 to be specified upstream in vcl-ut

    Two corrections worth recording rather than closing over:

    1. "Option A" is overloaded. hypatia#294's Option A put VCL parse+typecheck
    in a freestanding SNIF with the DB hop host-side. #86's Option A puts
    verisim-core itself in WASM. Different rulings that happen to share a letter —
    easy to conflate when reading the two issues together.

    2. The WASM surface is stateless kernels, not a resident store. snifs' pool
    re-instantiates the guest at every transaction boundary, so linear memory resets
    between calls. OctadStore cannot live in WASM — not for effort reasons, but
    because the isolation model forbids it. The Rust-native residue
    (verisim-octad, verisim-normalizer, verisim-wal, verisim-storage,
    verisim-planner, verisim-api) stays exactly where it is.

    Nothing is lost by closing this. verisim-nif already returns
    {:error, :not_implemented} at every entry point, so the silent-data-loss
    hazard — a write reported as success — is already gone and there is no
    correctness pressure. It should be retired once #86 Phase 5 ships a hex package;
    until then it stays as the loud-failure placeholder it now is.

    Tracking continues on #86.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    elixirenhancementrust

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions