chore: remove debug logging from curriculum modules

Remove console.log statements added during production issue debugging.
The circular import issue causing REINFORCEMENT_CONFIG.creditMultipliers
to be undefined has been fixed. Retain console.error statements for
actual error conditions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-12-13 14:25:47 -06:00
parent aae53aa426
commit 818fdb438d
3 changed files with 18 additions and 99 deletions

View File

@@ -5,8 +5,6 @@
* fluency in a skill and how fluency decays over time.
*/
console.log('[fluency-thresholds.ts] MODULE LOADING...')
// =============================================================================
// Fluency Achievement Thresholds
// =============================================================================
@@ -100,5 +98,3 @@ export const REINFORCEMENT_CONFIG = {
export type FluencyThresholds = typeof FLUENCY_THRESHOLDS
export type FluencyRecency = typeof FLUENCY_RECENCY
export type ReinforcementConfig = typeof REINFORCEMENT_CONFIG
console.log('[fluency-thresholds.ts] MODULE LOADED - REINFORCEMENT_CONFIG:', JSON.stringify(REINFORCEMENT_CONFIG, null, 2))

View File

@@ -15,14 +15,6 @@ import {
// 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'
// Debug: Log the imported config at module load time
console.log('[progress-manager.ts] MODULE LOAD - REINFORCEMENT_CONFIG debug:', {
exists: typeof REINFORCEMENT_CONFIG !== 'undefined',
type: typeof REINFORCEMENT_CONFIG,
keys: REINFORCEMENT_CONFIG ? Object.keys(REINFORCEMENT_CONFIG) : 'N/A',
fullObject: JSON.stringify(REINFORCEMENT_CONFIG, null, 2),
})
import type { HelpLevel } from '@/db/schema/session-plans'
// ============================================================================
@@ -303,27 +295,11 @@ export async function recordSkillAttemptWithHelp(
helpLevel: HelpLevel,
responseTimeMs?: number
): Promise<PlayerSkillMastery> {
console.log(
`[recordSkillAttemptWithHelp] Starting: playerId=${playerId}, skillId=${skillId}, isCorrect=${isCorrect}, helpLevel=${helpLevel}, responseTimeMs=${responseTimeMs}`
)
let existing
try {
existing = await getSkillMastery(playerId, skillId)
console.log(`[recordSkillAttemptWithHelp] getSkillMastery returned: ${existing ? 'found' : 'null'}`)
} catch (e) {
console.error(`[recordSkillAttemptWithHelp] getSkillMastery FAILED:`, e)
throw e
}
const existing = await getSkillMastery(playerId, skillId)
const now = new Date()
// Calculate effective credit based on help level
console.log(
`[recordSkillAttemptWithHelp] REINFORCEMENT_CONFIG.creditMultipliers=${JSON.stringify(REINFORCEMENT_CONFIG?.creditMultipliers)}, helpLevel=${helpLevel}`
)
const creditMultiplier = REINFORCEMENT_CONFIG.creditMultipliers[helpLevel]
console.log(`[recordSkillAttemptWithHelp] creditMultiplier=${creditMultiplier}`)
// Determine if this help level triggers reinforcement tracking
const isHeavyHelp = helpLevel >= REINFORCEMENT_CONFIG.helpLevelThreshold
@@ -373,30 +349,22 @@ export async function recordSkillAttemptWithHelp(
? existing.responseTimeCount + 1
: existing.responseTimeCount
console.log(`[recordSkillAttemptWithHelp] Updating existing record id=${existing.id}`)
try {
await db
.update(schema.playerSkillMastery)
.set({
attempts: newAttempts,
correct: newCorrect,
consecutiveCorrect: newConsecutive,
lastPracticedAt: now,
updatedAt: now,
needsReinforcement,
lastHelpLevel: helpLevel,
reinforcementStreak,
totalResponseTimeMs: newTotalResponseTimeMs,
responseTimeCount: newResponseTimeCount,
})
.where(eq(schema.playerSkillMastery.id, existing.id))
console.log(`[recordSkillAttemptWithHelp] Update succeeded`)
} catch (e) {
console.error(`[recordSkillAttemptWithHelp] Update FAILED:`, e)
throw e
}
await db
.update(schema.playerSkillMastery)
.set({
attempts: newAttempts,
correct: newCorrect,
consecutiveCorrect: newConsecutive,
lastPracticedAt: now,
updatedAt: now,
needsReinforcement,
lastHelpLevel: helpLevel,
reinforcementStreak,
totalResponseTimeMs: newTotalResponseTimeMs,
responseTimeCount: newResponseTimeCount,
})
.where(eq(schema.playerSkillMastery.id, existing.id))
console.log(`[recordSkillAttemptWithHelp] Fetching updated record`)
return (await getSkillMastery(playerId, skillId))!
}
@@ -419,16 +387,8 @@ export async function recordSkillAttemptWithHelp(
responseTimeCount: hasResponseTime ? 1 : 0,
}
console.log(`[recordSkillAttemptWithHelp] Inserting new record for skillId=${skillId}`)
try {
await db.insert(schema.playerSkillMastery).values(newRecord)
console.log(`[recordSkillAttemptWithHelp] Insert succeeded`)
} catch (e) {
console.error(`[recordSkillAttemptWithHelp] Insert FAILED:`, e)
throw e
}
await db.insert(schema.playerSkillMastery).values(newRecord)
console.log(`[recordSkillAttemptWithHelp] Fetching new record`)
return (await getSkillMastery(playerId, skillId))!
}

View File

@@ -500,9 +500,6 @@ export async function recordSlotResult(
planId: string,
result: Omit<SlotResult, 'timestamp' | 'partNumber'>
): Promise<SessionPlan> {
// Log entry for debugging production issues
console.log(`[recordSlotResult] Starting for plan ${planId}`)
let plan: SessionPlan | null
try {
plan = await getSessionPlan(planId)
@@ -515,11 +512,6 @@ export async function recordSlotResult(
if (!plan) throw new Error(`Plan not found: ${planId}`)
// Log plan state for debugging
console.log(
`[recordSlotResult] Plan ${planId}: status=${plan.status}, partIndex=${plan.currentPartIndex}, slotIndex=${plan.currentSlotIndex}, parts=${plan.parts ? 'defined' : 'undefined'}, results=${plan.results ? `array(${plan.results.length})` : 'undefined'}`
)
// Defensive check: ensure parts array exists and is valid
if (!plan.parts || !Array.isArray(plan.parts)) {
throw new Error(
@@ -552,20 +544,14 @@ export async function recordSlotResult(
throw new Error(`Plan ${planId} has invalid results: ${typeof plan.results} (expected array)`)
}
console.log(`[recordSlotResult] Creating newResult for plan ${planId}`)
const newResult: SlotResult = {
...result,
partNumber: currentPart.partNumber,
timestamp: new Date(),
}
console.log(`[recordSlotResult] newResult created, spreading results array`)
const updatedResults = [...plan.results, newResult]
console.log(`[recordSlotResult] updatedResults length: ${updatedResults.length}`)
// Advance to next slot, possibly moving to next part
let nextPartIndex = plan.currentPartIndex
let nextSlotIndex = plan.currentSlotIndex + 1
@@ -579,27 +565,9 @@ export async function recordSlotResult(
// Check if the entire session is complete
const isComplete = nextPartIndex >= plan.parts.length
console.log(
`[recordSlotResult] Next indices: part=${nextPartIndex}, slot=${nextSlotIndex}, isComplete=${isComplete}`
)
// Calculate elapsed time since start
const elapsedMs = plan.startedAt ? Date.now() - plan.startedAt.getTime() : 0
console.log(`[recordSlotResult] Calling calculateSessionHealth, elapsedMs=${elapsedMs}`)
let updatedHealth
try {
updatedHealth = calculateSessionHealth({ ...plan, results: updatedResults }, elapsedMs)
console.log(
`[recordSlotResult] calculateSessionHealth succeeded: ${JSON.stringify(updatedHealth)}`
)
} catch (healthError) {
console.error(`[recordSlotResult] calculateSessionHealth FAILED:`, healthError)
throw healthError
}
console.log(`[recordSlotResult] Starting Drizzle update for plan ${planId}`)
const updatedHealth = calculateSessionHealth({ ...plan, results: updatedResults }, elapsedMs)
let dbResult
try {
@@ -615,7 +583,6 @@ export async function recordSlotResult(
})
.where(eq(schema.sessionPlans.id, planId))
.returning()
console.log(`[recordSlotResult] Drizzle update returned, result length: ${dbResult?.length}`)
} catch (dbError) {
console.error(`[recordSlotResult] Drizzle update FAILED:`, dbError)
throw dbError
@@ -630,8 +597,6 @@ export async function recordSlotResult(
)
}
console.log(`[recordSlotResult] Plan ${planId} updated successfully, recording skill attempts`)
// Update global skill mastery with response time data
// This builds the per-kid stats for identifying strengths/weaknesses
if (result.skillsExercised && result.skillsExercised.length > 0) {
@@ -646,14 +611,12 @@ export async function recordSlotResult(
result.helpLevelUsed,
result.responseTimeMs
)
console.log(`[recordSlotResult] Skill attempts recorded successfully`)
} catch (skillError) {
console.error(`[recordSlotResult] recordSkillAttemptsWithHelp FAILED:`, skillError)
throw skillError
}
}
console.log(`[recordSlotResult] Returning updated plan ${planId}`)
return updated
}