From 147974a9f05ab6e46e0a21649be3bc1b226ab3e2 Mon Sep 17 00:00:00 2001 From: Thomas Hallock Date: Sat, 13 Dec 2025 10:08:07 -0600 Subject: [PATCH] fix(practice): fix circular import causing REINFORCEMENT_CONFIG.creditMultipliers to be undefined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The issue was that progress-manager.ts was importing REINFORCEMENT_CONFIG from @/db/schema/player-skill-mastery, which re-exported it from @/lib/curriculum/config. This created a circular dependency that caused the config object's creditMultipliers property to be undefined in production. Root cause found via logging: ``` REINFORCEMENT_CONFIG.creditMultipliers=undefined, helpLevel=0 ``` Fix: - Import REINFORCEMENT_CONFIG directly from @/lib/curriculum/config/fluency-thresholds - Remove unused re-export from player-skill-mastery.ts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- apps/web/src/db/schema/player-skill-mastery.ts | 6 +----- apps/web/src/lib/curriculum/progress-manager.ts | 3 ++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/apps/web/src/db/schema/player-skill-mastery.ts b/apps/web/src/db/schema/player-skill-mastery.ts index 27e1b0c1..1d8cc2f6 100644 --- a/apps/web/src/db/schema/player-skill-mastery.ts +++ b/apps/web/src/db/schema/player-skill-mastery.ts @@ -1,12 +1,9 @@ import { createId } from '@paralleldrive/cuid2' import { index, integer, sqliteTable, text, uniqueIndex } from 'drizzle-orm/sqlite-core' // Import tunable constants from centralized config -import { FLUENCY_RECENCY, FLUENCY_THRESHOLDS, REINFORCEMENT_CONFIG } from '@/lib/curriculum/config' +import { FLUENCY_RECENCY, FLUENCY_THRESHOLDS } from '@/lib/curriculum/config' import { players } from './players' -// Re-export for backwards compatibility -export { REINFORCEMENT_CONFIG } - /** * Fluency state - computed from practice history, NOT stored in database * - practicing: isPracticing=true but hasn't achieved fluency criteria yet @@ -144,7 +141,6 @@ export const FLUENCY_CONFIG = { ...FLUENCY_RECENCY, } as const -// REINFORCEMENT_CONFIG imported from @/lib/curriculum/config and re-exported above /** * Check if a student has achieved fluency in a skill based on their practice history. diff --git a/apps/web/src/lib/curriculum/progress-manager.ts b/apps/web/src/lib/curriculum/progress-manager.ts index 788a40f9..64666a4f 100644 --- a/apps/web/src/lib/curriculum/progress-manager.ts +++ b/apps/web/src/lib/curriculum/progress-manager.ts @@ -11,8 +11,9 @@ import { type FluencyState, type NewPlayerSkillMastery, type PlayerSkillMastery, - REINFORCEMENT_CONFIG, } from '@/db/schema/player-skill-mastery' +// Import directly from source to avoid circular dependency issues with re-exports +import { REINFORCEMENT_CONFIG } from '@/lib/curriculum/config/fluency-thresholds' import type { NewPracticeSession, PracticeSession } from '@/db/schema/practice-sessions' import type { HelpLevel } from '@/db/schema/session-plans'