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: compound chain accepts the other half of a compound, not just full forms
Adam Eivy8dc9551c5713
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 2e42c5b9f6..0beb4ceba4 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -1,3 +1,4 @@## Fixed- **POST drill scoring paired every answer to the first prompt** — `llmResponseSchema` in `postValidation.js` didn't list `questionIndex`, so Zod's default strip mode dropped the field on its way to the scorer. The scorer's `r.questionIndex ?? i` fallback then resolved to the response-array index — always 0 for the single-response submits the trainer makes — and every answer was evaluated against the FIRST prompt of the drill. Affected bridge-word, idiom-twist, double-meaning, and every other LLM-scored POST drill (the v1.43.0 client-side fix wired up `questionIndex` on the request but it never reached the scorer). Schema now declares `questionIndex` and a regression test in `postValidation.test.js` covers the round-trip.+- **Compound chain rejected the natural shorthand** — typing just the *other half* of a compound (e.g., `hose`, `pit`, `work` for the root `fire`) was scored as invalid because the local scorer required the user's input to literally include the root word. Players had to type `firehose` / `firepit` / `firework` in full, which slowed them down and produced misleading "0 valid compounds" scores. Scorer now accepts both the full compound and the half — bare root word still rejected, and the "you could also have said" suggestions correctly suppress examples the user already covered via either form. UI placeholder updated to "Type the full compound or just the other half...".diff --git a/client/src/components/meatspace/post/WordplayDrillUI.jsx b/client/src/components/meatspace/post/WordplayDrillUI.jsxindex 3c93507d20..be0e2aa9c6 100644--- a/client/src/components/meatspace/post/WordplayDrillUI.jsx+++ b/client/src/components/meatspace/post/WordplayDrillUI.jsx@@ -110,7 +110,7 @@ export function CompoundChainUI({ challenge, items, inputValue, setInputValue, otype="text"value={inputValue}onChange={e => setInputValue(e.target.value)}- placeholder="Type a compound word and press Enter..."+ placeholder="Type the full compound or just the other half..."autoFocusclassName="flex-1 bg-port-bg border border-port-border rounded-lg px-4 py-2.5 text-white placeholder-gray-600 focus:border-port-accent focus:outline-none"/>diff --git a/server/services/meatspacePostLlm.js b/server/services/meatspacePostLlm.jsindex c39d37c67d..163295d6fe 100644--- a/server/services/meatspacePostLlm.js+++ b/server/services/meatspacePostLlm.js@@ -526,17 +526,34 @@ function scoreLocalCompoundChain(drillData, userResponses) {const challenge = drillData.challenges?.[r.questionIndex ?? i];if (!challenge?.rootWord) return { score: 0, feedback: 'No root word', validCount: 0, invalidItems: [], missedExamples: [] };const root = challenge.rootWord.toLowerCase();+ const norm = s => s.toLowerCase().replace(/[\s-]/g, '');const seen = new Set();const valid = [];const invalid = [];+ // The "covered" set is the canonical full-compound form for each accepted+ // item: typing "firehouse" or just "house" both contribute "firehouse" so+ // missedExamples can suppress duplicates regardless of how the user typed it.+ const coveredFull = new Set();for (const item of (r.items || [])) {- const lower = item.toLowerCase().replace(/[\s-]/g, '');- if (seen.has(lower)) continue;+ const lower = norm(item);+ if (!lower || seen.has(lower)) continue;seen.add(lower);- if (lower.includes(root) && lower !== root) {+ if (lower === root) {+ // Bare root word is not itself a compound — reject.+ invalid.push(item);+ continue;+ }+ if (lower.includes(root)) {+ // Full compound already containing the root (e.g., "firehouse", "campfire").valid.push(item);+ coveredFull.add(lower);} else {- invalid.push(item);+ // Half-compound shorthand: assume the user means root+item or item+root+ // (e.g., "hose" → firehose). We can't validate against a dictionary+ // without an LLM call, so accept it and let the user keep momentum.+ valid.push(item);+ coveredFull.add(root + lower);+ coveredFull.add(lower + root);}}const target = challenge.minExpected || 8;@@ -544,11 +561,16 @@ function scoreLocalCompoundChain(drillData, userResponses) {const fb = valid.length >= target? `${valid.length} valid compounds — great job!`: `${valid.length} valid compound${valid.length !== 1 ? 's' : ''} (target: ${target})`;- // Show examples the user didn't find- const validLower = new Set(valid.map(v => v.toLowerCase().replace(/[\s-]/g, '')));- const missedExamples = (challenge.examples || []).filter(ex =>- !validLower.has(ex.toLowerCase().replace(/[\s-]/g, ''))- );+ // Show examples the user didn't find — match against either full compound or+ // the half (with root stripped from front or back).+ const missedExamples = (challenge.examples || []).filter(ex => {+ const exNorm = norm(ex);+ if (coveredFull.has(exNorm)) return false;+ // Also match if user typed just the half that pairs with the example.+ if (exNorm.startsWith(root) && coveredFull.has(exNorm)) return false;+ if (exNorm.endsWith(root) && coveredFull.has(exNorm)) return false;+ return true;+ });return { score, feedback: fb, validCount: valid.length, invalidItems: invalid, missedExamples };});const overallScore = averageScore(scores);diff --git a/server/services/meatspacePostLlm.test.js b/server/services/meatspacePostLlm.test.jsindex 9ceaa31dec..3a5fa3c933 100644--- a/server/services/meatspacePostLlm.test.js+++ b/server/services/meatspacePostLlm.test.js@@ -389,6 +389,37 @@ describe('scoreLlmDrill', () => {expect(result.score).toBeGreaterThan(0);expect(result.evaluation.overallScore).toBe(67);});++ it('compound-chain accepts both full compounds and the other half', async () => {+ // User-typed shorthand: "hose" instead of "firehose", "pit" instead of "firepit".+ // Both should count as valid compound contributions.+ const result = await scoreLlmDrill(+ 'compound-chain',+ { challenges: [{ rootWord: 'fire', position: 'either', minExpected: 4, examples: ['firehose', 'firepit', 'firework', 'campfire'] }] },+ [{ items: ['hose', 'pit', 'work', 'campfire'], responseMs: 30000 }],+ 60000+ );++ expect(result.evaluation.scores[0].validCount).toBe(4);+ expect(result.evaluation.scores[0].invalidItems).toEqual([]);+ // Examples already covered (either as full compound or half) shouldn't be re-suggested.+ expect(result.evaluation.scores[0].missedExamples).not.toContain('firehose');+ expect(result.evaluation.scores[0].missedExamples).not.toContain('firepit');+ expect(result.evaluation.scores[0].missedExamples).not.toContain('firework');+ expect(result.evaluation.scores[0].missedExamples).not.toContain('campfire');+ });++ it('compound-chain rejects bare root word', () => {+ return scoreLlmDrill(+ 'compound-chain',+ { challenges: [{ rootWord: 'fire', position: 'either', minExpected: 2, examples: [] }] },+ [{ items: ['fire', 'firework'], responseMs: 10000 }],+ 60000+ ).then(result => {+ expect(result.evaluation.scores[0].validCount).toBe(1);+ expect(result.evaluation.scores[0].invalidItems).toContain('fire');+ });+ });});// =============================================================================