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
feat: persist per-question breakdown in wordplay training log (#2114)
[._.]/ Adam Eivyf0782b6b9e4c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex e4bdf09513..84c1ba017c 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -17,6 +17,7 @@- **[issue-2101] POST config & UX polish: Morse in the sidebar, config presets, keyboard-accessible history, pausable transitions.** Morse is now a full nav entry under the POST sidebar section (previously reachable only via the launcher or ⌘K). The drill config page gained one-click presets — "Balanced daily", "Math focus", "Cognitive focus", and "Everything (local-only)" — plus per-group "Enable all / Disable all" buttons on the Mental Math, Cognitive, and LLM sections (bulk-enabling LLM drills is blocked until you've picked an AI provider). History session rows now expand/collapse with the keyboard (Enter/Space), not just a mouse click. The inter-drill transition screen gained a Pause/Resume control and pauses its 3-second auto-advance countdown while you're hovering or focused on it, so you're never yanked into the next drill mid-read.- **[issue-2097] The Wordplay tab now tracks your practice.** Completing a round of Compound Chain, Bridge Word, Double Meaning, or Idiom Twist in the standalone Wordplay tab used to score every response and then throw the result away — closing the tab meant the practice never happened. Each completed round now logs to your training history (same log the in-session drills and streak use), so Wordplay accuracy shows up in training stats and counts toward your practice streak. The standalone tab and the in-session drill runner now also share one scoring path for these four types, and a bug that always logged 0% accuracy for in-session LLM-drill training rounds (regardless of actual performance) is fixed too.+- **[issue-2114] Wordplay training-log entries now keep the per-question breakdown, not just the round total.** Follow-up to #2097: each completed Wordplay round previously logged only the aggregate question/correct counts. It now also stores each question's prompt/response, score, feedback, and whether it cleared the correct threshold — so a future progress dashboard can trend which individual wordplay prompts you miss. Entries without a breakdown (older rows, and other training modules) remain fully valid.- **[issue-2094] Scores now separate how *accurate* you were from how *fast* — and stop rewarding not answering.** Every scored drill now records accuracy (of the answers you actually gave), completion (how much of a timed drill you reached), and average speed as distinct numbers alongside the blended headline score, so the session and history views show accuracy and speed side by side instead of one merged figure. Running out of time on a timed drill now lowers *completion*, not accuracy — an unreached question no longer counts as wrong. Adaptive difficulty follows your accuracy (with a guard that skips adjusting when you barely started a drill), so a fast-but-sloppy run and a slow-but-careful run now push difficulty in different, correct directions. The n-back drill is rescored with proper signal-detection: never pressing now lands at ~50% (chance) instead of the old ~70% freebie, and always-pressing is penalized for its false alarms. The reaction-time drill is now scored on your median reaction speed (false starts invalidate their trial) with your best time tracked too. Older saved sessions without the new fields still display and chart correctly.- **[issue-2093] Session results now teach from mistakes on every drill, not just AI ones.** Expanding a math, memory, or cognitive (n-back, digit-span, Stroop, Schulte table, mental rotation, reaction time) drill row on the results screen used to do nothing — only AI-scored drills showed a review. Every drill row now expands into a per-question/per-trial breakdown: a "missed items" summary up top, then a type-appropriate view — a prompt/answer/expected table for math and memory, letter-sequence hit/miss/false-alarm marks for n-back, shown-vs-recalled digits for digit span, word/ink/your-answer for Stroop, and per-trial timing with slow-response outliers flagged for the pure speed drills. Unanswered questions are shown distinctly from wrong ones. The same review now also appears when you expand a past session in History.- **Multiplication drills now ramp up instead of starting hard.** The mental-math multiplication drill used to open at a fixed 2-digit × 2-digit difficulty (e.g. `566 × 191`) for everyone. It now climbs a mastery-gated ladder — `1×1` → `1×2` → `1×1×1` → `2×2` → … — starting at single-digit × single-digit and advancing to the next rung only after you answer a level quickly *and* accurately (≥90% correct within a per-rung speed target). The drill header and the config page show your current rung and per-level mastery. On by default; turn off "Progressive difficulty" on the Multiplication card to go back to the manual Max Digits setting.diff --git a/client/src/components/meatspace/post/WordplayTrainer.jsx b/client/src/components/meatspace/post/WordplayTrainer.jsxindex 67737496cd..89423ecffa 100644--- a/client/src/components/meatspace/post/WordplayTrainer.jsx+++ b/client/src/components/meatspace/post/WordplayTrainer.jsx@@ -9,7 +9,7 @@ import ProviderModelSelector from '../../ProviderModelSelector';import Modal from '../../ui/Modal';import toast from '../../ui/Toast';import { AILoadingIndicator, MissedExamplesDisplay, CompoundChainUI, BridgeWordUI, DoubleMeaningUI, IdiomTwistUI, ProgressBar, scoreWordplayResponse } from './WordplayDrillUI';-import { countLlmCorrect } from './constants';+import { countLlmCorrect, LLM_TRAINING_CORRECT_THRESHOLD } from './constants';// Coarse module bucket for training-log entries — matches the module// PostLlmDrillRunner's in-session runner logs LLM/wordplay drills under@@ -258,12 +258,25 @@ export default function WordplayTrainer({ onBack, config, onConfigUpdate }) {// that practice happened anywhere (issue #2097). Fire-and-forget, same// pattern as MorseTrainer's logTraining: a failed background write// shouldn't interrupt the results screen the user is already seeing.+ // `questions` carries the per-question breakdown already computed in+ // `results` (issue #2114) — the drill cache means these prompts are+ // reusable, so a future progress dashboard can trend which individual+ // wordplay prompts get missed rather than only the round aggregate.submitTrainingEntry({module: TRAINING_MODULE,drillType: selectedMode,questionCount: results.length,correctCount: countLlmCorrect(results),totalMs: Date.now() - roundStartRef.current,+ questions: results.map(r => ({+ prompt: r.prompt,+ response: r.response,+ items: r.items,+ responseMs: r.responseMs,+ score: r.score,+ feedback: r.feedback,+ correct: (r.score ?? 0) >= LLM_TRAINING_CORRECT_THRESHOLD,+ })),}).catch(() => {});} else {setQuestionIndex(questionIndex + 1);diff --git a/client/src/components/meatspace/post/WordplayTrainer.test.jsx b/client/src/components/meatspace/post/WordplayTrainer.test.jsxindex b22d4fd1cf..b009899a79 100644--- a/client/src/components/meatspace/post/WordplayTrainer.test.jsx+++ b/client/src/components/meatspace/post/WordplayTrainer.test.jsx@@ -67,6 +67,16 @@ describe('WordplayTrainer — training-log persistence (issue #2097)', () => {}));const entry = submitTrainingEntry.mock.calls[0][0];expect(entry.totalMs).toBeGreaterThanOrEqual(0);++ // Per-question breakdown (issue #2114) — one entry per scored response,+ // carrying the score/feedback already computed for the results screen.+ expect(entry.questions).toHaveLength(1);+ expect(entry.questions[0]).toMatchObject({+ items: ['firehouse'],+ score: 85,+ feedback: 'Nice compounds!',+ correct: true,+ });});it('does not submit a training entry before the round completes', async () => {diff --git a/server/lib/postValidation.js b/server/lib/postValidation.jsindex b6ef7ceb44..fde8417b2b 100644--- a/server/lib/postValidation.js+++ b/server/lib/postValidation.js@@ -373,6 +373,23 @@ export const morseLevelUpdateSchema = z.object({}).optional(),});+// Per-question breakdown for a training-log entry (issue #2114 — follow-up to+// #2097, which only persisted round-level aggregates). Optional and additive:+// entries without it (legacy rows, and non-wordplay training modules that+// never populate it) must stay valid. Field names mirror llmResponseSchema+// above (the shape scored POST sessions store per LLM-drill question) so a+// future progress dashboard can render training-log and scored-session+// breakdowns with the same renderer rather than inventing a training-only shape.+const trainingQuestionSchema = z.object({+ prompt: z.string().optional(),+ response: z.string().optional(),+ items: z.array(z.string()).optional(),+ responseMs: z.number().min(0).optional(),+ score: z.number().min(0).max(100).optional(),+ feedback: z.string().optional(),+ correct: z.boolean().optional(),+});+// Training log entry submissionexport const trainingEntrySchema = z.object({module: z.string(),@@ -384,6 +401,7 @@ export const trainingEntrySchema = z.object({questionCount: z.number().int().min(0),correctCount: z.number().int().min(0),totalMs: z.number().min(0),+ questions: z.array(trainingQuestionSchema).optional(),});export { LLM_DRILL_TYPES, MATH_DRILL_TYPES, MEMORY_DRILL_TYPES, POST_SUPPORTED_MEMORY_TYPES, COGNITIVE_DRILL_TYPES, MORSE_DRILL_TYPES };diff --git a/server/lib/postValidation.test.js b/server/lib/postValidation.test.jsindex 8a147714ae..af237c3702 100644--- a/server/lib/postValidation.test.js+++ b/server/lib/postValidation.test.js@@ -109,6 +109,42 @@ describe('trainingEntrySchema wordplay drill types (issue #2097)', () => {});});+describe('trainingEntrySchema per-question breakdown (issue #2114)', () => {+ // Follow-up to #2097: the training log previously kept only round-level+ // aggregates. `questions` is optional/additive so legacy entries with no+ // breakdown stay valid.+ it('accepts a training entry with no questions field (back-compat)', () => {+ const parsed = trainingEntrySchema.parse({+ module: 'llm-drills', drillType: 'compound-chain', questionCount: 5, correctCount: 4, totalMs: 60000+ });+ expect(parsed.questions).toBeUndefined();+ });++ it('accepts and preserves a per-question breakdown for a wordplay entry', () => {+ const parsed = trainingEntrySchema.parse({+ module: 'llm-drills',+ drillType: 'bridge-word',+ questionCount: 2,+ correctCount: 1,+ totalMs: 45000,+ questions: [+ { prompt: 'news___', response: 'paper', responseMs: 4200, score: 85, feedback: 'Nice.', correct: true },+ { items: ['firehouse', 'firewall'], responseMs: 5100, score: 40, feedback: 'Partial credit.', correct: false },+ ],+ });+ expect(parsed.questions).toHaveLength(2);+ expect(parsed.questions[0]).toMatchObject({ prompt: 'news___', response: 'paper', score: 85, correct: true });+ expect(parsed.questions[1]).toMatchObject({ items: ['firehouse', 'firewall'], score: 40, correct: false });+ });++ it('rejects a question entry with an out-of-range score', () => {+ expect(() => trainingEntrySchema.parse({+ module: 'llm-drills', drillType: 'bridge-word', questionCount: 1, correctCount: 0, totalMs: 1000,+ questions: [{ prompt: 'x', score: 150 }],+ })).toThrow();+ });+});+describe('questionResultSchema chunkId/element (issue #2016)', () => {// Regression: memory-sequence/memory-element-flash answers must carry// chunkId/element through postSessionSubmitSchema so submitPostSession candiff --git a/server/services/meatspacePostTraining.js b/server/services/meatspacePostTraining.jsindex 098e272e71..d56c9e2d01 100644--- a/server/services/meatspacePostTraining.js+++ b/server/services/meatspacePostTraining.js@@ -40,6 +40,13 @@ export async function submitTrainingEntry(entry) {correctCount: entry.correctCount ?? 0,totalMs: entry.totalMs ?? 0,};+ // Per-question breakdown (issue #2114) is optional — only wordplay training+ // currently supplies it. Gate on Array.isArray (not truthiness/length) so an+ // absent field stays absent rather than being coerced to `[]`, keeping+ // legacy/no-breakdown entries indistinguishable from before this change.+ if (Array.isArray(entry.questions)) {+ record.questions = entry.questions;+ }data.entries.push(record);await saveTrainingLog(data);diff --git a/server/services/meatspacePostTraining.test.js b/server/services/meatspacePostTraining.test.jsindex f4df7beeeb..289a2fb432 100644--- a/server/services/meatspacePostTraining.test.js+++ b/server/services/meatspacePostTraining.test.js@@ -43,6 +43,38 @@ describe('submitTrainingEntry', () => {expect(atomicWrite).toHaveBeenCalledOnce();});+ it('persists a per-question breakdown when supplied (issue #2114)', async () => {+ const questions = [+ { prompt: 'news___', response: 'paper', responseMs: 4200, score: 85, feedback: 'Nice.', correct: true },+ { items: ['firehouse'], responseMs: 5100, score: 40, feedback: 'Partial.', correct: false },+ ];++ const entry = await submitTrainingEntry({+ module: 'llm-drills',+ drillType: 'bridge-word',+ questionCount: 2,+ correctCount: 1,+ totalMs: 9300,+ questions,+ });++ expect(entry.questions).toEqual(questions);+ const savedData = atomicWrite.mock.calls[0][1];+ expect(savedData.entries[0].questions).toEqual(questions);+ });++ it('omits the questions field entirely when not supplied (back-compat)', async () => {+ const entry = await submitTrainingEntry({+ module: 'mental-math',+ drillType: 'multiplication',+ questionCount: 10,+ correctCount: 7,+ totalMs: 45000,+ });++ expect(entry).not.toHaveProperty('questions');+ });+it('appends to existing entries', async () => {readJSONFile.mockResolvedValue({entries: [{ id: 'old', module: 'mental-math', drillType: 'powers' }]