Skip to content

Latest commit

 

History

History
654 lines (557 loc) · 42.7 KB

local-callable-interface.md

File metadata and controls

654 lines (557 loc) · 42.7 KB

Local callable interface — issues #29–#35

Workspace paths: Compiler implementation and tests now live under crates/compiler/; CLI and browser adapter tests live under crates/cli/tests/ and crates/browser/tests/. The release records below retain their historical paths/commands. Use current validation for rebuild and package selection; this relocation does not change the callable contracts.

Frozen public interface and implementation ownership

Issue #29 implements capture-free local callable declarations and positional lexical invocation. Issue #30 adds shared captures of immediate-creator parameters and ordinary lets of every concrete type: number, bool, string, number[], and range. Captures refer to original shared bindings, never snapshots. Issue #31 adds all five numeric compound operators on captured places, including creator-side promoted bindings. Issue #32 implements nested original-binding capture forwarding and earlier context-requiring callable dependencies in the frontend/backend; validation passed. The parent issue #28 defines the full contract. #33 adds read-only iteration captures. #34 adds recursion, host-reentry and trap lifetime coverage without changing the compiler, public AST or ABI. #35 completes nested/transitive iteration-capture convergence and the full native/browser WP11 release; release gates passed. #30 subset validation passed; that record predates #31 and does not validate captured compounds. The historical #29 evidence below predates shared capture storage.

The confirmed test seams are Compiler::analyze, Compiler::compile_source, Compiler::compile on mutable public typed input, and the existing CLI adapter. Runtime and rebuilt-browser tests use the existing bounded subprocess support and remain ignored by default. Independent Wasm decoding supplements validation and runtime effects.

Public AST consumers must migrate as follows:

  • Raw Expr::Call adds its identifier-through-closing-parenthesis span.
  • Raw StatementKind::Let adds the identifier-only name_span.
  • Raw Expr::Lambda(Lambda) owns explicit parameters, LambdaBody::Expression or Block, and lambda/body byte spans. Parentheses are transparent.
  • CallableId is program-wide in source depth-first preorder, independently of named result-inference scheduling. BindingOwner::{Function, Closure} qualifies original bindings; variable and loop identities remain owner-local.
  • TypedStatementKind::Closure(TypedClosure) owns its parameters, concrete result, TypedClosureBody, declaration/lambda/body spans, captures and dependencies. owner identifies the enclosing owner; the body owner is Closure(id).
  • TypedExprKind::LexicalCall { callable, args, span } is a dedicated positional invocation. No typed lambda value, callable Type, or extra public user function is introduced.
  • TypedCapture identifies an original owner/variable/type/mutability. CaptureMutability distinguishes mutable locals/parameters and read-only for bindings; #30 accepts mutable immediate-creator parameters/ordinary lets, #32 forwards original ancestor parameter/let bindings through every intermediate helper, and #33 records ReadOnly for captured iteration bindings. Captures are unique and canonical by original owner/declaration order, with parameters before locals. Checked lowering derives declaration order independently of numeric VariableId values, since public typed input may use sparse IDs.
  • #30 adds TypedExprKind::Captured { owner: BindingOwner, id: VariableId, name: String }. Migrate exhaustive matches and distinguish captured reads, assignment targets and indexed array bases from owner-local Identifier nodes. Creator accesses remain Identifier, even when their storage is promoted. Matching local IDs in different owners do not identify the same binding.
  • dependencies: Vec<CallableId> records complete, unique earlier visible callable identities in source-preorder ID order, including transitive requirements of nested helpers. #32 supports context-requiring dependencies without changing public shapes; context-free dependencies remain lexical permissions only.

Backend planning borrows declaration-owned bodies, emits direct helpers after all existing runtime helpers, and validates all owners, identities, lexical availability, results, calls and transfers through existing checked lowering. Context-free helpers have only explicit parameters and allocate no callable environment. Ordinary body operations and handle signatures may still require memory.

