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
fix: validate cognitive drill pair constraints so saved settings match the run (#9460)
Adam Eivy66048f777148
diff --git a/client/src/components/meatspace/post/PostDrillConfig.jsx b/client/src/components/meatspace/post/PostDrillConfig.jsxindex 06a5d57e51..4046118556 100644--- a/client/src/components/meatspace/post/PostDrillConfig.jsx+++ b/client/src/components/meatspace/post/PostDrillConfig.jsx@@ -6,6 +6,7 @@ import { FormField } from '../../ui/FormField';import ProviderModelSelector from '../../ProviderModelSelector';import { filterSelectableModels, enabledApiProviderFilter } from '../../../utils/providers';import { GOAL_DEFS, POST_TOPICS, MODULE_LABELS, DRILL_LABELS, DRILL_DESCRIPTIONS, composedSessionDrillTypes } from './constants';+import { COGNITIVE_PAIR_CONSTRAINTS, validateCognitivePair, dependentMin } from '../../../../../server/lib/postCognitiveConfig.js';import { CognitiveDrillTutorialPreview, CognitiveDrillHowItWorksButton } from './CognitiveDrillTutorial';// Modules a Full/Quick composed session can draw from (issue #2100), DERIVED@@ -173,6 +174,8 @@ function seedLlmDrillTypes(saved) {// PostCognitiveDrillRunner.jsx). A `timeLimitSec` knob was previously// surfaced/validated for these drills without ever being consumed, which// promised behavior that didn't happen (issue #2008).+const pairBounds = (type, side) => ({ min: COGNITIVE_PAIR_CONSTRAINTS[type][side].min, max: COGNITIVE_PAIR_CONSTRAINTS[type][side].max });+const COGNITIVE_DRILL_META = {'n-back': {// `progressive: true` marks a laddered drill (ProgressiveBadge + toggle@@ -198,8 +201,8 @@ const COGNITIVE_DRILL_META = {{ value: 'forward', label: 'Forward' },{ value: 'backward', label: 'Backward' },] },- { key: 'startLength', label: 'Start Length', type: 'number', min: 3, max: 9 },- { key: 'maxLength', label: 'Max Length', type: 'number', min: 3, max: 12 },+ { key: 'startLength', label: 'Start Length', type: 'number', ...pairBounds('digit-span', 'low') },+ { key: 'maxLength', label: 'Max Length', type: 'number', ...pairBounds('digit-span', 'high') },{ key: 'showMs', label: 'Show Time (ms)', type: 'number', min: 400, max: 4000 },],defaults: { enabled: true, progressive: true, direction: 'forward', startLength: 3, maxLength: 8, showMs: 1000 },@@ -242,8 +245,8 @@ const COGNITIVE_DRILL_META = {{ value: 'choice', label: 'Choice' },] },{ 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 },+ { key: 'minDelayMs', label: 'Min Delay (ms)', type: 'number', ...pairBounds('reaction-time', 'low') },+ { key: 'maxDelayMs', label: 'Max Delay (ms)', type: 'number', ...pairBounds('reaction-time', 'high') },// 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.@@ -270,12 +273,12 @@ const COGNITIVE_DRILL_META = {fields: [{ key: 'count', label: 'Trials', type: 'number', min: 6, max: 60 },{ key: 'noGoPct', label: 'No-Go Trials (%)', type: 'number', min: 5, max: 80 },- { key: 'stimulusMs', label: 'Stimulus (ms)', type: 'number', min: 100, max: 2000 },+ { key: 'stimulusMs', label: 'Stimulus (ms)', type: 'number', ...pairBounds('go-no-go', 'low') },{ key: 'lureSimilarity', label: 'Lure Similarity', type: 'select', options: [{ value: 'low', label: 'Low' },{ value: 'high', label: 'High' },] },- { key: 'responseDeadlineMs', label: 'Response Deadline (ms)', type: 'number', min: 500, max: 5000 },+ { key: 'responseDeadlineMs', label: 'Response Deadline (ms)', type: 'number', ...pairBounds('go-no-go', 'high') },],defaults: { enabled: false, progressive: true, count: 20, noGoPct: 25, stimulusMs: 600, lureSimilarity: 'low', responseDeadlineMs: 1400 },},@@ -465,7 +468,7 @@ function GroupBulkToggle({ groupLabel, onEnableAll, onDisableAll }) {);}-function DrillCard({ type, meta, drillConfig, enabled, accent, onToggle, onUpdateField, adaptiveInfo, progressive, onToggleProgressive, progressInfo, managedFieldKeys = [], speedGated = false, managedLabel = 'Manual knobs', onPreviewHowItWorks }) {+function DrillCard({ type, meta, drillConfig, enabled, accent, onToggle, onUpdateField, adaptiveInfo, progressive, onToggleProgressive, progressInfo, managedFieldKeys = [], speedGated = false, managedLabel = 'Manual knobs', onPreviewHowItWorks, fieldErrors = [] }) {// Label and description both come from the shared registries in constants.js —// the per-module META objects carry only the knobs, so a drill rename is one edit.const label = DRILL_LABELS[type];@@ -545,8 +548,9 @@ function DrillCard({ type, meta, drillConfig, enabled, accent, onToggle, onUpdat) : (<inputtype="number"- min={field.min}+ min={COGNITIVE_PAIR_CONSTRAINTS[type]?.high.key === field.key ? dependentMin(type, drillConfig) : field.min}max={field.max}+ aria-invalid={fieldErrors.some(e => e.field === field.key) || undefined}value={drillConfig[field.key] ?? ''}onChange={e => onUpdateField(field.key, e.target.value)}className="w-full bg-port-bg border border-port-border rounded px-2 py-1.5 text-sm text-white focus:border-port-accent focus:outline-none"@@ -557,6 +561,10 @@ function DrillCard({ type, meta, drillConfig, enabled, accent, onToggle, onUpdat</div>)}+ {fieldErrors.map(e => (+ <p key={e.field} role="alert" className="text-xs text-port-error mt-2">{e.message}</p>+ ))}+{enabled && supportsProgressive && progressive && <ProgressiveBadge info={progressInfo} speedGated={speedGated} managedLabel={managedLabel} />}{enabled && !(supportsProgressive && progressive) && <AdaptiveBadge info={adaptiveInfo} />}</div>@@ -819,6 +827,11 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {const availableModels = filterSelectableModels(selectedProvider?.models);async function handleSave() {+ const pairError = Object.entries(cognitiveDrillTypes).flatMap(([type, cfg]) => validateCognitivePair(type, cfg))[0];+ if (pairError) {+ toast.error(pairError.message);+ return;+ }setSaving(true);const updated = await updatePostConfig({mentalMath: { drillTypes },@@ -1117,6 +1130,7 @@ export default function PostDrillConfig({ config, onSaved, onBack }) {speedGated={false}managedLabel="The difficulty knobs"onPreviewHowItWorks={() => setHowItWorksType(type)}+ fieldErrors={validateCognitivePair(type, drillConfig)}/>);})}diff --git a/client/src/components/meatspace/post/PostDrillConfig.test.jsx b/client/src/components/meatspace/post/PostDrillConfig.test.jsxindex f65bb1112b..9a0a55b03f 100644--- a/client/src/components/meatspace/post/PostDrillConfig.test.jsx+++ b/client/src/components/meatspace/post/PostDrillConfig.test.jsx@@ -642,3 +642,30 @@ describe('PostDrillConfig', () => {});});});++describe('PostDrillConfig cognitive pair constraints (#9460)', () => {+ const invalidConfig = {+ ...config,+ cognitive: {+ enabled: true,+ drillTypes: { 'reaction-time': { enabled: true, mode: 'simple', count: 15, minDelayMs: 5000, maxDelayMs: 300, choices: 3 } },+ },+ };++ it('shows a named field error and blocks Save for an inverted pair', async () => {+ await renderConfig(<PostDrillConfig config={invalidConfig} onSaved={vi.fn()} onBack={vi.fn()} />);+ expect(screen.getByRole('alert').textContent).toBe('Max Delay (ms) must be at least Min Delay (ms) (5000)');+ await saveConfig();+ expect(updatePostConfig).not.toHaveBeenCalled();+ });++ it('raises the dependent field minimum to the paired value and allows Save once valid', async () => {+ await renderConfig(<PostDrillConfig config={invalidConfig} onSaved={vi.fn()} onBack={vi.fn()} />);+ const maxInput = screen.getByLabelText('Max Delay (ms)');+ expect(maxInput.getAttribute('min')).toBe('5000');+ fireEvent.change(maxInput, { target: { value: '6000' } });+ expect(screen.queryByRole('alert')).toBeNull();+ await saveConfig();+ expect(updatePostConfig).toHaveBeenCalledTimes(1);+ });+});diff --git a/server/lib/README.md b/server/lib/README.mdindex 73cec6e010..4bc62268fe 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -49,6 +49,7 @@ The barrel `server/lib/index.js` is a machine-checkable enumeration of every pub| `fableLoomContinuity.js` | FableLoom episodic continuity review: multi-vector deterministic checks for visual entity bindings, convergence clarity, voice profile consistency/drift, pronunciation anchors, and playback safety. || `fableLoomOutline.js` | FableLoom story-first episode beat outlines: bounded log-lines, deterministic arc validation, and compact prompt rendering before teleplay expansion. || `fableLoomPlaytest.js` | FableLoom branching-playthrough harness: bounded exhaustive path enumeration, ending/loop/coverage diagnostics, aggregate loom reports, and compact traces for narrative-quality review. |+| `postCognitiveConfig.js` | Browser-safe limits and joint constraints (`COGNITIVE_PAIR_CONSTRAINTS`, `validateCognitivePair`, `dependentMin`) for the POST cognitive drills with related manual pairs — digit-span start/max length, reaction-time delay window, Go/No-Go stimulus/deadline — shared by the config UI, route validation, and generators. || `postDrillTypes.js` | MeatSpace POST drill vocabularies (`LLM_DRILL_TYPES`, `CACHEABLE_TYPES`, `COGNITIVE_DRILL_TYPES`, `POST_SUPPORTED_MEMORY_TYPES`), kept below validation so a route schema never pulls in the POST services (and, through them, the LLM drill generator). || `spriteVocabulary.js` | Sprite id pattern, record kinds, the canonical 8-direction order + derived anchor set, `TURNAROUND_ID`, and the animation provider ids — the alphabets the sprite route schemas enumerate, kept below the sprite services. || `spriteChromaKey.js` | Chroma-key selection color math (`CHROMA_KEYS`, `CHROMA_KEY_HEXES`, `DEFAULT_CHROMA_KEY`, hue-distance picking). Pure color math, no image I/O — that lives in `services/sprites/normalize.js`. |diff --git a/server/lib/index.js b/server/lib/index.jsindex 70b7c5a3ac..f1a52ad605 100644--- a/server/lib/index.js+++ b/server/lib/index.js@@ -592,6 +592,7 @@ export * from './spriteVocabulary.js';export * from './spriteChromaKey.js';export * from './spriteAnimationTracks.js';export * from './spriteAnimationTrackStore.js';+export * from './postCognitiveConfig.js';export * from './postDrillTypes.js';export * from './telegramClient.js';export * from './telegramMessage.js';diff --git a/server/lib/postCognitiveConfig.js b/server/lib/postCognitiveConfig.jsnew file mode 100644index 0000000000..1dd5896376--- /dev/null+++ b/server/lib/postCognitiveConfig.js@@ -0,0 +1,62 @@+/**+ * Shared limits and joint constraints for the POST cognitive drills whose+ * manual settings are RELATED pairs (digit-span span, reaction-time delay+ * window, Go/No-Go deadline vs stimulus). Browser-safe leaf: no imports.+ *+ * The generators (meatspacePostCognitive.js) normalize a pair that violates+ * its relation; this module lets the browser and the config route reject the+ * same pair up front so what is saved is what runs.+ */++/** `low` is the independent member; `high` must be >= `low`. */+export const COGNITIVE_PAIR_CONSTRAINTS = Object.freeze({+ 'digit-span': {+ low: { key: 'startLength', label: 'Start Length', min: 3, max: 9, fallback: 3 },+ high: { key: 'maxLength', label: 'Max Length', min: 3, max: 12, fallback: 8 },+ },+ 'reaction-time': {+ low: { key: 'minDelayMs', label: 'Min Delay (ms)', min: 300, max: 5000, fallback: 1000 },+ high: { key: 'maxDelayMs', label: 'Max Delay (ms)', min: 300, max: 8000, fallback: 3000 },+ },+ 'go-no-go': {+ low: { key: 'stimulusMs', label: 'Stimulus (ms)', min: 100, max: 2000, fallback: 600 },+ high: { key: 'responseDeadlineMs', label: 'Response Deadline (ms)', min: 500, max: 5000, fallback: 1400 },+ },+});++const isNum = (v) => typeof v === 'number' && Number.isFinite(v);++/** Ladder-managed types ignore manual pair values unless progressive is off. */+const LADDERED_TYPES = new Set(['digit-span', 'go-no-go']);++/**+ * Whether the stored pair values drive the run: reaction-time has no ladder,+ * the others only honor manual values when `progressive === false`.+ */+export function pairIsManual(type, config) {+ return !LADDERED_TYPES.has(type) || config?.progressive === false;+}++/**+ * Relational errors for a drill's (merged) config: `[{ field, message }]`,+ * empty when the type has no pair, the values are unset, or the ladder owns them.+ */+export function validateCognitivePair(type, config) {+ const pair = COGNITIVE_PAIR_CONSTRAINTS[type];+ if (!pair || !config || !pairIsManual(type, config)) return [];+ const low = config[pair.low.key];+ const high = config[pair.high.key];+ if (!isNum(low) || !isNum(high) || high >= low) return [];+ return [{+ field: pair.high.key,+ message: `${pair.high.label} must be at least ${pair.low.label} (${low})`,+ }];+}++/** Effective minimum for the dependent (`high`) member given its partner. */+export function dependentMin(type, config) {+ const pair = COGNITIVE_PAIR_CONSTRAINTS[type];+ if (!pair) return undefined;+ const low = config?.[pair.low.key];+ return isNum(low) ? Math.max(pair.high.min, low) : pair.high.min;+}diff --git a/server/lib/postValidation.js b/server/lib/postValidation.jsindex 7c16bc08f7..9ff1911a2e 100644--- a/server/lib/postValidation.js+++ b/server/lib/postValidation.js@@ -1,5 +1,6 @@import { z } from 'zod';import { CACHEABLE_TYPES, COGNITIVE_DRILL_TYPES, LLM_DRILL_TYPES, POST_SUPPORTED_MEMORY_TYPES } from './postDrillTypes.js';+import { validateCognitivePair } from './postCognitiveConfig.js';import { TOPIC_IDS } from './postTopics.js';import { HHMM_STRICT_RE } from './timezone.js';import { POST_LLM_MAX_SEMANTIC_CANDIDATES, postLlmEvaluationSchema } from './postLlmContracts.js';@@ -375,6 +376,14 @@ export const postConfigUpdateSchema = z.object({cognitive: z.object({enabled: z.boolean().optional(),drillTypes: z.partialRecord(z.enum(COGNITIVE_DRILL_TYPES), drillTypeConfigSchema).optional()+ }).superRefine((cog, ctx) => {+ // Joint constraints the generators would otherwise silently rewrite. A+ // one-field patch is re-checked against stored values in updatePostConfig.+ for (const [type, cfg] of Object.entries(cog.drillTypes || {})) {+ for (const { field, message } of validateCognitivePair(type, cfg)) {+ ctx.addIssue({ code: 'custom', path: ['drillTypes', type, field], message });+ }+ }}).optional(),// Memory practice (issue #3252). Mirrors the other module blocks, plus an// `items` map so an INDIVIDUAL memorized text — e.g. the seeded Elements Songdiff --git a/server/lib/postValidation.test.js b/server/lib/postValidation.test.jsindex 5892df01a2..4ed3aebf35 100644--- a/server/lib/postValidation.test.js+++ b/server/lib/postValidation.test.js@@ -1043,3 +1043,25 @@ describe('Practice Plan save body ↔ postConfigUpdateSchema (issue #3252)', ()expect(() => postConfigUpdateSchema.parse(body)).toThrow();});});++describe('postConfigUpdateSchema cognitive pair constraints (#9460)', () => {+ const patch = (type, cfg) => ({ cognitive: { drillTypes: { [type]: cfg } } });+ const issues = (body) => {+ const r = postConfigUpdateSchema.safeParse(body);+ return r.success ? [] : r.error.issues.map(i => i.path.join('.'));+ };++ it.each([+ ['go-no-go', { progressive: false, stimulusMs: 2000, responseDeadlineMs: 500 }, 'cognitive.drillTypes.go-no-go.responseDeadlineMs'],+ ['digit-span', { progressive: false, startLength: 9, maxLength: 3 }, 'cognitive.drillTypes.digit-span.maxLength'],+ ['reaction-time', { minDelayMs: 5000, maxDelayMs: 300 }, 'cognitive.drillTypes.reaction-time.maxDelayMs'],+ ])('rejects an inverted %s pair with a field-level issue', (type, cfg, path) => {+ expect(issues(patch(type, cfg))).toEqual([path]);+ });++ it('accepts valid pairs, partial records, and ladder-managed (progressive) values', () => {+ expect(issues(patch('reaction-time', { minDelayMs: 500, maxDelayMs: 500 }))).toEqual([]);+ expect(issues(patch('digit-span', { maxLength: 3 }))).toEqual([]);+ expect(issues(patch('go-no-go', { stimulusMs: 2000, responseDeadlineMs: 500 }))).toEqual([]);+ });+});diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.jsindex 9f1c7a566d..67a22855fc 100644--- a/server/services/meatspacePost.js+++ b/server/services/meatspacePost.js@@ -55,6 +55,7 @@ import { todayInTimezone } from '../lib/timezone.js';import { getUserTimezone, userLocalToday as localToday } from './userTimezone.js';import { getStoredPostSession, listPostSessions, saveStoredPostSession } from './postRunStore.js';import { ServerError } from '../lib/errorHandler.js';+import { validateCognitivePair } from '../lib/postCognitiveConfig.js';// Re-export the shared streak helper so existing importers of// `computePostStreaks` from this module keep working after it moved to@@ -335,6 +336,15 @@ export async function getPostConfig() {export async function updatePostConfig(updates) {const config = await getPostConfig();const merged = deepMerge(config, updates);+ // A partial patch (one field of a pair) is judged against the merged record+ // so it can't evade a relation with an already-stored partner. Only drill+ // types in the patch are checked: unrelated saves never trip on legacy values.+ const pairErrors = Object.keys(updates?.cognitive?.drillTypes || {}).flatMap(type =>+ validateCognitivePair(type, merged.cognitive?.drillTypes?.[type])+ .map(e => ({ path: `cognitive.drillTypes.${type}.${e.field}`, message: e.message })));+ if (pairErrors.length) {+ throw new ServerError('Validation failed', { status: 400, code: 'VALIDATION_ERROR', context: { details: pairErrors } });+ }if (updates?.reminder) {// Stamp WHEN the reminder's enabled/time settings last changed. Read by// meatspacePostReminder.js's missed-slot catch-up: a cron occurrencediff --git a/server/services/meatspacePost.test.js b/server/services/meatspacePost.test.jsindex 20a5b9e6bf..fd37ad4c59 100644--- a/server/services/meatspacePost.test.js+++ b/server/services/meatspacePost.test.js@@ -2749,3 +2749,34 @@ describe('resolveDrillConfig — maintenance-review bypass (issue #2096)', () =>expect(progression).toBeNull();});});++describe('updatePostConfig — cognitive pair constraints (#9460)', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ atomicWrite.mockResolvedValue(undefined);+ });++ it('rejects a one-field patch that inverts a pair with the stored partner, without writing', async () => {+ readJSONFile.mockResolvedValue({ cognitive: { drillTypes: { 'reaction-time': { minDelayMs: 4000, maxDelayMs: 5000 } } } });+ await expect(updatePostConfig({ cognitive: { drillTypes: { 'reaction-time': { maxDelayMs: 300 } } } }))+ .rejects.toMatchObject({ status: 400, code: 'VALIDATION_ERROR' });+ expect(atomicWrite).not.toHaveBeenCalled();+ });++ it('does not block unrelated patches because another drill holds a legacy inverted pair', async () => {+ readJSONFile.mockResolvedValue({ cognitive: { drillTypes: { 'reaction-time': { minDelayMs: 4000, maxDelayMs: 300 } } } });+ await expect(updatePostConfig({ adaptive: { enabled: true } })).resolves.toBeTruthy();+ expect(atomicWrite).toHaveBeenCalledTimes(1);+ });+});++describe('cognitive generators honor the shared pair contract (#9460)', () => {+ it('a valid manual pair runs exactly as saved', () => {+ expect(generateCognitiveDrill('go-no-go', { stimulusMs: 700, responseDeadlineMs: 900 }).config)+ .toMatchObject({ stimulusMs: 700, responseDeadlineMs: 900 });+ expect(generateCognitiveDrill('digit-span', { startLength: 4, maxLength: 6 }).config)+ .toMatchObject({ startLength: 4, maxLength: 6 });+ expect(generateCognitiveDrill('reaction-time', { minDelayMs: 500, maxDelayMs: 900 }).config)+ .toMatchObject({ minDelayMs: 500, maxDelayMs: 900 });+ });+});diff --git a/server/services/meatspacePostCognitive.js b/server/services/meatspacePostCognitive.jsindex 79272ea7a1..fe0d8665e1 100644--- a/server/services/meatspacePostCognitive.js+++ b/server/services/meatspacePostCognitive.js@@ -27,6 +27,7 @@ export const COGNITIVE_MODULE = 'cognitive';// this module — issue #4901.export { COGNITIVE_DRILL_TYPES } from '../lib/postDrillTypes.js';import { COGNITIVE_DRILL_TYPES } from '../lib/postDrillTypes.js';+import { COGNITIVE_PAIR_CONSTRAINTS } from '../lib/postCognitiveConfig.js';const NBACK_LETTERS = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];@@ -266,8 +267,9 @@ export function generateNBack(config = {}) {*/export function generateDigitSpan(config = {}) {const direction = config.direction === 'backward' ? 'backward' : 'forward';- const startLength = clampInt(config.startLength, 3, 9, 3);- const maxLength = clampInt(config.maxLength, startLength, 12, 8);+ const { low, high } = COGNITIVE_PAIR_CONSTRAINTS['digit-span'];+ const startLength = clampInt(config.startLength, low.min, low.max, low.fallback);+ const maxLength = clampInt(config.maxLength, Math.max(high.min, startLength), high.max, high.fallback);const sequences = [];for (let len = startLength; len <= maxLength; len++) {const digits = [];@@ -384,8 +386,9 @@ export function generateMentalRotation(config = {}) {export function generateReactionTime(config = {}) {const mode = config.mode === 'choice' ? 'choice' : 'simple';const count = clampInt(config.count, 5, 40, 15);- const minDelayMs = clampInt(config.minDelayMs, 300, 5000, 1000);- const maxDelayMs = Math.max(minDelayMs, clampInt(config.maxDelayMs, 300, 8000, 3000));+ const { low, high } = COGNITIVE_PAIR_CONSTRAINTS['reaction-time'];+ const minDelayMs = clampInt(config.minDelayMs, low.min, low.max, low.fallback);+ const maxDelayMs = Math.max(minDelayMs, clampInt(config.maxDelayMs, high.min, high.max, high.fallback));// `choices` is only meaningful (and only schema-valid, min 2) in choice mode —// simple mode omits it entirely rather than persisting an out-of-range value// like 1, which session submission's `choices: min(2)` schema would reject.@@ -468,8 +471,9 @@ export function generateGoNoGo(config = {}) {const random = seededRandom(seed);const count = clampInt(config.count, 6, 60, 20);const noGoPct = clampInt(config.noGoPct, 5, 80, 25);- const stimulusMs = clampInt(config.stimulusMs, 100, 2000, 600);- const responseDeadlineMs = clampInt(config.responseDeadlineMs, stimulusMs, 5000, 1400);+ const { low, high } = COGNITIVE_PAIR_CONSTRAINTS['go-no-go'];+ const stimulusMs = clampInt(config.stimulusMs, low.min, low.max, low.fallback);+ const responseDeadlineMs = clampInt(config.responseDeadlineMs, Math.max(high.min, stimulusMs), high.max, high.fallback);const lureSimilarity = config.lureSimilarity === 'high' ? 'high' : 'low';const noGoCount = Math.round(count * noGoPct / 100);const flags = shuffleWith([