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 (do:review): cognitive-drill config coherence + due-review ordering
[._.]/ Adam Eivy346e37db9245
diff --git a/client/src/components/meatspace/post/MemoryBuilder.jsx b/client/src/components/meatspace/post/MemoryBuilder.jsxindex 4b46c5e44f..e599341d11 100644--- a/client/src/components/meatspace/post/MemoryBuilder.jsx+++ b/client/src/components/meatspace/post/MemoryBuilder.jsx@@ -24,6 +24,17 @@ function isItemDue(item) {return Number.isNaN(t) || t <= Date.now();}+// Most-overdue first: earliest (or missing/invalid) nextReview leads, so+// "Review Next" picks the item that's waited longest — matching the server's+// `getDueMemoryItems` ordering rather than raw list order.+function mostOverdueFirst(a, b) {+ const ka = Date.parse(a?.schedule?.nextReview ?? '');+ const kb = Date.parse(b?.schedule?.nextReview ?? '');+ const va = Number.isNaN(ka) ? -Infinity : ka;+ const vb = Number.isNaN(kb) ? -Infinity : kb;+ return va === vb ? 0 : va < vb ? -1 : 1;+}+export default function MemoryBuilder({ onBack, onNavigateElements }) {const [items, setItems] = useState([]);const [selectedItem, setSelectedItem] = useState(null);@@ -150,7 +161,7 @@ export default function MemoryBuilder({ onBack, onNavigateElements }) {{/* Due Today — spaced repetition. Recomputes reactively as `items` update. */}{(() => {- const dueItems = items.filter(isItemDue);+ const dueItems = items.filter(isItemDue).sort(mostOverdueFirst);if (dueItems.length === 0) {return (<div className="flex items-center gap-2 text-sm text-gray-500 max-w-2xl">diff --git a/client/src/components/meatspace/post/PostDrillConfig.jsx b/client/src/components/meatspace/post/PostDrillConfig.jsxindex eef01e43ab..7755ba8f41 100644--- a/client/src/components/meatspace/post/PostDrillConfig.jsx+++ b/client/src/components/meatspace/post/PostDrillConfig.jsx@@ -160,8 +160,8 @@ const COGNITIVE_DRILL_META = {{ value: 'forward', label: 'Forward' },{ value: 'backward', label: 'Backward' },] },- { key: 'startLength', label: 'Start Length', type: 'number', min: 2, max: 12 },- { key: 'maxLength', label: 'Max Length', type: 'number', min: 2, max: 14 },+ { key: 'startLength', label: 'Start Length', type: 'number', min: 3, max: 9 },+ { key: 'maxLength', label: 'Max Length', type: 'number', min: 3, max: 12 },{ key: 'timeLimitSec', label: 'Time Limit (sec)', type: 'number', min: 10, max: 300 },],defaults: { enabled: true, direction: 'forward', startLength: 3, maxLength: 8, timeLimitSec: 120 },diff --git a/client/src/components/meatspace/tabs/PostTab.jsx b/client/src/components/meatspace/tabs/PostTab.jsxindex 2ee7c08f11..af1d03e5a0 100644--- a/client/src/components/meatspace/tabs/PostTab.jsx+++ b/client/src/components/meatspace/tabs/PostTab.jsx@@ -129,7 +129,6 @@ export default function PostTab({ tab = 'launcher', subtab }) {return (<PostCognitiveDrillRunnerdrill={session.currentDrill}- timeLimitSec={session.currentDrill?.timeLimitSec}drillIndex={session.currentDrillIndex}drillCount={session.drillCount}onComplete={session.completeCognitiveDrill}diff --git a/client/src/services/apiMeatspace.js b/client/src/services/apiMeatspace.jsindex 44f38a6a4a..2373ba9813 100644--- a/client/src/services/apiMeatspace.js+++ b/client/src/services/apiMeatspace.js@@ -202,7 +202,6 @@ export const fillPostDrillCache = (types, providerId, model) => request('/meatsp// MeatSpace - POST Memory Builderexport const getMemoryItems = () => request('/meatspace/post/memory-items');-export const getDueMemoryItems = () => request('/meatspace/post/memory-items/due');export const getMemoryItem = (id) => request(`/meatspace/post/memory-items/${id}`);export const createMemoryItem = (data) => request('/meatspace/post/memory-items', {method: 'POST',diff --git a/server/lib/postValidation.js b/server/lib/postValidation.jsindex 9d0bf78c86..32c7e5c25b 100644--- a/server/lib/postValidation.js+++ b/server/lib/postValidation.js@@ -63,12 +63,14 @@ const drillTypeConfigSchema = z.object({maxExponent: z.number().int().min(2).max(20).optional(),tolerancePct: z.number().min(1).max(50).optional(),// --- Cognitive drill knobs (n-back / digit-span / stroop) ---+ // Bounds match the generator clamps in meatspacePostCognitive.js so the UI /+ // API can't accept a value the generator will silently narrow.n: z.number().int().min(1).max(3).optional(),length: z.number().int().min(6).max(60).optional(),- stimulusMs: z.number().int().min(500).max(5000).optional(),+ stimulusMs: z.number().int().min(1000).max(5000).optional(),direction: z.enum(['forward', 'backward']).optional(),- startLength: z.number().int().min(2).max(12).optional(),- maxLength: z.number().int().min(2).max(14).optional(),+ startLength: z.number().int().min(3).max(9).optional(),+ maxLength: z.number().int().min(3).max(12).optional(),showMs: z.number().int().min(200).max(5000).optional()});diff --git a/server/services/meatspacePostCognitive.js b/server/services/meatspacePostCognitive.jsindex c14ae9ed06..a46aa0e9c0 100644--- a/server/services/meatspacePostCognitive.js+++ b/server/services/meatspacePostCognitive.js@@ -34,8 +34,12 @@ export const STROOP_COLORS = [function clampInt(value, min, max, fallback) {const n = Math.round(Number(value));- if (!Number.isFinite(n)) return fallback;- return Math.min(max, Math.max(min, n));+ // Clamp the fallback into [min,max] too — a fallback that sits outside the+ // range (e.g. maxLength's fallback 8 when startLength has clamped up to 9)+ // would otherwise slip through un-clamped and, for digit-span, make+ // maxLength < startLength → an empty drill.+ const v = Number.isFinite(n) ? n : fallback;+ return Math.min(max, Math.max(min, v));}function pick(arr) {diff --git a/server/services/meatspacePostCognitive.test.js b/server/services/meatspacePostCognitive.test.jsindex e7fce2e08a..24c67965d6 100644--- a/server/services/meatspacePostCognitive.test.js+++ b/server/services/meatspacePostCognitive.test.js@@ -42,6 +42,14 @@ describe('cognitive drill generators', () => {}});+ it('digit-span never yields an empty drill when maxLength is unset and startLength is at its ceiling', () => {+ // Regression: clampInt used to return maxLength's fallback (8) un-clamped, so+ // startLength=9 + no maxLength gave maxLength 8 < 9 → zero sequences → instant score 0.+ const drill = generateDigitSpan({ startLength: 9 });+ expect(drill.sequences.length).toBeGreaterThanOrEqual(1);+ expect(drill.sequences[0].length).toBe(9);+ });+it('stroop produces the requested trial count with a valid ink answer', () => {const drill = generateStroop({ count: 12 });expect(drill.type).toBe('stroop');