memlnaut-nisps/ALIGNMENT.md

171 lines
16 KiB
Markdown
Raw Normal View History

# ALIGNMENT
> Opinionated diagnosis of how well the codebase serves its mission, ranked by impact. Dated entries; remove when resolved rather than checking off. **Pruned every few weeks** — a stale diagnosis is worse than none.
## Mission
A research platform for interactive ML control of audio. We're building it to figure out what works and what doesn't — different ergonomics and ergodynamics of parameter sets, modes, ML architectures, audio engines, UI, and UX. Therefore: keep most/all parameters tweakable, ML/engine/UI/UX should each be configurable on their own axis, and the codebase has to enable/assist agentic AI coding patterns (confident changes, verifiable without hardware).
**Target vision (operator, 2026-07-20):** (1) one C++20 NISPS core serving RP2350 firmware and the browser, performance-sensitive on the MCU; (2) firmware modes runnable as modes in Manifold; (3) Manifold defaults to curated presets/modes, with the maximalist surface behind an "advanced" dev mode used to author them; (4) PlatformIO for hardware, no more .ino; (5) Manifold doubles as interface/editor for the hardware MEMLNaut (settings, presets, training, examples, visualisation).
The clean-slate rewrite (2026-04-29) consolidated everything into one C++20 codebase compiling to firmware AND WASM. Since 2026-07-13 (P1) the sole browser app is the React Manifold. JSON schemas remain the firmware↔browser parameter contract. A full-repo audit (2026-07-21, `docs/specs/recon/simplification-audit-2026-07.md`) grounds the entries below; mitigations are phased in `docs/specs/plans/simplification-plan.md`.
## Top defects (ranked by mission impact)
ci: restore verification — reachable submodule pin, codegen + WASM freshness gates Phase 0 of the 2026-07 simplification audit (plan §1). CI has been 100% red on main since 2026-07-13 and every "gates green" claim since rested on local runs. - S7 / critic gap 2: push memllib `feat/nisps-core-swap` (3 commits incl. the pin b37fc53) to monkey-w1n5t0n/memllib and repoint .gitmodules at the fork. Those commits existed on exactly one disk; `git ls-remote` now resolves the pin, so `submodules: recursive` checkout and fresh clones work again. Drops the compensating unreachable-pin error paragraph in build-firmware-arch.sh. - S24 / S31: the manifold-tests job regenerates from schemas/, runs the codegen golden test, and fails on a dirty diff — the "schema changes ship with both generated outputs" rule is now enforced rather than assumed. - S32: a WASM freshness gate runs the parity harness against the *committed* manifold/public/nisps.{js,wasm} before the CI rebuild overwrites it. That artifact is what the webhook ships to production, so a stale commit now fails loudly instead of shipping. - critic gap 3 / operator decision §7.4: the VPS webhook (~/.config/webhooks/meml-deploy.sh, not in this repo) waits for the `CI` workflow to conclude success on the pushed SHA before building. Fail-closed; MEML_SKIP_CI_GATE=1 for an emergency hand-deploy. Verified the gate query returns `failure` for fa37047, i.e. it would have blocked that deploy. - S31: corrected run-all-tests.sh's false "single command CI invokes" header. Docs moved with the code: ALIGNMENT defect 1 deleted (resolved) and the rest renumbered; MAP.md's unreachable-pin warning replaced with the fork pin and a pointer to the §7.5 vendoring decision; ONBOARDING documents the deploy gate and the tracked-WASM-ships-to-prod hazard; plan §1 marked burned down. Gates: scripts/run-all-tests.sh ALL GREEN (ctest 4/4, parity 1273 floats within 1e-5, lint, typecheck, 33 Playwright specs).
2026-07-21 11:57:32 +02:00
### 1. The mode layer is not shared: WASM re-orchestrates modes by hand (2026-07-21)
**What.** `nisps/modes/` — the CRTP layer binding ML config, engine, voice-space and I/O — compiles only into firmware. `nisps/wasm/bindings.cpp` includes engines and ML primitives but zero mode headers, and Manifold re-assembles mode behaviour (jolt stepping, OU, routing) in TS. "Firmware and WASM share the same modes" is true only at the engine level; every ModeBase behaviour must be mirrored browser-side by hand.
**Why it blocks the mission.** Vision bullet 2 is precisely this. Until the control-tick orchestration exists once in C++, every new mode behaviour is a dual implementation with drift risk.
**Rough cost.** Spec first, then ~a week: storage-policy the ModeBase orchestration the way P2 did MLPCore (verified shape in plan §6.5a — *not* binding monolithic mode objects, which would contradict the locked two-instance RT architecture). Related honesty gap: Manifold currently catalogues 4 modes that structurally cannot run in the browser (no mic input, event-only engines) — plan §6.5b (absorbs the old C15/mic-input defect; C15 itself lives on `archive/playground-solidjs`).
ci: restore verification — reachable submodule pin, codegen + WASM freshness gates Phase 0 of the 2026-07 simplification audit (plan §1). CI has been 100% red on main since 2026-07-13 and every "gates green" claim since rested on local runs. - S7 / critic gap 2: push memllib `feat/nisps-core-swap` (3 commits incl. the pin b37fc53) to monkey-w1n5t0n/memllib and repoint .gitmodules at the fork. Those commits existed on exactly one disk; `git ls-remote` now resolves the pin, so `submodules: recursive` checkout and fresh clones work again. Drops the compensating unreachable-pin error paragraph in build-firmware-arch.sh. - S24 / S31: the manifold-tests job regenerates from schemas/, runs the codegen golden test, and fails on a dirty diff — the "schema changes ship with both generated outputs" rule is now enforced rather than assumed. - S32: a WASM freshness gate runs the parity harness against the *committed* manifold/public/nisps.{js,wasm} before the CI rebuild overwrites it. That artifact is what the webhook ships to production, so a stale commit now fails loudly instead of shipping. - critic gap 3 / operator decision §7.4: the VPS webhook (~/.config/webhooks/meml-deploy.sh, not in this repo) waits for the `CI` workflow to conclude success on the pushed SHA before building. Fail-closed; MEML_SKIP_CI_GATE=1 for an emergency hand-deploy. Verified the gate query returns `failure` for fa37047, i.e. it would have blocked that deploy. - S31: corrected run-all-tests.sh's false "single command CI invokes" header. Docs moved with the code: ALIGNMENT defect 1 deleted (resolved) and the rest renumbered; MAP.md's unreachable-pin warning replaced with the fork pin and a pointer to the §7.5 vendoring decision; ONBOARDING documents the deploy gate and the tracked-WASM-ships-to-prod hazard; plan §1 marked burned down. Gates: scripts/run-all-tests.sh ALL GREEN (ctest 4/4, parity 1273 floats within 1e-5, lint, typecheck, 33 Playwright specs).
2026-07-21 11:57:32 +02:00
### 2. No curated/advanced split and no in-UI mode picker — the UI fights vision 3 (2026-07-21)
**What.** Manifold is 100% dev-maximalist: five drawers of everything, no preset data model to author against, and mode switching exists only via the debug hook — there is no instrument picker in the UI at all (the plumbing, `ctx.modes`/`setModeId`, already exists unused). A stratum of decorative controls (training-param sliders, master volume, bpm, A/B, snapshots, fabricated gradient health) renders real-looking UI that drives nothing.
**Why it blocks the mission.** The default experience is supposed to be curated presets; the advanced surface is the authoring tool. Neither exists, and the decorative stratum actively misleads research use.
feat: curve truth, DriverConfig, real telemetry, engine benchmark Four items from one workflow, committed together because their build and CI wiring genuinely interleaves — nisps/CMakeLists.txt, run-all-tests.sh and ci.yml each carry hunks from two of them, and the stage renumbering (1/5 -> 1/6) touches every line. Splitting would produce commits that do not build, which is worse than a commit that does four things and says so. S26 part 2 — the curve declaration now matches reality. params[].curve stays the mode-wide DEFAULT; a voice_spaces entry may now be {name, curve_overrides} declaring only the slots where THAT voice space deviates. The 6 modes with one voice space are byte-identical. The values were derived MECHANICALLY by a new codegen/curve-audit.ts that models the four idioms a p[N]*p[N] regex misses (alias form, memlcelium's implicit-counter sq() lambda, loop-generated indices, smooth_params_), inlines helpers, and RAISES rather than guessing when it cannot reduce an expression. A drift gate cross-checks 1179 (voice space x param) slots against engine source on every run and was proved to fail loudly on three drift classes. Application stays in the engine: nisps/engines, nisps/pipeline and nisps/core are untouched, generated output is pure insertion (755 insertions, 0 deletions), and the rebuilt nisps.wasm was byte-identical. S4 / 7.2 — firmware reads the active mode's driver config at mode start, and mic/line is real. My brief assumed the engine owns this; the code disagreed and the code was right. sound_analysis_midi's EngineT is NoOpEngine — the mic lives on a separately-composed AnalysisEngine member — so engine-level wiring would have compiled, passed every gate, and left the one mic mode on line input. Hence a mode-level seam defaulting to engine().driver_config(). Separately, DriverConfig's defaults (line_level 0, output_volume 1.0) had drifted from memllib's actual 3/0.8 because nothing had ever read them; wiring them as-is would have made every silent mode louder and its line input maximally insensitive — a behaviour change disguised as plumbing. Now pinned by a test. Also: GetSysClockSpeed() panic()s on unsupported sample rates and runs on the first line of setup(), so sample_rate needed a fallback ahead of clock setup. CI's firmware env list gains soundanalysismidi — it is the only mic variant and nothing else compiles that path. Plan 5e — telemetry is real. A loss_history C-API entry across the full 5-layer chain lets the browser read the per-iteration loss the core already records. The audit named one fabrication site; there were two — wasm-iml.ts's synchronous train() published lossHistory: [loss] as well. A third, ctx.loss, was not merely dead but actively synthetic (fallbacks of prev * 0.82 and a literal 0.5, rendered by nothing) and is deleted. The firmware buffer stays untouched, per the L25 call. EngineApi.lossHistory() reads spine state rather than the MLP handle, because trainAsync() fits on the worker's mirror net and the handle would give a subtly-wrong second answer. Plan 5f — engine throughput is measurable. One source compiled twice (CMake natively, emcc for WASM) so the targets compare directly and no WASM export is added. Sequencers are driven into a working state, and every row prints its own working-state evidence so a number produced by an idle engine is visible rather than plausible. Reports, never asserts: a wall-clock threshold on shared hardware is meaningless or flaky, same call as the firmware size job. ALIGNMENT: the telemetry defect is deleted (built, not deferred); the performance defect is rewritten to what is actually left — these are HOST numbers, and nothing measures the RP2350 at 150 MHz, which is the target the mission's constraint is about. Q4 (memllib ownership) and Q5 (legacy feedback modes) are closed. Corrections to my own earlier claims, both found by agents contradicting the brief: manifold/ONBOARDING.md was NOT "now accurate" — its primitives list still named five deleted primitives and cited a seededGradient() that does not exist. And the parity harness misses the sequencer engines because it runs 128 frames while their sequencers evaluate every 400-500 samples, NOT because all-params-0.5 fails to trigger them (it does trigger: 0.5 maps to ratio 2, firing three times per bar). The fix is a longer window, not different params. Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS, lint clean, curve drift 1179 slots ok, 39 e2e (was 33). Firmware: 5 envs built including the mic variant.
2026-07-21 22:02:23 +02:00
**Rough cost.** Product-model decision first (plan §7.6), then incremental: picker is days; the curated-preset model seeds from `backends/presets.ts` + schemas; disclosure via per-drawer depth levels — which as of §6.5e (2026-07-21) has its first genuinely advanced-only consumer, the training-health panel, so the mechanism is proven rather than theoretical. The decorative stratum itself went in the Phase-1 sweep.
build(firmware): migrate to PlatformIO and vendor memllib (plan §5) One cut, no dual path. Closes ALIGNMENT defect 3 ("Arduino-CLI build machinery is actively hostile") and vision bullet 4. platformio.ini carries 16 [env:], one per variant, each passing -DMEMLNAUT_MODE_TYPE; selftest passes -DNISPS_SELFTEST=1 instead. The env list IS the registry now — the .ino comment-registry and the NISPS_ST_* token-paste table are deleted rather than migrated. L12 noted that table was already silently missing the currently-shipped SLPWorkshop variant, which is the whole argument against having a second list. Also deleted: the Python/sed machinery that rewrote the COMMITTED .ino on every build, the sketch symlink forest, the global TFT_eSPI User_Setup.h mutation (now -D flags — TFT_eSPI's own documented PlatformIO recipe), the UF2 boot-mount detection stack (upload_protocol=picotool talks to the bootloader directly), and build-firmware-arch.sh entirely. Scripts 683 -> 435 lines. memllib is vendored at lib/memllib/ from upstream e291192; no submodules remain. VENDORED.md records provenance and the re-sync procedure. S9: a firmware-build CI job compiles three representative envs against a cached toolchain and reports per-variant flash/RAM. Firmware is in an automated gate for the FIRST time. The old ci.yml comment justified excluding it as "low verification value" — an assessment that did not survive contact, since the SelfTest variant sat broken for an unknown period calling a DisplayDriver method that did not exist at the pinned memllib commit, and nothing noticed because nothing built it. Verified: all 16 envs build from an empty cache, each within ~520 bytes of the arduino-cli binary it replaces, flash and RAM. Measured as .text+.rodata / .data+.bss+vector+uninitialized — NOT PlatformIO's console line, which double-counts .data on this board. This does not prove the hardware boots; no flash+smoke test was possible and that stays an operator chokepoint. slpworkshop 248232/145028 pafsynth 256880/149716 selftest 216228/17960 (all 16 in the CI log format; none exceeds 2% of a 16 MB flash) Two traps recorded so nobody rediscovers them: vendoring memllib's subdirs without a src/ wrapper makes PlatformIO's library builder silently compile NOTHING while still linking; and project build_flags land BEFORE the framework's own -std=gnu++17 -Os, so build_unflags is required. CORRECTION carried in this commit: the firmware sizes in c19d846's message and the first version of the memllib recon doc were wrong — SLPWorkshop 145348, PAFSynth 145300, SelfTest 141840. They came from building variants in sequence through a SHARED incremental arduino-cli build directory, which reused stale objects and under-reported by ~75 KB. Clean-cache rebuilds of the identical commit give 216736/18492 for SelfTest. The real cost of the memllib upstream bump is +216 bytes flash, not +316. Never measure firmware size through a reused build dir. HISTORY NOTE: this commit and the docs commit before it were rebuilt (force-push, 2026-07-21) so that each contains only what its message describes. The first versions had the firmware deletions stranded in the docs commit by a shared-index race between concurrent agents; content is byte-identical to the originals. Gates: run-all-tests.sh ALL GREEN (nisps/ untouched by this change beyond include paths); 16/16 pio envs build.
2026-07-21 20:17:58 +02:00
### 3. Manifold-as-hardware-editor is a facade (2026-07-21)
**What.** Vision bullet 5 exists as a 237-line Web Serial shell: sound connect lifecycle, zero protocol (`saveModel`/`restoreModel`/`getSettings` are literal stubs), and firmware has no serial command surface or on-device persistence to talk to.
**Why it blocks the mission.** The hardware research loop (train on device, inspect/curate in browser) is closed only by this bridge.
**Rough cost.** Week+, spec-first (plan §6.5d). The right discipline already exists in-repo: useq-celium's C-header wire truth + TS mirror + parity test; settings payloads should derive from schema codegen.
build(firmware): migrate to PlatformIO and vendor memllib (plan §5) One cut, no dual path. Closes ALIGNMENT defect 3 ("Arduino-CLI build machinery is actively hostile") and vision bullet 4. platformio.ini carries 16 [env:], one per variant, each passing -DMEMLNAUT_MODE_TYPE; selftest passes -DNISPS_SELFTEST=1 instead. The env list IS the registry now — the .ino comment-registry and the NISPS_ST_* token-paste table are deleted rather than migrated. L12 noted that table was already silently missing the currently-shipped SLPWorkshop variant, which is the whole argument against having a second list. Also deleted: the Python/sed machinery that rewrote the COMMITTED .ino on every build, the sketch symlink forest, the global TFT_eSPI User_Setup.h mutation (now -D flags — TFT_eSPI's own documented PlatformIO recipe), the UF2 boot-mount detection stack (upload_protocol=picotool talks to the bootloader directly), and build-firmware-arch.sh entirely. Scripts 683 -> 435 lines. memllib is vendored at lib/memllib/ from upstream e291192; no submodules remain. VENDORED.md records provenance and the re-sync procedure. S9: a firmware-build CI job compiles three representative envs against a cached toolchain and reports per-variant flash/RAM. Firmware is in an automated gate for the FIRST time. The old ci.yml comment justified excluding it as "low verification value" — an assessment that did not survive contact, since the SelfTest variant sat broken for an unknown period calling a DisplayDriver method that did not exist at the pinned memllib commit, and nothing noticed because nothing built it. Verified: all 16 envs build from an empty cache, each within ~520 bytes of the arduino-cli binary it replaces, flash and RAM. Measured as .text+.rodata / .data+.bss+vector+uninitialized — NOT PlatformIO's console line, which double-counts .data on this board. This does not prove the hardware boots; no flash+smoke test was possible and that stays an operator chokepoint. slpworkshop 248232/145028 pafsynth 256880/149716 selftest 216228/17960 (all 16 in the CI log format; none exceeds 2% of a 16 MB flash) Two traps recorded so nobody rediscovers them: vendoring memllib's subdirs without a src/ wrapper makes PlatformIO's library builder silently compile NOTHING while still linking; and project build_flags land BEFORE the framework's own -std=gnu++17 -Os, so build_unflags is required. CORRECTION carried in this commit: the firmware sizes in c19d846's message and the first version of the memllib recon doc were wrong — SLPWorkshop 145348, PAFSynth 145300, SelfTest 141840. They came from building variants in sequence through a SHARED incremental arduino-cli build directory, which reused stale objects and under-reported by ~75 KB. Clean-cache rebuilds of the identical commit give 216736/18492 for SelfTest. The real cost of the memllib upstream bump is +216 bytes flash, not +316. Never measure firmware size through a reused build dir. HISTORY NOTE: this commit and the docs commit before it were rebuilt (force-push, 2026-07-21) so that each contains only what its message describes. The first versions had the firmware deletions stranded in the docs commit by a shared-index race between concurrent agents; content is byte-identical to the originals. Gates: run-all-tests.sh ALL GREEN (nisps/ untouched by this change beyond include paths); 16/16 pio envs build.
2026-07-21 20:17:58 +02:00
### 4. Dead mass and registry sprawl across every layer (2026-07-21)
**What.** *Phase 1 landed 2026-07-21 and removed the bulk of this:* the dead focus/altitude UI system, the decorative control stratum, 12 dead WASM API entries across the 5-file registration chain, the vendored daisysp tree, retired-playground artifacts and root planning relics, 5 unused primitives, the duplicate backend editor and catalogue, `voice_space.hpp`, `fixed_buffer.hpp`, the dead perf-macro regime, and the OSC bridge twin. What remains is the *registry* half: mode identity spread across ~6 hand-maintained registries with demonstrated drift, MLP dims typed twice, per-mode schema blocks hand-written in C++, and assorted stale specs presenting a deleted world as present tense.
**Why it blocks the mission.** The registries are dual-truth bugs waiting to fire (one already did: the selftest table). Stale specs are agent-confusing surface area.
**Rough cost.** Plan phase 3 (~23 days, codegen takes ownership) plus the docs disposition pass (§8). The behaviour bugs found en route (dataset-cap divergence, VCV 2-D input truncation, VCV audio-thread race and JSON) were fixed in phase 2 on 2026-07-21.
feat: curve truth, DriverConfig, real telemetry, engine benchmark Four items from one workflow, committed together because their build and CI wiring genuinely interleaves — nisps/CMakeLists.txt, run-all-tests.sh and ci.yml each carry hunks from two of them, and the stage renumbering (1/5 -> 1/6) touches every line. Splitting would produce commits that do not build, which is worse than a commit that does four things and says so. S26 part 2 — the curve declaration now matches reality. params[].curve stays the mode-wide DEFAULT; a voice_spaces entry may now be {name, curve_overrides} declaring only the slots where THAT voice space deviates. The 6 modes with one voice space are byte-identical. The values were derived MECHANICALLY by a new codegen/curve-audit.ts that models the four idioms a p[N]*p[N] regex misses (alias form, memlcelium's implicit-counter sq() lambda, loop-generated indices, smooth_params_), inlines helpers, and RAISES rather than guessing when it cannot reduce an expression. A drift gate cross-checks 1179 (voice space x param) slots against engine source on every run and was proved to fail loudly on three drift classes. Application stays in the engine: nisps/engines, nisps/pipeline and nisps/core are untouched, generated output is pure insertion (755 insertions, 0 deletions), and the rebuilt nisps.wasm was byte-identical. S4 / 7.2 — firmware reads the active mode's driver config at mode start, and mic/line is real. My brief assumed the engine owns this; the code disagreed and the code was right. sound_analysis_midi's EngineT is NoOpEngine — the mic lives on a separately-composed AnalysisEngine member — so engine-level wiring would have compiled, passed every gate, and left the one mic mode on line input. Hence a mode-level seam defaulting to engine().driver_config(). Separately, DriverConfig's defaults (line_level 0, output_volume 1.0) had drifted from memllib's actual 3/0.8 because nothing had ever read them; wiring them as-is would have made every silent mode louder and its line input maximally insensitive — a behaviour change disguised as plumbing. Now pinned by a test. Also: GetSysClockSpeed() panic()s on unsupported sample rates and runs on the first line of setup(), so sample_rate needed a fallback ahead of clock setup. CI's firmware env list gains soundanalysismidi — it is the only mic variant and nothing else compiles that path. Plan 5e — telemetry is real. A loss_history C-API entry across the full 5-layer chain lets the browser read the per-iteration loss the core already records. The audit named one fabrication site; there were two — wasm-iml.ts's synchronous train() published lossHistory: [loss] as well. A third, ctx.loss, was not merely dead but actively synthetic (fallbacks of prev * 0.82 and a literal 0.5, rendered by nothing) and is deleted. The firmware buffer stays untouched, per the L25 call. EngineApi.lossHistory() reads spine state rather than the MLP handle, because trainAsync() fits on the worker's mirror net and the handle would give a subtly-wrong second answer. Plan 5f — engine throughput is measurable. One source compiled twice (CMake natively, emcc for WASM) so the targets compare directly and no WASM export is added. Sequencers are driven into a working state, and every row prints its own working-state evidence so a number produced by an idle engine is visible rather than plausible. Reports, never asserts: a wall-clock threshold on shared hardware is meaningless or flaky, same call as the firmware size job. ALIGNMENT: the telemetry defect is deleted (built, not deferred); the performance defect is rewritten to what is actually left — these are HOST numbers, and nothing measures the RP2350 at 150 MHz, which is the target the mission's constraint is about. Q4 (memllib ownership) and Q5 (legacy feedback modes) are closed. Corrections to my own earlier claims, both found by agents contradicting the brief: manifold/ONBOARDING.md was NOT "now accurate" — its primitives list still named five deleted primitives and cited a seededGradient() that does not exist. And the parity harness misses the sequencer engines because it runs 128 frames while their sequencers evaluate every 400-500 samples, NOT because all-params-0.5 fails to trigger them (it does trigger: 0.5 maps to ratio 2, firing three times per bar). The fix is a longer window, not different params. Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS, lint clean, curve drift 1179 slots ok, 39 e2e (was 33). Firmware: 5 envs built including the mic variant.
2026-07-21 22:02:23 +02:00
### 5. Performance is measured on the host but not on the target that constrains it (2026-07-21)
feat: curve truth, DriverConfig, real telemetry, engine benchmark Four items from one workflow, committed together because their build and CI wiring genuinely interleaves — nisps/CMakeLists.txt, run-all-tests.sh and ci.yml each carry hunks from two of them, and the stage renumbering (1/5 -> 1/6) touches every line. Splitting would produce commits that do not build, which is worse than a commit that does four things and says so. S26 part 2 — the curve declaration now matches reality. params[].curve stays the mode-wide DEFAULT; a voice_spaces entry may now be {name, curve_overrides} declaring only the slots where THAT voice space deviates. The 6 modes with one voice space are byte-identical. The values were derived MECHANICALLY by a new codegen/curve-audit.ts that models the four idioms a p[N]*p[N] regex misses (alias form, memlcelium's implicit-counter sq() lambda, loop-generated indices, smooth_params_), inlines helpers, and RAISES rather than guessing when it cannot reduce an expression. A drift gate cross-checks 1179 (voice space x param) slots against engine source on every run and was proved to fail loudly on three drift classes. Application stays in the engine: nisps/engines, nisps/pipeline and nisps/core are untouched, generated output is pure insertion (755 insertions, 0 deletions), and the rebuilt nisps.wasm was byte-identical. S4 / 7.2 — firmware reads the active mode's driver config at mode start, and mic/line is real. My brief assumed the engine owns this; the code disagreed and the code was right. sound_analysis_midi's EngineT is NoOpEngine — the mic lives on a separately-composed AnalysisEngine member — so engine-level wiring would have compiled, passed every gate, and left the one mic mode on line input. Hence a mode-level seam defaulting to engine().driver_config(). Separately, DriverConfig's defaults (line_level 0, output_volume 1.0) had drifted from memllib's actual 3/0.8 because nothing had ever read them; wiring them as-is would have made every silent mode louder and its line input maximally insensitive — a behaviour change disguised as plumbing. Now pinned by a test. Also: GetSysClockSpeed() panic()s on unsupported sample rates and runs on the first line of setup(), so sample_rate needed a fallback ahead of clock setup. CI's firmware env list gains soundanalysismidi — it is the only mic variant and nothing else compiles that path. Plan 5e — telemetry is real. A loss_history C-API entry across the full 5-layer chain lets the browser read the per-iteration loss the core already records. The audit named one fabrication site; there were two — wasm-iml.ts's synchronous train() published lossHistory: [loss] as well. A third, ctx.loss, was not merely dead but actively synthetic (fallbacks of prev * 0.82 and a literal 0.5, rendered by nothing) and is deleted. The firmware buffer stays untouched, per the L25 call. EngineApi.lossHistory() reads spine state rather than the MLP handle, because trainAsync() fits on the worker's mirror net and the handle would give a subtly-wrong second answer. Plan 5f — engine throughput is measurable. One source compiled twice (CMake natively, emcc for WASM) so the targets compare directly and no WASM export is added. Sequencers are driven into a working state, and every row prints its own working-state evidence so a number produced by an idle engine is visible rather than plausible. Reports, never asserts: a wall-clock threshold on shared hardware is meaningless or flaky, same call as the firmware size job. ALIGNMENT: the telemetry defect is deleted (built, not deferred); the performance defect is rewritten to what is actually left — these are HOST numbers, and nothing measures the RP2350 at 150 MHz, which is the target the mission's constraint is about. Q4 (memllib ownership) and Q5 (legacy feedback modes) are closed. Corrections to my own earlier claims, both found by agents contradicting the brief: manifold/ONBOARDING.md was NOT "now accurate" — its primitives list still named five deleted primitives and cited a seededGradient() that does not exist. And the parity harness misses the sequencer engines because it runs 128 frames while their sequencers evaluate every 400-500 samples, NOT because all-params-0.5 fails to trigger them (it does trigger: 0.5 maps to ratio 2, firing three times per bar). The fix is a longer window, not different params. Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS, lint clean, curve drift 1179 slots ok, 39 e2e (was 33). Firmware: 5 envs built including the mic variant.
2026-07-21 22:02:23 +02:00
**What.** *Mostly closed 2026-07-21.* Size: the Phase 4 firmware CI job reports per-variant
flash/RAM on every push. Time: `scripts/bench-engines.sh` now reports per-engine ns/sample,
blocks/s and realtime factor on native AND WASM from one source
(`tests/cpp/engine_bench.cpp`), engines driven into a working state, with `--compare` for
per-engine deltas and a report step in CI. An engine getting 3x slower is now visible.
feat: curve truth, DriverConfig, real telemetry, engine benchmark Four items from one workflow, committed together because their build and CI wiring genuinely interleaves — nisps/CMakeLists.txt, run-all-tests.sh and ci.yml each carry hunks from two of them, and the stage renumbering (1/5 -> 1/6) touches every line. Splitting would produce commits that do not build, which is worse than a commit that does four things and says so. S26 part 2 — the curve declaration now matches reality. params[].curve stays the mode-wide DEFAULT; a voice_spaces entry may now be {name, curve_overrides} declaring only the slots where THAT voice space deviates. The 6 modes with one voice space are byte-identical. The values were derived MECHANICALLY by a new codegen/curve-audit.ts that models the four idioms a p[N]*p[N] regex misses (alias form, memlcelium's implicit-counter sq() lambda, loop-generated indices, smooth_params_), inlines helpers, and RAISES rather than guessing when it cannot reduce an expression. A drift gate cross-checks 1179 (voice space x param) slots against engine source on every run and was proved to fail loudly on three drift classes. Application stays in the engine: nisps/engines, nisps/pipeline and nisps/core are untouched, generated output is pure insertion (755 insertions, 0 deletions), and the rebuilt nisps.wasm was byte-identical. S4 / 7.2 — firmware reads the active mode's driver config at mode start, and mic/line is real. My brief assumed the engine owns this; the code disagreed and the code was right. sound_analysis_midi's EngineT is NoOpEngine — the mic lives on a separately-composed AnalysisEngine member — so engine-level wiring would have compiled, passed every gate, and left the one mic mode on line input. Hence a mode-level seam defaulting to engine().driver_config(). Separately, DriverConfig's defaults (line_level 0, output_volume 1.0) had drifted from memllib's actual 3/0.8 because nothing had ever read them; wiring them as-is would have made every silent mode louder and its line input maximally insensitive — a behaviour change disguised as plumbing. Now pinned by a test. Also: GetSysClockSpeed() panic()s on unsupported sample rates and runs on the first line of setup(), so sample_rate needed a fallback ahead of clock setup. CI's firmware env list gains soundanalysismidi — it is the only mic variant and nothing else compiles that path. Plan 5e — telemetry is real. A loss_history C-API entry across the full 5-layer chain lets the browser read the per-iteration loss the core already records. The audit named one fabrication site; there were two — wasm-iml.ts's synchronous train() published lossHistory: [loss] as well. A third, ctx.loss, was not merely dead but actively synthetic (fallbacks of prev * 0.82 and a literal 0.5, rendered by nothing) and is deleted. The firmware buffer stays untouched, per the L25 call. EngineApi.lossHistory() reads spine state rather than the MLP handle, because trainAsync() fits on the worker's mirror net and the handle would give a subtly-wrong second answer. Plan 5f — engine throughput is measurable. One source compiled twice (CMake natively, emcc for WASM) so the targets compare directly and no WASM export is added. Sequencers are driven into a working state, and every row prints its own working-state evidence so a number produced by an idle engine is visible rather than plausible. Reports, never asserts: a wall-clock threshold on shared hardware is meaningless or flaky, same call as the firmware size job. ALIGNMENT: the telemetry defect is deleted (built, not deferred); the performance defect is rewritten to what is actually left — these are HOST numbers, and nothing measures the RP2350 at 150 MHz, which is the target the mission's constraint is about. Q4 (memllib ownership) and Q5 (legacy feedback modes) are closed. Corrections to my own earlier claims, both found by agents contradicting the brief: manifold/ONBOARDING.md was NOT "now accurate" — its primitives list still named five deleted primitives and cited a seededGradient() that does not exist. And the parity harness misses the sequencer engines because it runs 128 frames while their sequencers evaluate every 400-500 samples, NOT because all-params-0.5 fails to trigger them (it does trigger: 0.5 maps to ratio 2, firing three times per bar). The fix is a longer window, not different params. Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS, lint clean, curve drift 1179 slots ok, 39 e2e (was 33). Firmware: 5 envs built including the mic variant.
2026-07-21 22:02:23 +02:00
**What is left.** The numbers are HOST numbers. The mission's performance constraint is the
**RP2350 at 150 MHz**, and nothing measures there — a host realtime factor of 100x says
nothing about whether an engine fits in the MCU's per-block budget, and the two targets have
different FPU, cache and memory behaviour. The honest next step is an on-device timing report
(cycle counter around the audio callback, published over the existing display/serial surface),
which lands naturally with the hardware editor (defect 3) since that is what gives firmware a
command surface to report through.
feat: curve truth, DriverConfig, real telemetry, engine benchmark Four items from one workflow, committed together because their build and CI wiring genuinely interleaves — nisps/CMakeLists.txt, run-all-tests.sh and ci.yml each carry hunks from two of them, and the stage renumbering (1/5 -> 1/6) touches every line. Splitting would produce commits that do not build, which is worse than a commit that does four things and says so. S26 part 2 — the curve declaration now matches reality. params[].curve stays the mode-wide DEFAULT; a voice_spaces entry may now be {name, curve_overrides} declaring only the slots where THAT voice space deviates. The 6 modes with one voice space are byte-identical. The values were derived MECHANICALLY by a new codegen/curve-audit.ts that models the four idioms a p[N]*p[N] regex misses (alias form, memlcelium's implicit-counter sq() lambda, loop-generated indices, smooth_params_), inlines helpers, and RAISES rather than guessing when it cannot reduce an expression. A drift gate cross-checks 1179 (voice space x param) slots against engine source on every run and was proved to fail loudly on three drift classes. Application stays in the engine: nisps/engines, nisps/pipeline and nisps/core are untouched, generated output is pure insertion (755 insertions, 0 deletions), and the rebuilt nisps.wasm was byte-identical. S4 / 7.2 — firmware reads the active mode's driver config at mode start, and mic/line is real. My brief assumed the engine owns this; the code disagreed and the code was right. sound_analysis_midi's EngineT is NoOpEngine — the mic lives on a separately-composed AnalysisEngine member — so engine-level wiring would have compiled, passed every gate, and left the one mic mode on line input. Hence a mode-level seam defaulting to engine().driver_config(). Separately, DriverConfig's defaults (line_level 0, output_volume 1.0) had drifted from memllib's actual 3/0.8 because nothing had ever read them; wiring them as-is would have made every silent mode louder and its line input maximally insensitive — a behaviour change disguised as plumbing. Now pinned by a test. Also: GetSysClockSpeed() panic()s on unsupported sample rates and runs on the first line of setup(), so sample_rate needed a fallback ahead of clock setup. CI's firmware env list gains soundanalysismidi — it is the only mic variant and nothing else compiles that path. Plan 5e — telemetry is real. A loss_history C-API entry across the full 5-layer chain lets the browser read the per-iteration loss the core already records. The audit named one fabrication site; there were two — wasm-iml.ts's synchronous train() published lossHistory: [loss] as well. A third, ctx.loss, was not merely dead but actively synthetic (fallbacks of prev * 0.82 and a literal 0.5, rendered by nothing) and is deleted. The firmware buffer stays untouched, per the L25 call. EngineApi.lossHistory() reads spine state rather than the MLP handle, because trainAsync() fits on the worker's mirror net and the handle would give a subtly-wrong second answer. Plan 5f — engine throughput is measurable. One source compiled twice (CMake natively, emcc for WASM) so the targets compare directly and no WASM export is added. Sequencers are driven into a working state, and every row prints its own working-state evidence so a number produced by an idle engine is visible rather than plausible. Reports, never asserts: a wall-clock threshold on shared hardware is meaningless or flaky, same call as the firmware size job. ALIGNMENT: the telemetry defect is deleted (built, not deferred); the performance defect is rewritten to what is actually left — these are HOST numbers, and nothing measures the RP2350 at 150 MHz, which is the target the mission's constraint is about. Q4 (memllib ownership) and Q5 (legacy feedback modes) are closed. Corrections to my own earlier claims, both found by agents contradicting the brief: manifold/ONBOARDING.md was NOT "now accurate" — its primitives list still named five deleted primitives and cited a seededGradient() that does not exist. And the parity harness misses the sequencer engines because it runs 128 frames while their sequencers evaluate every 400-500 samples, NOT because all-params-0.5 fails to trigger them (it does trigger: 0.5 maps to ratio 2, firing three times per bar). The fix is a longer window, not different params. Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS, lint clean, curve drift 1179 slots ok, 39 e2e (was 33). Firmware: 5 envs built including the mic variant.
2026-07-21 22:02:23 +02:00
**Rough cost.** Host half is done. On-device: ~a day, and it wants defect 3's serial protocol
to have somewhere to send the number.
fix(ml): port RMSProp — ported learning rates were landing in SGD Upstream memlp (github.com/MusicallyEmbodiedML/memlp @ ea777502, the commit upstream/main pins) applies gradients with RMSProp everywhere: Layer.h:239 ApplyAccumulatedGradients, the m_sq_grad_avg running average at Layer.h:601, StaticMLP.h:268. nisps/ml/training.hpp shipped SGD only and filed the difference as an optimiser-choice research question. It was not one. RMSProp divides each step by the running gradient magnitude, so an upstream lr is a NORMALISED step; under SGD the same number multiplies the raw gradient. Every learning rate ported from upstream therefore landed in an optimiser that reads it differently — most visibly feedback.hpp's `geo_lr_ = 0.001f // upstream InterfaceRL.hpp:312`, an RMSProp LR pasted into a single SGD step. rmsprop_step() ports Layer.h:239 exactly: clip at +/-10, sq = min(0.9*sq + 0.1*g^2, 1e6), adj = min(lr/(sqrt(sq)+1e-6), 1.0), w -= adj*g. The adjusted-LR clamp stays one-sided as upstream's std::min is, so the negative lr used by train_targets' "train away from this target" path behaves as it does upstream. The per-weight squared-gradient average is new persistent state and lives in the storage policies (FixedStorage arrays / DynamicStorage arena) so nisps/ stays allocation-free and the firmware's zero-heap contract holds. It is optimiser state, not model state: excluded from weight_count()/get_weights()/set_weights(), matching upstream, and cleared by MLPCore::reset_optimizer_state() (upstream ResetOptimizerState). draw_weights() deliberately does NOT clear it — upstream's DrawWeights doesn't either. Measured with tests/cpp/ml_bench.cpp: D1 one geometric dislike moves the mapping 1.6e-2, up from 5.3e-5 (~295x), and repeated presses now CONVERGE on the intended 0.5 push (0.12 at 10, 0.56 at 100) instead of creeping linearly forever. A4 geometric-vs-Diffuse gap narrows from ~4100x to ~14x in one press. U4 the upstream-LR positive path actually trains now (range_util 0.71 at 100 ticks/gesture, was 0.016 — it was inert under SGD). Not fixed by this, and now tracked as ALIGNMENT defect 6d: the dose asymmetry. lurch_max is still ~1.08 against a [0,1] output range. Golden vector stages 2 and 3 re-captured; stages 0 and 1 are pre-training and did not move, which is the cross-check that only the update rule changed. manifold/public/nisps.wasm rebuilt so parity-check compares like with like — it FAILED at up to 5e-2 against the stale artifact and PASSES at 2.4e-7 against a fresh one. parity-check.sh only builds the WASM when it is missing, never when it is stale; noted in MAP.md and filed separately. ALIGNMENT defect 6 resolved (moved to Recently resolved); 6b's optimiser cross-reference updated; new defect 6d for the positive-training dose. Gates: build-cpp-tests 138 tests / ctest 4/4, parity-check PASS, lint-cpp clean, manifold typecheck clean.
2026-07-25 11:11:23 +02:00
### 6d. One like still heaves the whole mapping (2026-07-25)
**What.** A thumbs-up trains at `lr 1.0 x 1000 iterations` on every gesture. `ml_bench`
U1/U4 measure **lurch** — how far the mapping the musician is playing moves per single
gesture, averaged over the field: `lurch_max` 1.08 against a [0,1] output range, i.e.
one thumbs-up can move the mapping somewhere in the space by more than the entire output
range. Retention (how much of the previous teaching survives) is 0.38; at `iters=1` it
is 0.80.
**Why it blocks the mission.** RMSProp did NOT fix the positive lurch — normalising the
step size does not change its dose. The negative path now exposes upstream-style repeated
small steps (rate/lifetime/LR are live controls), so its old fixed ~70x comparison is no
longer current. Positive teaching remains one enormous blocking train, and the two doses
still need a matched head-to-head rather than independent tuning.
fix(ml): port RMSProp — ported learning rates were landing in SGD Upstream memlp (github.com/MusicallyEmbodiedML/memlp @ ea777502, the commit upstream/main pins) applies gradients with RMSProp everywhere: Layer.h:239 ApplyAccumulatedGradients, the m_sq_grad_avg running average at Layer.h:601, StaticMLP.h:268. nisps/ml/training.hpp shipped SGD only and filed the difference as an optimiser-choice research question. It was not one. RMSProp divides each step by the running gradient magnitude, so an upstream lr is a NORMALISED step; under SGD the same number multiplies the raw gradient. Every learning rate ported from upstream therefore landed in an optimiser that reads it differently — most visibly feedback.hpp's `geo_lr_ = 0.001f // upstream InterfaceRL.hpp:312`, an RMSProp LR pasted into a single SGD step. rmsprop_step() ports Layer.h:239 exactly: clip at +/-10, sq = min(0.9*sq + 0.1*g^2, 1e6), adj = min(lr/(sqrt(sq)+1e-6), 1.0), w -= adj*g. The adjusted-LR clamp stays one-sided as upstream's std::min is, so the negative lr used by train_targets' "train away from this target" path behaves as it does upstream. The per-weight squared-gradient average is new persistent state and lives in the storage policies (FixedStorage arrays / DynamicStorage arena) so nisps/ stays allocation-free and the firmware's zero-heap contract holds. It is optimiser state, not model state: excluded from weight_count()/get_weights()/set_weights(), matching upstream, and cleared by MLPCore::reset_optimizer_state() (upstream ResetOptimizerState). draw_weights() deliberately does NOT clear it — upstream's DrawWeights doesn't either. Measured with tests/cpp/ml_bench.cpp: D1 one geometric dislike moves the mapping 1.6e-2, up from 5.3e-5 (~295x), and repeated presses now CONVERGE on the intended 0.5 push (0.12 at 10, 0.56 at 100) instead of creeping linearly forever. A4 geometric-vs-Diffuse gap narrows from ~4100x to ~14x in one press. U4 the upstream-LR positive path actually trains now (range_util 0.71 at 100 ticks/gesture, was 0.016 — it was inert under SGD). Not fixed by this, and now tracked as ALIGNMENT defect 6d: the dose asymmetry. lurch_max is still ~1.08 against a [0,1] output range. Golden vector stages 2 and 3 re-captured; stages 0 and 1 are pre-training and did not move, which is the cross-check that only the update rule changed. manifold/public/nisps.wasm rebuilt so parity-check compares like with like — it FAILED at up to 5e-2 against the stale artifact and PASSES at 2.4e-7 against a fresh one. parity-check.sh only builds the WASM when it is missing, never when it is stale; noted in MAP.md and filed separately. ALIGNMENT defect 6 resolved (moved to Recently resolved); 6b's optimiser cross-reference updated; new defect 6d for the positive-training dose. Gates: build-cpp-tests 138 tests / ctest 4/4, parity-check PASS, lint-cpp clean, manifold typecheck clean.
2026-07-25 11:11:23 +02:00
**Rough cost.** Cheap to change, expensive to choose: the tuning space is now measurable
(`ml_bench` U4 sweeps dose; U1 sweeps upstream's soft-target alpha, where alpha=1 is
NISPS today). It wants a matched-N head-to-head, not a guess.
test(ml): behavioural benchmark + 20 invariants for the control mapping NISPS is a controller, not a synth: the object of study is the mapping f: control-space -> parameter-space and how a musician's gestures deform it. Loss measures fit to points the user dictated, which is the one thing they never experience. So this measures geometry and gesture-response. tests/cpp/ml_bench.cpp 61 scenarios, REPORTS never asserts (same discipline as engine_bench.cpp). Shape- agnostic via MLPCore<DynamicStorage> (--shape, default 2,16,16,16,8), seeded RNG throughout, branch points replayed from scratch rather than snapshotted. tests/cpp/test_ml_behaviour.cpp 20 asserting invariants, wired into nisps_core_tests. scripts/bench-ml.sh native + WASM from one source; --compare, --sweep-shape, --smoke, --scenario, --seed. Documents two contracts that fail SILENTLY (both now pinned by tests): a thumbs-up must call BOTH mlp.add_example() and fb.store_positive(), since dislike_geometric k-NNs the replay buffer and not the MLP dataset; and placed_output() is valid only while state == Placing, after which an empty span whose l2() is 0 scores a broken lifecycle as a perfect place. ALIGNMENT defect 6 re-ranked (SGD-vs-RMSProp is not a research axis - it silently invalidated every ported hyperparameter) and split into 6b (the geometric dislike was ported from a superseded upstream design) and 6c (InterfaceRL, the reference impl, is not in the tree). Gates: build-cpp-tests (138 tests, ctest 4/4), parity-check PASS, lint-cpp clean, bench-ml.sh --smoke runs end to end.
2026-07-25 11:02:24 +02:00
## Open mission questions
### Q1: Per-mode MLP architectures or one shared shape? (2026-04-29)
Schemas declare per-mode dims and since P5.3 both targets honour them. Is the mission served by maintaining per-mode shapes (research diversity) or collapsing to one (simpler ops)? Note the audit found all 9 mode schemas share copy-pasted ML defaults and 20 params are anonymous placeholders — the per-mode diversity is currently nominal (plan L40).
### Q2: Engine event taxonomy (2026-04-29)
`ControlEvent` is a flat enum consumed by the two sequencer modes. Revisit when a third event-emitting mode lands.
### Q3: Should Manifold stay desktop-first? (2026-04-29)
Legacy a-immersive was mobile-first; Manifold is desktop-first. Defer until user data exists.
## Deferred / accepted debt
- **EOC effects chain, ShapeSeq sequencer, modular engine (Phase E)** — legacy features consciously out of the v1 rewrite; revisit only if a mode wants them.
- **Inputs multi-source composition** (2026-06-28, reaffirmed 2026-07-21) — mix-and-match pad+gamepad+MIDI is a recorded, unreversed decision; the UI currently enforces exclusive single-source and the composition machinery sits dormant *by design*. Schedule or keep dormant — but the inputs-spec must stop presenting composition as current behaviour (plan §8).
- **Schema content is partially placeholder** (2026-07-21) — 20 anonymous "Param NN" slots across paf_synth/channel_strip/xiasri and copy-pasted ML defaults across all 9 modes. Name them during the first curated-preset pass per mode (plan §6.5c), or shrink `output_size` where the engine allows.
- **Geometric-dislike deliberate divergences** (2026-07-25): (1) the degenerate-branch RNG draws from deterministic `nisps::Rng`, not libc `rand()`; (2) each live rejection computes its liked centroid at its own stored input, rather than upstream reinterpreting every old rejection around the cursor's current position; (3) live negatives are applied as deterministic per-item RMSProp steps rather than one shuffled `TrainBatch`; (4) a repeated nearby rejection refreshes its lifetime (upstream's current dedup path leaves the original timestamp untouched); (5) upstream's default removal of a nearby positive is not yet adopted because Manifold also has a separate positive MLP dataset that would keep pulling; (6) `RandomiseMlp` uses `draw_weights(spread)` rather than old asymmetric ranges. Native↔WASM parity covers the elapsed-time replay path.
- **Manifold dock splits `state`/`muted`/`armed`** (2026-06-28) — deliberate divergence from the deployed conflated `frozen`↔`muted` model (dock-spec §3.3). `muted`-downstream and the `soloMode` gradient-mask variants remain UI-only; the C API exposes `set_focus` but no per-mode gradient masking yet. (The audit found `soloMode` behaviourally inert in the controller — plan L20 trims it until `train_masked` exists.)
## Recently resolved (delete after a few weeks)
fix(ml): re-base the geometric dislike on upstream e291192 — delete the taper geo_push.hpp and replay.hpp cited memllib @ 0a541cc. upstream/main pins e291192, where the same code had been deliberately redesigned — and because InterfaceRL was not in the tree (fixed one commit ago), we carried the superseded version for months. Three changes, all upstream's: kGeometricPushScale 0.5 -> 1.0 (InterfaceRL.hpp:409) kNegLRBase 0.5 -> 1.5 (InterfaceRL.hpp:410) /(1+len) taper deleted (InterfaceRL.tpp:724) Upstream's own comment on the taper: "a 'no' should clearly move the mapping away even from a sound already far from the liked region (the taper used to kill exactly that case)". The direction is already a unit vector, so the taper only ever shrank the push for exactly the sounds a user is most likely to be rejecting. Cold start is folded into the same path. Upstream's useRandom is `!havePositives || len <= 1e-4`: with nothing liked yet there is no centroid to push away from, so every dim goes in a random direction. Ours instead kept the older 0a541cc fallback — train AWAY from the heard action at a NEGATIVE lr — which was inert whenever the heard action equalled the net's own output, i.e. in the common case. One path now, and a "no" moves the mapping before any likes exist (ml_bench E1: 0 -> 2.3e-3). The GeometricColdStart action is still reported so callers keep their "like a few sounds first" prompt; only the training changed. Measured (ml_bench, one dislike at a point): A4 0.0157 -> 0.0533 at-point displacement (3.4x), so end to end across this and the RMSProp fix: 5.3e-5 -> 5.3e-2, ~1000x. The gap to the legacy Diffuse design closes from ~4100x to ~4.2x. D1 effective_lr 4.7e-4 -> 1.5e-3; 10 presses now reach 0.34, 100 reach the full intended push. A5 compounding 0.87 -> 0.96 (a second press at the same spot is no longer noticeably weaker than the first). A7 damage_ratio essentially unchanged (0.87-1.57) — the collateral damage to protected positives scales with the push and is NOT addressed here; it is the negative-feedback design question. NOT adopted, deliberately: upstream's per-tick batch retraining over all live negatives, and its fixed kDislikeLifetimeMs=2500 in place of our proportional decay. Both need something the core does not have — a per-tick call site and a millisecond clock inside nisps/ml — so they change FeedbackControllerCore's interface rather than its constants. Recorded in ALIGNMENT's deferred-debt entry alongside the existing one-press-one-step divergence, and filed as its own task. test_mlp_geo_dislike.cpp: the taper test now pins its ABSENCE (equal displacement near and far), the cold-start test pins movement where it used to pin inertness, and a new test covers the random-direction branch. ALIGNMENT defect 6b resolved. Gates: build-cpp-tests 139 tests / ctest 4/4, parity-check PASS (WASM rebuilt), lint-cpp clean, firmware slpworkshop SUCCESS.
2026-07-25 11:22:15 +02:00
- 2026-07-25: **The geometric dislike is re-based on upstream `e291192` (defect 6b).**
`kGeometricPushScale` 0.5 -> 1.0, `kNegLRBase` 0.5 -> 1.5, and the `/(1+len)` taper
deleted — upstream's own comment is that a "no" should clearly move the mapping away
even from a sound already far from the liked region, which is exactly the case the
taper killed. Cold start folded into the same path (random direction when nothing is
liked yet) instead of the superseded negative-LR branch, so a "no" now moves the
mapping before any likes exist (`ml_bench` E1: 0 -> 2.3e-3). One dislike moves the
mapping **5.3e-2**, up from 1.6e-2 after the RMSProp fix and 5.3e-5 before it — a
~1000x change end to end, and now within ~4x of the legacy Diffuse design instead of
~4100x (`ml_bench` A4). The follow-up now adopts upstream's repeated-all-negatives
schedule and full-strength wall-clock lifetime through a deterministic elapsed-time
core seam. After operator calibration, Manifold defaults to 0.003 LR, 200 Hz and
2500 ms, exposes all three in the expanded Learning panel, and allows rate/lifetime
zero as an explicit one-shot A/B. The shared core fallback and the panel's explicit
"Upstream defaults" preset remain 0.001 LR, 200 Hz and 2500 ms.
- 2026-07-25: **`InterfaceRL` is back in the tree (defect 6c).** Vendored verbatim from
memllib `e291192` at `firmware/MEMLNaut-NISPS/lib/memllib/reference/` — outside `src/`,
so PlatformIO never compiles it. Upstream drift in the feedback subsystem is a `diff`
again rather than an archaeology session.
fix(ml): port RMSProp — ported learning rates were landing in SGD Upstream memlp (github.com/MusicallyEmbodiedML/memlp @ ea777502, the commit upstream/main pins) applies gradients with RMSProp everywhere: Layer.h:239 ApplyAccumulatedGradients, the m_sq_grad_avg running average at Layer.h:601, StaticMLP.h:268. nisps/ml/training.hpp shipped SGD only and filed the difference as an optimiser-choice research question. It was not one. RMSProp divides each step by the running gradient magnitude, so an upstream lr is a NORMALISED step; under SGD the same number multiplies the raw gradient. Every learning rate ported from upstream therefore landed in an optimiser that reads it differently — most visibly feedback.hpp's `geo_lr_ = 0.001f // upstream InterfaceRL.hpp:312`, an RMSProp LR pasted into a single SGD step. rmsprop_step() ports Layer.h:239 exactly: clip at +/-10, sq = min(0.9*sq + 0.1*g^2, 1e6), adj = min(lr/(sqrt(sq)+1e-6), 1.0), w -= adj*g. The adjusted-LR clamp stays one-sided as upstream's std::min is, so the negative lr used by train_targets' "train away from this target" path behaves as it does upstream. The per-weight squared-gradient average is new persistent state and lives in the storage policies (FixedStorage arrays / DynamicStorage arena) so nisps/ stays allocation-free and the firmware's zero-heap contract holds. It is optimiser state, not model state: excluded from weight_count()/get_weights()/set_weights(), matching upstream, and cleared by MLPCore::reset_optimizer_state() (upstream ResetOptimizerState). draw_weights() deliberately does NOT clear it — upstream's DrawWeights doesn't either. Measured with tests/cpp/ml_bench.cpp: D1 one geometric dislike moves the mapping 1.6e-2, up from 5.3e-5 (~295x), and repeated presses now CONVERGE on the intended 0.5 push (0.12 at 10, 0.56 at 100) instead of creeping linearly forever. A4 geometric-vs-Diffuse gap narrows from ~4100x to ~14x in one press. U4 the upstream-LR positive path actually trains now (range_util 0.71 at 100 ticks/gesture, was 0.016 — it was inert under SGD). Not fixed by this, and now tracked as ALIGNMENT defect 6d: the dose asymmetry. lurch_max is still ~1.08 against a [0,1] output range. Golden vector stages 2 and 3 re-captured; stages 0 and 1 are pre-training and did not move, which is the cross-check that only the update rule changed. manifold/public/nisps.wasm rebuilt so parity-check compares like with like — it FAILED at up to 5e-2 against the stale artifact and PASSES at 2.4e-7 against a fresh one. parity-check.sh only builds the WASM when it is missing, never when it is stale; noted in MAP.md and filed separately. ALIGNMENT defect 6 resolved (moved to Recently resolved); 6b's optimiser cross-reference updated; new defect 6d for the positive-training dose. Gates: build-cpp-tests 138 tests / ctest 4/4, parity-check PASS, lint-cpp clean, manifold typecheck clean.
2026-07-25 11:11:23 +02:00
- 2026-07-25: **The optimiser mismatch (defect 6) is fixed.** `nisps/ml/training.hpp` was
SGD-only while upstream `memlp` (`ea777502`) applies **RMSProp everywhere**, so every
learning rate we ported landed in an optimiser that reads it differently — an RMSProp
`lr` is a normalised step, an SGD `lr` multiplies the raw gradient. `rmsprop_step()`
now ports `Layer.h:239 ApplyAccumulatedGradients` exactly (decay 0.9, eps 1e-6,
sq-avg clamp 1e6, one-sided adjusted-LR clamp 1.0), with the per-weight running
squared-gradient average living in the storage policies so the zero-heap contract
holds. Measured on `ml_bench` D1: one geometric dislike moves the mapping **1.6e-2,
up from 5.3e-5**, and repeated presses now converge on the intended 0.5 push (0.12 at
10 presses, 0.56 at 100) instead of creeping linearly. Golden vector stages 2 and 3
were re-captured; stages 0 and 1 are pre-training and did not move. What this does NOT
fix: the dose asymmetry, now tracked as defect 6d.
feat: curve truth, DriverConfig, real telemetry, engine benchmark Four items from one workflow, committed together because their build and CI wiring genuinely interleaves — nisps/CMakeLists.txt, run-all-tests.sh and ci.yml each carry hunks from two of them, and the stage renumbering (1/5 -> 1/6) touches every line. Splitting would produce commits that do not build, which is worse than a commit that does four things and says so. S26 part 2 — the curve declaration now matches reality. params[].curve stays the mode-wide DEFAULT; a voice_spaces entry may now be {name, curve_overrides} declaring only the slots where THAT voice space deviates. The 6 modes with one voice space are byte-identical. The values were derived MECHANICALLY by a new codegen/curve-audit.ts that models the four idioms a p[N]*p[N] regex misses (alias form, memlcelium's implicit-counter sq() lambda, loop-generated indices, smooth_params_), inlines helpers, and RAISES rather than guessing when it cannot reduce an expression. A drift gate cross-checks 1179 (voice space x param) slots against engine source on every run and was proved to fail loudly on three drift classes. Application stays in the engine: nisps/engines, nisps/pipeline and nisps/core are untouched, generated output is pure insertion (755 insertions, 0 deletions), and the rebuilt nisps.wasm was byte-identical. S4 / 7.2 — firmware reads the active mode's driver config at mode start, and mic/line is real. My brief assumed the engine owns this; the code disagreed and the code was right. sound_analysis_midi's EngineT is NoOpEngine — the mic lives on a separately-composed AnalysisEngine member — so engine-level wiring would have compiled, passed every gate, and left the one mic mode on line input. Hence a mode-level seam defaulting to engine().driver_config(). Separately, DriverConfig's defaults (line_level 0, output_volume 1.0) had drifted from memllib's actual 3/0.8 because nothing had ever read them; wiring them as-is would have made every silent mode louder and its line input maximally insensitive — a behaviour change disguised as plumbing. Now pinned by a test. Also: GetSysClockSpeed() panic()s on unsupported sample rates and runs on the first line of setup(), so sample_rate needed a fallback ahead of clock setup. CI's firmware env list gains soundanalysismidi — it is the only mic variant and nothing else compiles that path. Plan 5e — telemetry is real. A loss_history C-API entry across the full 5-layer chain lets the browser read the per-iteration loss the core already records. The audit named one fabrication site; there were two — wasm-iml.ts's synchronous train() published lossHistory: [loss] as well. A third, ctx.loss, was not merely dead but actively synthetic (fallbacks of prev * 0.82 and a literal 0.5, rendered by nothing) and is deleted. The firmware buffer stays untouched, per the L25 call. EngineApi.lossHistory() reads spine state rather than the MLP handle, because trainAsync() fits on the worker's mirror net and the handle would give a subtly-wrong second answer. Plan 5f — engine throughput is measurable. One source compiled twice (CMake natively, emcc for WASM) so the targets compare directly and no WASM export is added. Sequencers are driven into a working state, and every row prints its own working-state evidence so a number produced by an idle engine is visible rather than plausible. Reports, never asserts: a wall-clock threshold on shared hardware is meaningless or flaky, same call as the firmware size job. ALIGNMENT: the telemetry defect is deleted (built, not deferred); the performance defect is rewritten to what is actually left — these are HOST numbers, and nothing measures the RP2350 at 150 MHz, which is the target the mission's constraint is about. Q4 (memllib ownership) and Q5 (legacy feedback modes) are closed. Corrections to my own earlier claims, both found by agents contradicting the brief: manifold/ONBOARDING.md was NOT "now accurate" — its primitives list still named five deleted primitives and cited a seededGradient() that does not exist. And the parity harness misses the sequencer engines because it runs 128 frames while their sequencers evaluate every 400-500 samples, NOT because all-params-0.5 fails to trigger them (it does trigger: 0.5 maps to ratio 2, firing three times per bar). The fix is a longer window, not different params. Gates: run-all-tests.sh ALL GREEN — 4/4 ctest, parity PASS, lint clean, curve drift 1179 slots ok, 39 e2e (was 33). Firmware: 5 envs built including the mic variant.
2026-07-21 22:02:23 +02:00
- 2026-07-21: **Q4 (who owns memllib) closed.** Vendored at `firmware/MEMLNaut-NISPS/lib/memllib/`
from upstream `e291192`; the submodule and the fork are both gone. **Q5 (legacy feedback modes)
closed** — operator kept all four (`RandomiseOutputs`/`RandomiseMlp`/`Diffuse`/`on_drag`) as
building blocks for comparing how instruments feel under different behaviours, which upholds
rather than reverses `docs/adr/rl-feedback-design.md`.
- 2026-07-21: **Training-health telemetry (old defect 6) is gone** — the browser reads the real
per-iteration loss the core records, both fabrication sites are deleted (`wasm-worker.ts`'s
1-element array AND `wasm-iml.ts`'s sync-train twin, which the audit missed), and the display
sits behind the existing `expanded` drawer depth. The firmware buffer stays, per the L25 call.
- 2026-07-21: **Training-health telemetry (old defect 6) is real.** `nisps_ml_loss_history` now
crosses all five WASM registration layers, so the browser reads the SAME per-iteration curve the
firmware MLP records; `wasm-worker.ts`'s 1-element `new Float32Array([loss])` fake is gone from
both the sync and the async train paths; and the curve + the already-plumbed `get_layer_stats`
render in `manifold/src/console/TrainingHealth.tsx` at the Learning drawer's `expanded` depth.
The firmware buffer stays, per the operator call — it is the record the hardware editor
(defect 3) will read. One more fabrication went with it: `ConsoleCtx.loss`, a synthetic
`prev * 0.82` series no drawer read. With no history the panel says "no training run yet"
rather than drawing a plausible curve.
build(firmware): migrate to PlatformIO and vendor memllib (plan §5) One cut, no dual path. Closes ALIGNMENT defect 3 ("Arduino-CLI build machinery is actively hostile") and vision bullet 4. platformio.ini carries 16 [env:], one per variant, each passing -DMEMLNAUT_MODE_TYPE; selftest passes -DNISPS_SELFTEST=1 instead. The env list IS the registry now — the .ino comment-registry and the NISPS_ST_* token-paste table are deleted rather than migrated. L12 noted that table was already silently missing the currently-shipped SLPWorkshop variant, which is the whole argument against having a second list. Also deleted: the Python/sed machinery that rewrote the COMMITTED .ino on every build, the sketch symlink forest, the global TFT_eSPI User_Setup.h mutation (now -D flags — TFT_eSPI's own documented PlatformIO recipe), the UF2 boot-mount detection stack (upload_protocol=picotool talks to the bootloader directly), and build-firmware-arch.sh entirely. Scripts 683 -> 435 lines. memllib is vendored at lib/memllib/ from upstream e291192; no submodules remain. VENDORED.md records provenance and the re-sync procedure. S9: a firmware-build CI job compiles three representative envs against a cached toolchain and reports per-variant flash/RAM. Firmware is in an automated gate for the FIRST time. The old ci.yml comment justified excluding it as "low verification value" — an assessment that did not survive contact, since the SelfTest variant sat broken for an unknown period calling a DisplayDriver method that did not exist at the pinned memllib commit, and nothing noticed because nothing built it. Verified: all 16 envs build from an empty cache, each within ~520 bytes of the arduino-cli binary it replaces, flash and RAM. Measured as .text+.rodata / .data+.bss+vector+uninitialized — NOT PlatformIO's console line, which double-counts .data on this board. This does not prove the hardware boots; no flash+smoke test was possible and that stays an operator chokepoint. slpworkshop 248232/145028 pafsynth 256880/149716 selftest 216228/17960 (all 16 in the CI log format; none exceeds 2% of a 16 MB flash) Two traps recorded so nobody rediscovers them: vendoring memllib's subdirs without a src/ wrapper makes PlatformIO's library builder silently compile NOTHING while still linking; and project build_flags land BEFORE the framework's own -std=gnu++17 -Os, so build_unflags is required. CORRECTION carried in this commit: the firmware sizes in c19d846's message and the first version of the memllib recon doc were wrong — SLPWorkshop 145348, PAFSynth 145300, SelfTest 141840. They came from building variants in sequence through a SHARED incremental arduino-cli build directory, which reused stale objects and under-reported by ~75 KB. Clean-cache rebuilds of the identical commit give 216736/18492 for SelfTest. The real cost of the memllib upstream bump is +216 bytes flash, not +316. Never measure firmware size through a reused build dir. HISTORY NOTE: this commit and the docs commit before it were rebuilt (force-push, 2026-07-21) so that each contains only what its message describes. The first versions had the firmware deletions stranded in the docs commit by a shared-index race between concurrent agents; content is byte-identical to the originals. Gates: run-all-tests.sh ALL GREEN (nisps/ untouched by this change beyond include paths); 16/16 pio envs build.
2026-07-21 20:17:58 +02:00
- 2026-07-21: **Arduino-CLI build machinery (old defect 3) is gone.** Phase 4 replaced it with a
PlatformIO project: one `[env:]` per variant is now the only variant registry, the `.ino`-mutating
Python/sed machinery and the `NISPS_ST_*` token-paste table and the sketch symlink forest and the
global TFT_eSPI mutation are all deleted, memllib is vendored (no submodule), and firmware finally
entered CI — three representative envs per run, which is what would have caught the SelfTest
variant sitting broken. All 16 envs build; sizes match arduino-cli within ~520 bytes.
- 2026-07-21: Full-repo simplification audit landed (recon + plan + this rewrite). Superseded entries removed: "browser-only engines incomplete" (→ defect 2/plan 5b), "loss curve not plumbed" (→ defect 7), "NISPS_AUDIO_FUNC misshapen" (→ plan Phase 1, S21/L13), stale "VCV not currently maintained" note (vcv/ is active and consumes `nisps/` directly post-P6).
- 2026-07-18: Browser curve maths unified onto the canonical `nisps/core/math.hpp` catalog at P4; four silently-divergent TS curves re-baselined.
- 2026-07-14: WASM MLP fixed-architecture defect resolved by P2 (`MLPCore<Storage>`; browser runtime-shaped, firmware zero-heap fixed).