memlnaut-nisps/scripts/build-wasm.sh

103 lines
3.9 KiB
Bash
Raw Normal View History

feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
#!/usr/bin/env bash
# scripts/build-wasm.sh — compile nisps/wasm/bindings.cpp via Emscripten and
# write the result to manifold/public/.
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
#
# Requires emcc. Defaults to /usr/lib/emscripten/emcc; override via the EMCC
# env var. Sample invocation:
#
# EMCC=$(which emcc) scripts/build-wasm.sh
#
# Output:
# manifold/public/nisps.js — Emscripten glue, MODULARIZE factory
# manifold/public/nisps.wasm — the compiled module
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
set -euo pipefail
EMCC="${EMCC:-$(command -v emcc || echo /usr/lib/emscripten/emcc)}"
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
OUT="$ROOT/manifold/public"
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
SRC="$ROOT/nisps/wasm/bindings.cpp"
# EMCC may be a bare command name on PATH (emsdk installs it that way) or an
# absolute path. Resolve the former before the existence check, which otherwise
# looks for a file of that name in the CWD and always fails.
if [[ "$EMCC" != */* ]]; then
EMCC="$(command -v "$EMCC" || echo "$EMCC")"
fi
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
if [[ ! -x "$EMCC" && ! -f "$EMCC" ]]; then
echo "[build-wasm] emcc not found at $EMCC" >&2
echo "[build-wasm] set EMCC=/path/to/emcc (or put emcc on PATH) and retry." >&2
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
exit 2
fi
mkdir -p "$OUT"
# Exported C functions. Keep this list synchronised with the
# EMSCRIPTEN_KEEPALIVE annotations in bindings.cpp; the build will not
# fail if extras are listed but it WILL fail (or silently strip) if any
# function is missing.
EXPORTED_FUNCS='[
"_malloc","_free",
refactor(wasm): delete 12 dead C-API entries and the weights-publish channel Phase 1 group 4 (S33, S34, L54). - S33: removed 12 dead entries across the full 5-layer registration chain (bindings.cpp KEEPALIVE -> EXPORTED_FUNCTIONS -> the NispsModule declaration table -> the WasmIML wrapper -> the EngineApi facade): nisps_ml_reset, example_count, move_weights, feedback_learning_paused, feedback_drag, jolt_lr_scale, jolt_tick_lr_ramp, pipeline_state_size/save_state/load_state, feedback_placing and feedback_state. Each was grepped against manifold/src, manifold/tests, the e2e specs, manifold/tests/wasm-load.ts and tests/cpp/parity_wasm.mjs — the parity gate builds its own API via cwrap and is a real consumer, so it counts. KEPT deliberately: EXPORTED_RUNTIME's heap views + ccall/cwrap (the parity harness and wasm-load.ts depend on them), and nisps_ml_feedback_static_output, whose C export IS called directly by parity_wasm.mjs even though no TS wrapper reaches it. Also dropped parity_wasm.mjs's moveWeights cwrap, which was declared but never invoked. - S34: deleted the publishWeights_ channel — EngineSink.setWeights, Spine.setWeights/weights()/liveWeights and every call site. It ran a C->heap copy plus a fresh Float32Array allocation at up to 200 Hz into a field nothing read. getWeights survives for persistence and the debug probe. - L54: worklet loader — deleted the unused imports object, the 'c' branch, exMap and the duplicate second loop, and replaced the silent `() => 0` stub with one that throws, so a missing import fails loudly instead of returning plausible zeros into the audio path. manifold/public/nisps.{js,wasm} rebuilt with the trimmed export list (emcc 3.1.69, the CI-pinned version) and committed — the freshness gate added in Phase 0 requires it, and the webhook ships this artifact to production. Gates: run-all-tests.sh ALL GREEN, parity 1273 floats within 1e-5.
2026-07-21 12:48:50 +02:00
"_nisps_ml_create","_nisps_ml_destroy","_nisps_ml_reshape",
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
"_nisps_ml_set_input","_nisps_ml_process","_nisps_ml_outputs","_nisps_ml_infer_batch",
refactor(ml): one runtime-configurable training default (S26) The operator's call: "there should be one default learning rate and one default max iterations and they should both be configurable at runtime." There were SIX copies, not the four the audit described, and they did not agree: nisps/ml/mlp.hpp no-arg train() hardcoding 1.f / 1000u / 0.001f — and firmware's ONLY training path calls exactly this, so firmware had no runtime knob at all wasm-iml.ts train() and trainAsync() TS default params (x2) engine-api.ts learningRate ?? 1.0, with no maxIterations knob vcv/src/iml.hpp 200 / 0.1 / 0.00001 — silently divergent external_synth_midi.hpp its own kDefaultLearningRate/kDefaultMaxIterations schemas/modes/*.json x9, identical, read by nobody at runtime Now: schemas/ml_defaults.json is the single declaration (validated against a sibling meta-schema, matching the midi_device.schema.json convention), codegen emits it to C++ and TS in the same run, and MLPCore carries a TrainConfig whose default member initialisers read the generated constant. set_train_config()/nisps_ml_set_train_config() make it runtime-overridable on every target; the explicit-argument train() overload is untouched. min_error joins the tuple — it was duplicated identically and belongs with the other two. The per-mode ml block loses default_learning_rate/default_max_iterations. default_spread stays (genuinely wired on both targets) and input_channels stays (codegen-time validated, real information for sound_analysis_midi). VCV BEHAVIOUR CHANGE, deliberate: MEMLNaut.cpp constructs IML positionally and relies on those defaults, so the module moves to 1000/1.0/0.001 — 5x the max iterations, 10x the learning rate, and a 100x looser early-stop threshold. The old values were never justified anywhere; they arrived with fbc68eb alongside an unrelated module rewrite and no tuning rationale. Firmware and WASM have shipped 1.0/1000 all along. It is now runtime-settable if this turns out worse. The generated header lands in nisps/ml/generated/, not nisps/modes/generated/ where the rest of codegen output lives: training hyperparameters are an ML fact, and nisps/ml sits below nisps/modes, so emitting them there would make mlp.hpp include upward. The agent that built this flagged the directory-crossing rather than hiding it; this is the fix. CI's generated-freshness gate learns the new directory. Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS (max delta 2.38e-7), lint clean, manifold typecheck + 17 unit + 33 e2e (which exercise train() and trainAsync() through a real browser).
2026-07-21 17:20:10 +02:00
"_nisps_ml_add_example","_nisps_ml_train","_nisps_ml_set_train_config","_nisps_ml_eval_loss",
refactor(wasm): delete 12 dead C-API entries and the weights-publish channel Phase 1 group 4 (S33, S34, L54). - S33: removed 12 dead entries across the full 5-layer registration chain (bindings.cpp KEEPALIVE -> EXPORTED_FUNCTIONS -> the NispsModule declaration table -> the WasmIML wrapper -> the EngineApi facade): nisps_ml_reset, example_count, move_weights, feedback_learning_paused, feedback_drag, jolt_lr_scale, jolt_tick_lr_ramp, pipeline_state_size/save_state/load_state, feedback_placing and feedback_state. Each was grepped against manifold/src, manifold/tests, the e2e specs, manifold/tests/wasm-load.ts and tests/cpp/parity_wasm.mjs — the parity gate builds its own API via cwrap and is a real consumer, so it counts. KEPT deliberately: EXPORTED_RUNTIME's heap views + ccall/cwrap (the parity harness and wasm-load.ts depend on them), and nisps_ml_feedback_static_output, whose C export IS called directly by parity_wasm.mjs even though no TS wrapper reaches it. Also dropped parity_wasm.mjs's moveWeights cwrap, which was declared but never invoked. - S34: deleted the publishWeights_ channel — EngineSink.setWeights, Spine.setWeights/weights()/liveWeights and every call site. It ran a C->heap copy plus a fresh Float32Array allocation at up to 200 Hz into a field nothing read. getWeights survives for persistence and the debug probe. - L54: worklet loader — deleted the unused imports object, the 'c' branch, exMap and the duplicate second loop, and replaced the silent `() => 0` stub with one that throws, so a missing import fails loudly instead of returning plausible zeros into the audio path. manifold/public/nisps.{js,wasm} rebuilt with the trimmed export list (emcc 3.1.69, the CI-pinned version) and committed — the freshness gate added in Phase 0 requires it, and the webhook ships this artifact to production. Gates: run-all-tests.sh ALL GREEN, parity 1273 floats within 1e-5.
2026-07-21 12:48:50 +02:00
"_nisps_ml_clear_examples",
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
"_nisps_ml_weight_count","_nisps_ml_get_weights","_nisps_ml_set_weights",
refactor(wasm): delete 12 dead C-API entries and the weights-publish channel Phase 1 group 4 (S33, S34, L54). - S33: removed 12 dead entries across the full 5-layer registration chain (bindings.cpp KEEPALIVE -> EXPORTED_FUNCTIONS -> the NispsModule declaration table -> the WasmIML wrapper -> the EngineApi facade): nisps_ml_reset, example_count, move_weights, feedback_learning_paused, feedback_drag, jolt_lr_scale, jolt_tick_lr_ramp, pipeline_state_size/save_state/load_state, feedback_placing and feedback_state. Each was grepped against manifold/src, manifold/tests, the e2e specs, manifold/tests/wasm-load.ts and tests/cpp/parity_wasm.mjs — the parity gate builds its own API via cwrap and is a real consumer, so it counts. KEPT deliberately: EXPORTED_RUNTIME's heap views + ccall/cwrap (the parity harness and wasm-load.ts depend on them), and nisps_ml_feedback_static_output, whose C export IS called directly by parity_wasm.mjs even though no TS wrapper reaches it. Also dropped parity_wasm.mjs's moveWeights cwrap, which was declared but never invoked. - S34: deleted the publishWeights_ channel — EngineSink.setWeights, Spine.setWeights/weights()/liveWeights and every call site. It ran a C->heap copy plus a fresh Float32Array allocation at up to 200 Hz into a field nothing read. getWeights survives for persistence and the debug probe. - L54: worklet loader — deleted the unused imports object, the 'c' branch, exMap and the duplicate second loop, and replaced the silent `() => 0` stub with one that throws, so a missing import fails loudly instead of returning plausible zeros into the audio path. manifold/public/nisps.{js,wasm} rebuilt with the trimmed export list (emcc 3.1.69, the CI-pinned version) and committed — the freshness gate added in Phase 0 requires it, and the webhook ships this artifact to production. Gates: run-all-tests.sh ALL GREEN, parity 1273 floats within 1e-5.
2026-07-21 12:48:50 +02:00
"_nisps_ml_draw_weights",
"_nisps_ml_feedback_set_mode","_nisps_ml_feedback_get_mode",
refactor(wasm): delete 12 dead C-API entries and the weights-publish channel Phase 1 group 4 (S33, S34, L54). - S33: removed 12 dead entries across the full 5-layer registration chain (bindings.cpp KEEPALIVE -> EXPORTED_FUNCTIONS -> the NispsModule declaration table -> the WasmIML wrapper -> the EngineApi facade): nisps_ml_reset, example_count, move_weights, feedback_learning_paused, feedback_drag, jolt_lr_scale, jolt_tick_lr_ramp, pipeline_state_size/save_state/load_state, feedback_placing and feedback_state. Each was grepped against manifold/src, manifold/tests, the e2e specs, manifold/tests/wasm-load.ts and tests/cpp/parity_wasm.mjs — the parity gate builds its own API via cwrap and is a real consumer, so it counts. KEPT deliberately: EXPORTED_RUNTIME's heap views + ccall/cwrap (the parity harness and wasm-load.ts depend on them), and nisps_ml_feedback_static_output, whose C export IS called directly by parity_wasm.mjs even though no TS wrapper reaches it. Also dropped parity_wasm.mjs's moveWeights cwrap, which was declared but never invoked. - S34: deleted the publishWeights_ channel — EngineSink.setWeights, Spine.setWeights/weights()/liveWeights and every call site. It ran a C->heap copy plus a fresh Float32Array allocation at up to 200 Hz into a field nothing read. getWeights survives for persistence and the debug probe. - L54: worklet loader — deleted the unused imports object, the 'c' branch, exMap and the duplicate second loop, and replaced the silent `() => 0` stub with one that throws, so a missing import fails loudly instead of returning plausible zeros into the audio path. manifold/public/nisps.{js,wasm} rebuilt with the trimmed export list (emcc 3.1.69, the CI-pinned version) and committed — the freshness gate added in Phase 0 requires it, and the webhook ships this artifact to production. Gates: run-all-tests.sh ALL GREEN, parity 1273 floats within 1e-5.
2026-07-21 12:48:50 +02:00
"_nisps_ml_feedback_exploring",
"_nisps_ml_feedback_set_focus","_nisps_ml_feedback_down",
refactor(wasm): delete 12 dead C-API entries and the weights-publish channel Phase 1 group 4 (S33, S34, L54). - S33: removed 12 dead entries across the full 5-layer registration chain (bindings.cpp KEEPALIVE -> EXPORTED_FUNCTIONS -> the NispsModule declaration table -> the WasmIML wrapper -> the EngineApi facade): nisps_ml_reset, example_count, move_weights, feedback_learning_paused, feedback_drag, jolt_lr_scale, jolt_tick_lr_ramp, pipeline_state_size/save_state/load_state, feedback_placing and feedback_state. Each was grepped against manifold/src, manifold/tests, the e2e specs, manifold/tests/wasm-load.ts and tests/cpp/parity_wasm.mjs — the parity gate builds its own API via cwrap and is a real consumer, so it counts. KEPT deliberately: EXPORTED_RUNTIME's heap views + ccall/cwrap (the parity harness and wasm-load.ts depend on them), and nisps_ml_feedback_static_output, whose C export IS called directly by parity_wasm.mjs even though no TS wrapper reaches it. Also dropped parity_wasm.mjs's moveWeights cwrap, which was declared but never invoked. - S34: deleted the publishWeights_ channel — EngineSink.setWeights, Spine.setWeights/weights()/liveWeights and every call site. It ran a C->heap copy plus a fresh Float32Array allocation at up to 200 Hz into a field nothing read. getWeights survives for persistence and the debug probe. - L54: worklet loader — deleted the unused imports object, the 'c' branch, exMap and the duplicate second loop, and replaced the silent `() => 0` stub with one that throws, so a missing import fails loudly instead of returning plausible zeros into the audio path. manifold/public/nisps.{js,wasm} rebuilt with the trimmed export list (emcc 3.1.69, the CI-pinned version) and committed — the freshness gate added in Phase 0 requires it, and the webhook ships this artifact to production. Gates: run-all-tests.sh ALL GREEN, parity 1273 floats within 1e-5.
2026-07-21 12:48:50 +02:00
"_nisps_ml_feedback_up","_nisps_ml_feedback_static_output",
"_nisps_ml_feedback_enter_explore","_nisps_ml_feedback_exit_explore",
"_nisps_ml_feedback_reroll","_nisps_ml_feedback_nudge","_nisps_ml_feedback_undo",
"_nisps_ml_feedback_like","_nisps_ml_feedback_commit_place","_nisps_ml_feedback_cancel_place",
refactor(wasm): delete 12 dead C-API entries and the weights-publish channel Phase 1 group 4 (S33, S34, L54). - S33: removed 12 dead entries across the full 5-layer registration chain (bindings.cpp KEEPALIVE -> EXPORTED_FUNCTIONS -> the NispsModule declaration table -> the WasmIML wrapper -> the EngineApi facade): nisps_ml_reset, example_count, move_weights, feedback_learning_paused, feedback_drag, jolt_lr_scale, jolt_tick_lr_ramp, pipeline_state_size/save_state/load_state, feedback_placing and feedback_state. Each was grepped against manifold/src, manifold/tests, the e2e specs, manifold/tests/wasm-load.ts and tests/cpp/parity_wasm.mjs — the parity gate builds its own API via cwrap and is a real consumer, so it counts. KEPT deliberately: EXPORTED_RUNTIME's heap views + ccall/cwrap (the parity harness and wasm-load.ts depend on them), and nisps_ml_feedback_static_output, whose C export IS called directly by parity_wasm.mjs even though no TS wrapper reaches it. Also dropped parity_wasm.mjs's moveWeights cwrap, which was declared but never invoked. - S34: deleted the publishWeights_ channel — EngineSink.setWeights, Spine.setWeights/weights()/liveWeights and every call site. It ran a C->heap copy plus a fresh Float32Array allocation at up to 200 Hz into a field nothing read. getWeights survives for persistence and the debug probe. - L54: worklet loader — deleted the unused imports object, the 'c' branch, exMap and the duplicate second loop, and replaced the silent `() => 0` stub with one that throws, so a missing import fails loudly instead of returning plausible zeros into the audio path. manifold/public/nisps.{js,wasm} rebuilt with the trimmed export list (emcc 3.1.69, the CI-pinned version) and committed — the freshness gate added in Phase 0 requires it, and the webhook ships this artifact to production. Gates: run-all-tests.sh ALL GREEN, parity 1273 floats within 1e-5.
2026-07-21 12:48:50 +02:00
"_nisps_ml_feedback_undo_depth",
"_nisps_ml_feedback_placed_output",
feat(ml)!: P3 core — geometric dislike in nisps/, jolt/OU + geo ABI Geometric dislike (rl-feedback-design §2.1/§4; upstream InterfaceRL @ 0a541cc ported verbatim, constants included): - nisps/ml/replay.hpp: ReplayView over storage-owned buffers — deepen-or- store negatives (dedup 0.05, clamp -16), k-NN positive centroid with deterministic index tie-break + fixed accumulation order, proportional decay (0.0025*max(|r|,1)) + eviction, order-preserving compaction. - nisps/ml/geo_push.hpp: push-away target (pushStep clamp(|avgNeg|,.25,1) *0.5, taper /(1+len), useRandom on len<=1e-4 via nisps::Rng — the single deliberate divergence from libc rand()), negLRRatio 0.5-0.4*negFraction. - mlp.hpp: train_targets(input, computed-target, lr, out_mask) — trains toward computed targets (negative lr = cold-start train-away); solo/ focus gating zeroes masked derivs. - feedback.hpp: AvoidStyle {Geometric (new default), Diffuse (legacy move_weights, kept for A/B)}; dislike_geometric() collapses upstream's press+optimise into one synchronous call; on_up in geometric Avoid feeds the positive centroid; dislike-multiplier bookkeeping. Storage gains replay buffers (Fixed: ReplayCap=32 firmware default ≈ +8KB SRAM; Dynamic arena: cap 64). - bindings: nisps_ml_feedback_{dislike_geometric,store_positive, positive_count,negative_count,set_avoid_style} + P3.2 jolt/OU ABI: nisps_ml_jolt_{press,step,release,active,lr_scale,tick_lr_ramp}, nisps_ml_explore_{intensity,get_intensity,apply} (OUNoise<4096> over-provisioned; same code the firmware ModeBase runs). - parity v4: Stage 6 scripted geometric session (2 likes → 2 dislikes, f32-exact heard vectors via Math.fround) — 961 floats PASS at 2.4e-7. - tests: test_mlp_geo_dislike.cpp (replay dedup/deepen/clamp, centroid tie-break, push direction/taper/mask/clamp, cold-start inertness + train-away, determinism, Diffuse legacy); legacy Avoid test pinned to Diffuse per the ADR's deliberate-break note. Firmware: PAFSynth .text/.data unchanged (geometric path not referenced by current glue). NOTE: discovered pre-existing bug 10c3e55c — the explore/place wiring is linker-GC'd out of the PAFSynth ELF (predates this refactor; evidence in the ergo task).
2026-07-14 04:16:21 +02:00
"_nisps_ml_feedback_dislike_geometric","_nisps_ml_feedback_store_positive",
"_nisps_ml_feedback_positive_count","_nisps_ml_feedback_negative_count",
"_nisps_ml_feedback_set_avoid_style",
"_nisps_ml_jolt_press","_nisps_ml_jolt_step","_nisps_ml_jolt_release",
refactor(wasm): delete 12 dead C-API entries and the weights-publish channel Phase 1 group 4 (S33, S34, L54). - S33: removed 12 dead entries across the full 5-layer registration chain (bindings.cpp KEEPALIVE -> EXPORTED_FUNCTIONS -> the NispsModule declaration table -> the WasmIML wrapper -> the EngineApi facade): nisps_ml_reset, example_count, move_weights, feedback_learning_paused, feedback_drag, jolt_lr_scale, jolt_tick_lr_ramp, pipeline_state_size/save_state/load_state, feedback_placing and feedback_state. Each was grepped against manifold/src, manifold/tests, the e2e specs, manifold/tests/wasm-load.ts and tests/cpp/parity_wasm.mjs — the parity gate builds its own API via cwrap and is a real consumer, so it counts. KEPT deliberately: EXPORTED_RUNTIME's heap views + ccall/cwrap (the parity harness and wasm-load.ts depend on them), and nisps_ml_feedback_static_output, whose C export IS called directly by parity_wasm.mjs even though no TS wrapper reaches it. Also dropped parity_wasm.mjs's moveWeights cwrap, which was declared but never invoked. - S34: deleted the publishWeights_ channel — EngineSink.setWeights, Spine.setWeights/weights()/liveWeights and every call site. It ran a C->heap copy plus a fresh Float32Array allocation at up to 200 Hz into a field nothing read. getWeights survives for persistence and the debug probe. - L54: worklet loader — deleted the unused imports object, the 'c' branch, exMap and the duplicate second loop, and replaced the silent `() => 0` stub with one that throws, so a missing import fails loudly instead of returning plausible zeros into the audio path. manifold/public/nisps.{js,wasm} rebuilt with the trimmed export list (emcc 3.1.69, the CI-pinned version) and committed — the freshness gate added in Phase 0 requires it, and the webhook ships this artifact to production. Gates: run-all-tests.sh ALL GREEN, parity 1273 floats within 1e-5.
2026-07-21 12:48:50 +02:00
"_nisps_ml_jolt_active",
feat(ml)!: P3 core — geometric dislike in nisps/, jolt/OU + geo ABI Geometric dislike (rl-feedback-design §2.1/§4; upstream InterfaceRL @ 0a541cc ported verbatim, constants included): - nisps/ml/replay.hpp: ReplayView over storage-owned buffers — deepen-or- store negatives (dedup 0.05, clamp -16), k-NN positive centroid with deterministic index tie-break + fixed accumulation order, proportional decay (0.0025*max(|r|,1)) + eviction, order-preserving compaction. - nisps/ml/geo_push.hpp: push-away target (pushStep clamp(|avgNeg|,.25,1) *0.5, taper /(1+len), useRandom on len<=1e-4 via nisps::Rng — the single deliberate divergence from libc rand()), negLRRatio 0.5-0.4*negFraction. - mlp.hpp: train_targets(input, computed-target, lr, out_mask) — trains toward computed targets (negative lr = cold-start train-away); solo/ focus gating zeroes masked derivs. - feedback.hpp: AvoidStyle {Geometric (new default), Diffuse (legacy move_weights, kept for A/B)}; dislike_geometric() collapses upstream's press+optimise into one synchronous call; on_up in geometric Avoid feeds the positive centroid; dislike-multiplier bookkeeping. Storage gains replay buffers (Fixed: ReplayCap=32 firmware default ≈ +8KB SRAM; Dynamic arena: cap 64). - bindings: nisps_ml_feedback_{dislike_geometric,store_positive, positive_count,negative_count,set_avoid_style} + P3.2 jolt/OU ABI: nisps_ml_jolt_{press,step,release,active,lr_scale,tick_lr_ramp}, nisps_ml_explore_{intensity,get_intensity,apply} (OUNoise<4096> over-provisioned; same code the firmware ModeBase runs). - parity v4: Stage 6 scripted geometric session (2 likes → 2 dislikes, f32-exact heard vectors via Math.fround) — 961 floats PASS at 2.4e-7. - tests: test_mlp_geo_dislike.cpp (replay dedup/deepen/clamp, centroid tie-break, push direction/taper/mask/clamp, cold-start inertness + train-away, determinism, Diffuse legacy); legacy Avoid test pinned to Diffuse per the ADR's deliberate-break note. Firmware: PAFSynth .text/.data unchanged (geometric path not referenced by current glue). NOTE: discovered pre-existing bug 10c3e55c — the explore/place wiring is linker-GC'd out of the PAFSynth ELF (predates this refactor; evidence in the ergo task).
2026-07-14 04:16:21 +02:00
"_nisps_ml_explore_intensity","_nisps_ml_explore_get_intensity","_nisps_ml_explore_apply",
"_nisps_pipeline_create","_nisps_pipeline_destroy",
"_nisps_input_set_config","_nisps_input_process","_nisps_input_reset",
"_nisps_output_set_config","_nisps_output_set_freeze_mask",
"_nisps_output_process","_nisps_output_reset",
"_nisps_curve_apply","_nisps_curve_apply_batch",
feat(playground/wasm): WASM bridge between C++ core and SolidJS playground (meml-tgm) Stream 7 wires nisps/ml + nisps/engines into the playground via Emscripten. Highlights: - nisps/wasm/bindings.cpp: flat C API per architecture.md §6.2. Fixed-arch MLP<2, 10, 14, 18, 126>; engine string→type dispatch table with NoOp fallback. - scripts/build-wasm.sh: emcc invocation, MODULARIZE=1, exports listed explicitly; produces playground/public/nisps.{js,wasm}. - playground/src/ml/wasm-iml.ts: main-thread MLP host (sync inference, sync training, RL ops, weights I/O, layer stats, localStorage). - playground/src/ml/wasm-worker.ts: disposable Web Worker for off-thread async training, owns its own WASM instance. - playground/src/ml/dataset.ts: Float32Array-backed FIFO with sample-weight modes (uniform/global/local/combined). Port of legacy dataset.js. - playground/src/audio/engine-host.ts: AudioContext + AudioWorkletNode lifecycle, with start/stop/setEngine/setParams. - playground/src/audio/worklet/nisps-processor.ts: WASM-loading AudioWorkletProcessor that runs engine.process_block per 128-sample block. Loads its own WASM instance from main-thread-supplied bytes (no fetch in worklet). - playground/src/stores/ml-store.ts: wired stub methods to WasmIML singleton; lazy initialize(). - playground/src/debug/probe.ts: window.__nisps now calls real WasmIML via the store; lazy-init on first use. Verified: - bash scripts/build-wasm.sh succeeds (94 KB nisps.wasm) - bun run typecheck OK - bun run build OK (production bundle) - vite dev server serves /nisps.{js,wasm} with COOP/COEP Known limitation: WASM is fixed at one MLP shape. Multi-arch deferred — documented in nisps/wasm/README.md.
2026-04-29 15:36:29 +02:00
"_nisps_ml_get_layer_stats","_nisps_ml_describe",
"_nisps_engine_create","_nisps_engine_destroy",
"_nisps_engine_set_params","_nisps_engine_process_block"
]'
# Runtime helpers we want exposed on the JS module. HEAP* views are needed by
# wasm-iml.ts/wasm-worker.ts/nisps-processor.ts to copy buffers in and out.
EXPORTED_RUNTIME='[
"HEAP8","HEAP16","HEAP32","HEAPU8","HEAPU16","HEAPU32","HEAPF32","HEAPF64",
"ccall","cwrap"
]'
set -x
"$EMCC" "$SRC" \
-std=c++20 -O3 \
-I "$ROOT/nisps" \
-fno-exceptions \
-fno-rtti \
-s WASM=1 \
-s MODULARIZE=1 \
-s EXPORT_NAME=createNispsModule \
-s ENVIRONMENT=web,worker \
-s ALLOW_MEMORY_GROWTH=1 \
-s INITIAL_MEMORY=8388608 \
-s STACK_SIZE=1048576 \
-s FILESYSTEM=0 \
-s SINGLE_FILE=0 \
-s ASSERTIONS=0 \
-s EXPORTED_FUNCTIONS="$EXPORTED_FUNCS" \
-s EXPORTED_RUNTIME_METHODS="$EXPORTED_RUNTIME" \
-o "$OUT/nisps.js"
{ set +x; } 2>/dev/null
echo "[build-wasm] wrote $OUT/nisps.js + $OUT/nisps.wasm"
ls -lh "$OUT/nisps.js" "$OUT/nisps.wasm"