Effects
GPU and WebAssembly
Stage 4 is complete (host-c3f76b6df86ca585). Culm now supports GPU shader regions (contours), custom GLSL effects (customEffects via addCustomEffect / effects/*.json), and the bounded WebAssembly field-v1 simulation tier (ripple_field), all running in a worker OffscreenCanvas plane under generated strict Content Security Policies and verified temporal/spatial-frequency limits.
Architecture & guarantees
Opt-in capability: GPU features are gated behind createRegistry({ gpu: { enabled: true } }) (folder sites declare "features": { "gpu": true } in culm.json). Sites without GPU keep identical HTML, scripts, and buildIdentity.
Static GLSL checker (checkEffectShader): Custom shaders only access read-only inputs u_time, u_scroll, u_resolution, u_pointer, u_noise, and typed u_set_<key> uniforms, capped at 4,096 source bytes, 16 settings, 64 loop passes, 16 texture reads, 512 weighted ops/pixel, and WebGL 2.0's 1,024-character token limit. Private u_field is reserved strictly for reviewed/approved field-v1 WASM effects and refused everywhere else (shader.input).
Fixed-memory zero-import WASM (field-v1): scripts/wasm/ripple-field.wat compiles via npm run gen:wasm into
packages/core/src/registry/rippleModule.ts(382 raw bytes <= 512, 512 base64 bytes <= 684, SHA-256
9c670ad9c22f68c14e778bcb41c1f947c84e862fae4cd4e98bac65724f97ee11). At runtime, the worker enforces zero imports, fixed 1-page memory (65,536 bytes; grow(1) throws RangeError), and bounded integer fieldPtr (0..64512) before uploading a 32×32 R8 texture to u_field. Any WASM failure isolates that single region back to its static poster while sibling regions keep painting.
Conditional CSP (scriptPolicy): 'wasm-unsafe-eval' is emitted only when a compiled live page actually runs a wasm region inside <main>. Pages using only contours or custom GLSL omit 'wasm-unsafe-eval'; plain pages omit both 'wasm-unsafe-eval' and worker-src blob:. _culm/gpu.js is lazy-loaded via IntersectionObserver with Subresource Integrity and skipped under prefers-reduced-motion: reduce or Save-Data.
Flash & adaptive limits: The last-pass limiter bounds linear-light changes to 0.25 units/channel/s (elapsed capped at 33 ms), downgrades scale on sustained slow frames (> 25 ms), persists slow flags per effect in localStorage inside try/catch, and falls back cleanly on watchdog (1,500 ms) or context loss.
Production script budgets (npm run gen:scripts)
Artifact / mixed fixture
Measured bytes
Ceiling
Remaining
Artifact / mixed fixture
GPU_HOST_SCRIPT (6,125 host + 3,388 worker)
Measured bytes
9,513
Ceiling
9,513
Remaining
0
Artifact / mixed fixture
GPU_LOADER_SCRIPT (with leading ; join)
Measured bytes
893
Ceiling
—
Remaining
—
Artifact / mixed fixture
PLAYBACK_TIMELINE_SCRIPT / TIMELINE_SCRIPT
Measured bytes
4,681 / 7,214
Ceiling
8,192
Remaining
978
Artifact / mixed fixture
STATES_SCRIPT
Measured bytes
1,654
Ceiling
6,193
Remaining
4,539
Artifact / mixed fixture
Standard mixed page (playback, reviewed GPU)
Measured bytes
17,429
Ceiling
20,000
Remaining
2,571
Artifact / mixed fixture
Interactive unreviewed mixed page
Measured bytes
19,962
Ceiling
20,000
Remaining
38
Offline flash / EA IRIS qualification
Both deterministic 180-frame 30 fps captures (achromatic and saturated-red) generated by scripts/gpu-flash-capture.ts for production host
c3f76b6df86ca58552cee72159cac104fd83e25c9e7747c516d36695b9c7f06a(worker
38d52b3f5cf4e3f7e82c937d1ce2e3be7c1781d71ed7eeadedf7bbe3b6f98348) produced byte-identical uncompressed AVI streams (a132dfcbb8b292ab..., f872ca2cba925b72..., 3aa0e7444f3363bc..., bd0d25e0770d332f...) verified by EA IRIS analysis (PASS on both limited clips with zero warnings; FAIL on both positive controls). Evidence and logs live under
docs/gpu/evidence/task-7/host-c3f76b6df86ca585/and
docs/gpu/evidence/iris/host-c3f76b6df86ca585/, and are pinned by
scripts/__tests__/gpu-flash-evidence.spec.tsand
scripts/__tests__/gpu-page-budget.spec.ts.
Previous
Next