feat: add learner memory ingestion

This commit is contained in:
user
2026-04-26 16:34:52 +09:00
parent 4a4240fea2
commit 600acf7303
23 changed files with 931 additions and 24 deletions

View File

@@ -24,6 +24,7 @@ func TestStubRunnerGradesAnswer(t *testing.T) {
runner := NewStubRunner()
grade, err := runner.GradeInterviewAnswer(context.Background(), GradeAnswerInput{
UserID: "user-1",
QuestionID: "q-1",
AnswerID: "a-1",
AnswerText: "Indexes can speed reads by helping the database find rows, but they add write overhead.",
@@ -37,6 +38,9 @@ func TestStubRunnerGradesAnswer(t *testing.T) {
if grade.AnswerID != "a-1" {
t.Fatalf("AnswerID = %q", grade.AnswerID)
}
if grade.UserID != "user-1" {
t.Fatalf("UserID = %q", grade.UserID)
}
if len(grade.Concepts) != 1 {
t.Fatalf("concepts = %d, want 1", len(grade.Concepts))
}
@@ -44,3 +48,40 @@ func TestStubRunnerGradesAnswer(t *testing.T) {
t.Fatalf("evidence = %d, want 1", len(grade.Evidence))
}
}
func TestStubRunnerExtractsLearningMemory(t *testing.T) {
runner := NewStubRunner()
grade := GradedAnswer{
UserID: "user-1",
AnswerID: "a-1",
QuestionID: "q-1",
Concepts: []ConceptRef{
{ID: "cache-invalidation", Label: "Cache invalidation", Track: "backend-developer"},
},
Overall: AnswerPartial,
Evidence: []EvidenceRef{
{Kind: EvidenceAnswer, ID: "a-1", Confidence: 1},
},
FollowUp: FollowUpRecommendation{
Needed: true,
Question: "Can you explain the tradeoff?",
Purpose: FollowUpRepair,
},
}
candidate, err := runner.ExtractLearningMemory(context.Background(), grade)
if err != nil {
t.Fatalf("ExtractLearningMemory error: %v", err)
}
if candidate.UserID != "user-1" {
t.Fatalf("UserID = %q", candidate.UserID)
}
if len(candidate.Updates) != 4 {
t.Fatalf("updates = %d, want 4", len(candidate.Updates))
}
for _, update := range candidate.Updates {
if len(update.Evidence) == 0 {
t.Fatal("expected every memory update to carry evidence")
}
}
}