Immediate pipeline helper ownership (#48)

#44 adds known lexical callable pipeline stages; #45–#47 add placeholder local callables with exact local/collection constraints, control flow and nested regions. #48 implements immediate unary typed-lambda and placeholder stages: 10 |> ((x: number) => x * 2) and 10 |> (_ * 2). They require exactly one parameter and no written arguments. Placeholder parameter types infer only within their region, never from input. Ordinary calls remain identifier-led; this adds neither first-class callable values nor general postfix invocation.

Raw PipelineStage.target: PipelineStageTarget replaces name with Named(String) or Immediate { expression: Expr, expression_span: Span }; immediate args are empty. Existing TypedNormalizedCall constructors add immediate_closure: None. For an immediate stage, Some(TypedClosure) owns the helper body under the lexical owner containing the pipeline; the helper body owner remains Closure(id). Its name is the internal label "<pipeline stage>", never a lexical lookup name. The normalized call invokes that helper directly through LexicalCall, with its sole input supplied by the unique first PipelineInput binding.

Discovery/checking includes the stage-owned helper, while creator-local planning excludes its body. Reuse the existing checked helper lifecycle, source-preorder callable IDs, capture/dependency validation and direct-helper ABI; no second IR or runtime callable representation is introduced. Input executes before creating the stage environment. A trapping/diverging input creates no stage environment or body effects, without skipping static checks. Original captured bindings still use eager shared-cell promotion, including cells allocated before reaching a stage; shared captures, iteration mutability and lifetime rules are unchanged.

See the implemented #48 milestone and public ownership/span migration. Validation is ongoing; integrated WP12 release evidence is pending. WP11 release and #44/#45–#47 milestone records retain their historical scope.

Typed-array interaction (#37)

#37 adds bool[] and string[] to the existing shared-binding/callable contracts, including adapters/runtime. Final #37 release gates passed after the accessor fix (1,251 workspace tests, none ignored; 25 browser smoke groups). #35's record remains evidence for the earlier WP11 surface, not #37. See typed-array contracts and Rust migration.

Array captures share the original handle/binding and mutable storage, including nested forwarding and earlier live callable contexts. Typed indexing and ordinary replacement use the original static element type; only numeric elements support compounds. Iteration yields a read-only bool or string (or existing number) and validates the consumed element before binding/capture promotion/body effects. A captured string iteration value retains its yielded immutable string handle; later replacement of the source array slot does not replace that scalar binding. Alias mutations to future unvisited slots remain visible to iteration.

The private uniform eight-byte capture-cell/environment layout is unchanged; one-byte boolean payloads and four-byte string-array slots do not imply packed capture storage. Preserve fresh per-yield cells, original read-only provenance, transitive forwarding, invocation-local recursion/reentry contexts, monotonic allocation and completed effects after traps. Refresh host views after growth.

Anonymous results remain independently inferred with no new result annotation syntax: let empty = () => []; infers number[], not a later caller's expected array type. Explicit callable parameter types do supply call-argument literal context. Public typed literals now carry ArrayElementType, and typed For adds element_type: Type, independently checked against the iterable even for forged, unreachable or skipped input. See the public migration.

Backend implementation ownership

crates/compiler/src/codegen/closures.rs is a private child module of function.rs, exposed internally as codegen::closures. It owns plan(), BodyEmitter callable declaration lifecycle operations, and emit_closure()'s checked helper lowering. Child-module access keeps emitter state private to function.rs rather than exposing it to sibling modules.

CallablePlan separates immutable planned facts (borrowed declaration, signatures, indices, context requirements and environment layout) from a private OnceCell<CreatorEstablished>. The creator publishes capture_order and lexical_prefix together only after declaration checks and environment lowering succeed, then activates the declaration's lexical availability. This establishes creator facts, not evidence that the helper body has been checked.

ValidatedProgram retains the ordering: complete all layout, check/lower all user functions in source order, then check/lower helpers in source depth-first preorder. emit_closure() checks the helper body and result before exact capture/dependency usage completeness. Cached encoded helper bodies are the evidence of successful helper checks; there is no separate checked boolean. Module assembly consumes those cached bodies rather than checking them again.

A failed compilation discards its plans and partial output; there is no retry or rollback protocol. This ownership refactor preserves exact emitted bytes, errors and check ordering, and runtime allocation behavior. It changes no language, public typed-AST or ABI contract, and adds no release-validation claim.

Implemented shared-capture subset (#30)

Outer and helper reads/writes observe the same binding; ordinary indexed array mutation and array-binding reassignment retain existing alias/type rules. Capture resolution preserves declaration-time initialization and shadowing. Helpers keep independent parameter/local/return/loop contexts. #30 initially supported only immediate-creator captures and earlier context-free callable composition; #32 extends these limits as described below.

#33 removes the former capturing for bindings is not supported in this subset rejection; see the read-only iteration-capture contract. Ordinary read-only-write checks now apply to those captures.

#32 removes the former nested capture forwarding is not supported in this subset and context-requiring callable dependencies are not supported in this subset rejections; ordinary scope, type and mutability checks remain.

Captured parameter cells allocate eagerly in formal order after all parameter validation and ordered contracts; captured let cells allocate only after completing their initializers. Structural promotion can allocate a cell even when a later capturing declaration is skipped. A nonempty environment allocates only when its declaration executes; context-free declarations allocate no environment and add no hidden parameter. Helpers requiring captures or callable contexts receive a hidden first i32 environment argument. No declaration executes its helper body.

See the private layout and lifetime contract for uniform eight-byte cells/slots, allocation traps, monotonic growth and host view refresh obligations. None of this adds a public callable ABI or changes explicit string/array marshaling or external range restrictions.

Implemented captured numeric compounds (#31)

+=, -=, *=, /=, and %= support captured number bindings and elements of captured number[] bindings, as well as creator-side promoted bindings before or after the capturing declaration. The former semantic captured-compound guards are removed; ordinary numeric type, mutability and checked-backend rules remain. Whole-array compounds and compounds on nonnumeric bindings remain invalid.

Lowering uses the existing checked place path in src/codegen/place.rs. Resolve the target once and read its old value before evaluating the RHS. A promoted scalar retains its original cell address and old f64 on the operand stack. An indexed compound saves the original checked element address and old value in the existing i32/f64 scratch slots. RHS mutation, array-binding rebinding, calls or memory growth do not retarget the write or replace the saved old value. Bounds and descriptor failures trap before RHS effects. Ordinary indexed assignment also preserves its checked pre-RHS element address, without a compound old-value read. %= uses the existing exact floating remainder helper.

No new AST form, scratch policy, cell/environment layout or public ABI is added. #32 extends parameter/let forwarding and #33 adds read-only iteration captures as described below. #35 release gates passed. #31 validation passed. The #29/#30 records below retain their historical scope.

Implemented nested captures and callable contexts (#32)

An ancestor parameter/ordinary-let capture keeps its original (BindingOwner, VariableId), concrete type and mutability through every intermediate helper, even when only a deeper descendant reads or writes it. The owning helper uses Identifier for its own binding; descendants use Captured. Forwarding reuses the original shared cell, never snapshots its value or allocates a replacement cell. Initialization and lexical shadowing retain their declaration-time rules.

Earlier visible context-requiring callable dependencies forward the earlier callable's original live environment, including through intermediate helpers with no direct value captures. Requirements stop at the creator that owns the relevant binding or callable declaration. Declaration-before-use and lexical visibility remain mandatory; this adds no self/forward hoisting or callable values.

Environments place canonical original owner/declaration-ordered captures first, then context-requiring dependency slots in source-preorder callable-ID order. Context requirements propagate through earlier dependencies. Context-free dependencies have no slots and introduce no hidden argument or allocation of their own. A helper with either captures or contextful dependencies receives a hidden first i32; a truly context-free helper retains only explicit parameters. All slots use the existing private eight-byte layout and allocation timing.

Checked lowering independently verifies complete, unique, canonical metadata, including requirements used only by descendants. Missing/extra entries, wrong owners/types/mutability, uninitialized or invisible bindings, invalid dependency visibility/order and forged sparse variable IDs retain checked diagnostics. Helpers remain borrowed, direct and unexported; no public typed shape changes. #33 adds iteration captures below; #35 validates their composition with nested forwarding and transitive live callable dependencies through the same storage path.

Implemented read-only iteration captures (#33)

Closures may read the numeric iteration binding of a range or number[] for. The frontend records CaptureMutability::ReadOnly. Before lowering helpers, the backend independently derives mutability from the original For binding's BindingKind::Iteration provenance and checks capture metadata against it; public metadata cannot grant write permission. Ordinary assignment and all five numeric compound writes (+=, -=, *=, /=, %=) to captured iteration bindings are rejected, including skipped and unreachable writes. Distinct shadowing lets retain their own mutability.

The existing promotion path runs for each successfully yielded captured binding, before the body: after the range endpoint test and conversion/local set, or after the checked array element load/local set. It allocates a fresh uniform eight-byte cell for every yielded iteration, rather than reusing a previous iteration's cell. Promotion is eager and structural even if the capturing declaration is skipped. Empty/exhausted loops and failed yields allocate no iteration cell. Nonempty environments still allocate only when their declarations execute.

Cells remain monotonic: they are neither reused nor reclaimed. Allocation may grow memory or trap without rollback. Endpoint-before-conversion range behavior, checked array loads, continue/break/return targets, array alias visibility and all existing loop/control semantics remain intact. There is no AST or ABI shape change; see the private storage contract.

#35 validates combined nested/transitive iteration captures in the full WP11 release. #33 validation passed for the earlier read-only iteration-capture subset, not the full WP11 contract.

Capture lifetime across recursion, reentry and traps (#34)

Each named creator invocation owns distinct parameter/local cells and declaration environments, including recursive calls made from helpers and synchronous host reentry into the same instance. Nested helpers and earlier callable dependencies share only their invocation's original live cells/environments. Returning from an inner call or catching its trap in a host callback leaves the suspended outer invocation's context intact.

Cells, environments, arrays and host-created strings use the same monotonic allocator. There is no general heap reset, frame reclamation or trap-unwind cleanup. A guest bounds trap or host allocation trap preserves completed writes, host effects and earlier successful allocations; the instance can be called again. Retained array/string descriptor offsets remain valid across those calls and memory growth, provided hosts preserve the existing descriptor and string rules. Refresh JavaScript views after any possibly growing operation, including reentry from a host callback; retain offsets, not views into an old buffer.

Repeated bounded calls can still consume unbounded cumulative storage until allocation fails. This is not garbage collection, transactional rollback, host isolation, guest fuel or process-tree cancellation. No separate frame allocator, new dependency or optimizer change is introduced. #35 validates these existing lifetime scenarios alongside nested/transitive iteration-capture convergence.

Coverage at the confirmed seams:

  • tests/closures_lowering.rs validates/decodes invocation-local environment pointers across host/recursive calls, allocator-only heap-global writes, direct nested dependency forwarding, import order and analyzed host snapshots.
  • tests/closures_runtime.rs checks bounded nested recursion, host reentry with a caught inner trap, post-trap calls, retained mutable arrays and independently specified host UTF-8 bytes, and actual capture-driven memory growth. All four optimization levels must produce identical bytes and literal expected events.
  • tests/closures_adapters.rs checks CLI/core byte parity and host-retained arrays across recursive/reentrant calls, a helper trap, later allocations and actual host allocator-driven memory growth, at all four optimization levels.

The new scenarios passed against the existing implementation on their first run; no compiler defect or behavior change was needed. Runtime/adapter execution stays ignored by default and uses the existing bounded subprocess support.

Issue #34 validation (2026-10-15)

Node.js v24.12.0, cargo 1.98.0 and wasm-pack 0.15.0 were available. No tools or dependencies were added. The browser rebuild used offline/no-install mode and cached wasm-bindgen tooling; its output still included Installing wasm-bindgen.

Exact command (repository root) Result
cargo test --offline --test closures_runtime recursive_creators_keep_original_cells_and_nested_live_dependencies_per_invocation -- --ignored --exact Passed; all four optimization levels
cargo test --offline --test closures_runtime reentrant_live_contexts_and_retained_handles_survive_inner_traps_and_growth -- --ignored --exact Passed; all four optimization levels
cargo test --offline --test closures_lowering recursive_contexts_keep_local_environment_pointers_and_only_allocator_writes_heap -- --exact Passed; all four optimization levels
cargo test --offline --test closures_adapters cli_capture_lifetime_survives_recursion_reentry_trap_and_memory_growth -- --ignored --exact Passed; adapter agent and independent reviewer each ran it
cargo check --offline --test closures_adapters Passed; adapter agent
cargo check --offline --all-targets Passed
cargo test --offline --test closures_frontend --test closures_lowering --test closures_runtime --test closures_adapters -- --include-ignored Passed: 34 frontend, 48 lowering, 25 runtime, 5 adapter tests
wasm-pack build browser --target web --out-dir ../pkg --out-name was_compiler --mode no-install --no-opt --offline Passed; rebuilt current-source browser package
node tests/browser.cjs pkg Passed
cargo test --offline Passed complete default suite
cargo test --offline -- --include-ignored Passed complete suite, including runtime/browser cases
cargo clippy --offline --all-targets -- -D warnings Passed
cargo clippy --offline -p was-compiler-browser --target wasm32-unknown-unknown --lib -- -D warnings Passed
git --no-pager diff --check Passed; lifetime section anchor and seven local links also checked

Independent standards review found no documented-standard breach and one optional low-priority duplication smell in adapter execution boilerplate; it was retained to keep scenarios local rather than add a test abstraction. Independent spec review found no missing requirements, wrong behavior or scope creep, and independently reran all four new tests successfully. This is #34 lifetime evidence, not full WP11 release validation. No runtime prerequisite was missing.

Issue #35 WP11 release validation (2026-10-15)

WP11 is implemented and release-validated through the core library, native CLI and freshly rebuilt browser adapter. #35 adds integration tests and reconciles documentation; the existing compiler required no behavior, AST or ABI changes. The accepted ownership/storage ADR and glossary remain authoritative. Earlier #29–#34 records retain their historical scope and counts. This closes the WP11 release gate only: WP12 placeholders/callable pipeline stages and separately authorized WP13 optimization remain outside this work. Immediate invocation, first-class/escaping callables, reclamation and heap rewind remain unsupported.

Integrated acceptance evidence

  • tests/closures_frontend.rs: 37 tests, including original owner/variable/type/read-only provenance through nested range/array captures, canonical transitive dependencies, shadowing and all six write forms rejected even when skipped/unreachable.
  • tests/closures_lowering.rs: 51 tests, including independent decoding of the complete integrated 19-function signature/helper order, capture-before-context slots, direct call targets, creator/helper local separation and source order despite inference dependencies. Both iteration nesting directions receive forged metadata and unreachable-write checks. Existing tests cover sparse IDs, host snapshots/import order, external eligibility, memory exports/collisions, context-free memory omission, no tables/indirect calls/helper exports and all-body checking.
  • tests/closures_runtime.rs: 27 ignored-by-default tests. New scenarios compose nested range/array iteration captures, intermediate helpers, transitive original live environments, all five scalar/indexed compounds and RHS array rebinding with named/default calls, contracts, pipelines and matches. Literal expected events and results supplement Wasm validation at all four optimization levels. Existing #34 recursion/reentry/trap/retained-handle/growth tests ran as part of the release.
  • tests/closures_adapters.rs: 7 tests, 4 ignored by default. CLI bytes/WAT match library output and freshly rebuilt browser output across optimization/export selections. The integrated range/array/dependency/indexed-rebinding scenario executes repeatedly in CLI output and in browser-compiled Wasm, yielding 373 and events [19, 111, 111, 113]. Nested read-only errors preserve variants/reasons and independently located byte spans with Unicode, comments, tabs and CRLF. A literal EOF error span 48..48 additionally checks native/browser rendering, CLI exit 1, unchanged destinations and no temporary artifacts. Existing lifetime adapter execution also passed. Bounded subprocesses do not provide guest fuel, process-tree cancellation or transactional rollback.
  • The complete default and include-ignored suites preserve ordinary features, compatibility fixtures, export selection, host integration and option parity. No fixtures were regenerated and no dependencies or tooling were installed.

Prerequisites and exact validation commands

Windows native target x86_64-pc-windows-msvc; Node.js v24.12.0, cargo 1.98.0 (797e8a9bc 2026-08-05), rustc 1.98.0 (88d9e12ae 2026-08-18), wasm-pack 0.15.0, installed wasm32-unknown-unknown, and cached Rust dependencies were available. wasm-bindgen was not on PATH; wasm-pack's existing local cache contained compatible 0.2.129 (also 0.2.128). The offline/no-install rebuild succeeded; its progress text still said Installing wasm-bindgen, not evidence of an actual installation. No missing prerequisite or unrelated test failure blocked release. Initial adapter test authoring exposed a private-Span-field pattern and an incorrect hand-added expected sum (473 rather than 373); both test mistakes were corrected without changing production behavior.

All commands below ran from the repository root, with bounded execution:

Exact command Result
cargo check --offline --all-targets Passed before and after integration
cargo test --offline --test closures_lowering nested_iteration Passed, 3 integrated tests
cargo test --offline --test closures_lowering Passed, 51 tests
cargo test --offline --test closures_adapters -- --include-ignored Passed, 7 tests
wasm-pack build browser --target web --out-dir ../pkg --out-name was_compiler --mode no-install --no-opt --offline Passed; current-source package rebuilt before browser/full ignored tests
node tests/browser.cjs pkg Passed, 25 tests
cargo test --offline --test closures_frontend --test closures_lowering --test closures_runtime --test closures_adapters -- --include-ignored Passed: 37 frontend, 51 lowering, 27 runtime, 7 adapter tests
cargo test --offline Passed complete default suite; runtime/browser ignore policy retained
cargo test --offline -- --include-ignored Passed complete suite, including runtime/browser coverage
cargo clippy --offline --all-targets -- -D warnings Passed
cargo clippy --offline -p was-compiler-browser --target wasm32-unknown-unknown --lib -- -D warnings Passed
rustfmt --edition 2024 --config skip_children=true tests/closures_frontend.rs tests/closures_lowering.rs tests/closures_runtime.rs tests/closures_adapters.rs Passed; edited files only
git --no-pager diff --check Passed; only Git LF/CRLF notices

Independent standards review found no documented-standard breaches and one optional low-priority repeated-switch smell in a new forged-metadata test. Its diagnostic reason and expected origin now come from one local match; the three integrated lowering tests and targeted Clippy passed again. Independent spec review found no missing requirement, wrong behavior or scope creep and reran integrated cases and all seven adapter tests successfully. The standards reviewer independently reran all 122 closure tests with ignored cases included. Review used the pre-task commit 96f5bf27a6bf9d8f37406a18a8129b34133bcea0 against the working tree. After the review adjustment, both full Cargo suites and both Clippy gates passed again. Final documentation checks resolved 499 local link paths and all 44 #35 release-anchor references; whitespace/status review passed.

Issue #33 validation (2026-10-15)

Validation passed for #33's read-only range/array iteration-capture subset, as reported by the integration owner and runtime-suite agent. Node.js v24.12.0 and wasm-pack 0.15.0 were available; no tools were installed. The browser build used --mode no-install and cached wasm-bindgen tooling even though its output included Installing wasm-bindgen. Current-source browser bindings were rebuilt before browser validation and the full include-ignored run.

Exact command (repository root) Result
cargo check --offline Passed during implementation slices
cargo check --offline --all-targets Passed; passed again after the review-driven assertion change
cargo test --offline --test closures_frontend --test closures_lowering --test closures_adapters Passed: 34 frontend, 47 lowering, 2 default adapter tests; 2 adapter tests ignored by default
cargo test --offline --test closures_runtime -- --ignored Runtime-suite agent reported 23 passed, exercising all four optimization levels
cargo test --offline --test closures_frontend --test closures_lowering --test closures_runtime --test closures_adapters -- --include-ignored Passed final focused run: 34 frontend, 47 lowering, 23 runtime and 4 adapter tests
wasm-pack build browser --target web --out-dir ../pkg --out-name was_compiler --mode no-install --no-opt --offline Passed; rebuilt current-source browser package
node tests/browser.cjs pkg Passed
cargo test --offline Passed complete default suite
cargo test --offline -- --include-ignored Passed complete suite including ignored runtime/browser cases
cargo clippy --offline --all-targets -- -D warnings Passed
cargo clippy --offline -p was-compiler-browser --target wasm32-unknown-unknown --lib -- -D warnings Passed
git --no-pager diff --check Passed

Independent review found no behavioral defect or standards violation, only optional code smells. One weak branch-depth assertion was strengthened to require the exact nested-region sequence [BrIf1, Br3, Br5, Br0, Br0], plus an explicit continue latch followed by induction add/set/backedge. The subsequent closures_lowering rerun passed all 47 tests, and the all-target check passed again. This was a test-strength improvement, not a compiler behavior fix.

The final focused include-ignored run and a subsequent full repository include-ignored rerun passed after the strengthened lowering assertions and all-five-compound forged-write checks. Runtime/browser tests retain their ignored-by-default policy.

This validated #33's read-only iteration-capture subset. At that checkpoint, combined nested/transitive iteration-capture convergence and full WP11 release remained deferred; #35's later release record above supersedes that status. Earlier issue records below retain their historical scope.

Issue #32 validation (2026-10-14)

Final integrated validation passed, as reported by the parent/integration owner. Node.js v24.12.0, wasm-pack 0.15.0, the Wasm target, compatible tooling and cached dependencies were available; the agent installed no dependencies or tooling. Browser bindings were rebuilt from current source before the final browser, focused closure-suite and full include-ignored runs.

Exact command (repository root) Final result
cargo check --offline --all-targets Passed
cargo test --offline --test closures_frontend --test closures_lowering --test closures_runtime --test closures_adapters -- --include-ignored Passed: 33 frontend, 44 lowering, 17 runtime and 4 adapter tests
wasm-pack build browser --target web --out-dir ../pkg --out-name was_compiler --mode no-install --no-opt --offline Passed; rebuilt current-source browser package before final browser/focused/include-ignored coverage
node tests/browser.cjs pkg Passed: 25 cases
cargo test --offline Passed complete default suite
cargo test --offline -- --include-ignored Passed complete suite including ignored runtime/browser cases
cargo clippy --offline --all-targets -- -D warnings Passed
cargo clippy --offline -p was-compiler-browser --target wasm32-unknown-unknown --lib -- -D warnings Passed
git --no-pager diff --check Passed

Frontend and forged-input/decoded-lowering coverage checks original-binding forwarding, complete canonical metadata and capture-before-dependency slot layout. New runtime cases verify original shared cells through shadowing helper parameters and locals, plus dependency-only intermediate helpers, at all four optimization levels. The adapter fixture exercises nested captures and live callable dependencies through native/browser byte parity and the CLI. Runtime/browser cases retain their ignored-by-default policy; the explicit runs above establish execution coverage.

The initial adapter run failed because two obsolete rejection fixtures used syntax now allowed by #32. They were replaced with still-deferred captured-for rejection cases; the final reruns passed.

Two-axis review compared the working diff against 28ecae41224ff31ca299c2d9e568f53d38b99b32. Spec reported zero findings; Standards reported zero breaches or bugs and one nonblocking judgment call about possible primitive obsession in the capture-order tuple. The small internal tuple was retained without adding an abstraction.

This validates #32's nested original-binding capture and live callable-context forwarding subset, not parent #28 or full WP11 release. Captured for bindings and full WP11 release remain deferred. Historical #29–#31 evidence below retains its original scope.

Issue #31 validation (2026-10-14)

The integrated captured-place subset passed the following offline checks. Node.js v24.12.0, wasm-pack 0.15.0, the Wasm target and cached dependencies were available; no dependencies or tooling were installed. Browser bindings were rebuilt from current source before the final browser and include-ignored runs.

Exact command (repository root) Result
cargo check --offline --all-targets Passed
cargo test --offline --test closures_frontend --test closures_lowering --test closures_runtime --test closures_adapters -- --include-ignored Passed: 29 frontend, 40 lowering, 15 runtime and 4 adapter tests
wasm-pack build browser --target web --out-dir ../pkg --out-name was_compiler --mode no-install --no-opt --offline Passed; rebuilt current-source browser package
node tests/browser.cjs pkg Passed: 25 cases
cargo test --offline Passed complete default suite
cargo test --offline -- --include-ignored Passed complete suite including ignored runtime/browser cases
cargo clippy --offline --all-targets -- -D warnings Passed
cargo clippy --offline -p was-compiler-browser --target wasm32-unknown-unknown --lib -- -D warnings Passed
git --no-pager diff --check Passed

Red-first frontend and forged-input tests demonstrated the former subset rejection before implementation. Coverage now includes all five captured scalar/indexed compounds, creator-side promotion before declarations, saved places and old values through RHS mutation/rebinding, aliases, descriptor/bounds traps before RHS events, independent IEEE-754 expectations, and abrupt RHS transfers. Decoded instruction and scratch assertions supplement wasmparser::Validator; bounded execution checks observable effects at all four optimization levels. CLI bytes/WAT match the core. Runtime/browser cases retain their ignored-by-default policy.

The first integrated run exposed two test-fixture errors, not compiler defects: a CLI expectation omitted a later scalar reset, and a transfer case used an out-of-bounds array index. Both were corrected using independent source arithmetic and intended event order before the successful final runs.

Both Standards and Spec reviews compared the uncommitted implementation with starting HEAD c7af8b16bd4a6cbc2172501c95626745e5833e27 and reported no actionable findings. This validates #31's captured-place slice, not the deferred parent #28 or full WP11 release.

Issue #30 validation (2026-10-14)

Final validation on the current integrated code passed after review fixes, as reported by the integration owner. Node.js v24.12.0 and wasm-pack 0.15.0 were available with the Wasm target, compatible bindings tooling and cached dependencies; no tooling or dependencies were installed. Browser bindings were rebuilt from current source before the final browser and include-ignored coverage.

Exact command (repository root) Final result
cargo check --offline --all-targets Passed
cargo test --offline --test closures_frontend --test closures_lowering --test closures_runtime --test closures_adapters -- --include-ignored Passed: 27 frontend, 34 lowering, 10 runtime and 3 adapter tests, including rebuilt-browser coverage
wasm-pack build browser --target web --out-dir ../pkg --out-name was_compiler --mode no-install --no-opt --offline Passed; rebuilt current-source browser package
node tests/browser.cjs pkg Passed: 25 cases
cargo test --offline Passed complete default suite
cargo test --offline -- --include-ignored Passed complete suite including ignored runtime/browser cases
cargo clippy --offline --all-targets -- -D warnings Passed
cargo clippy --offline -p was-compiler-browser --target wasm32-unknown-unknown --lib -- -D warnings Passed
git --no-pager diff --check Passed

Runtime coverage includes independent allocation counts, parameter validation and ordered contracts before parameter-cell promotion, and noncompleting initializers allocating no corresponding let cell. Cases cover shared mutation across all concrete types, lexical shadowing, array-binding rebinding, recursive and host- reentrant creators, and post-trap retained handles remaining valid across memory growth. These explicit runtime/browser runs, not default Cargo success alone, establish the subset's execution coverage. The ignored-by-default policy remains unchanged.

Review compared the uncommitted implementation against starting HEAD b797d480689f166366ab0360b576c56f89e4ea64. The Spec review found no findings. The Standards review found a linear capture-access scan and duplicate compound- place bookkeeping across repeated inference/body checks. Owner-qualified lookup and ordered deduplication fixed those hot paths, with regression tests preserving first-error order and repeated analysis. Both fixes were re-reviewed with no remaining findings; final body checks remain intact without AST cloning.

This validates only #30's immediate-creator parameter/ordinary-let capture subset. At that checkpoint, nested forwarding, context-requiring callable dependencies, captured compound places and captured for bindings remained deferred, as did full WP11 release. #31 subsequently implements captured numeric compounds; this record does not validate that extension. No parent #28 release or broader WP11 acceptance claim follows from these results. The historical #29 evidence below retains its original scope and counts.

Historical #29 implementation ownership

Exclusive implementation write scopes for #29:

  • Frontend integration: tokens/lexer/parser/grammar, src/semantic.rs and src/semantic/, frontend constructor migrations, tests/closures_frontend.rs.
  • Backend integration: src/codegen/, backend constructor migrations, tests/closures_lowering.rs.
  • Integration owner: public src/ast.rs and src/typed_ast.rs, runtime/adapter tests, documentation and final validation. Public shapes above are frozen before work is dispatched; changes require coordination with the integration owner.

Historical #29 subset validation — 2026-10-14

The #29 subset is implemented and validated, not full shared-capture WP11. Frontend/lowering suites each pass 22 tests. The seven Node runtime tests and three adapter tests (including rebuilt-browser parity) pass when explicitly run. Default runs keep the seven Node and one browser cases ignored.

Actual successful commands from the repository root:

cargo check --offline
cargo test --offline --test closures_frontend --test closures_lowering
cargo test --offline --test closures_runtime --test closures_adapters -- --include-ignored
wasm-pack build browser --target web --out-dir ../pkg --out-name was_compiler --mode no-install --no-opt --offline
node tests/browser.cjs pkg
cargo test --offline
cargo test --offline -- --include-ignored
cargo clippy --offline --all-targets -- -D warnings
cargo clippy --offline -p was-compiler-browser --target wasm32-unknown-unknown --lib -- -D warnings
git --no-pager diff --check

Node v24.12.0, wasm-pack 0.15.0 and the installed Wasm target/cached dependencies were available. The browser package was rebuilt after the final compiler changes; its existing browser smoke suite passed 25 cases, and the dedicated closure adapter compared current-source native/browser bytes, WAT, bounded execution and rendered diagnostics at all four optimization levels and three export selections.

Review used the starting commit 9b4d172636acf9d7ab386d32ea86f1f916c0f509 against the uncommitted implementation (the requested review precedes commit). The spec axis found no actionable deviations. The standards axis identified exponential nested inference and quadratic retained callable-permission snapshots; both were fixed and re-reviewed. Concrete closure-result memoization retains final body checks, while fixed-size lexical predecessor links preserve declaration-time permissions and forged missing-dependency diagnostics. Regression coverage includes depth-16 declarations and 2,048 independent sibling helpers. An earlier 120-second default-suite attempt timed out; the final bounded broader runs above succeeded.

These runs covered #29 before shared capture storage was implemented. They do not validate #30's cells/environments or establish full WP11 parent acceptance gates. See the separate #30 validation record for the #30 shared-capture subset, before #31 captured compounds.