Skip to content

CL-25: lexlean check on wasm32-wasip1 (#494) - #503

Merged
afflom merged 5 commits into
release/v0.4from
claude/wasi-check-494
Nov 15, 2026
Merged

afflom merged 5 commits into
release/v0.4from
claude/wasi-check-494

Conversation

@humuhumu33

@humuhumu33 humuhumu33 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Closes #494.

Draft proposal. It answers the scope review on #494 by fixing each boundary in SPEC.md before any scope is chosen. The 0.3.0 demonstration is not evidence here; everything below was measured on release/v0.4 at 465b8ab00. Native behavior and native error guarantees are unchanged.

The boundaries (SPEC.md §8.3, new paragraph; CL-25)

Review point What this does
target_family = "wasm" implies nothing about the host Every gate is target_os = "wasi". The claim names wasm32-wasip1 and check only.
LLC0104 must not be dropped On WASI a file's identity is the device and inode WASI's stat reports, read through rustix (already a shipped dependency, safe API). same-file refuses every path there, so it and fs4 become non-WASI dependencies. A hard-linked module is LLC0104 on both hosts.
Locking must not be dropped, and one writer must not be assumed WASI has no file lock, so on WASI acquire_lock refuses with LLV7010 before it touches the project. That refuses lock, fmt, build, verify and migrate. check takes no lock.
A trap must not replace LLS8002 The executable is linked with an 80 MiB stack (config::WASI_STACK_BYTES). That one constant is what build.rs links with (-zstack-size) and what compile_stack_plan caps the hosted depth with. The hosted depth on WASI is 1,024, and deeper input is LLS8002 naming both bounds. Stated host requirement: an engine call stack at least Node 22's default. An embedder that links the library into its own module links at least WASI_STACK_BYTES.
Check-only stays distinct §8.3 claims check. Verification and production stay native, and are refused on WASI before they start.

What changed, site by site

Site Change
crates/lexlean/Cargo.toml fs4 and same-file for cfg(not(target_os = "wasi")); rustix with fs for WASI.
api.rs acquire_lock On WASI, a separate definition that refuses with LLV7010. The native definition is byte for byte as before.
project.rs all_modules file_identity: same_file::Handle natively, (st_dev, st_ino) on WASI.
link.rs check_project On WASI, a separate definition that runs check_project_inline on the one stack. The native thread path is unchanged.
config.rs, wasi_stack.rs, build.rs MAX_COMPILE_STACK_BYTES is WASI_STACK_BYTES on WASI, and build.rs links the executable with it.
lib.rs embedded_digest A worker that cannot be spawned reads on the calling thread, as identity_bytes already does. No target gate. Natively every spawn succeeds as before, and the rows and the digest are the same.
verify/lifeline.rs An end_leader for WASI that reports failure. No process is ever started there.
backend/core.rs on_stack_for Unchanged: a failed spawn is already a typed LLS8002.

The 0.3.0 patch's other site is not needed any more. Register: 493 → 494 (§31, model/ids.toml, RP-07 counts, README). §8.5 roles name the WASI split. The CHANGELOG entry and the VERIFICATION.md record are included.

The test (conformance_cl_25)

It builds lexlean for wasm32-wasip1 from the tree (release profile), runs it under Node's node:wasi over the real file system, and compares it with lexlean::cli::run as the fixture runner calls it:

  • every single-step check fixture of §28.2 with no toolchain, overlay or environment of its own, and every example: same exit code, same stdout and stderr, byte for byte;
  • a hard-linked module: LLC0104 on both builds, identical output;
  • fmt on WASI: exit 3, LLV7010, project unchanged;
  • max_scope_depth = 100000000 with nesting 1,000 (identical to native) and 1,040 (LLS8002, exit 4, on WASI).

On the normative host a missing node or a missing target standard library fails the case. Elsewhere the case says it did not run. CI's vv legs add the target with rustup target add wasm32-wasip1; rust-toolchain.toml is untouched, because the export custody records its bytes. The case stays in the rest remainder. On a shared 12-core host it cost the release wasm build (15 to 20 min; release here is thin LTO and one codegen unit) plus 435 s for the case; a part of its own would need rows in bdd-parts.json, vv-rows.json and intel-host-lanes.json, which is the maintainers' call.

Node 22 collects garbage inside its fast call of WASI path_filestat_get and dies with SIGSEGV on language-1.2 projects (backtrace: uvwasi_path_filestat_get → MallocImpl → Heap::CollectGarbage). The host runs with --no-turbo-fast-api-calls, which avoids that call path. This is a Node defect, not a LexLean one.

Measured

On Linux x86-64 (WSL Ubuntu, a host shared with other builds), Rust 1.97.1, Node 22.22.2, base 465b8ab00:

What Result
cargo fmt --all -- --check pass
cargo xtask validate-model pass: 494 IDs, 86 codes, audits clean (audit-shipped included)
cargo xtask validate-spec-links pass: 494 rows
cargo clippy --workspace --all-targets --all-features -- -D warnings pass
cargo clippy -p lexlean --target wasm32-wasip1 --lib --bins -- -D warnings pass (--all-targets cannot build for WASI: the dev-dependency proptest pulls wait-timeout, which has no WASI implementation)
cargo build --release --target wasm32-wasip1 -p lexlean --bin lexlean 49.5 MB, imports only wasi_snapshot_preview1, initial memory 115 MiB (80 MiB of it the linked stack)
conformance_cl_25 pass, 435 s: 277 projects identical, plus the hard-link, fmt, and depth vectors
cargo test -p lexlean unit tests 225 passed; end_children 9 of 10: a_signal_the_host_did_not_handle_ends_it_by_default fails identically on untouched release/v0.4 (465b8ab00) when run the same way. My runs were detached background jobs, which start with SIGQUIT ignored, so its host never receives the default action. Not a defect of either tree; CI runs it in the normal way
Prism's corpus (17 projects from the Prism AI Foundry repository, both selection scopes, plus a two-module project with its own lock), native vs WASI from this commit 35 of 35 identical exit codes and JSON (LLT4001, LLP2001, LLL1004 refusals and passes). About 1.0 to 1.3 s a check under Node, the 1.2 identity computed each process.

Planted defect: build.rs without the stack link argument. conformance_cl_25 still agrees on the 277 projects and then fails at CL-25: nesting 1000 on WASI with RuntimeError: memory access out of bounds. Restored, it passes. Recorded in VERIFICATION.md.

Not tested

  • just vv whole. Lean verification, examples, golden, repro and the full bdd were not run locally (shared machine). CI runs them on this PR.
  • cargo deny with the new WASI-only edge (rustix → libc for WASI).
  • Browsers, wasmtime, or any WASI host but Node 22.22.2 on Linux x86-64.
  • Hosts whose call stack is smaller than Node's default.
  • wasm32-wasip1-threads and wasm32-wasip2, which this does not claim.

For a maintainer

  • Is a check-only WASI host, with mutating commands refused, the scope you want? Or should lock be allowed under a host-declared single-writer contract?
  • 80 MiB of linked stack is the cost of keeping depth 1,024 typed. A smaller constant gives a smaller hosted depth with the same LLS8002 guarantee.
  • Whether CL-25 should get a part of its own.

🤖 Generated with Claude Code

WASI has no threads, no file lock and no processes, so check runs there
with each boundary stated in SPEC.md §8.3 and native code unchanged:

- File identity on WASI is the device and inode of WASI stat, read through
  rustix; a module with two names of one file is still LLC0104. fs4 and
  same-file are dependencies of the other targets only.
- acquire_lock refuses with LLV7010 on WASI before touching the project, so
  only check (which takes no lock) runs there.
- check_project runs on the one stack, and the executable is linked with
  config::WASI_STACK_BYTES (80 MiB), which build.rs links and the depth plan
  caps with, so deep input is LLS8002 at a hosted depth of 1,024, not a trap.
- embedded_digest reads on the calling thread when no worker can be had.
- lifeline has an end_leader for WASI that reports failure.

conformance_cl_25 builds the target and compares it with lexlean::cli::run
under Node's node:wasi on every single-step check fixture and every example
(277 projects), a hard-linked module, a refused fmt, and nesting 1,000 and
1,040. Register 493 -> 494; VERIFICATION.md records the run and a planted
defect (no linked stack) that the depth vector catches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@afflom afflom left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bounded review at5f88a303. Engineering direction: retain the narrowly specified WASI checker with mutating/certifying operations refused; do not infer a private filesystem or single writer. Keep the present CL case in rest until actual scheduling evidence warrants another partition. The explicit80MiB linked-stack/host-depth contract can be reviewed as stated; no new benchmark or smaller-stack experiment is requested. Full/native proof obligations and exact future WASI variant qualification remain unchanged.

P2 — init misses the early-refusal boundary. CLI Init reaches init_project; around cli.rs904 it creates the destination, and write_skeleton writes project files before Engine::lock reaches the WASI LLV7010 refusal. Cleanup after the error does not satisfy the promised refusal before touching the project. Put the capability refusal before creation/writes and cover this entry point alongside fmt, reusing the same built WASI binary.

P2 — Coordinate the claim ID. Existing #439 head15c667 reserves CL-25 for lexlean snapshot. #503 uses CL-25 for WASI. Reconcile one unique allocation and its register/scenario/test/spec references with that owner before the release lines meet; account authorship does not make the reservation free.

Concrete overhead reduction: .github/workflows/ci.yml adds the WASI target unconditionally to every vv matrix leg, although this case runs only in rest. Condition that existing install step on matrix.part == 'rest'. This removes demonstrated unrelated installations while retaining honesty dependencies and complete test coverage; no extra BDD partition is needed for that correction.

The inspected WASI stat identity check, typed lock refusal and native/default paths remain; digest spawn failure now falls back on the calling thread on native too, so qualify the body's 'unchanged' wording for that resource-failure behavior. No concrete digest error was demonstrated. Existing owner retains implementation and qualification. No local build, runtime, log or producer was repeated; neither #494 nor this draft is complete.

The case cleared Node's whole environment, PATH included, so a runner
whose node is found only through PATH could not start it. The WASI
program's own environment is still empty (host.mjs passes env: {}).
The README's capability row names CL-01..CL-25 and check on
wasm32-wasip1, as RP-11 requires of the register's last CL ID.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The register is 497 IDs (496 on the line + CL-25): §31's total, RP-07's
two checks and the README line follow; CONFORMANCE.md and ERRORS.md are
rewritten by validate-model --write. Cargo.toml and build.rs keep both
the WASI target dependencies and stack link argument and the line's
rustc-address build dependency and production-data feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX
@afflom
afflom marked this pull request as ready for review November 14, 2026 22:02
claude and others added 2 commits November 15, 2026 00:04
Brings in #535 (Intel macOS on the line). The only conflict was the
Unreleased CHANGELOG list; both entries are kept. #535 adds no register
IDs, so the count stays 497.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX
@afflom
afflom merged commit 4f4c684 into release/v0.4 Nov 15, 2026
68 checks passed
@afflom
afflom deleted the claude/wasi-check-494 branch November 15, 2026 06:41
afflom pushed a commit that referenced this pull request Nov 15, 2026
afflom pushed a commit that referenced this pull request Nov 15, 2026
Keep both MAX_COMPILE_STACK_BYTES definitions from #503 (native and
WASI) at the crate visibility this PR needs for on_stack callers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3M8ULnzEQwLLngyBBX

afflom commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Post-landing audit: actual4f4c684d has a different tree from final proposal0fd089b7, with two incoming #536 paths. Proposal43670404538 finished64 successful jobs/764 successful steps and3 skipped Intel obligations; exact proposal reproducibility passed. Actual43686612111 remains pending, while actual reproducibility43686612035 passed all seven steps. These receipts do not establish full premerge or actual-tree acceptance under the standing instruction.

Final-source disposition now confirms all four earlier findings remain at0fd089b7 and actual4f4c (relevant blobs unchanged into the landing):

  • crates/lexlean/src/cli.rs:912,936,956: init creates the directory/writes the skeleton before lock refusal. The WASI case at crates/conformance/src/cases/wasi.rs:303–321 still covers fmt only. Refuse init before writes and assert absent/empty destinations remain unchanged using the same built binary.
  • wasi.rs:1: CL25 remains allocated to WASI while open Execute native Host commands with modeled effects and mirrored validation #439 still reserves CL25 for snapshot. Coordinate a unique allocation and update authoritative register/scenario/test/spec references.
  • .github/workflows/ci.yml:317: WASI target installation is unconditional although the case belongs to rest. Condition the existing step on matrix.part == 'rest'; no new partition is needed.
  • The PR body still claims unchanged native guarantees/every native spawn succeeds, while crates/lexlean/src/lib.rs:278–284 falls back to the calling thread on spawn failure. Qualify that resource-failure behavior; this is not a claim of a wrong digest result.

Independent final-source receipt ff07e702706d715914bdff305b63c428b669311c7f402ef01b81fe90a2b4ca53 reuses the completed actual audit e9fc1f9a; no gates/logs/producers were repeated. Existing owner retains the corrective batch and qualification. #494 remains open. No skipped/canceled aggregation, retrospective approval, retry, CI control or stopped-runtime adoption.

humuhumu33 added a commit that referenced this pull request Nov 15, 2026
…#535, #536) into the arrays branch

The generated outputs that both sides rewrote take release/v0.4's copy, or
are removed where the line no longer has them; regenerate.yml rewrites the
whole set from this tree.

Lean moves to 4.32.2 with #518, so the array authority follows the other Lean
rows: LEAN-ARRAY-4-32-1 becomes LEAN-ARRAY-4-32-2, cited at f3b06c705e6c.
The three files its statement rests on (src/include/lean/lean.h,
src/Init/Prelude.lean, src/Init/Data/Array/Set.lean) are byte-identical at
f054605aea4b and f3b06c705e6c, so the statement carries over unchanged.

runtime-1.2/library.toml keeps the line's toolchain and the branch's Arrays
module. LANGUAGE_1_2_SEMANTICS_ID is the merged tree's, as RP-10 recomputes it.
CHANGELOG and VERIFICATION keep both sides' entries.

Co-Authored-By: Claude Opus 5.5 <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.

3 participants