|
1 | | -## 2026-02-24 — Build iscc-ffi as wasm32-wasip1 module with alloc/dealloc helpers |
| 1 | +## 2026-02-24 — Review of: Build iscc-ffi as wasm32-wasip1 module with alloc/dealloc helpers |
2 | 2 |
|
3 | | -**Done:** Added `iscc_alloc` and `iscc_dealloc` extern "C" functions to the FFI crate for WASM host |
4 | | -memory management. The crate now compiles as a wasm32-wasip1 module, producing a ~10.5MB debug |
5 | | -`.wasm` binary from the existing `cdylib` crate type. |
| 3 | +**Verdict:** PASS |
6 | 4 |
|
7 | | -**Files changed:** |
8 | | - |
9 | | -- `crates/iscc-ffi/src/lib.rs`: Added `iscc_alloc(size) -> *mut u8` and `iscc_dealloc(ptr, size)` |
10 | | - under a `// --- Memory allocation helpers (for WASM host) ---` section, placed between |
11 | | - `clear_last_error` and `result_to_c_string`. Both use `#[unsafe(no_mangle)]` matching the |
12 | | - crate's edition 2024 style. `iscc_alloc` returns a dangling non-null pointer for `size == 0`. |
13 | | - `iscc_dealloc` guards against both null pointers and zero-size frees. |
| 5 | +**Summary:** The advance agent added `iscc_alloc` and `iscc_dealloc` helper functions to the FFI |
| 6 | +crate, enabling WASM host memory management for Go/wazero bindings. The implementation is clean, |
| 7 | +well-documented, correctly handles edge cases (null pointers, zero-size allocations), and compiles |
| 8 | +to a ~10.5MB wasm32-wasip1 module. All existing tests pass unchanged. |
14 | 9 |
|
15 | 10 | **Verification:** |
16 | 11 |
|
17 | | -- [x] `rustup target add wasm32-wasip1` succeeds |
| 12 | +- [x] `rustup target add wasm32-wasip1` succeeds (idempotent) |
18 | 13 | - [x] `cargo build -p iscc-ffi --target wasm32-wasip1` compiles without errors |
19 | | -- [x] `target/wasm32-wasip1/debug/iscc_ffi.wasm` exists (10,992,662 bytes) |
| 14 | +- [x] `ls target/wasm32-wasip1/debug/iscc_ffi.wasm` — file exists (10,992,662 bytes) |
20 | 15 | - [x] `cargo test -p iscc-ffi` passes all 62 existing tests |
21 | 16 | - [x] `cargo clippy -p iscc-ffi -- -D warnings` clean |
22 | 17 | - [x] `grep 'fn iscc_alloc'` returns exactly 1 match |
23 | 18 | - [x] `grep 'fn iscc_dealloc'` returns exactly 1 match |
24 | 19 | - [x] `mise run check` passes all 14 pre-commit hooks |
| 20 | +- [x] No quality gate circumvention in diff |
| 21 | + |
| 22 | +**Issues found:** |
| 23 | + |
| 24 | +- (none) |
25 | 25 |
|
26 | | -**Next:** The WASM module is ready for Go/wazero integration. The next step would be creating the |
27 | | -`packages/go/` directory with the Go wrapper code that loads this `.wasm` module and calls the |
28 | | -exported FFI functions through wazero. |
| 26 | +**Next:** Create the `packages/go/` directory with the Go module scaffold and wazero bridge. This is |
| 27 | +step 2 of the Go bindings multi-step plan: set up `go.mod`, embed the `.wasm` binary, and implement |
| 28 | +the wazero runtime initialization + basic memory helpers that call `iscc_alloc`/`iscc_dealloc`. |
29 | 29 |
|
30 | | -**Notes:** No surprises. The existing `crate-type = ["cdylib", "staticlib"]` in Cargo.toml works |
31 | | -without modification for WASM — cargo produces the `.wasm` from the `cdylib` target automatically. |
32 | | -The debug binary is ~10.5MB; release + wasm-opt would reduce this significantly but is explicitly |
33 | | -out of scope for this step. |
| 30 | +**Notes:** The existing `crate-type = ["cdylib", "staticlib"]` works without modification for WASM |
| 31 | +targets. The `thread_local!` macro in the FFI crate (for error storage) compiles for wasm32-wasip1 |
| 32 | +since WASM is single-threaded. Debug binary is ~10.5MB; release + wasm-opt optimization is a |
| 33 | +separate future step. |
0 commit comments