Files
sausage/host/cred-script/vendor/PATCHES.md
T

51 lines
3.4 KiB
Markdown

# Local compatibility patches
## LLRT utilities (SAU-330)
`llrt_buffer = 0.8.1-beta` and `llrt_encoding` remain published crate dependencies,
matching rquickjs 0.11 without changing the engine/vendor patches below.
The published `llrt_utils_watts = 0.8.1-beta` does not compile for wasm32-wasip2:
`signals::kill` unconditionally references `kill_process_raw` and `is_not_found`,
but those are only defined on Unix/Windows. The failed unpatched build is archived
at `/logs/cargo/2026-10-28/01a184d5-151b-7454-8333-b5d1d468b6d6.stderr.log`.
Fallback: `llrt_utils_watts/` is the unchanged published crate archive from
https://static.crates.io/crates/llrt_utils_watts/llrt_utils_watts-0.8.1-beta.crate
(SHA256 `5ace6f63a6b60a3bf738bf19f393c834c83a06d9e52c31d1c30a526584519569`),
except `src/lib.rs` adds `#[cfg(any(unix, windows))]` to `pub mod signals`.
The root Cargo patch points here. No utility module is registered as a JS module.
The upstream Apache-2.0 license is included (absent in the published archive).
This build-only patch does not alter Buffer. Before user module initialization,
the evaluator clears Buffer's global lexical binding and deletes its global-object
property, and removes Blob, File and Date, retaining only atob/btoa from the module.
SAU-330's mediator decision excludes the Node Buffer API rather than patching
its external-allocation heap bypass or empty-fill panic. Tests cover absent
identifiers, globalThis properties and global own-property names, plus base64
errors and clean near-heap-limit failure. See
`/docs/symphony/artifacts/SAU-330/implementation.md` for evidence.
## QuickJS (SAU-103)
`rquickjs-sys` was downloaded unchanged from https://crates.io/api/v1/crates/rquickjs-sys/0.11.0/download, then changed in exactly two files:
- `quickjs/quickjs.c`, `update_stack_limit`: remove the `__wasi__` special case that sets `stack_limit = 0` regardless of `JS_SetMaxStackSize`. Use the normal stack-top-minus-size implementation on WASI too. Without this patch the recursion test traps the WASM instance even with 16KiB / 256KiB limits. With the patch it returns `Maximum call stack size exceeded`.
- `build.rs`: skip upstream WASI SDK download/CC override when `CC_wasm32_wasip2` is supplied, letting `cc` honor cargo.build's target-specific CC/AR. Also emit the selected compiler/args as a diagnostic.
No engine features or host APIs were added. Keep this patch when reusing the evaluator; setting the Rust stack-limit API alone is **not sufficient** with unmodified rquickjs-sys 0.11.0. Upstream 0.14.0's source was inspected (not compiled) and still contains the WASI stack-limit bypass.
The bundled sources retain their upstream notices/licenses. This is a spike-local vendoring choice, not an SDK or live toolchain change.
## Sausage memory-error classification (D58)
`quickjs.c` records a sticky flag when `JS_ThrowOutOfMemory` runs.
`sausage_js_had_oom` exposes that flag to the guest's Rust evaluator.
`quickjs.h` declares this guest-internal function.
`build.rs` watches the QuickJS source directory, so Cargo rebuilds the library after a patch.
It adds no JavaScript API or host import.
A full heap can prevent QuickJS from creating its error object.
The unchanged `runaway_allocation` test reproduced that case and received `Throw` instead of `Limit`.
The flag preserves the memory-error category without another allocation.
Each evaluation creates a fresh runtime, so it also resets the flag.