Skip to content

feat: wrong-answer remediation loop - #115

Merged
willwearing merged 1 commit into
mainfrom
feat/wrong-answer-remediation-loop
Apr 12, 2026
Merged

feat: wrong-answer remediation loop#115
willwearing merged 1 commit into
mainfrom
feat/wrong-answer-remediation-loop

Conversation

@willwearing

Copy link
Copy Markdown
Owner

Summary

  • Slice 1 — KP-level "more practice" loop: On a wrong answer, the learner stays on the same KP and gets a new problem from the bank until 2 consecutive correct. Worked example re-surfaces verbatim on first miss per KP per session. Anti-gaming retry delay on 2+ attempts. Frontend lesson-flow.tsx rewritten from fixed practice list to stream-driven loop via nextProblemHint.
  • Slice 2 — Session-based lesson pause: After 6 failed KP attempts with unpassed KPs, the concept is paused for the rest of the session and re-surfaces as priority P3.5 next session. Math Academy reports 80% second-attempt pass rate without intervention (p.415).
  • Slice 3 — Key-prerequisite remediation + quiz follow-up: KPPlateauDetector fires on 4+ attempts across 2+ sessions when a key-prereq is authored, creating a P1 remediation. Quiz misses create immediate P1 remediation records. keyPrerequisiteConceptId added to KnowledgePoint schema (nullable during backfill). Quality gate warns on missing links.

Schema changes

3 migrations:

  • 20260411120000_add_lesson_pause_statepaused_at_session_id + session_failed_kp_attempts on student_concept_states
  • 20260411130000_add_kp_key_prerequisitekey_prerequisite_concept_id FK on knowledge_points
  • 20260411140000_add_kp_failed_session_trackingfirst_failed_session_id + last_failed_session_id on student_kp_states

All nullable/default-zero — no breaking changes to existing data.

New files

File Purpose
kp-remediation-selector.ts (+spec) Pure function: pick next problem during lesson practice loop
lesson-pause-policy.ts (+spec) Pure function: should we pause this lesson? Is it paused now?
kp-plateau-detector.ts (+spec) Pure function: has this KP plateaued across sessions?
remediation-core.module.ts Thin DI module to break Assessment <-> LearningEngine circular dep

Test plan

  • 25 new unit tests for the 3 pure functions (kp-remediation-selector, lesson-pause-policy, kp-plateau-detector)
  • 5 new tests in problem-submission.service.spec.ts for nextProblemHint behavior
  • 2 new tests in quiz.service.spec.ts for quiz-miss remediation
  • 3 new tests in task-selector.spec.ts for session-based pause behavior
  • 3 new tests in domain.test.ts for key_prerequisite_links quality gate warnings
  • All 613 backend tests pass
  • All 24 shared package tests pass
  • No type errors (backend + frontend)
  • E2E: learner misses a KP problem and is served another on the same KP
  • E2E: learner accumulates 6 session failures and concept is paused
  • Manual: verify worked-example panel re-opens on first miss, stays collapsed on subsequent misses

🤖 Generated with Claude Code

…e, key-prerequisite remediation

Implements the three-slice wrong-answer remediation loop from the Math
Academy Way doctrine:

Slice 1 — KP-level "more practice" loop:
- KPRemediationSelector pure function serves same-KP problems on miss
  until 2 consecutive correct before advancing
- Worked example re-surfaces on first miss per KP per session (verbatim,
  no generated rewording — FAQ p.416)
- Anti-gaming retry delay after 2+ attempts on the same KP
- Frontend lesson-flow.tsx rewritten for stream-driven practice via
  nextProblemHint from the backend

Slice 2 — Session-based lesson pause:
- LessonPausePolicy pauses concepts after 6 failed KP attempts with
  unpassed KPs remaining
- Paused concepts hidden for rest of session, re-surface as priority
  P3.5 in the next session (80% pass rate without intervention — p.415)
- Task selector respects pause state across all priority tiers

Slice 3 — Key-prerequisite remediation + quiz follow-up:
- KPPlateauDetector fires on 4+ attempts across 2+ sessions when a
  key-prereq is authored (slow peel-back anti-gaming — p.415-416)
- Quiz misses create immediate P1 remediation records (Ch 21 p.300)
- Schema: keyPrerequisiteConceptId on KnowledgePoint (nullable, backfill
  in progress), pausedAtSessionId + sessionFailedKPAttempts on
  StudentConceptState, firstFailedSessionId + lastFailedSessionId on
  StudentKPState
- Quality gate: graspful review warns on missing key-prereq links
- RemediationCoreModule breaks circular dependency between Assessment
  and LearningEngine modules

Docs: adaptive-learning-architecture.md updated with new wrong-answer
doctrine, all claims cite Math Academy Way page numbers.

All 613 backend tests pass. All 24 shared package tests pass. No type errors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Apr 12, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
graspful Building Building Preview, Comment Apr 12, 2026 2:01am

@willwearing
willwearing merged commit 835fc7c into main Apr 12, 2026
1 of 3 checks passed
@willwearing
willwearing deleted the feat/wrong-answer-remediation-loop branch April 12, 2026 02:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant