Skip to content

feat(napi): let the embedder choose the WebAssembly policy - #98

Closed
theduke wants to merge 1 commit into
split/napi-05-heap-safetyfrom
split/napi-06-wasm-policy
Closed

theduke wants to merge 1 commit into
split/napi-05-heap-safetyfrom
split/napi-06-wasm-policy

Conversation

@theduke

@theduke theduke commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

V8 WebAssembly memories and code bypass the guest ArrayBuffer allocator. Guest environments therefore need a restrictive default, while the trusted host needs an explicit way to select a policy before accounting-backed enablement.

Add Rust WasmPolicy configuration and carry it into each provider environment and VM context through a private environment-creation entry. Keep the native public creation signature and the guest's wasm32 options layout unchanged: a guest cannot set or inspect host policy. Unknown values reject creation and release the transferred guest heap exactly once.

The default remains restricted. EnabledUnmetered is an explicit trusted-use option; its WebAssembly memory/code/compiler work is not covered by tenant accounting. VM code-generation restrictions and fresh realms continue to fail closed where required. The next two PRs add the accounting required by the metered option.

Stack and provenance

#93 → #94 → #95 → #96 → #97 → #98 → #99 → #100 → #101

Part 6 of the audited split of #84, reconstructed on current main eac0a13fa65a4d6103864d875ed76ab7efb1816e. Review against split/napi-05-heap-safety; predecessor branches are required. Original PR #84 remains unchanged. The stack preserves newer main host-JS behavior and deliberately excludes the unused frozen 0.0.1 ABI adapter.

Validation

Restricted/unmetered root and VM context tests, codeGeneration.wasm, fresh realms, successive contexts, unknown policy and exact-once guest-heap release.

Integrated unit and host-control coverage completed before local execution stopped at the user’s request. New CI runs the native policy tests and Rust unit tests; final branch results are pending. The public standalone SDK and the intended Edge SDK have distinct shared-memory detachment capabilities, documented in the accounting PR.

Latest-main rebase

Rebased the dependency stack onto eac0a13fa65a4d6103864d875ed76ab7efb1816e after main merged PR #92. This preserves unsigned guest IDs, pointers and lengths, bounded result/argv writes, host-JS buffer failure cleanup and the high-pointer/high-ID regressions. Conflicts received independent native and host-JS source review. All historical local results above predate this rebase; no local tests or builds were run for it, as requested. Updated-head validation belongs to CI and may be pending. This PR keeps its prerequisite branch as its base to preserve the focused diff.

@theduke
theduke force-pushed the split/napi-06-wasm-policy branch from 7ed41f1 to 89c0e97 Compare October 22, 2026 08:20
@theduke
theduke added this pull request to stack #102 October 22, 2026 08:24
@theduke
theduke marked this pull request as ready for review October 22, 2026 08:26
@theduke theduke closed this Oct 23, 2026
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