Book 1 · Lesson 1.4

The WASM boundary

  • Explain why WASM runs sandboxed linear memory
  • Describe copy-in / compute / copy-out at the JS boundary
  • Connect to radar 1:1 PII redaction

Prerequisites: 1.3

WebAssembly (WASM) is a portable binary format. Browsers load .wasm modules and call exported functions from JavaScript — with a strict memory boundary.

Why WASM for privacy?

In the radar 1:1 portal, manager notes stay in the browser. Rust code compiled to WASM runs redact_pii_deterministic locally — raw email addresses never POST to your API.

Package: packages/redact-wasm/ · UI: apps/radar/ route /1on1

JavaScript heap

Plaintext lives in the browser only.
copy bytes · run Rust · return string

WASM linear memory

— awaiting call —redact_pii_deterministic()

Boundary rules

SideMemoryTrust
JavaScriptGC heapFull browser APIs
WASMLinear memorySandboxed — no DOM, no network unless imported

Crossing the boundary copies strings/bytes — not shared pointers.

Build path (monorepo)

pnpm build:wasm   # wasm-pack → packages/redact-wasm/pkg/

Teach-back prompt

Why is browser WASM redaction different from sending text to the LLM worker?

Load WASM redaction

Lesson 1.4 check

1. WASM linear memory is…