test(manifold): port probe-API contract + spine-invariant e2e from playground
Migrate the specs worth keeping from playground/tests/e2e (retired in P1) into
manifold/tests/e2e, adapted to Manifold's probe surface:
- probe-api.spec.ts: the window.__nisps debug-probe contract (ready, bounded
outputs, example count, randomise, setInputs inference, thumbsUp/Down,
addExample, train loss non-increasing, async train, clearExamples, evalLoss,
inferBatch, getLayerStats, getWeights). Retargeted to MLP<32,10,14,18,126>
(weight_count 3148) and Manifold's direct addExample/routedOutputs surface;
dropped the playground's __init/iml-poke escape hatches and stream-pending
skips.
- spine.spec.ts: the spine invariant — setInputs -> processed -> ml -> routed
yields bounded, consistent routed outputs; the probe stays alive across dock
output-mode switches (driven via the real selector UI, replacing the
playground's localStorage-reload mode cycling).
- helpers.ts: loadProbe(?debug=1 + cleared storage + __ready wait), settleInputs
for EMA convergence, bounded/changed assertions.
Dropped playground UI specs (ui-interactions, persistence, mode-registry list)
that die with the playground chrome. No probe.ts changes needed.
2026-07-13 23:26:00 +02:00
|
|
|
/**
|
|
|
|
|
* Debug-probe API contract — `window.__nisps` (gated behind `?debug=1`).
|
|
|
|
|
*
|
|
|
|
|
* Ported from `playground/tests/e2e/ml-engine.spec.ts`. This is the ENGINE
|
|
|
|
|
* contract, not playground UI, so it survives the playground's retirement:
|
|
|
|
|
* every probe accessor must return the documented shape and never throw.
|
|
|
|
|
*
|
|
|
|
|
* Adaptations vs. the playground original:
|
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
|
|
|
* - Manifold's net is runtime-shaped and (since P5.3) boots at the BOOT MODE's
|
|
|
|
|
* schema `ml` config, so dims + weight count are derived from the imported
|
|
|
|
|
* schema, never hard-coded.
|
test(manifold): port probe-API contract + spine-invariant e2e from playground
Migrate the specs worth keeping from playground/tests/e2e (retired in P1) into
manifold/tests/e2e, adapted to Manifold's probe surface:
- probe-api.spec.ts: the window.__nisps debug-probe contract (ready, bounded
outputs, example count, randomise, setInputs inference, thumbsUp/Down,
addExample, train loss non-increasing, async train, clearExamples, evalLoss,
inferBatch, getLayerStats, getWeights). Retargeted to MLP<32,10,14,18,126>
(weight_count 3148) and Manifold's direct addExample/routedOutputs surface;
dropped the playground's __init/iml-poke escape hatches and stream-pending
skips.
- spine.spec.ts: the spine invariant — setInputs -> processed -> ml -> routed
yields bounded, consistent routed outputs; the probe stays alive across dock
output-mode switches (driven via the real selector UI, replacing the
playground's localStorage-reload mode cycling).
- helpers.ts: loadProbe(?debug=1 + cleared storage + __ready wait), settleInputs
for EMA convergence, bounded/changed assertions.
Dropped playground UI specs (ui-interactions, persistence, mode-registry list)
that die with the playground chrome. No probe.ts changes needed.
2026-07-13 23:26:00 +02:00
|
|
|
* - No `probe.__init()` / no `mlStore.iml` poke-through: Manifold's probe
|
|
|
|
|
* exposes `addExample()` and `routedOutputs()` directly, so the training
|
|
|
|
|
* tests drive the real public surface instead of an escape hatch.
|
|
|
|
|
* - The playground's `test.skip(!probeReady)` guard is gone — on Manifold the
|
|
|
|
|
* probe is only installed once WASM is live, so a not-ready probe is a
|
|
|
|
|
* genuine failure, not a pending-stream skip.
|
|
|
|
|
*/
|
|
|
|
|
import { test, expect } from '@playwright/test';
|
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 { loadProbe, getOutputs, countChanged, allWithin, weightCountFromMl } from './helpers';
|
|
|
|
|
import { PafSynthSchema } from '../../src/modes/generated';
|
test(manifold): port probe-API contract + spine-invariant e2e from playground
Migrate the specs worth keeping from playground/tests/e2e (retired in P1) into
manifold/tests/e2e, adapted to Manifold's probe surface:
- probe-api.spec.ts: the window.__nisps debug-probe contract (ready, bounded
outputs, example count, randomise, setInputs inference, thumbsUp/Down,
addExample, train loss non-increasing, async train, clearExamples, evalLoss,
inferBatch, getLayerStats, getWeights). Retargeted to MLP<32,10,14,18,126>
(weight_count 3148) and Manifold's direct addExample/routedOutputs surface;
dropped the playground's __init/iml-poke escape hatches and stream-pending
skips.
- spine.spec.ts: the spine invariant — setInputs -> processed -> ml -> routed
yields bounded, consistent routed outputs; the probe stays alive across dock
output-mode switches (driven via the real selector UI, replacing the
playground's localStorage-reload mode cycling).
- helpers.ts: loadProbe(?debug=1 + cleared storage + __ready wait), settleInputs
for EMA convergence, bounded/changed assertions.
Dropped playground UI specs (ui-interactions, persistence, mode-registry list)
that die with the playground chrome. No probe.ts changes needed.
2026-07-13 23:26:00 +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; all dims derive from its schema `ml` config.
|
|
|
|
|
const N_OUTPUTS = PafSynthSchema.ml.output_size; // 33
|
|
|
|
|
const WEIGHT_COUNT = weightCountFromMl(PafSynthSchema.ml); // 4→[10,10,14]→33 = 809
|
|
|
|
|
// 4 layers (3 hidden + output) * 4 stats per layer.
|
test(manifold): port probe-API contract + spine-invariant e2e from playground
Migrate the specs worth keeping from playground/tests/e2e (retired in P1) into
manifold/tests/e2e, adapted to Manifold's probe surface:
- probe-api.spec.ts: the window.__nisps debug-probe contract (ready, bounded
outputs, example count, randomise, setInputs inference, thumbsUp/Down,
addExample, train loss non-increasing, async train, clearExamples, evalLoss,
inferBatch, getLayerStats, getWeights). Retargeted to MLP<32,10,14,18,126>
(weight_count 3148) and Manifold's direct addExample/routedOutputs surface;
dropped the playground's __init/iml-poke escape hatches and stream-pending
skips.
- spine.spec.ts: the spine invariant — setInputs -> processed -> ml -> routed
yields bounded, consistent routed outputs; the probe stays alive across dock
output-mode switches (driven via the real selector UI, replacing the
playground's localStorage-reload mode cycling).
- helpers.ts: loadProbe(?debug=1 + cleared storage + __ready wait), settleInputs
for EMA convergence, bounded/changed assertions.
Dropped playground UI specs (ui-interactions, persistence, mode-registry list)
that die with the playground chrome. No probe.ts changes needed.
2026-07-13 23:26:00 +02:00
|
|
|
const LAYER_STATS = 16;
|
|
|
|
|
|
|
|
|
|
const EXAMPLE_LOW = { input: [0.1, 0.9], output: new Array(N_OUTPUTS).fill(0.1) };
|
|
|
|
|
const EXAMPLE_HIGH = { input: [0.9, 0.1], output: new Array(N_OUTPUTS).fill(0.9) };
|
|
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
|
|
|
await loadProbe(page);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test.describe('ML engine — debug probe contract', () => {
|
|
|
|
|
test('probe is installed and reports ready', async ({ page }) => {
|
|
|
|
|
const kind = await page.evaluate(() => typeof window.__nisps);
|
|
|
|
|
expect(kind).toBe('object');
|
|
|
|
|
const ready = await page.evaluate(() => window.__nisps!.__ready);
|
|
|
|
|
expect(ready).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('initial outputs are bounded in [0, 1]', async ({ page }) => {
|
|
|
|
|
const outs = await getOutputs(page);
|
|
|
|
|
expect(outs).toHaveLength(N_OUTPUTS);
|
|
|
|
|
expect(allWithin(outs, 0, 1)).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('initial state is 0 examples and no loss', async ({ page }) => {
|
|
|
|
|
const count = await page.evaluate(() => window.__nisps!.getExampleCount());
|
|
|
|
|
expect(count).toBe(0);
|
|
|
|
|
const loss = await page.evaluate(() => window.__nisps!.getLoss());
|
|
|
|
|
expect(loss).toBeNull();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('randomise changes outputs', async ({ page }) => {
|
|
|
|
|
await page.evaluate(() => window.__nisps!.setInputs(0.3, 0.7));
|
|
|
|
|
const before = await getOutputs(page);
|
|
|
|
|
await page.evaluate(() => window.__nisps!.randomise());
|
|
|
|
|
await page.evaluate(() => window.__nisps!.setInputs(0.3, 0.7));
|
|
|
|
|
const after = await getOutputs(page);
|
|
|
|
|
expect(countChanged(before, after, 1e-3)).toBeGreaterThan(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('setInputs runs inference and yields bounded outputs', async ({ page }) => {
|
|
|
|
|
await page.evaluate(() => window.__nisps!.setInputs(0.25, 0.75));
|
|
|
|
|
const outs = await getOutputs(page);
|
|
|
|
|
expect(outs).toHaveLength(N_OUTPUTS);
|
|
|
|
|
expect(allWithin(outs, 0, 1)).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('thumbsUp returns a finite FeedbackAction and keeps the count sane', async ({ page }) => {
|
|
|
|
|
await page.evaluate(() => window.__nisps!.setInputs(0.4, 0.6));
|
|
|
|
|
const action = await page.evaluate(() => window.__nisps!.thumbsUp());
|
|
|
|
|
expect(typeof action).toBe('number');
|
|
|
|
|
expect(Number.isFinite(action)).toBe(true);
|
|
|
|
|
const count = await page.evaluate(() => window.__nisps!.getExampleCount());
|
|
|
|
|
expect(Number.isInteger(count)).toBe(true);
|
|
|
|
|
expect(count).toBeGreaterThanOrEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
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
|
|
|
test('thumbsDown returns a finite action; a geometric dislike changes outputs', async ({ page }) => {
|
|
|
|
|
// Under the geometric-dislike core (one-core-engine P3) a dislike trains AWAY
|
|
|
|
|
// from the HEARD (post-pipeline) vector. Passing the net's OWN output — as the
|
|
|
|
|
// bare thumbsDown probe does — is intentionally inert (zero MSE derivative), so
|
|
|
|
|
// we assert only its SHAPE there and drive a real, distinct heard vector for
|
|
|
|
|
// the behaviour. Everything runs in ONE evaluate so the app's input rAF loop
|
|
|
|
|
// cannot drift the input-pipeline EMA between reads (which would make the delta
|
|
|
|
|
// timing-dependent).
|
|
|
|
|
const r = await page.evaluate((n) => {
|
|
|
|
|
const p = window.__nisps!;
|
|
|
|
|
p.setFeedbackMode('avoid'); // geometric dislike proto mode maps to core Avoid
|
|
|
|
|
p.setAvoidStyle(0); // Geometric (default)
|
|
|
|
|
p.setInputs(0.3, 0.7);
|
|
|
|
|
// Contract: thumbsDown returns a finite FeedbackAction and never throws.
|
|
|
|
|
const action = p.thumbsDown();
|
|
|
|
|
// Behaviour: a dislike with a heard vector DISTINCT from the output trains a
|
|
|
|
|
// real push → outputs change deterministically.
|
|
|
|
|
const before = Array.from(p.getOutputs());
|
|
|
|
|
const heard = new Array(n).fill(0.9);
|
|
|
|
|
p.dislikeGeometric(heard, 1.0); // trains + re-processes at the same input
|
|
|
|
|
const after = Array.from(p.getOutputs());
|
|
|
|
|
let changed = 0;
|
|
|
|
|
for (let i = 0; i < before.length; ++i) {
|
|
|
|
|
if (Math.abs(before[i]! - after[i]!) > 1e-4) ++changed;
|
|
|
|
|
}
|
|
|
|
|
return { action, changed };
|
|
|
|
|
}, N_OUTPUTS);
|
|
|
|
|
expect(typeof r.action).toBe('number');
|
|
|
|
|
expect(Number.isFinite(r.action)).toBe(true);
|
|
|
|
|
expect(r.changed).toBeGreaterThan(0);
|
test(manifold): port probe-API contract + spine-invariant e2e from playground
Migrate the specs worth keeping from playground/tests/e2e (retired in P1) into
manifold/tests/e2e, adapted to Manifold's probe surface:
- probe-api.spec.ts: the window.__nisps debug-probe contract (ready, bounded
outputs, example count, randomise, setInputs inference, thumbsUp/Down,
addExample, train loss non-increasing, async train, clearExamples, evalLoss,
inferBatch, getLayerStats, getWeights). Retargeted to MLP<32,10,14,18,126>
(weight_count 3148) and Manifold's direct addExample/routedOutputs surface;
dropped the playground's __init/iml-poke escape hatches and stream-pending
skips.
- spine.spec.ts: the spine invariant — setInputs -> processed -> ml -> routed
yields bounded, consistent routed outputs; the probe stays alive across dock
output-mode switches (driven via the real selector UI, replacing the
playground's localStorage-reload mode cycling).
- helpers.ts: loadProbe(?debug=1 + cleared storage + __ready wait), settleInputs
for EMA convergence, bounded/changed assertions.
Dropped playground UI specs (ui-interactions, persistence, mode-registry list)
that die with the playground chrome. No probe.ts changes needed.
2026-07-13 23:26:00 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('addExample reports success and bumps the example count', async ({ page }) => {
|
|
|
|
|
const ok = await page.evaluate(
|
|
|
|
|
([ex]) => window.__nisps!.addExample(ex.input, ex.output),
|
|
|
|
|
[EXAMPLE_LOW],
|
|
|
|
|
);
|
|
|
|
|
expect(typeof ok).toBe('boolean');
|
|
|
|
|
expect(ok).toBe(true);
|
|
|
|
|
const count = await page.evaluate(() => window.__nisps!.getExampleCount());
|
|
|
|
|
expect(count).toBe(1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('train() with two contrasting examples does not increase loss', async ({ page }) => {
|
|
|
|
|
await page.evaluate(
|
|
|
|
|
([low, high]) => {
|
|
|
|
|
window.__nisps!.addExample(low.input, low.output);
|
|
|
|
|
window.__nisps!.addExample(high.input, high.output);
|
|
|
|
|
},
|
|
|
|
|
[EXAMPLE_LOW, EXAMPLE_HIGH],
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const loss1 = await page.evaluate(() => window.__nisps!.train());
|
|
|
|
|
expect(typeof loss1).toBe('number');
|
|
|
|
|
expect(Number.isFinite(loss1)).toBe(true);
|
|
|
|
|
expect(loss1).toBeGreaterThanOrEqual(0);
|
|
|
|
|
|
|
|
|
|
const loss2 = await page.evaluate(() => window.__nisps!.train());
|
|
|
|
|
expect(loss2).toBeLessThanOrEqual(loss1 + 1e-6);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('async training resolves to a finite non-negative loss', async ({ page }) => {
|
|
|
|
|
await page.evaluate(
|
|
|
|
|
([low, high]) => {
|
|
|
|
|
window.__nisps!.addExample(low.input, low.output);
|
|
|
|
|
window.__nisps!.addExample(high.input, high.output);
|
|
|
|
|
},
|
|
|
|
|
[EXAMPLE_LOW, EXAMPLE_HIGH],
|
|
|
|
|
);
|
|
|
|
|
const loss = await page.evaluate(() => window.__nisps!.trainAsync());
|
|
|
|
|
expect(typeof loss).toBe('number');
|
|
|
|
|
expect(Number.isFinite(loss)).toBe(true);
|
|
|
|
|
expect(loss).toBeGreaterThanOrEqual(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('clearExamples resets the dataset count to 0', async ({ page }) => {
|
|
|
|
|
await page.evaluate(
|
|
|
|
|
([ex]) => window.__nisps!.addExample(ex.input, ex.output),
|
|
|
|
|
[EXAMPLE_LOW],
|
|
|
|
|
);
|
|
|
|
|
expect(await page.evaluate(() => window.__nisps!.getExampleCount())).toBe(1);
|
|
|
|
|
await page.evaluate(() => window.__nisps!.clearExamples());
|
|
|
|
|
expect(await page.evaluate(() => window.__nisps!.getExampleCount())).toBe(0);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('evalLoss returns a non-negative number or null', async ({ page }) => {
|
|
|
|
|
const v = await page.evaluate(() => window.__nisps!.evalLoss());
|
|
|
|
|
if (v !== null) {
|
|
|
|
|
expect(Number.isFinite(v)).toBe(true);
|
|
|
|
|
expect(v).toBeGreaterThanOrEqual(0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('inferBatch returns N * outputSize bounded floats', async ({ page }) => {
|
|
|
|
|
const points: ReadonlyArray<readonly [number, number]> = [
|
|
|
|
|
[0.0, 0.0],
|
|
|
|
|
[0.5, 0.5],
|
|
|
|
|
[1.0, 1.0],
|
|
|
|
|
];
|
|
|
|
|
const flat = await page.evaluate(
|
|
|
|
|
(pts) => Array.from(window.__nisps!.inferBatch(pts as [number, number][])),
|
|
|
|
|
points,
|
|
|
|
|
);
|
|
|
|
|
expect(flat).toHaveLength(points.length * N_OUTPUTS);
|
|
|
|
|
expect(allWithin(flat, 0, 1)).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getLayerStats returns 4 floats per layer, all finite', async ({ page }) => {
|
|
|
|
|
const stats = await page.evaluate(() => Array.from(window.__nisps!.getLayerStats()));
|
|
|
|
|
expect(stats).toHaveLength(LAYER_STATS);
|
|
|
|
|
for (const v of stats) expect(Number.isFinite(v)).toBe(true);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('getWeights returns the full weight vector', async ({ page }) => {
|
|
|
|
|
const len = await page.evaluate(() => window.__nisps!.getWeights().length);
|
|
|
|
|
expect(len).toBe(WEIGHT_COUNT);
|
|
|
|
|
});
|
|
|
|
|
});
|