Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (claude): add chirality invariant test, expose reaction-time choices in UI
Adam Eivye01fa4f119e4
diff --git a/client/src/components/meatspace/post/PostDrillConfig.jsx b/client/src/components/meatspace/post/PostDrillConfig.jsxindex 2102184d67..21dac26c59 100644--- a/client/src/components/meatspace/post/PostDrillConfig.jsx+++ b/client/src/components/meatspace/post/PostDrillConfig.jsx@@ -204,9 +204,13 @@ const COGNITIVE_DRILL_META = {{ key: 'count', label: 'Trials', type: 'number', min: 5, max: 40 },{ key: 'minDelayMs', label: 'Min Delay (ms)', type: 'number', min: 300, max: 5000 },{ key: 'maxDelayMs', label: 'Max Delay (ms)', type: 'number', min: 300, max: 8000 },+ // Only meaningful in Choice mode (the generator ignores it for Simple),+ // but shown unconditionally — DrillCard has no per-field conditional+ // visibility and this mirrors how other fields already behave.+ { key: 'choices', label: 'Choices (Choice mode)', type: 'number', min: 2, max: 4 },{ key: 'timeLimitSec', label: 'Time Limit (sec)', type: 'number', min: 10, max: 300 },],- defaults: { enabled: true, mode: 'simple', count: 15, minDelayMs: 1000, maxDelayMs: 3000, timeLimitSec: 90 },+ defaults: { enabled: true, mode: 'simple', count: 15, minDelayMs: 1000, maxDelayMs: 3000, choices: 3, timeLimitSec: 90 },},};diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.jsindex 4eb86c4e61..0310f483aa 100644--- a/server/services/meatspacePost.js+++ b/server/services/meatspacePost.js@@ -50,7 +50,7 @@ const DEFAULT_CONFIG = {'stroop': { enabled: true, count: 15, timeLimitSec: 60 },'schulte-table': { enabled: true, size: 5, timeLimitSec: 120 },'mental-rotation': { enabled: true, count: 8, timeLimitSec: 120 },- 'reaction-time': { enabled: true, mode: 'simple', count: 15, minDelayMs: 1000, maxDelayMs: 3000, timeLimitSec: 90 }+ 'reaction-time': { enabled: true, mode: 'simple', count: 15, minDelayMs: 1000, maxDelayMs: 3000, choices: 3, timeLimitSec: 90 }}},sessionModules: ['mental-math'],diff --git a/server/services/meatspacePostCognitive.js b/server/services/meatspacePostCognitive.jsindex 0e3f1a6ee1..32df4574a4 100644--- a/server/services/meatspacePostCognitive.js+++ b/server/services/meatspacePostCognitive.js@@ -78,14 +78,17 @@ function shuffle(arr) {}// --- Mental rotation: grid-cell shape helpers --------------------------------// Four chiral pentomino footprints, each within a 4x4 box. Verified (see-// meatspacePostCognitive.test.js) that every rotation is distinct from every-// mirrored-rotation, AND all 4 rotations of each are themselves distinct —-// so "rotated match" vs "mirrored distractor" is always unambiguous and there-// are always 3 distinct mirrored candidates to fill the distractor slots.-// (The classic Z/S-pentomino was excluded: it has 180deg rotational symmetry,-// leaving only 2 distinct mirrored variants — not enough for 3 distractors.)-const ROTATION_SHAPES = {+// Four chiral pentomino footprints, each within a 4x4 box. Verified (see the+// "ROTATION_SHAPES chirality invariant" test in meatspacePostCognitive.test.js,+// which exercises this exact set via the exported ROTATION_SHAPES) that every+// rotation is distinct from every mirrored-rotation, AND all 4 rotations of+// each are themselves distinct — so "rotated match" vs "mirrored distractor"+// is always unambiguous and there are always 3 distinct mirrored candidates+// to fill the distractor slots. (The classic Z/S-pentomino was excluded: it+// has 180deg rotational symmetry, leaving only 2 distinct mirrored variants —+// not enough for 3 distractors.) Exported so the test can assert the+// invariant directly against the real shape set, not a hand-copied one.+export const ROTATION_SHAPES = {F: [[1, 0], [2, 0], [0, 1], [1, 1], [1, 2]],L: [[0, 0], [0, 1], [0, 2], [0, 3], [1, 3]],N: [[0, 0], [0, 1], [1, 1], [1, 2], [1, 3]],@@ -99,8 +102,9 @@ function normalizeCells(cells) {}// Rotate 90deg clockwise `times` times (0-3) around the origin, then-// re-normalize into the non-negative quadrant.-function rotateCells(cells, times) {+// re-normalize into the non-negative quadrant. Exported so tests can verify+// the ROTATION_SHAPES chirality invariant directly (see meatspacePostCognitive.test.js).+export function rotateCells(cells, times) {let pts = cells;for (let t = 0; t < ((times % 4) + 4) % 4; t++) {pts = pts.map(([x, y]) => [y, -x]);@@ -110,11 +114,11 @@ function rotateCells(cells, times) {// Mirror across the vertical axis (flip x) — same footprint size, opposite// chirality, so it looks similar but is not reachable by rotation alone.-function mirrorCells(cells) {+export function mirrorCells(cells) {return normalizeCells(cells.map(([x, y]) => [-x, y]));}-function cellsKey(cells) {+export function cellsKey(cells) {return cells.map(([x, y]) => `${x},${y}`).join('|');}diff --git a/server/services/meatspacePostCognitive.test.js b/server/services/meatspacePostCognitive.test.jsindex f656565d04..bd749c5f58 100644--- a/server/services/meatspacePostCognitive.test.js+++ b/server/services/meatspacePostCognitive.test.js@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';import {COGNITIVE_DRILL_TYPES,STROOP_COLORS,+ ROTATION_SHAPES,generateNBack,generateDigitSpan,generateStroop,@@ -10,6 +11,9 @@ import {generateReactionTime,generateCognitiveDrill,scoreCognitiveDrill,+ rotateCells,+ mirrorCells,+ cellsKey,} from './meatspacePostCognitive.js';describe('cognitive drill generators', () => {@@ -110,6 +114,23 @@ describe('cognitive drill generators', () => {}});+ it('ROTATION_SHAPES chirality invariant: every rotation is distinct, every mirrored-rotation is distinct, and no rotation ever equals a mirrored-rotation', () => {+ // This is the invariant generateMentalRotation's distractor-fill loop relies+ // on: without it, a base shape could silently yield fewer than 3 distinct+ // mirrored distractors (an infinite-guard exhaustion) or a "distractor" that+ // is secretly a true rotation of the reference shape (a broken drill).+ for (const [shapeName, baseCells] of Object.entries(ROTATION_SHAPES)) {+ const rotationKeys = [0, 1, 2, 3].map(steps => cellsKey(rotateCells(baseCells, steps)));+ const mirrorKeys = [0, 1, 2, 3].map(steps => cellsKey(mirrorCells(rotateCells(baseCells, steps))));++ expect(new Set(rotationKeys).size, `${shapeName}: all 4 rotations must be distinct`).toBe(4);+ expect(new Set(mirrorKeys).size, `${shapeName}: all 4 mirrored-rotations must be distinct`).toBe(4);+ for (const mirrorK of mirrorKeys) {+ expect(rotationKeys, `${shapeName}: a mirrored-rotation must never equal any rotation`).not.toContain(mirrorK);+ }+ }+ });+it('reaction-time defaults to simple mode with no per-trial target', () => {const drill = generateReactionTime({ count: 5 });expect(drill.type).toBe('reaction-time');