Skip to content

erlang: make BEAM runtime smoke self-contained (real Node smoke)#820

Open
brandonpayton wants to merge 2 commits into
mainfrom
gascity/kd-1mr/kd-fyqz-erlang-beam-smoke
Open

erlang: make BEAM runtime smoke self-contained (real Node smoke)#820
brandonpayton wants to merge 2 commits into
mainfrom
gascity/kd-1mr/kd-fyqz-erlang-beam-smoke

Conversation

@brandonpayton

Copy link
Copy Markdown
Member

What

Make the Erlang/OTP 28 BEAM runtime smoke a real Node smoke instead of
artifact-only. The suite packages/registry/erlang/test/erlang.test.ts already
booted BEAM on Kandelo for 4 cases, but its 5th test called an external ring
module that is never compiled, so ring:start() died with
{undef,[{ring,start,...}]}.

This replaces the ring test with a self-contained named-fun ring driven via
-eval, so all 5 tests boot BEAM and run a real Erlang program with no
compilation step:

  • prints hello world, evaluates arithmetic, handles lists and pattern matching, spawns lightweight processes, and runs a ring benchmark with inter-process message passing (spawn/2 + message passing across a 50-process
    ring, sized so the ~0.06s compute finishes well inside serve.ts's 2s
    idle-exit watchdog).
  • demo/ring.erl and demo/serve.ts doc comments are corrected: they had
    advertised ring:start()., which cannot work on-platform.

Why not just compile ring.erl on Kandelo?

The on-Kandelo Erlang compiler crashes in beam_asm because erlang:md5/1
returns badarg on iolist input
in this wasm BEAM build (it works only on a
binary), and beam_asm computes each module's MD5 over an iolist of chunks.
Verified directly: erlang:md5(<<"test">>)<<9,143,...>>; erlang:md5("abc")
error:badarg. Filed as follow-up kd-qe2c. Until that is fixed, Erlang
modules must be precompiled on a host; the smoke therefore uses a self-contained
-eval program that needs no compilation.

Verification

  • Node smoke: cd host && npx vitest run ../packages/registry/erlang/test/erlang.test.ts
    inside scripts/dev-shell.sh5 passed / 5. Outcome lists + JSON report
    under test-runs/kd-fyqz/.
  • maxAddr: explicit and logged by serve.ts — max_addr = 0x3fdc0000 (page
    16348), reserving the top of the wasm32 address space for BEAM thread
    channels/TLS.
  • Browser smoke: skipped — no browser BEAM harness exists (the erlang demo
    has only a Node launcher). Documented as a boundary; a browser BEAM smoke is a
    candidate follow-up once the OTP runtime tree is a publishable sidecar
    (kd-1mr.6 / kd-yuef).
  • ABI: scripts/check-abi-version.sh → snapshot/ABI_VERSION consistent (no
    kernel/ABI change here).
  • Scope: this is a test + demo-doc change; it touches no Rust/kernel/libc/syscall
    code, so those gates are not relevant.

Notes / limitations

  • The suite keeps its pre-existing describe.skipIf(!hasErlang) contract: it
    passes when erlang.wasm + the erlang-install/ OTP tree are present locally,
    and skips otherwise. The abi release ships only erlang.wasm, not the OTP
    tree, so CI/browser without a staged tree records these as skipped, not failed.
    Publishing the OTP runtime tree is separate packaging work (kd-1mr.6 / kd-yuef).
  • The Homebrew erlang.rb Formula + build-erlang.sh sandbox changes from the
    kd-xhdd harvest are intentionally not included — they are build/Formula
    concerns that overlap a divergent erlang.rb already on kd-p3hr's Add Homebrew formulas for language runtimes #810, and
    belong to the build/publish lane, not this smoke harness.

Bead: kd-fyqz. Follow-up: kd-qe2c (erlang:md5/1 iolist badarg).

🤖 Generated with Claude Code

brandonpayton and others added 2 commits July 1, 2026 04:36
The BEAM runtime smoke's ring test called an external `ring` module that
is never compiled, so `ring:start()` died with `{undef,[{ring,start,...}]}`
and the smoke was effectively artifact-only for that case. Erlang cannot
compile modules on Kandelo yet: beam_asm hashes each module with
erlang:md5/1 over an iolist, and erlang:md5/1 returns badarg on iolist
input in this wasm build (it works only on a binary) — tracked as kd-qe2c.

Replace the ring test with a self-contained named-fun ring driven through
-eval, so all 5 tests boot BEAM and run a real Erlang program with no
compilation step. Size it 50x10 so the silent compute (~0.06s) finishes
well inside serve.ts's 2s idle-exit watchdog. Correct the ring.erl and
serve.ts doc comments that advertised the broken ring:start() path.

Node smoke: 5/5 pass (host vitest, dev-shell). maxAddr is explicit
(0x3fdc0000). Browser smoke: skipped (no browser BEAM harness).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Durable pass/fail/skip outcome lists, vitest JSON report, and a summary
(before/after counts, maxAddr, browser-smoke status, harvest scope
decision) for the kd-fyqz Erlang BEAM runtime smoke.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant