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
Merge remote-tracking branch 'origin/main' into next/issue-2095
Adam Eivy921818264e80
diff --cc .changelog/NEXT.mdindex dab3f71db6,5606149ed6..be0eba29a9--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@@ -25,7 -31,7 +31,8 @@@## POST Training+- **[issue-2095] Cognitive drills now level up as you master them, instead of training at one fixed difficulty forever.** N-back, digit span, Schulte table, mental rotation, and Stroop each climb their own mastery-gated ladder: n-back ramps 1-back → 2-back → 3-back and then squeezes the flash speed (2500 → 2000 → 1600ms); digit span grows its span and adds backward recall; Schulte grows the grid 4×4 → 6×6; mental rotation and Stroop add trials. You advance a rung only after sustained high accuracy at the current one (n-back uses the fair signal-detection accuracy, so never-pressing can't bank a level), and you're never demoted below a rung you've earned. Each drill now stamps its difficulty into your saved results, so progress is tracked per level (a 2-back run no longer pools with a 3-back run). The config page shows each drill's current rung and progress toward the next, with a per-drill "Progressive" toggle (on by default) — turn it off to set the knobs by hand, including the previously-hidden n-back stimulus speed and digit-span show time. Reaction time stays a fixed measurement. On by default for existing installs with no migration.+ - **[issue-2091] A unified Progress dashboard shows whether you're actually improving.** POST has a new **Progress** page (in the POST sidebar section, ⌘K, and voice nav) that pulls scored sessions, Morse/memory practice, and mastery into one view. It charts your score, accuracy, and response-time trends over time — so "am I getting faster?" finally has an answer — with same-day sessions rolled into one point (no more overlapping dots), a per-domain focus selector, and time-in-training cards. Your practice streak is now a single number counting *any* active day — a scored session **or** a Morse/memory practice — so the launcher, the Morse trainer, the Progress page, and the dashboard widgets all show the same streak instead of three different ones. A mastery panel shows your multiplication ladder rung and each memory item's mastery and due status. The full session-history table lives on as a sub-view.- **[issue-2092] Morse progress now lives on the server, with WPM/accuracy trends and a per-character confusion matrix.** Your Koch level and every completed drill round are now saved server-side instead of only in the browser — so clearing browser data or switching devices (over Tailscale) no longer wipes your Morse mastery, and your level is identical everywhere. The first time you open the trainer it adopts your existing browser level once, then keeps both in sync. A new **Morse Progress** panel on `/post/morse` charts accuracy and effective-WPM trends per mode (Copy / Head Copy / Send), highlights your most-confused character pairs (E↔I and friends), and lists your weakest characters worst-first so you know exactly which to drill next. Send-mode rounds record per-character keying accuracy and timing too.## Roundsdiff --cc client/src/components/meatspace/post/PostDrillConfig.test.jsxindex b27bc6439d,efd4207fe5..120178c34c--- a/client/src/components/meatspace/post/PostDrillConfig.test.jsx+++ b/client/src/components/meatspace/post/PostDrillConfig.test.jsx@@@ -11,24 -10,18 +11,18 @@@ vi.mock('../../../services/api', () =>vi.mock('../../ui/Toast', () => ({ default: { success: vi.fn(), error: vi.fn() } }));import PostDrillConfig from './PostDrillConfig';-import { updatePostConfig, getProviders, getPostAdaptivePreview, getPostMultiplicationProgress } from '../../../services/api';+import { updatePostConfig, getProviders, getPostAdaptivePreview, getPostMultiplicationProgress, getPostCognitiveProgress } from '../../../services/api';+ import { LLM_DRILL_TYPES, DRILL_LABELS } from './constants';- // The 14 generatable LLM drill types (mirror server + client constants).- const ALL_LLM_TYPES = [- 'pun-wordplay', 'word-association', 'compound-chain', 'bridge-word',- 'double-meaning', 'idiom-twist', 'story-recall', 'verbal-fluency',- 'wit-comeback', 'what-if', 'alternative-uses', 'story-prompt',- 'invention-pitch', 'reframe',- ];- const LABELS = {- 'pun-wordplay': 'Pun & Wordplay', 'word-association': 'Word Association',- 'compound-chain': 'Compound Chain', 'bridge-word': 'Bridge Word',- 'double-meaning': 'Double Meaning', 'idiom-twist': 'Idiom Twist',- 'story-recall': 'Story Recall', 'verbal-fluency': 'Verbal Fluency',- 'wit-comeback': 'Wit & Comeback', 'what-if': 'What If?',- 'alternative-uses': 'Alternative Uses', 'story-prompt': 'Story Prompt',- 'invention-pitch': 'Invention Pitch', 'reframe': 'Reframe',- };+ // The generatable LLM drill types + labels, imported from the canonical+ // client constant (mirrors server LLM_DRILL_TYPES in meatspacePostLlm.js) —+ // NOT a hardcoded parallel copy, so this test can't stay green against a+ // stale list if a drill type is ever added/removed/relabeled.+ const ALL_LLM_TYPES = LLM_DRILL_TYPES;+ // The 5 legacy drills that ship enabled by default (server DEFAULT_CONFIG);+ // everything else in ALL_LLM_TYPES is newly-exposed and defaults to opt-in.+ const LEGACY_ENABLED_TYPES = ['pun-wordplay', 'word-association', 'story-recall', 'verbal-fluency', 'wit-comeback'];+ const NEWLY_EXPOSED_TYPES = ALL_LLM_TYPES.filter(t => !LEGACY_ENABLED_TYPES.includes(t));// Mirrors the server DEFAULT_CONFIG: only the 5 legacy LLM drills ship enabled.const config = {diff --cc client/src/services/apiMeatspace.jsindex 149afea6b6,f9e089da16..cef404e19c--- a/client/src/services/apiMeatspace.js+++ b/client/src/services/apiMeatspace.js@@@ -186,9 -186,12 +186,13 @@@ export const submitPostSession = (data...options});export const getPostStats = (days) => request(`/meatspace/post/stats${days != null ? `?days=${days}` : ''}`);+ export const getPostProgress = (days, options = {}) => request(+ `/meatspace/post/progress${days != null ? `?days=${days}` : ''}`,+ options+ );export const getPostAdaptivePreview = () => request('/meatspace/post/adaptive-preview');export const getPostMultiplicationProgress = () => request('/meatspace/post/multiplication-progress');+export const getPostCognitiveProgress = () => request('/meatspace/post/cognitive-progress');export const generatePostDrill = (type, config = {}, providerId, model, options = {}) => request('/meatspace/post/drill', {method: 'POST',body: JSON.stringify({ type, config, ...(providerId && { providerId }), ...(model && { model }) }),diff --cc server/lib/README.mdindex 5f63f8090c,60d04a8a22..c2ea16489d--- a/server/lib/README.md+++ b/server/lib/README.md@@@ -214,8 -214,8 +214,9 @@@ The barrel `server/lib/index.js` is a m| `textUtils.js` | Pure server-side prose helpers. `countWords(text)` — canonical whitespace-token count (`\S+`), the single home for what `writersRoom/local.js`, `issueLength.js`, and the client's `formatters.js` used to each re-implement. || `pipelineIssueOrder.js` | Pure renumber algorithm for pipeline issues. || `postAdaptive.js` | Pure POST adaptive-difficulty policy — nudges a math drill's primary knob (`steps`/`maxDigits`/`maxExponent`/`tolerancePct`) up/down within clamped bounds from recent scored performance. Opt-in via the config Adaptive toggle. |-| `postMultiplicationLadder.js` | Pure progressive multiplication ladder — mastery-gated difficulty rungs (`[1,1]` → `[1,2]` → `[1,1,1]` → …). Resolves the user's current level from per-level speed+accuracy stats so the plain multiplication drill ramps up instead of starting at a fixed hard difficulty. On by default. |+| `postMultiplicationLadder.js` | Pure progressive multiplication ladder — mastery-gated difficulty rungs (`[1,1]` → `[1,2]` → `[1,1,1]` → …). Resolves the user's current level from per-level speed+accuracy stats so the plain multiplication drill ramps up instead of starting at a fixed hard difficulty. On by default. Built on `postProgression.js`. |+| `postProgression.js` | Generic mastery-gated progression ladder (extracted from `postMultiplicationLadder.js`) — `createProgression({ levels, describeLevel, speedTargetForLevel? })` resolves a user's current rung from per-level stats with an anti-demotion floor. Also defines the cognitive-drill ladders (n-back / digit-span / schulte / mental-rotation / stroop) and their level→generator-config mapping. |+ | `postStreak.js` | Pure DST-safe POST practice-streak math — the single `computePostStreaks` implementation shared by scored sessions and the training log, plus `computeUnifiedStreak` (a day is active with EITHER a session or a practice entry). || `planIds.js` | Utilities for PLAN.md `[slug]` IDs. || `renderSlot.js` | Render-slot helpers for `(proof\|final)Image` per stage. || `telegramClient.js` | Telegram bot client. |diff --cc server/lib/index.jsindex 9362a65ce8,d56cbf5779..cef1b1ae7c--- a/server/lib/index.js+++ b/server/lib/index.js@@@ -190,7 -190,7 +190,8 @@@ export * from './personaTraitBlend.js'export * from './pipelineIssueOrder.js';export * from './postAdaptive.js';export * from './postMultiplicationLadder.js';+export * from './postProgression.js';+ export * from './postStreak.js';export * from './planIds.js';export * from './renderSlot.js';export * from './telegramClient.js';diff --cc server/services/meatspacePost.jsindex 80343d2d78,b6de8f1e78..ab8d56792f--- a/server/services/meatspacePost.js+++ b/server/services/meatspacePost.js@@@ -13,15 -13,15 +13,22 @@@ import { deepMerge, isPlainObject } froimport { LLM_DRILL_TYPES, MEMORY_DRILL_TYPES, POST_SUPPORTED_MEMORY_TYPES } from '../lib/postValidation.js';import { adaptDrillConfig, ADAPTIVE_SPECS, ADAPTIVE_DEFAULTS } from '../lib/postAdaptive.js';import { resolveMultiplicationLevel, MASTERY_DEFAULTS } from '../lib/postMultiplicationLadder.js';+import {+ cognitiveLadder,+ cognitiveLevelConfig,+ resolveCognitiveProgression,+ COGNITIVE_LADDER_TYPES,+ COGNITIVE_MASTERY_DEFAULTS,+} from '../lib/postProgression.js';import { COGNITIVE_DRILL_TYPES, generateCognitiveDrill, scoreCognitiveDrill } from './meatspacePostCognitive.js';- import { advanceScheduleFromSession, mergeMasteryFromSession } from './meatspacePostMemory.js';+ import { advanceScheduleFromSession, mergeMasteryFromSession, getMemoryItems, getDueMemoryItems } from './meatspacePostMemory.js';+ import { getAllTrainingEntries } from './meatspacePostTraining.js';+ import { computePostStreaks, computeUnifiedStreak, ymdToUTC } from '../lib/postStreak.js';++ // Re-export the shared streak helper so existing importers of+ // `computePostStreaks` from this module keep working after it moved to+ // server/lib/postStreak.js (single implementation — see that file).+ export { computePostStreaks };const MEATSPACE_DIR = PATHS.meatspace;const SESSIONS_FILE = join(MEATSPACE_DIR, 'post-sessions.json');diff --cc server/services/meatspacePost.test.jsindex 711690e2d3,582d960657..af6be548be--- a/server/services/meatspacePost.test.js+++ b/server/services/meatspacePost.test.js@@@ -28,9 -28,9 +28,11 @@@ importpostConfigEvents,resolveDrillConfig,getMultiplicationProgress,+ getCognitiveProgress,+ generateDrill,+ getAdaptivePreview,getPostStats,+ getAdaptivePreview,deriveTaskAccuracy,deriveTaskCompletion,} from './meatspacePost.js';@@@ -855,147 -982,66 +984,207 @@@ describe('resolveDrillConfig — progre});// =============================================================================+// PROGRESSIVE COGNITIVE LADDERS — resolveDrillConfig / getCognitiveProgress /+// difficulty stamping through submitPostSession (issue #2095)+// =============================================================================++describe('progressive cognitive drills', () => {+ const today = new Date().toISOString().split('T')[0];+ const oldDate = new Date(Date.now() - 60 * 86400000).toISOString().split('T')[0];++ // A completed cognitive drill at `level` with a given task-level accuracy —+ // the shape getCognitiveLevelStats buckets by (accuracy-only mastery).+ function cognitiveSession(type, level, accuracy, date = today, count = 20) {+ return {+ date,+ tasks: [{+ module: 'cognitive',+ type,+ config: { level },+ accuracy,+ totalCount: count,+ questions: Array.from({ length: count }, () => ({ answered: 'x' })),+ }],+ };+ }++ function mockSessions(sessions, configOverride) {+ readJSONFile.mockImplementation((path, defaultValue) => {+ const p = String(path);+ if (p.includes('post-sessions')) return Promise.resolve({ sessions });+ if (p.includes('post-config')) return Promise.resolve(configOverride ?? defaultValue);+ return Promise.resolve(defaultValue);+ });+ }++ beforeEach(() => {+ vi.clearAllMocks();+ });++ it('starts a fresh user at n-back level 0 (1-back) and stamps the rung knobs', async () => {+ mockSessions([]);+ const { config, progression } = await resolveDrillConfig('n-back', { length: 20 });+ expect(progression.level).toBe(0);+ expect(config.level).toBe(0);+ expect(config.n).toBe(1);+ expect(config.stimulusMs).toBe(2500);+ });++ it('advances a cognitive rung on sustained balanced accuracy', async () => {+ // 3 clean 1-back runs at 90% balanced accuracy → clears level 0.+ mockSessions([+ cognitiveSession('n-back', 0, 0.9),+ cognitiveSession('n-back', 0, 0.92),+ cognitiveSession('n-back', 0, 0.95),+ ]);+ const { config, progression } = await resolveDrillConfig('n-back', {});+ expect(progression.level).toBe(1);+ expect(config.n).toBe(2);+ });++ it('does not advance on high-accuracy but low-completion runs (skipped hard trials)', async () => {+ // Answered only the easy sequence (100% accuracy) but left the rest blank —+ // low completion must not bank a mastery sample (issue #2095 review).+ const lowCompletion = (level, date = today) => ({+ date,+ tasks: [{ module: 'cognitive', type: 'digit-span', config: { level }, accuracy: 1, completion: 0.25, totalCount: 4, questions: [{ answered: '1' }] }],+ });+ mockSessions([lowCompletion(0), lowCompletion(0), lowCompletion(0)]);+ const { progression } = await resolveDrillConfig('digit-span', {});+ expect(progression.level).toBe(0);+ });++ it('does not advance when accuracy is below the mastery bar', async () => {+ mockSessions([+ cognitiveSession('n-back', 0, 0.6),+ cognitiveSession('n-back', 0, 0.7),+ cognitiveSession('n-back', 0, 0.5),+ ]);+ const { progression } = await resolveDrillConfig('n-back', {});+ expect(progression.level).toBe(0);+ });++ it('never demotes below the earned floor when the window aged out', async () => {+ mockSessions([+ cognitiveSession('digit-span', 3, 0.9, oldDate),+ cognitiveSession('digit-span', 3, 0.95, oldDate),+ cognitiveSession('digit-span', 3, 0.9, oldDate),+ ]);+ const { progression, config } = await resolveDrillConfig('digit-span', {});+ expect(progression.level).toBe(3);+ expect(progression.floorLevel).toBe(3);+ expect(config.direction).toBe('backward');+ });++ it('passes config through unchanged when the drill Progressive toggle is off', async () => {+ mockSessions([], { cognitive: { drillTypes: { 'n-back': { progressive: false } } } });+ const { config, progression } = await resolveDrillConfig('n-back', { n: 3, stimulusMs: 1200 });+ expect(progression == null).toBe(true);+ expect(config).toEqual({ n: 3, stimulusMs: 1200 });+ });++ it('reaction-time has no ladder — always passes config through', async () => {+ mockSessions([]);+ const { config, progression } = await resolveDrillConfig('reaction-time', { mode: 'choice' });+ expect(progression == null).toBe(true);+ expect(config).toEqual({ mode: 'choice' });+ });++ it('generateDrill stamps the resolved level into the generated cognitive config', async () => {+ mockSessions([]);+ const { config } = await resolveDrillConfig('n-back', { length: 12 });+ const drill = generateDrill('n-back', config);+ expect(drill.config.level).toBe(0);+ expect(drill.config.n).toBe(1);+ });++ it('getCognitiveProgress separates per-level history (n=2 vs n=3 recoverable)', async () => {+ mockSessions([+ cognitiveSession('n-back', 1, 0.9),+ cognitiveSession('n-back', 1, 0.95),+ cognitiveSession('n-back', 1, 0.92),+ ]);+ const progress = await getCognitiveProgress();+ expect(progress['n-back'].level).toBe(2); // level-1 mastered → sits on level 2+ expect(progress['n-back'].levels[1].mastered).toBe(true);+ expect(progress['n-back'].levels[2].mastered).toBe(false);+ // Every laddered type reports; reaction-time is absent.+ expect(Object.keys(progress).sort()).toEqual(['digit-span', 'mental-rotation', 'n-back', 'schulte-table', 'stroop']);+ });++ it('difficulty stamp survives submitPostSession (stored task carries config.level)', async () => {+ mockSessions([]);+ const { config } = await resolveDrillConfig('schulte-table', {});+ const drill = generateDrill('schulte-table', config);+ // Client submits the served drill's config (with level) + drillData.+ const questions = drill.cells.map((_, i) => ({ index: i, answered: i + 1, responseMs: 500 }));+ const session = await submitPostSession({+ modules: ['cognitive'],+ tasks: [{ module: 'cognitive', type: 'schulte-table', config: drill.config, drillData: drill, questions, totalMs: 5000 }],+ });+ const stored = session.tasks[0];+ expect(stored.config.level).toBe(0);+ expect(Number.isFinite(stored.accuracy)).toBe(true);+ // ADAPTIVE PREVIEW / resolveDrillConfig PARITY — multiplication (issue #2099, fix #2)+ //+ // getAdaptivePreview used to always build multiplication's preview off the+ // generic maxDigits Adaptive knob, even though resolveDrillConfig hands+ // multiplication's difficulty entirely to the progressive ladder whenever+ // `progressive !== false` (the default) — so the previewed maxDigits+ // adjustment could never actually apply. This locks the two functions'+ // multiplication branch in parity for both progressive modes.+ // =============================================================================++ describe('getAdaptivePreview — multiplication parity with resolveDrillConfig', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ readJSONFile.mockImplementation((path, defaultValue) => {+ const p = String(path);+ if (p.includes('post-sessions')) return Promise.resolve({ sessions: [] });+ return Promise.resolve(defaultValue);+ });+ });++ it('previews the progressive ladder rung (not a maxDigits knob) when progressive is on (the default)', async () => {+ const preview = await getAdaptivePreview();+ const resolved = await resolveDrillConfig('multiplication', { count: 10, maxDigits: 2 });++ expect(preview.drills.multiplication.ladder).toBe(true);+ // Same rung resolveDrillConfig would actually generate a drill at.+ expect(preview.drills.multiplication.level).toBe(resolved.progression.level);+ expect(preview.drills.multiplication.factors).toEqual(resolved.progression.factors);+ // The generic Adaptive maxDigits field must NOT be present — showing it+ // would advertise an adjustment resolveDrillConfig will never apply.+ expect(preview.drills.multiplication.field).toBeUndefined();+ expect(preview.drills.multiplication.to).toBeUndefined();+ });++ it('previews the maxDigits Adaptive knob when progressive is turned off', async () => {+ readJSONFile.mockImplementation((path, defaultValue) => {+ const p = String(path);+ if (p.includes('post-sessions')) return Promise.resolve({ sessions: [] });+ if (p.includes('post-config')) {+ return Promise.resolve({ mentalMath: { drillTypes: { multiplication: { progressive: false } } } });+ }+ return Promise.resolve(defaultValue);+ });++ const preview = await getAdaptivePreview();+ const resolved = await resolveDrillConfig('multiplication', { count: 10, maxDigits: 2 });++ // No live adaptation without scored history, but the field/shape must+ // match the maxDigits knob resolveDrillConfig's Adaptive branch would use+ // — not the ladder shape.+ expect(preview.drills.multiplication.ladder).toBeUndefined();+ expect(preview.drills.multiplication.field).toBe('maxDigits');+ expect(resolved.progression == null).toBe(true);+ expect(resolved.config.maxDigits).toBe(2);+ });++ it('other math drill types are unaffected (still the generic Adaptive preview)', async () => {+ const preview = await getAdaptivePreview();+ expect(preview.drills['doubling-chain'].field).toBe('steps');+ expect(preview.drills['doubling-chain'].ladder).toBeUndefined();});});