feat(scoring): heuristic difficulty tuner [STORY-018]#18
Merged
Conversation
Per-episode signal (`difficultySignal`) → next-difficulty step (`nextDifficulty`) + per-concept skill score updater (`updateSkillScore`) with EWMA + asymptotic confidence growth. All coefficients live in a Zod-schema'd config with sensible defaults — operators can pass partials per call. Sibling to `policies/difficulty-policy.ts` (which picks tiers from the multi-episode catalog EWMA); these new helpers handle the finer-grained per-episode decision. 20 unit tests cover perfect/hint-heavy/repeated-failure/overtime/ under-time/no-progress + capped-at-extremes + operator-stricter- threshold scenarios. Boundary cases use inclusive `>=`/`<=` thresholds so the default `correctness_bonus = step_up_threshold` boundary actually steps up. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
difficultySignal()(clamped overtime/hints/failures + correctness bonus →s ∈ [-1, +1]),nextDifficulty()(steps the catalog tier when|s|crosses the threshold),episodeSuccessScore()(penalty-floored success in[0, 1]),updateSkillScore()(EWMA on skill + asymptotic confidence growth) — all inpackages/scoring/src/difficulty.ts.DifficultyHeuristicConfigSchema(Zod) with sensible defaults exposed asDEFAULT_DIFFICULTY_HEURISTIC. No magic numbers in code paths.policies/difficulty-policy.ts(EloEwmaPolicypicks tiers from a multi-episode catalog EWMA); the new helpers are the per-episode complement.packages/scoring, not the spec'dpackages/profile(noprofilepackage exists;scoringis its sibling and already houses the catalog-tier policy).Story
Closes STORY-018.
Test plan
pnpm --filter @learnpro/scoring test→ 40 tests pass (20 new + 20 existing)pnpm formatcleanpnpm lintcleanpnpm typecheckcleanpnpm test→ 12 tasks, all green🤖 Generated with Claude Code