diff --git a/.factory/skills/solidjs-worker/SKILL.md b/.factory/skills/solidjs-worker/SKILL.md
index e2db6b7..6d32006 100644
--- a/.factory/skills/solidjs-worker/SKILL.md
+++ b/.factory/skills/solidjs-worker/SKILL.md
@@ -36,9 +36,9 @@ All feature implementation for the SolidJS migration. This worker builds compone
### Step 3: Write Tests First (TDD)
1. Write failing tests BEFORE implementation. Tests go in `tests/` at the repo root.
-2. For SolidJS components: use vitest + solid-testing-library (install if needed).
+2. For SolidJS components: use Playwright e2e tests against the Vite dev server (see `playwright-solidjs.config.ts`).
3. For behavioral assertions matching the validation contract: write Playwright e2e tests that use the `window.__nisps` debug probe.
-4. For transplanted core modules: write unit tests verifying the same behavior as the old JS code.
+4. For transplanted core modules: write Playwright e2e tests verifying the same behavior as the old JS code.
5. Run tests to confirm they fail (red).
### Step 4: Implement
diff --git a/src/App.tsx b/src/App.tsx
index ad26cd8..51245ff 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -8,6 +8,7 @@ import FlowField from './components/visual/FlowField';
import Dock from './components/layout/Dock';
import TrainingDrawer from './components/layout/TrainingDrawer';
import StatusLine from './components/layout/StatusLine';
+import RLButtons from './components/rl/RLButtons';
/**
* Root application component for the NISPS immersive app.
@@ -131,7 +132,7 @@ export default function App() {
- {(store) => }
+ {(store) => }
{/* Dock + Drawers + Status (only when ready and ML store exists) */}
@@ -143,6 +144,7 @@ export default function App() {
onClose={() => closeDrawer('training')}
/>
+
diff --git a/src/components/input/Joystick.tsx b/src/components/input/Joystick.tsx
index 37c3eec..7276a4d 100644
--- a/src/components/input/Joystick.tsx
+++ b/src/components/input/Joystick.tsx
@@ -6,6 +6,7 @@
* - Draggable thumb dot that follows pointer
* - Glow effect when touching
* - Follow mode (toggled by double-click) with badge and pulse
+ * - Noise ring indicator (RL exploration level)
* - Position readout at bottom
*
* Pointer events (unified mouse/touch):
@@ -22,13 +23,16 @@ import {
onMount,
onCleanup,
createEffect,
+ createMemo,
Show,
} from 'solid-js';
import type { InputStore } from '../../stores/input-store';
+import type { MLStore } from '../../stores/ml-store';
import './joystick.css';
export interface JoystickProps {
inputStore: InputStore;
+ mlStore?: MLStore;
size?: number;
}
@@ -36,6 +40,17 @@ export default function Joystick(props: JoystickProps) {
let canvasRef: HTMLCanvasElement | undefined;
const size = () => props.size ?? 180;
+ // ─── Noise ring class computation ─────────────────────────────────
+
+ const noiseRingClass = createMemo(() => {
+ const mlStore = props.mlStore;
+ if (!mlStore) return 'noise-ring';
+ const noise = mlStore.noiseLevel();
+ if (noise > 0.15) return 'noise-ring active high';
+ if (noise > 0.01) return 'noise-ring active';
+ return 'noise-ring';
+ });
+
// ─── Drawing ─────────────────────────────────────────────────────
function draw(): void {
@@ -166,6 +181,8 @@ export default function Joystick(props: JoystickProps) {
props.inputStore.joyY();
props.inputStore.isDragging();
props.inputStore.followMode();
+ // Also track noise level (triggers redraw for noise-dependent visuals)
+ if (props.mlStore) props.mlStore.noiseLevel();
draw();
});
@@ -185,6 +202,7 @@ export default function Joystick(props: JoystickProps) {
onPointerUp={onPointerUp}
onDblClick={onDoubleClick}
/>
+
FOLLOW
diff --git a/src/components/input/joystick.css b/src/components/input/joystick.css
index a4ccb83..2d9975d 100644
--- a/src/components/input/joystick.css
+++ b/src/components/input/joystick.css
@@ -47,3 +47,23 @@
0%, 100% { opacity: 1; box-shadow: 0 0 4px rgba(204, 85, 0, 0.4); }
50% { opacity: 0.7; box-shadow: 0 0 12px rgba(204, 85, 0, 0.8); }
}
+
+/* Noise ring (RL exploration indicator) */
+.noise-ring {
+ position: absolute;
+ inset: -4px;
+ border-radius: 50%;
+ border: 0px solid rgba(255, 100, 50, 0.0);
+ pointer-events: none;
+ transition: border-width 0.3s, border-color 0.3s;
+}
+
+.noise-ring.active {
+ border-width: 3px;
+ border-color: rgba(255, 100, 50, 0.5);
+}
+
+.noise-ring.high {
+ border-width: 6px;
+ border-color: rgba(255, 60, 40, 0.6);
+}
diff --git a/src/components/rl/RLButtons.tsx b/src/components/rl/RLButtons.tsx
new file mode 100644
index 0000000..ccae980
--- /dev/null
+++ b/src/components/rl/RLButtons.tsx
@@ -0,0 +1,66 @@
+/**
+ * RLButtons — Floating thumbs-up/thumbs-down buttons for RL feedback.
+ *
+ * Matches the old app's rl-buttons div:
+ * - Thumbs-down (−): explore more (adds noise to weights)
+ * - Thumbs-up (+): keep this (adds example + async training + decays noise)
+ *
+ * Positioned at bottom-center of viewport, above the status line.
+ * Glass morphism circular buttons with keyboard shortcut hints.
+ */
+
+import { createEffect } from 'solid-js';
+import type { MLStore } from '../../stores/ml-store';
+import './rl-buttons.css';
+
+export interface RLButtonsProps {
+ mlStore: MLStore;
+}
+
+export default function RLButtons(props: RLButtonsProps) {
+ let thumbsUpBtn: HTMLButtonElement | undefined;
+ let thumbsDownBtn: HTMLButtonElement | undefined;
+
+ function onThumbsUp(): void {
+ flashButton(thumbsUpBtn);
+ props.mlStore.thumbsUp().then(() => {
+ // Training callback handles UI update via reactive signals
+ });
+ }
+
+ function onThumbsDown(): void {
+ flashButton(thumbsDownBtn);
+ props.mlStore.thumbsDown();
+ }
+
+ function flashButton(btn: HTMLButtonElement | undefined): void {
+ if (!btn) return;
+ btn.classList.add('flash');
+ setTimeout(() => btn.classList.remove('flash'), 300);
+ }
+
+ return (
+
+
+
+
+ );
+}
diff --git a/src/components/rl/rl-buttons.css b/src/components/rl/rl-buttons.css
new file mode 100644
index 0000000..1d11580
--- /dev/null
+++ b/src/components/rl/rl-buttons.css
@@ -0,0 +1,83 @@
+/* RL floating buttons — thumbs-up/down for reinforcement learning feedback */
+
+.rl-buttons {
+ position: fixed;
+ bottom: 50px;
+ left: 50%;
+ transform: translateX(-50%);
+ display: flex;
+ gap: 24px;
+ z-index: 45;
+ transition: opacity 0.3s;
+}
+
+.rl-btn {
+ width: 56px;
+ height: 56px;
+ border-radius: 50%;
+ border: 2px solid var(--glass-border, rgba(255, 255, 255, 0.12));
+ background: var(--glass-bg, rgba(10, 10, 20, 0.65));
+ backdrop-filter: blur(var(--glass-blur, 12px));
+ -webkit-backdrop-filter: blur(var(--glass-blur, 12px));
+ color: var(--text, #e0e0e8);
+ cursor: pointer;
+ transition: all 0.15s;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ justify-content: center;
+ padding-top: 2px;
+ gap: 0;
+}
+
+.rl-icon {
+ font-size: 24px;
+ font-weight: 700;
+ line-height: 1;
+}
+
+.key-num {
+ font-size: 10px;
+ color: rgba(255, 255, 255, 0.4);
+ font-family: var(--font-mono, monospace);
+ line-height: 1;
+ margin-top: -1px;
+}
+
+.rl-btn:active {
+ transform: scale(0.9);
+}
+
+/* Thumbs-up — green accent */
+.rl-up {
+ border-color: rgba(0, 200, 160, 0.4);
+ color: #00c8a0;
+ background: rgba(0, 200, 160, 0.08);
+}
+
+.rl-up:active {
+ background: rgba(0, 200, 160, 0.2);
+ box-shadow: 0 0 20px rgba(0, 200, 160, 0.3);
+}
+
+/* Thumbs-down — red/orange accent */
+.rl-down {
+ border-color: rgba(220, 60, 20, 0.4);
+ color: #dc3c14;
+ background: rgba(220, 60, 20, 0.08);
+}
+
+.rl-down:active {
+ background: rgba(220, 60, 20, 0.2);
+ box-shadow: 0 0 20px rgba(220, 60, 20, 0.3);
+}
+
+/* Button flash animation */
+.rl-btn.flash {
+ animation: rl-flash 0.3s ease-out;
+}
+
+@keyframes rl-flash {
+ 0% { filter: brightness(1.8); }
+ 100% { filter: brightness(1); }
+}
diff --git a/tests/solidjs/rl-controls-noise.spec.ts b/tests/solidjs/rl-controls-noise.spec.ts
new file mode 100644
index 0000000..db76415
--- /dev/null
+++ b/tests/solidjs/rl-controls-noise.spec.ts
@@ -0,0 +1,349 @@
+/**
+ * e2e tests for f09-rl-controls-noise.
+ * Validates:
+ * VAL-ML-011: Thumbs up adds example and decays noise
+ * VAL-ML-012: Thumbs down changes outputs with spread-aware noise
+ * VAL-JOY-004: Noise ring indicator around joystick
+ */
+import { test, expect } from '@playwright/test';
+import { loadSolidApp } from './helpers';
+
+test.describe('RL Controls + Noise Ring (f09)', () => {
+
+ // ─── VAL-ML-011: Thumbs up adds example and decays noise ───
+
+ test('VAL-ML-011a: thumbsUp increments exampleCount', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const result = await page.evaluate(async () => {
+ const probe = (window as any).__nisps;
+ const countBefore = probe.getExampleCount();
+ await probe.thumbsUp();
+ const countAfter = probe.getExampleCount();
+ return { countBefore, countAfter };
+ });
+
+ expect(result.countBefore).toBe(0);
+ expect(result.countAfter).toBe(1);
+ });
+
+ test('VAL-ML-011b: thumbsUp decreases noise level', async ({ page }) => {
+ await loadSolidApp(page);
+
+ // First, thumbs-down to raise noise, then thumbs-up to decay it
+ const result = await page.evaluate(async () => {
+ const probe = (window as any).__nisps;
+ const store = (window as any).__nispsStore;
+
+ // Get initial noise
+ const noiseInitial = store.noiseLevel();
+
+ // Thumbs-down to raise noise
+ probe.thumbsDown();
+ const noiseAfterDown = store.noiseLevel();
+
+ // Thumbs-up should decay noise
+ await probe.thumbsUp();
+ const noiseAfterUp = store.noiseLevel();
+
+ return { noiseInitial, noiseAfterDown, noiseAfterUp };
+ });
+
+ // Thumbs-down should raise noise
+ expect(result.noiseAfterDown).toBeGreaterThan(result.noiseInitial);
+ // Thumbs-up should decay it
+ expect(result.noiseAfterUp).toBeLessThan(result.noiseAfterDown);
+ });
+
+ test('VAL-ML-011c: thumbsUp triggers async training (loss becomes non-null)', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const result = await page.evaluate(async () => {
+ const probe = (window as any).__nisps;
+ const lossBefore = probe.getLoss();
+
+ // Thumbs-up adds example + triggers async training
+ await probe.thumbsUp();
+
+ const lossAfter = probe.getLoss();
+ const countAfter = probe.getExampleCount();
+
+ return { lossBefore, lossAfter, countAfter };
+ });
+
+ expect(result.lossBefore).toBeNull();
+ expect(result.countAfter).toBe(1);
+ // After training with 1 example, loss should be a finite number
+ expect(result.lossAfter).not.toBeNull();
+ if (result.lossAfter !== null) {
+ expect(Number.isFinite(result.lossAfter)).toBe(true);
+ expect(result.lossAfter).toBeGreaterThanOrEqual(0);
+ }
+ });
+
+ test('VAL-ML-011d: multiple thumbsUp calls accumulate examples', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const result = await page.evaluate(async () => {
+ const probe = (window as any).__nisps;
+
+ await probe.thumbsUp();
+ const count1 = probe.getExampleCount();
+
+ await probe.thumbsUp();
+ const count2 = probe.getExampleCount();
+
+ await probe.thumbsUp();
+ const count3 = probe.getExampleCount();
+
+ return { count1, count2, count3 };
+ });
+
+ expect(result.count1).toBe(1);
+ expect(result.count2).toBe(2);
+ expect(result.count3).toBe(3);
+ });
+
+ // ─── VAL-ML-012: Thumbs down changes outputs with spread-aware noise ───
+
+ test('VAL-ML-012a: thumbsDown changes at least one output', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const result = await page.evaluate(() => {
+ const probe = (window as any).__nisps;
+ probe.setInputs(0.5, 0.5);
+ const before = [...probe.getOutputs()];
+ probe.thumbsDown();
+ const after = [...probe.getOutputs()];
+ return { before, after };
+ });
+
+ const changed = result.before.some((v: number, i: number) => v !== result.after[i]);
+ expect(changed).toBe(true);
+ });
+
+ test('VAL-ML-012b: thumbsDown outputs remain bounded [0,1]', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const result = await page.evaluate(() => {
+ const probe = (window as any).__nisps;
+ probe.thumbsDown();
+ return probe.getOutputs();
+ });
+
+ for (const v of result) {
+ expect(v).toBeGreaterThanOrEqual(0);
+ expect(v).toBeLessThanOrEqual(1);
+ }
+ });
+
+ test('VAL-ML-012c: thumbsDown noise magnitude respects spread param', async ({ page }) => {
+ await loadSolidApp(page);
+
+ // Test with default spread=0.6: noiseCap = 0.3*(1-0.6) + 0.05*0.6 = 0.12 + 0.03 = 0.15
+ const result = await page.evaluate(() => {
+ const probe = (window as any).__nisps;
+ const store = (window as any).__nispsStore;
+
+ const spreadLevel = store.state.spreadLevel;
+ const expectedCap = 0.3 * (1 - spreadLevel) + 0.05 * spreadLevel;
+
+ const noiseInitial = store.noiseLevel();
+ probe.thumbsDown();
+ const noiseAfter = store.noiseLevel();
+
+ return { noiseInitial, noiseAfter, spreadLevel, expectedCap };
+ });
+
+ expect(result.noiseAfter).toBeGreaterThan(result.noiseInitial);
+ // Noise should be capped at the expected cap for the current spread
+ expect(result.noiseAfter).toBeLessThanOrEqual(result.expectedCap + 0.001);
+ });
+
+ test('VAL-ML-012d: thumbsDown with higher spread has lower noise cap', async ({ page }) => {
+ await loadSolidApp(page);
+
+ // Test that spread=1 produces lower noise than spread=0
+ const result = await page.evaluate(() => {
+ const probe = (window as any).__nisps;
+ const store = (window as any).__nispsStore;
+
+ // Save state, set spread to 1
+ store.setSpreadLevel(1.0);
+ const capHigh = 0.3 * (1 - 1.0) + 0.05 * 1.0; // = 0.05
+
+ // Reset noise
+ store.randomise(); // resets noise to 0.05
+
+ probe.thumbsDown();
+ const noiseHighSpread = store.noiseLevel();
+
+ // Now set spread to 0
+ store.setSpreadLevel(0.0);
+ store.randomise(); // resets noise to 0.05
+
+ probe.thumbsDown();
+ const noiseLowSpread = store.noiseLevel();
+
+ return { noiseHighSpread, noiseLowSpread };
+ });
+
+ // spread=0 allows much higher noise than spread=1
+ expect(result.noiseLowSpread).toBeGreaterThan(result.noiseHighSpread);
+ });
+
+ test('VAL-ML-012e: thumbsDown increases noise level', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const result = await page.evaluate(() => {
+ const probe = (window as any).__nisps;
+ const store = (window as any).__nispsStore;
+
+ const noiseBefore = store.noiseLevel();
+ probe.thumbsDown();
+ const noiseAfter = store.noiseLevel();
+
+ return { noiseBefore, noiseAfter };
+ });
+
+ expect(result.noiseAfter).toBeGreaterThan(result.noiseBefore);
+ });
+
+ // ─── VAL-JOY-004: Noise ring indicator ───
+
+ test('VAL-JOY-004a: noise ring element exists in DOM', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const ring = page.locator('#noise-ring');
+ await expect(ring).toBeAttached();
+ });
+
+ test('VAL-JOY-004b: noise ring is not active at default noise level', async ({ page }) => {
+ await loadSolidApp(page);
+
+ // Default noise is 0.05 — which is > 0.01 so ring should be active (low)
+ const classes = await page.locator('#noise-ring').getAttribute('class');
+ // At default noise 0.05 > 0.01, ring should have 'active' class
+ expect(classes).toContain('active');
+ // But not 'high' (that requires > 0.15)
+ expect(classes).not.toContain('high');
+ });
+
+ test('VAL-JOY-004c: noise ring becomes high after repeated thumbs-down', async ({ page }) => {
+ await loadSolidApp(page);
+
+ // Lower spread to allow higher noise cap (spread=0 → cap=0.3)
+ await page.evaluate(() => {
+ const store = (window as any).__nispsStore;
+ store.setSpreadLevel(0.0);
+ });
+
+ await page.evaluate(() => {
+ const probe = (window as any).__nisps;
+ // Repeated thumbs-down to raise noise above 0.15
+ for (let i = 0; i < 10; i++) {
+ probe.thumbsDown();
+ }
+ });
+
+ const classes = await page.locator('#noise-ring').getAttribute('class');
+ expect(classes).toContain('high');
+ });
+
+ test('VAL-JOY-004d: noise ring thickness increases with noise level', async ({ page }) => {
+ await loadSolidApp(page);
+
+ // Lower spread to allow higher noise cap
+ await page.evaluate(() => {
+ const store = (window as any).__nispsStore;
+ store.setSpreadLevel(0.0);
+ });
+
+ // Get border width at low noise (default 0.05 → .active class = 3px)
+ await page.waitForTimeout(100); // Wait for reactive update
+ const lowWidth = await page.locator('#noise-ring').evaluate((el: HTMLElement) => {
+ return getComputedStyle(el).borderWidth;
+ });
+
+ // Raise noise with thumbs-down
+ await page.evaluate(() => {
+ const probe = (window as any).__nisps;
+ for (let i = 0; i < 10; i++) {
+ probe.thumbsDown();
+ }
+ });
+
+ // Wait for CSS transition (300ms) and reactive update
+ await page.waitForTimeout(400);
+
+ // Get border width at high noise
+ const highWidth = await page.locator('#noise-ring').evaluate((el: HTMLElement) => {
+ return getComputedStyle(el).borderWidth;
+ });
+
+ // High noise should have thicker border (active=3px, high=6px)
+ const lowVal = parseFloat(lowWidth);
+ const highVal = parseFloat(highWidth);
+ expect(highVal).toBeGreaterThan(lowVal);
+ });
+
+ // ─── RL Buttons UI ───
+
+ test('RL buttons are visible in DOM', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const thumbsUp = page.locator('#btn-thumbsup');
+ const thumbsDown = page.locator('#btn-thumbsdown');
+ await expect(thumbsUp).toBeVisible();
+ await expect(thumbsDown).toBeVisible();
+ });
+
+ test('clicking thumbs-up button increments exampleCount', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const countBefore = await page.evaluate(() => (window as any).__nisps.getExampleCount());
+ await page.locator('#btn-thumbsup').click();
+ // Wait for async training
+ await page.waitForTimeout(500);
+ const countAfter = await page.evaluate(() => (window as any).__nisps.getExampleCount());
+
+ expect(countAfter).toBe(countBefore + 1);
+ });
+
+ test('clicking thumbs-down button changes outputs', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const outputsBefore = await page.evaluate(() => (window as any).__nisps.getOutputs());
+ await page.locator('#btn-thumbsdown').click();
+ const outputsAfter = await page.evaluate(() => (window as any).__nisps.getOutputs());
+
+ const changed = outputsBefore.some((v: number, i: number) => v !== outputsAfter[i]);
+ expect(changed).toBe(true);
+ });
+
+ // ─── RL interaction flow ───
+
+ test('VAL-CROSS-002 partial: thumbs-down → noise up → thumbs-up → noise down', async ({ page }) => {
+ await loadSolidApp(page);
+
+ const result = await page.evaluate(async () => {
+ const probe = (window as any).__nisps;
+ const store = (window as any).__nispsStore;
+
+ const noiseInitial = store.noiseLevel();
+
+ // Thumbs-down raises noise
+ probe.thumbsDown();
+ const noiseAfterDown = store.noiseLevel();
+
+ // Thumbs-up decays noise
+ await probe.thumbsUp();
+ const noiseAfterUp = store.noiseLevel();
+
+ return { noiseInitial, noiseAfterDown, noiseAfterUp };
+ });
+
+ expect(result.noiseAfterDown).toBeGreaterThan(result.noiseInitial);
+ expect(result.noiseAfterUp).toBeLessThan(result.noiseAfterDown);
+ });
+});