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 (codex): bump scorer version, fix benchmark time limit, per-run legacy tags, honest day-average label
[._.]/ Adam Eivy80b8b8adb4f1
diff --git a/client/src/components/meatspace/post/PostProgress.jsx b/client/src/components/meatspace/post/PostProgress.jsxindex 1be8308d4a..9d41de1ed4 100644--- a/client/src/components/meatspace/post/PostProgress.jsx+++ b/client/src/components/meatspace/post/PostProgress.jsx@@ -122,8 +122,12 @@ export default function PostProgress({ subtab, onBack }) {// "Score Trend" above which includes every scored session. `excludedCount`// is surfaced explicitly rather than silently omitted.const benchmark = progress?.series?.benchmark || null;+ // `sessions` carries through so a same-day-average point can be labeled+ // honestly — getPostProgress buckets by day, so a day with 2+ compatible+ // runs reports their MEAN, not either individual run's actual score+ // (issue #4442 codex review).const benchmarkScoreData = useMemo(- () => (benchmark?.byDay || []).filter(p => p.score != null).map(p => ({ date: p.date, score: p.score })),+ () => (benchmark?.byDay || []).filter(p => p.score != null).map(p => ({ date: p.date, score: p.score, sessions: p.sessions })),[benchmark]);@@ -292,7 +296,10 @@ export default function PostProgress({ subtab, onBack }) {{`Benchmark Trend — ${benchmark.protocolId} v${benchmark.protocolVersion}`}</h3><div className="text-sm text-gray-300">- Latest compatible run: <span className="font-mono font-bold text-white">{benchmarkScoreData[0].score}</span> on {benchmarkScoreData[0].date}. Complete another benchmark to chart a trend.+ {benchmarkScoreData[0].sessions > 1+ ? <>Day average ({benchmarkScoreData[0].sessions} runs): <span className="font-mono font-bold text-white">{benchmarkScoreData[0].score}</span> on {benchmarkScoreData[0].date}.</>+ : <>Latest compatible run: <span className="font-mono font-bold text-white">{benchmarkScoreData[0].score}</span> on {benchmarkScoreData[0].date}.</>}+ {' '}Complete another benchmark to chart a trend.</div></div>) : (diff --git a/client/src/components/meatspace/post/PostProgress.test.jsx b/client/src/components/meatspace/post/PostProgress.test.jsxindex c93a34a2b7..606d1ad10a 100644--- a/client/src/components/meatspace/post/PostProgress.test.jsx+++ b/client/src/components/meatspace/post/PostProgress.test.jsx@@ -160,6 +160,26 @@ describe('PostProgress — benchmark trend', () => {expect(screen.queryByText(/No compatible benchmark runs yet/)).not.toBeInTheDocument();});+ it('labels a single displayed point as a day average when it aggregates multiple same-day runs (issue #4442 codex review round 2)', async () => {+ getPostProgress.mockResolvedValue({+ ...PROGRESS,+ series: {+ ...PROGRESS.series,+ benchmark: {+ protocolId: 'post-foundation-battery',+ protocolVersion: 1,+ scorerVersion: 'post-deterministic-v2',+ byDay: [{ date: '2026-06-03', score: 70, sessions: 2 }],+ excludedCount: 0,+ },+ },+ });+ renderProgress();+ await waitFor(() => expect(screen.getByText(/Benchmark Trend/)).toBeInTheDocument());+ expect(screen.getByText(/Day average \(2 runs\)/)).toBeInTheDocument();+ expect(screen.queryByText(/Latest compatible run/)).not.toBeInTheDocument();+ });+it('surfaces the excluded-legacy-runs note when excludedCount is set', async () => {getPostProgress.mockResolvedValue({...PROGRESS,diff --git a/client/src/hooks/usePostSession.js b/client/src/hooks/usePostSession.jsindex 12c4fd0a8a..49b65e6a15 100644--- a/client/src/hooks/usePostSession.js+++ b/client/src/hooks/usePostSession.js@@ -173,14 +173,24 @@ export function usePostSession() {// the /post/session/:id results URL — so a saved session's URL === its run id.const [runId, setRunId] = useState(restored?.runId ?? null);const [conditions, setConditions] = useState(restored?.conditions ?? {}); // session conditions captured at launch- // Read-only carrier for a run resumed from a PRE-upgrade snapshot that still- // has the legacy free-text `tags` shape (e.g. a mid-session refresh spanning- // a deploy). Never written by this session — the launcher only ever produces- // `conditions` now — so it's captured once here and submitted verbatim under- // the legacy `tags` field on save, rather than silently dropped or coerced- // into `conditions`'s fixed enums (its free-text values wouldn't validate as- // enum members anyway).- const legacyTags = restored?.tags && !restored?.conditions ? restored.tags : null;+ // Carrier for a run resumed from a PRE-upgrade snapshot that still has the+ // legacy free-text `tags` shape (e.g. a mid-session refresh spanning a+ // deploy). Never written by the launcher (which only ever produces+ // `conditions` now) — captured on restore and submitted verbatim under the+ // legacy `tags` field on save, rather than silently dropped or coerced into+ // `conditions`'s fixed enums (its free-text values wouldn't validate as+ // enum members anyway). Real per-run STATE, not a plain const: it must be+ // (a) part of the periodic snapshot so a SECOND refresh of the same+ // resumed run doesn't lose it (the first snapshot write after restore+ // would otherwise drop it, since it wasn't a key the old writer knew+ // about), and (b) cleared on `startSession`/`reset` so an abandoned run's+ // legacy tags can never bleed into an unrelated new session (issue #4442+ // codex review). `restored.legacyTags` covers a snapshot already written by+ // this code; the `tags`-without-`conditions` check covers the first-ever+ // restore of a genuinely pre-upgrade snapshot.+ const [legacyTags, setLegacyTags] = useState(+ () => restored?.legacyTags ?? (restored?.tags && !restored?.conditions ? restored.tags : null)+ );const [sessionPlan, setSessionPlan] = useState(restored?.sessionPlan ?? null);const [benchmark, setBenchmark] = useState(restored?.benchmark ?? null);const [lastAnswer, setLastAnswer] = useState(null); // { correct, expected, answered } for training feedback@@ -212,7 +222,7 @@ export function usePostSession() {if (typeof sessionStorage === 'undefined') return;sessionStorage.setItem(RUN_STORAGE_KEY, JSON.stringify({runId, state, drills, currentDrillIndex, currentDrill, currentQuestionIndex,- answers, drillResults, sessionScore, isTraining, conditions, sessionPlan,+ answers, drillResults, sessionScore, isTraining, conditions, legacyTags, sessionPlan,benchmark,// Persist the timing anchors (mutated synchronously on each question/drill// transition, just before the state change that fires this effect) so a@@ -222,7 +232,7 @@ export function usePostSession() {runStartedAt: runStartedAtRef.current,runCompletedAt: runCompletedAtRef.current,}));- }, [runId, state, drills, currentDrillIndex, currentDrill, currentQuestionIndex, answers, drillResults, sessionScore, isTraining, conditions, sessionPlan, benchmark]);+ }, [runId, state, drills, currentDrillIndex, currentDrill, currentQuestionIndex, answers, drillResults, sessionScore, isTraining, conditions, legacyTags, sessionPlan, benchmark]);const startSession = useCallback(async (drillConfigs, training = false, sessionConditions = {}, plan = null, benchmarkMetadata = null) => {// drillConfigs: [{ type, config, timeLimitSec }]@@ -245,6 +255,9 @@ export function usePostSession() {// conditions to submit, so both survive a mid-run refresh via the snapshot.setRunId(newRunId());setConditions(sessionConditions || {});+ // A fresh run never inherits a PRIOR (possibly abandoned) run's legacy+ // tags — those belong only to the resumed run they were restored with.+ setLegacyTags(null);const first = drillConfigs[0];const drill = await generatePostDrill(first.type, first.config, first.providerId, first.model, { silent: true }).catch(err => {@@ -623,7 +636,7 @@ export function usePostSession() {toast.success(`POST complete — score: ${session.score}`);setState(STATES.SAVED);return session;- }, [drillResults, isTraining, conditions, runId, sessionPlan, benchmark]);+ }, [drillResults, isTraining, conditions, legacyTags, runId, sessionPlan, benchmark]);const reset = useCallback(() => {setState(STATES.IDLE);@@ -640,6 +653,7 @@ export function usePostSession() {runStartedAtRef.current = null;runCompletedAtRef.current = null;setConditions({});+ setLegacyTags(null);setSessionPlan(null);setBenchmark(null);setLastAnswer(null);diff --git a/server/services/meatspacePost.js b/server/services/meatspacePost.jsindex 7ee1f68cae..de2637699b 100644--- a/server/services/meatspacePost.js+++ b/server/services/meatspacePost.js@@ -89,7 +89,15 @@ export const postConfigEvents = new EventEmitter();export const POST_BENCHMARK_PROTOCOL = Object.freeze({protocolId: 'post-foundation-battery',protocolVersion: 1,- scorerVersion: 'post-deterministic-v1',+ // v2: benchmark scoring now ignores the user's live config.scoring.weights+ // and mentalMath.drillTypes[type].timeLimitSec, using the protocol's fixed+ // weighting (uniform) and the registered form's timeLimitSec instead — a+ // scoring-contract change, so the version bumps (issue #4442 codex+ // review). A v1-scored session (weighted by whatever config was active at+ // submit time) is no longer "compatible" with a v2 one — benchmarkCompatibility()+ // correctly buckets it as legacy/excluded rather than blending two+ // different scoring formulas into one trend.+ scorerVersion: 'post-deterministic-v2',forms: Object.freeze([Object.freeze({formId: 'a',@@ -408,6 +416,14 @@ export async function submitPostSession(sessionData) {// would then prefer over a questions[] derivation.const rawTasks = Array.isArray(sessionData.tasks) ? sessionData.tasks : [];assertBenchmarkSession(sessionData.benchmark, rawTasks, sessionData.modules);+ // A math drill's time limit is normally the user's live, editable+ // mentalMath.drillTypes[type].timeLimitSec — but a benchmark's speed bonus+ // must come from the REGISTERED form, or the same protocol/version/scorer+ // could still score differently across runs if the user edits their+ // configured time limit in between (issue #4442 codex review). Resolved+ // once here; assertBenchmarkSession already confirmed the form exists and+ // matches when sessionData.benchmark is present.+ const benchmarkForm = sessionData.benchmark ? getPostBenchmarkForm(sessionData.benchmark.formId) : null;const rescoredTasks = rawTasks.map(t => {const {score: _score, correct: _correct,@@ -470,8 +486,9 @@ export async function submitPostSession(sessionData) {const { correct: _qCorrect, ...qRest } = q;return qRest;});+ const benchmarkTimeLimitSec = benchmarkForm?.tasks.find(bt => bt.type === rest.type)?.timeLimitSec;const drillConfig = config.mentalMath?.drillTypes?.[rest.type] || {};- const timeLimitMs = (drillConfig.timeLimitSec || 120) * 1000;+ const timeLimitMs = (benchmarkTimeLimitSec ?? drillConfig.timeLimitSec ?? 120) * 1000;const scored = scoreDrill(rest.type, sanitizedQuestions, timeLimitMs, rest.config || drillConfig);return { ...rest, ...scored };});diff --git a/server/services/meatspacePost.test.js b/server/services/meatspacePost.test.jsindex b7d8f099ff..d98d322b24 100644--- a/server/services/meatspacePost.test.js+++ b/server/services/meatspacePost.test.js@@ -79,7 +79,7 @@ describe('Fixed POST benchmark protocol', () => {expect(protocol).toMatchObject({protocolId: 'post-foundation-battery',protocolVersion: 1,- scorerVersion: 'post-deterministic-v1',+ scorerVersion: POST_BENCHMARK_PROTOCOL.scorerVersion,nextFormId: 'a',});expect(protocol.forms).toHaveLength(2);@@ -99,7 +99,7 @@ describe('Fixed POST benchmark protocol', () => {benchmark: {protocolId: 'post-foundation-battery',protocolVersion: 1,- scorerVersion: 'post-deterministic-v1',+ scorerVersion: POST_BENCHMARK_PROTOCOL.scorerVersion,formId: 'a',},})).rejects.toMatchObject({ code: 'INVALID_BENCHMARK', status: 400 });@@ -107,27 +107,30 @@ describe('Fixed POST benchmark protocol', () => {});// A benchmark's score must be comparable across runs regardless of the-// user's live scoring.weights config — otherwise two "compatible" (same-// protocol/version/scorer) runs could land on different scales and the-// benchmark trend (getPostProgress's series.benchmark) would silently-// compare apples to oranges (issue #4442 codex review).-describe('submitPostSession — benchmark scoring ignores config.scoring.weights', () => {+// user's live scoring.weights / drill-timeLimit config — otherwise two+// "compatible" (same protocol/version/scorer) runs could land on different+// scales and the benchmark trend (getPostProgress's series.benchmark) would+// silently compare apples to oranges (issue #4442 codex review).+describe('submitPostSession — benchmark scoring is fixed by the protocol', () => {beforeEach(() => { vi.clearAllMocks(); });const FORM_A = POST_BENCHMARK_PROTOCOL.forms.find(f => f.formId === 'a');const MATH_TASK_CONFIG = FORM_A.tasks.find(t => t.type === 'doubling-chain').config;+ const MATH_TASK_TIME_LIMIT_SEC = FORM_A.tasks.find(t => t.type === 'doubling-chain').timeLimitSec;const COGNITIVE_TASK_CONFIG = FORM_A.tasks.find(t => t.type === 'task-switching').config;- function benchmarkFormATasks() {+ function benchmarkFormATasks({ mathResponseMs = 100 } = {}) {const cognitiveDrill = generateCognitiveDrill('task-switching', COGNITIVE_TASK_CONFIG);return [{module: 'mental-math',type: 'doubling-chain',config: MATH_TASK_CONFIG,- // All 8 answered correctly and fast — deterministically scores ~100.- questions: Array.from({ length: 8 }, () => ({ prompt: '2 x 2', expected: 4, answered: 4, responseMs: 100 })),- totalMs: 800,+ // All 8 answered correctly and fast — deterministically scores ~100+ // (default responseMs), or a caller-tuned response time for probing+ // the speed-bonus / time-limit behavior.+ questions: Array.from({ length: 8 }, () => ({ prompt: '2 x 2', expected: 4, answered: 4, responseMs: mathResponseMs })),+ totalMs: mathResponseMs * 8,},{module: 'cognitive',@@ -141,10 +144,10 @@ describe('submitPostSession — benchmark scoring ignores config.scoring.weights];}- function benchmarkSubmission() {+ function benchmarkSubmission(taskOpts) {return {modules: ['mental-math', 'cognitive'],- tasks: benchmarkFormATasks(),+ tasks: benchmarkFormATasks(taskOpts),benchmark: {protocolId: POST_BENCHMARK_PROTOCOL.protocolId,protocolVersion: POST_BENCHMARK_PROTOCOL.protocolVersion,@@ -189,6 +192,41 @@ describe('submitPostSession — benchmark scoring ignores config.scoring.weights// behavior above is benchmark-specific, not a global scoring regression.expect(session.score).toBe(2);});++ it("ignores the user's configured mentalMath timeLimitSec, using the registered form's instead", async () => {+ readJSONFile.mockImplementation((path, defaultValue) => {+ const p = String(path);+ if (p.includes('post-config')) {+ // A user-configured 1s time limit — if this leaked into a benchmark+ // rescore, a 900ms response would blow almost the whole window and+ // tank the speed bonus. The form's real limit is 60s (MATH_TASK_TIME_LIMIT_SEC).+ return Promise.resolve({ mentalMath: { drillTypes: { 'doubling-chain': { timeLimitSec: 1 } } } });+ }+ return Promise.resolve(defaultValue);+ });+ const session = await submitPostSession(benchmarkSubmission({ mathResponseMs: 900 }));+ const mathTask = session.tasks.find(t => t.type === 'doubling-chain');+ // speedBonus = 1 - 900/(MATH_TASK_TIME_LIMIT_SEC*1000) ≈ 0.985 (form limit),+ // not 1 - 900/1000 = 0.1 (the buggy user-configured 1s limit) — the two+ // round to very different task scores (100 vs 82).+ expect(MATH_TASK_TIME_LIMIT_SEC).toBe(60);+ expect(mathTask.score).toBe(100);+ });++ it("a non-benchmark session with the SAME task honors the user's configured timeLimitSec", async () => {+ readJSONFile.mockImplementation((path, defaultValue) => {+ const p = String(path);+ if (p.includes('post-config')) {+ return Promise.resolve({ mentalMath: { drillTypes: { 'doubling-chain': { timeLimitSec: 1 } } } });+ }+ return Promise.resolve(defaultValue);+ });+ const { benchmark: _benchmark, ...plainSubmission } = benchmarkSubmission({ mathResponseMs: 900 });+ const session = await submitPostSession(plainSubmission);+ const mathTask = session.tasks.find(t => t.type === 'doubling-chain');+ // Confirms the fixed-time-limit behavior above is benchmark-specific.+ expect(mathTask.score).toBe(82);+ });});// Structured session conditions (issue #4442) — sleepQuality/caffeine/stress