Skip to content

Lasm 0.8.0

Choose a tag to compare

@github-actions github-actions released this 15 Nov 04:42
· 586 commits to main since this release
c157c95

Lasm 0.8.0

A minor release: the fetch template moves off Lasm.Fetch except on Node, and Fastly, WASI and wasi-http programs use far less memory. Upgrade with npm install -D @lasm/cli@0.8.0; ^0.7.0 does not pick it up.

What changes: lasm init --template fetch generates a handler on the web's Request and Response (Lasm.JS.Web) served as the program's default export, with a separate entry module per platform for Fastly (Lasm.Fastly), wasi:http and Spin (Lasm.WASI.Http) and WASI (a CGI program); it uses Lasm.Fetch only on Node (#218). Existing projects keep building: Lasm.Fetch still ships in 0.8.0 and is scheduled for removal in a later release. Fastly, WASI and wasi-http programs link Lasm's own mimalloc build and use far less memory per request (#246, #253). Three generated browser bindings that returned some of null now return none (#232). @lasm/cli now has no npm dependencies: the tar package is gone, and Lasm's own reader and writer (src/tar.mjs) handle every archive, extracting 15 to 35 % faster (#270).

The example apps (Conduit, Folio, Porter, Ledger, Tandem) build with 0.7.0's platform bindings and use Lasm.Fetch at most for Node. Since 0.7.0, Lasm's own testing grew Lean models with proofs of the CLI's pure logic, equivalence and fuzz suites for the example apps, and metamorphic compiler tests; none of these change the published package.

Example apps

  • Conduit and Folio build with 0.7.0 and use Lasm.Fetch only for Node.
    Each platform runs the app's handler with its own server: Cloudflare Workers and
    the edge platforms through the program's default export
    (Lasm.JS.exportDefault), Deno with Deno.serve (Lasm.JS.Deno), Bun with
    Bun.serve (Lasm.JS.Bun), Fastly Compute on its host calls (Lasm.Fastly) and
    wasi-http on the proxy world's interfaces (Lasm.WASI.Http). Node keeps
    Lasm.Fetch's server until how Lean servers run on Node is decided. What
    Lasm.Fetch provided that has no replacement (embedded static files, the
    request type and its path parsing, outbound HTTP on wasi-http, the Worker's
    env) is now code inside each app (Server/ in both), listed in
    docs/REVIEW.md. Conduit reads its Fastly secret with the generated
    SecretStore calls. Every platform each app ran on before is still checked
    in CI, with the same suites and thresholds.

  • Porter builds with 0.7.0 and uses Lasm.Fetch only for Node, as
    Conduit and Folio do: Workers through the default export, Deno with
    Deno.serve, Bun with Bun.serve. Its request type, embedded files and
    cookie joining are code inside the app (examples/porter/Server/).

  • Ledger builds with 0.7.0 and uses Lasm.Fetch only for Node, as
    Conduit and Folio do: Workers through the default export, Deno with
    Deno.serve, Bun with Bun.serve. Its request type and embedded files are
    code inside the app (examples/ledger/Server/).

  • Tandem builds with 0.7.0 and no longer uses Lasm.Fetch. Workers serves
    through the default export, Deno with Deno.serve and Deno.upgradeWebSocket,
    Bun with Bun.serve and its WebSocket handlers, Node with Tandem's own
    node:http server and the ws package, as before. Its request type and
    embedded files are code inside the app (examples/tandem/Server/).

Changes

  • @lasm/cli has no npm dependencies (#270). The tar package it bundled
    is replaced by src/tar.mjs, an in-repo reader (ustar, pax, GNU long
    names) and writer, used for the managed Lean and tool downloads, npm
    artifacts and Fastly packages. On 20 real archives (every Lean 4.35.0 tier,
    the full toolchain, npm tarballs, binaryen, the edge runtime) it yields
    exactly the same entries as the tar package, 15 to 35 % faster (the
    toolchain in 23.4 s instead of 28.7 s). It refuses archives that the tar
    package would guess about: no end-of-archive block, unknown entry types,
    sparse files, names that are not UTF-8, malformed pax records.

Templates

  • lasm init --template fetch no longer uses Lasm.Fetch except on Node.
    Main.lean is a handler on the web's Request and Response
    (Lasm.JS.Web), served as the program's default export on Bun, Deno,
    Cloudflare Workers and the other edge targets; Node keeps Lasm.Fetch's
    Node server until Lasm's Node server lands. Fastly, wasi:http and WASI each
    get their own program with the same routes on that platform's own
    interface: --deploy fastly adds Fastly.lean (Lasm.Fastly),
    --deploy wasi-http and --deploy spin add WasiHttp.lean
    (Lasm.WASI.Http), and --deploy wasi adds Cgi.lean (a CGI program in
    Lean's IO); their build:<target> scripts build them. Existing projects
    keep building: Lasm.Fetch still ships.

Fixes

  • HTMLCanvasElement.getContext, Document.currentScript and
    HTMLFormControlsCollection.namedItem return none for null.
    They were
    some of a reference to null (an unsupported context id, no current
    script, no such control). The generator now requests a nullable Value
    result as data (Lasm.JS.Web.Support.optionalValue). Types are unchanged.

  • Fastly, WASI and wasi-http programs use far less memory (issue #246).
    --target fastly, wasi and wasi-http now link Lasm's own build of
    Emscripten's mimalloc (its unchanged sources, MIT, in src/mimalloc).
    The build has 2 MiB arenas and a page map for 32-bit addresses, in place of
    the prebuilt one's 16 MiB arenas and its 8 MiB page map. Measured on
    Viceroy:

    • examples/fastly uses 4.2 MB of heap per request instead of 27.8 MB, with
      the same throughput.
    • Folio's site server uses 6.1 MB per request instead of 27.9 MB.
    • Folio's largest inputs peak lower. On Fastly, unclosed <!-- now fits
      the 128 MB heap.
  • Edge and browser programs start at 4 MiB of Wasm memory instead of 26.6
    (issue #247). Every edge target (Workers, Vercel Edge, Netlify Edge,
    Supabase, Deno Deploy, Deno, Bun) and --target browser now link the same
    mimalloc build, so memory grows 2 MiB at a time instead of 16. Measured on
    wrangler dev:

    • Porter, Ledger and Conduit start at 5–6 MiB instead of about 28, and peak
      at 7–9 MiB during their suites.
    • Folio's largest inputs peak lower: unclosed <!-- 186 → 129 MiB,
      backticks 321 → 306 MiB.
    • Throughput is unchanged.
  • Rejection diagnoses name the right modules and declarations (#263). When
    a build is rejected for pulling in Lean's compiler or kernel, the
    explanation reads module and declaration names back from their C names. It
    decoded them as older Lean versions mangled them, so some names came out
    wrong: initialize_Foo_00x86 named module Foo.00x86 instead of Foo.x86,
    and private names kept their _private prefix. It now decodes exactly as
    Lean 4.35's Name.demangle does, checked against Lean's own and against a
    Lean model with a proved round trip (mangle_round_trip).

  • The dev server no longer hangs on a directory named like a compressed
    file
    (#269, in #299). lasm dev's static server took a directory such as
    app.js.br/ for the precompressed copy of app.js, so the request hung.
    Precompressed copies must now be regular files, and a read error ends the
    response. The server's path resolution has a Lean model with a proof that
    every file it serves lies under the root (static_inside_root).

  • The dev server answers 400 to a path with malformed percent-encoding
    (#256), such as /%, /%zz or a cut UTF-8 sequence. It answered 500
    "URI malformed".

  • IO errors with codes named like Object.prototype members (#271, in
    #299). In Node programs, an IO error whose code was constructor,
    toString or another such name got that function as its message (and a
    C runtime error lost its code). The tables have no prototype now.

Internals (no change to how programs build or run)

  • The edge link's initializer plan is computed by Lean, compiled by Lasm
    (#286, #294, #295). The part of the CLI that chooses which module initializers an
    edge or browser link keeps and in what order (src/edge/edge-initializers.mjs)
    now calls a WASI program built from its proved Lean model
    (verification/cli/Lasm/Cli/Glue.lean), shipped as src/glue/lasm-glue.wasm
    and run in process with only WebAssembly (Node, Bun and Deno alike). The
    output is the same; there is no JavaScript fallback. The wasi-http
    component splicing (src/wasi/wasi-component.mjs) runs in the same program
    the same way (#295).
  • More of the CLI has Lean models with proofs (#263 and #299: #257, #258,
    #269, #271, #278, #279, #281, #282): the link driver's strings, the names
    lasm init generates, the dev server's path resolution, Lean IO errors,
    the reachability link's map reader, insideDirectory, initializer closure
    and the file worker's message codec, each checked against the JavaScript
    by a differential test.

Repository

  • CI and the release build use Node 26.13.1 and 24.22.3 (were 26.13.0 and
    24.22.2; #288). The supported Node range is unchanged.
  • Two scripts the cleanup removed are back (#297):
    scripts/application-tests/classify-mixed.mjs and
    scripts/language-coverage/make-adapter-review.mjs, which regenerate the Lean
    coverage evidence. A test now fails when a workflow or current document
    names a script that does not exist.
  • The release build's pack step uses less memory (#298): it hard-links the
    staged Lean runtime instead of copying it, so its peak fell from about
    1.6 GiB, where the resource guard stopped it at random, to about 1.2 GiB.
    The guard and the package's contents are unchanged.