feat(manifold): geometric dislike + jolt/OU via shared core (one-core-engine P3)
TS half of P3.1/P3.2/P3.3: wire the new WASM exports and delete the TS
approximations now that geometric-dislike, jolt, OU, and the seeded RNG live
in the C++/WASM core.
- types.ts/wasm-iml.ts: bind + wrap dislike_geometric, store_positive,
positive/negative_count, set_avoid_style, jolt_press/step/release/active/
lr_scale/tick_lr_ramp, explore_intensity/get/apply. Weight-mutating wrappers
republish weights (version bump); explore_apply reuses feedbackBuf.
- engine-api: extend .feedback (dislikeGeometric/storePositive/counts/
setAvoidStyle) + new .explore facade. thumbsDown now passes the HEARD
(routed) vector, not the raw MLP output (raw == net output => inert cold-start).
- feedback/controller.ts: delete dislikes[] + applyDislikeBias + both C++ GAP
blocks + the SeededRng field; dislike() -> core dislikeGeometric (returns
action, 15 => cold-start prompt); like() feeds the centroid via the core
thumbsUp; getState() exposes positive/negative counts. Delete feedback/rng.ts.
- engine/exploration.ts: execute the P3 SWAP POINT -> drive engine.explore.*;
delete engine/jolt.ts + ou-explore.ts. UI surface unchanged.
- ConsoleApp: one-time cold-start banner (British spelling), routed heard vector
at the dislike call site.
- App.tsx/spine.ts: under ?debug=1 pin a fixed seed + fixed per-tick dt so the
probe/e2e are deterministic (production keeps time-seeded, real-time dt).
- tests: new geo-dislike.spec.ts; probe gains dislikeGeometric/storePositive/
feedbackCounts/setAvoidStyle; the thumbsDown probe test now drives a real
distinct-heard-vector dislike (bare thumbsDown on the net's own output is
correctly inert under the geometric core). 27 e2e + 9 unit green.
Docs: manifold/ONBOARDING.md engine+feedback sections synced.
2026-07-14 04:54:27 +02:00
|
|
|
/**
|
|
|
|
|
* Geometric dislike (feedback Mode 1) — the SHARED C++/WASM core primitive
|
|
|
|
|
* (one-core-engine P3; rl-feedback-design §2.1). Drives the probe's read-only
|
|
|
|
|
* count accessors + the dislikeGeometric driver.
|
|
|
|
|
*
|
|
|
|
|
* The core reads the MLP's CURRENT input and the passed HEARD (post-pipeline)
|
|
|
|
|
* output vector. With NO positives it runs the cold-start fallback and returns
|
|
|
|
|
* FeedbackAction 15 (GeometricColdStart); with positives it computes the k-NN
|
|
|
|
|
* centroid push-away target and returns 14 (GeometricPush).
|
|
|
|
|
*/
|
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
|
import { loadProbe, settleInputs, countChanged, allWithin } from './helpers';
|
feat(manifold): P5.2/P5.3 — derive MF_MODES from schema truth + per-mode engine dims
Schema-backed modes in console/model.ts are now DERIVED from the codegen
schemas in src/modes/generated/ (source of truth): real param names/groups/
count, plus each mode's ml net shape (MFMode.ml) and schema engine_id. A thin
manifold OVERLAY supplies only label/glyph/ModeClass/input/ordering. New
browser-viable modes xiasri + slp_workshop get derived entries; schema-less
visualizer + c15 stay hand-written on DEFAULT_MODE_ML. Schema min/max/default/
label/curve surface as engine-unit metadata (schemaMin/... on MFParam) without
touching the 0..1 routing semantics.
Switching instrument mode reshapes the runtime-shaped WASM net to the mode's
schema ml config (ConsoleApp effect keyed on [engine, modeId]; no confirm
modal). Boot lands paf_synth dims (4->[10,10,14]->33) once WASM is ready. The
P2.3 axis-count reshape offer still reads the engine's live inputSize and does
not spuriously prompt on a mode switch.
Adds schema-modes.spec.ts (P5 gate): drives switches via a new window.__mf
debug seam and asserts describe() dims, getWeights count, output length/bounds,
and UI param count FROM the imported schemas; spot-checks trainAsync after a
switch. Updates reshape/probe-api/geo-dislike specs to assert from the boot
mode schema instead of the retired fixed 32/126 shape.
All gates green: typecheck, unit (9), build, e2e (33).
2026-07-18 12:45:06 +02:00
|
|
|
import { PafSynthSchema } from '../../src/modes/generated';
|
feat(manifold): geometric dislike + jolt/OU via shared core (one-core-engine P3)
TS half of P3.1/P3.2/P3.3: wire the new WASM exports and delete the TS
approximations now that geometric-dislike, jolt, OU, and the seeded RNG live
in the C++/WASM core.
- types.ts/wasm-iml.ts: bind + wrap dislike_geometric, store_positive,
positive/negative_count, set_avoid_style, jolt_press/step/release/active/
lr_scale/tick_lr_ramp, explore_intensity/get/apply. Weight-mutating wrappers
republish weights (version bump); explore_apply reuses feedbackBuf.
- engine-api: extend .feedback (dislikeGeometric/storePositive/counts/
setAvoidStyle) + new .explore facade. thumbsDown now passes the HEARD
(routed) vector, not the raw MLP output (raw == net output => inert cold-start).
- feedback/controller.ts: delete dislikes[] + applyDislikeBias + both C++ GAP
blocks + the SeededRng field; dislike() -> core dislikeGeometric (returns
action, 15 => cold-start prompt); like() feeds the centroid via the core
thumbsUp; getState() exposes positive/negative counts. Delete feedback/rng.ts.
- engine/exploration.ts: execute the P3 SWAP POINT -> drive engine.explore.*;
delete engine/jolt.ts + ou-explore.ts. UI surface unchanged.
- ConsoleApp: one-time cold-start banner (British spelling), routed heard vector
at the dislike call site.
- App.tsx/spine.ts: under ?debug=1 pin a fixed seed + fixed per-tick dt so the
probe/e2e are deterministic (production keeps time-seeded, real-time dt).
- tests: new geo-dislike.spec.ts; probe gains dislikeGeometric/storePositive/
feedbackCounts/setAvoidStyle; the thumbsDown probe test now drives a real
distinct-heard-vector dislike (bare thumbsDown on the net's own output is
correctly inert under the geometric core). 27 e2e + 9 unit green.
Docs: manifold/ONBOARDING.md engine+feedback sections synced.
2026-07-14 04:54:27 +02:00
|
|
|
|
feat(manifold): P5.2/P5.3 — derive MF_MODES from schema truth + per-mode engine dims
Schema-backed modes in console/model.ts are now DERIVED from the codegen
schemas in src/modes/generated/ (source of truth): real param names/groups/
count, plus each mode's ml net shape (MFMode.ml) and schema engine_id. A thin
manifold OVERLAY supplies only label/glyph/ModeClass/input/ordering. New
browser-viable modes xiasri + slp_workshop get derived entries; schema-less
visualizer + c15 stay hand-written on DEFAULT_MODE_ML. Schema min/max/default/
label/curve surface as engine-unit metadata (schemaMin/... on MFParam) without
touching the 0..1 routing semantics.
Switching instrument mode reshapes the runtime-shaped WASM net to the mode's
schema ml config (ConsoleApp effect keyed on [engine, modeId]; no confirm
modal). Boot lands paf_synth dims (4->[10,10,14]->33) once WASM is ready. The
P2.3 axis-count reshape offer still reads the engine's live inputSize and does
not spuriously prompt on a mode switch.
Adds schema-modes.spec.ts (P5 gate): drives switches via a new window.__mf
debug seam and asserts describe() dims, getWeights count, output length/bounds,
and UI param count FROM the imported schemas; spot-checks trainAsync after a
switch. Updates reshape/probe-api/geo-dislike specs to assert from the boot
mode schema instead of the retired fixed 32/126 shape.
All gates green: typecheck, unit (9), build, e2e (33).
2026-07-18 12:45:06 +02:00
|
|
|
// The boot mode is paf_synth; the heard vector must match its output arity.
|
|
|
|
|
const N_OUTPUTS = PafSynthSchema.ml.output_size; // 33
|
feat(manifold): geometric dislike + jolt/OU via shared core (one-core-engine P3)
TS half of P3.1/P3.2/P3.3: wire the new WASM exports and delete the TS
approximations now that geometric-dislike, jolt, OU, and the seeded RNG live
in the C++/WASM core.
- types.ts/wasm-iml.ts: bind + wrap dislike_geometric, store_positive,
positive/negative_count, set_avoid_style, jolt_press/step/release/active/
lr_scale/tick_lr_ramp, explore_intensity/get/apply. Weight-mutating wrappers
republish weights (version bump); explore_apply reuses feedbackBuf.
- engine-api: extend .feedback (dislikeGeometric/storePositive/counts/
setAvoidStyle) + new .explore facade. thumbsDown now passes the HEARD
(routed) vector, not the raw MLP output (raw == net output => inert cold-start).
- feedback/controller.ts: delete dislikes[] + applyDislikeBias + both C++ GAP
blocks + the SeededRng field; dislike() -> core dislikeGeometric (returns
action, 15 => cold-start prompt); like() feeds the centroid via the core
thumbsUp; getState() exposes positive/negative counts. Delete feedback/rng.ts.
- engine/exploration.ts: execute the P3 SWAP POINT -> drive engine.explore.*;
delete engine/jolt.ts + ou-explore.ts. UI surface unchanged.
- ConsoleApp: one-time cold-start banner (British spelling), routed heard vector
at the dislike call site.
- App.tsx/spine.ts: under ?debug=1 pin a fixed seed + fixed per-tick dt so the
probe/e2e are deterministic (production keeps time-seeded, real-time dt).
- tests: new geo-dislike.spec.ts; probe gains dislikeGeometric/storePositive/
feedbackCounts/setAvoidStyle; the thumbsDown probe test now drives a real
distinct-heard-vector dislike (bare thumbsDown on the net's own output is
correctly inert under the geometric core). 27 e2e + 9 unit green.
Docs: manifold/ONBOARDING.md engine+feedback sections synced.
2026-07-14 04:54:27 +02:00
|
|
|
// A heard vector deliberately distinct from any plausible net output.
|
|
|
|
|
const HEARD = new Array(N_OUTPUTS).fill(0.9);
|
|
|
|
|
|
|
|
|
|
test.describe('geometric dislike (Mode 1) — core-backed', () => {
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
|
await loadProbe(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('dislike before any likes returns cold-start (15) and stores a negative', async ({ page }) => {
|
|
|
|
|
const r = await page.evaluate((heard) => {
|
|
|
|
|
const p = window.__nisps!;
|
|
|
|
|
p.setFeedbackMode('avoid'); // geometric dislike proto mode maps to core Avoid
|
|
|
|
|
p.setAvoidStyle(0); // Geometric (default)
|
|
|
|
|
p.setInputs(0.5, 0.5);
|
|
|
|
|
const action = p.dislikeGeometric(heard);
|
|
|
|
|
return { action, counts: p.feedbackCounts() };
|
|
|
|
|
}, HEARD);
|
|
|
|
|
expect(r.action).toBe(15); // GeometricColdStart
|
|
|
|
|
expect(r.counts.positive).toBe(0);
|
|
|
|
|
expect(r.counts.negative).toBe(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('two likes then a dislike pushes (14), changes the disliked output, stays bounded', async ({ page }) => {
|
|
|
|
|
await page.evaluate(() => {
|
|
|
|
|
window.__nisps!.setFeedbackMode('avoid');
|
|
|
|
|
window.__nisps!.setAvoidStyle(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Like at two distinct inputs — the core's thumbsUp auto-stores a positive
|
|
|
|
|
// into the k-NN centroid while in Avoid+Geometric mode (ADR §2.1).
|
|
|
|
|
await settleInputs(page, 0.2, 0.3);
|
|
|
|
|
await page.evaluate(() => window.__nisps!.thumbsUp());
|
|
|
|
|
await settleInputs(page, 0.8, 0.7);
|
|
|
|
|
await page.evaluate(() => window.__nisps!.thumbsUp());
|
|
|
|
|
|
|
|
|
|
// Settle at a third input and capture the heard-≠-output baseline there.
|
|
|
|
|
const before = await settleInputs(page, 0.5, 0.5);
|
|
|
|
|
// Sanity: the heard vector we will pass genuinely differs from the outputs.
|
|
|
|
|
expect(countChanged(before, HEARD, 1e-3)).toBeGreaterThan(0);
|
|
|
|
|
|
|
|
|
|
// Dislike at the settled input with an explicit lr for a visibly-audible push.
|
|
|
|
|
const res = await page.evaluate((heard) => {
|
|
|
|
|
const p = window.__nisps!;
|
|
|
|
|
const action = p.dislikeGeometric(heard, 1.0);
|
|
|
|
|
return { action, counts: p.feedbackCounts() };
|
|
|
|
|
}, HEARD);
|
|
|
|
|
|
|
|
|
|
// Re-settle at the same input; the weights moved, so the output must too.
|
|
|
|
|
const after = await settleInputs(page, 0.5, 0.5);
|
|
|
|
|
|
|
|
|
|
expect(res.action).toBe(14); // GeometricPush (positives exist → not cold-start)
|
|
|
|
|
expect(res.counts.positive).toBeGreaterThanOrEqual(2);
|
|
|
|
|
expect(res.counts.negative).toBe(1);
|
|
|
|
|
expect(countChanged(before, after, 1e-4)).toBeGreaterThan(0);
|
|
|
|
|
expect(allWithin(after, 0, 1)).toBe(true);
|
|
|
|
|
});
|
2026-07-25 16:14:35 +02:00
|
|
|
|
|
|
|
|
test('parameterised replay applies configured dose then expires by wall time', async ({ page }) => {
|
|
|
|
|
const result = await page.evaluate((heard) => {
|
|
|
|
|
const p = window.__nisps!;
|
|
|
|
|
p.setFeedbackMode('avoid');
|
|
|
|
|
p.setAvoidStyle(0);
|
|
|
|
|
p.setGeometricConfig(0.001, 20, 100);
|
|
|
|
|
p.setInputs(0.4, 0.6);
|
|
|
|
|
p.dislikeGeometric(heard);
|
|
|
|
|
const first = p.advanceGeometric(0.05);
|
|
|
|
|
const live = p.feedbackCounts().negative;
|
|
|
|
|
const second = p.advanceGeometric(0.05);
|
|
|
|
|
const expired = p.feedbackCounts().negative;
|
|
|
|
|
return { first, live, second, expired };
|
|
|
|
|
}, HEARD);
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual({ first: 1, live: 1, second: 1, expired: 0 });
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-25 17:43:52 +02:00
|
|
|
test('Push away starts once on pointer-down and holding never rerolls', async ({ page }) => {
|
|
|
|
|
const button = page.getByTitle(/Dislike — push the sound away/);
|
|
|
|
|
const box = await button.boundingBox();
|
|
|
|
|
if (!box) throw new Error('negative-feedback button has no bounds');
|
|
|
|
|
|
|
|
|
|
await page.mouse.move(box.x + box.width / 2, box.y + box.height / 2);
|
|
|
|
|
await page.mouse.down();
|
|
|
|
|
expect(await page.evaluate(() => window.__nisps!.feedbackCounts().negative)).toBe(1);
|
|
|
|
|
|
|
|
|
|
await page.waitForTimeout(700);
|
|
|
|
|
expect(await page.evaluate(() => window.__nisps!.feedbackCounts().negative)).toBe(1);
|
|
|
|
|
|
|
|
|
|
await page.mouse.up();
|
|
|
|
|
expect(await page.evaluate(() => window.__nisps!.feedbackCounts().negative)).toBe(1);
|
|
|
|
|
await expect(button).not.toHaveAttribute('title', /hold|re-roll/);
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-25 17:18:44 +02:00
|
|
|
test('expanded Learning panel starts calibrated and can restore upstream defaults', async ({ page }) => {
|
2026-07-25 16:14:35 +02:00
|
|
|
await page.getByTitle('Learning', { exact: true }).click();
|
|
|
|
|
await page.getByTitle('Expand', { exact: true }).click();
|
|
|
|
|
|
|
|
|
|
await expect(page.getByText('push · learning rate', { exact: true })).toBeVisible();
|
|
|
|
|
await expect(page.getByText('push · updates / second', { exact: true })).toBeVisible();
|
|
|
|
|
await expect(page.getByText('push · lifetime', { exact: true })).toBeVisible();
|
2026-07-25 17:18:44 +02:00
|
|
|
await expect(page.getByText('0.0030', { exact: true })).toBeVisible();
|
2026-07-25 16:14:35 +02:00
|
|
|
await expect(page.getByText('200 Hz', { exact: true })).toBeVisible();
|
|
|
|
|
await expect(page.getByText('2.5 s', { exact: true })).toBeVisible();
|
|
|
|
|
await expect(page.getByText('≈ 500 replay updates + the press')).toBeVisible();
|
2026-07-25 17:18:44 +02:00
|
|
|
|
|
|
|
|
await page.getByRole('button', { name: 'Upstream defaults' }).click();
|
|
|
|
|
await expect(page.getByText('0.0010', { exact: true })).toBeVisible();
|
2026-07-25 16:14:35 +02:00
|
|
|
});
|
feat(manifold): geometric dislike + jolt/OU via shared core (one-core-engine P3)
TS half of P3.1/P3.2/P3.3: wire the new WASM exports and delete the TS
approximations now that geometric-dislike, jolt, OU, and the seeded RNG live
in the C++/WASM core.
- types.ts/wasm-iml.ts: bind + wrap dislike_geometric, store_positive,
positive/negative_count, set_avoid_style, jolt_press/step/release/active/
lr_scale/tick_lr_ramp, explore_intensity/get/apply. Weight-mutating wrappers
republish weights (version bump); explore_apply reuses feedbackBuf.
- engine-api: extend .feedback (dislikeGeometric/storePositive/counts/
setAvoidStyle) + new .explore facade. thumbsDown now passes the HEARD
(routed) vector, not the raw MLP output (raw == net output => inert cold-start).
- feedback/controller.ts: delete dislikes[] + applyDislikeBias + both C++ GAP
blocks + the SeededRng field; dislike() -> core dislikeGeometric (returns
action, 15 => cold-start prompt); like() feeds the centroid via the core
thumbsUp; getState() exposes positive/negative counts. Delete feedback/rng.ts.
- engine/exploration.ts: execute the P3 SWAP POINT -> drive engine.explore.*;
delete engine/jolt.ts + ou-explore.ts. UI surface unchanged.
- ConsoleApp: one-time cold-start banner (British spelling), routed heard vector
at the dislike call site.
- App.tsx/spine.ts: under ?debug=1 pin a fixed seed + fixed per-tick dt so the
probe/e2e are deterministic (production keeps time-seeded, real-time dt).
- tests: new geo-dislike.spec.ts; probe gains dislikeGeometric/storePositive/
feedbackCounts/setAvoidStyle; the thumbsDown probe test now drives a real
distinct-heard-vector dislike (bare thumbsDown on the net's own output is
correctly inert under the geometric core). 27 e2e + 9 unit green.
Docs: manifold/ONBOARDING.md engine+feedback sections synced.
2026-07-14 04:54:27 +02:00
|
|
|
});
|