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

@@ -27,13 +27,13 @@ interview-ready after each short practice loop.
### Learner Memory
- [ ] **MEM-01**: System stores learner profile with role, stack, timeline, and
- [x] **MEM-01**: System stores learner profile with role, stack, timeline, and
preferences.
- [ ] **MEM-02**: System stores concept mastery states with evidence.
- [ ] **MEM-03**: System stores recurring misconceptions with supporting
- [x] **MEM-02**: System stores concept mastery states with evidence.
- [x] **MEM-03**: System stores recurring misconceptions with supporting
answers.
- [ ] **MEM-04**: System stores intervention history and review schedule.
- [ ] **MEM-05**: Temporary session context does not become durable memory
- [x] **MEM-04**: System stores intervention history and review schedule.
- [x] **MEM-05**: Temporary session context does not become durable memory
without evidence.
### Progression
@@ -96,7 +96,7 @@ interview-ready after each short practice loop.
|-------------|-------|--------|
| BACK-01..BACK-05 | Phase 1 | Complete |
| INT-01..INT-06 | Phase 2 | Complete |
| MEM-01..MEM-05 | Phase 3 | Pending |
| MEM-01..MEM-05 | Phase 3 | Complete |
| PROG-01..PROG-05 | Phase 4 | Pending |
| ONTO-01..ONTO-04 | Phase 5 | Pending |
| ASSET-01..ASSET-03 | Phase 6 | Pending |
@@ -108,4 +108,4 @@ interview-ready after each short practice loop.
---
*Requirements defined: 2026-04-26*
*Last updated: 2026-04-26 after Phase 2 execution.*
*Last updated: 2026-04-26 after Phase 3 execution.*

View File

@@ -7,7 +7,7 @@ See: `.planning/PROJECT.md` (updated 2026-04-26)
**Core value:** The user should feel and prove that they are becoming more
interview-ready after each short practice loop.
**Current focus:** Phase 3 planning: Learner Memory.
**Current focus:** Phase 4 planning: Progression.
## Current Decisions
@@ -24,14 +24,17 @@ interview-ready after each short practice loop.
- Phase 1 Go backend scaffold is implemented and verified.
- Phase 2 diagnostic interview loop is implemented and verified with in-memory
sessions.
- Phase 3 learner memory is implemented and verified with evidence-backed
in-memory profiles, mastery, misconceptions, interventions, and review
schedules.
## Next Actions
1. Plan Phase 3 learner memory with GSD.
1. Plan Phase 4 progression with GSD.
2. Keep `docs/planning/WORKFLOW_CONTRACTS.md` aligned with Go structs during
future workflow implementation.
3. Decide whether Phase 3 learner memory remains in-memory for MVP proof or
introduces a small persistence boundary.
3. Decide whether Phase 4 readiness map reads directly from learner memory or
introduces a derived progression projection.
## Validation Log
@@ -45,6 +48,9 @@ interview-ready after each short practice loop.
- 2026-04-26: Phase 2 implementation verified with `go test ./...`, live
`/healthz` smoke, live diagnostic create/answer/get smoke, OpenSpec, and Go
source line-count check.
- 2026-04-26: Phase 3 implementation verified with `go test ./...`,
`openspec validate bootstrap-job-tutor-platform --strict`, live diagnostic
answer to learner-memory smoke, and Go source line-count check.
---
*State initialized: 2026-04-26.*

View File

@@ -0,0 +1,79 @@
# Phase 3: Learner Memory - Context
**Gathered:** 2026-04-26
**Status:** Ready for planning
**Source:** GSD continuation after Phase 2 completion
<domain>
## Phase Boundary
Phase 3 converts graded answer evidence into structured learner memory. It
should build the memory boundary needed by later progression work while keeping
storage in-memory for now.
</domain>
<decisions>
## Implementation Decisions
### Persistence
- Use in-memory learner memory storage in Phase 3.
- Do not introduce a database until the product loop needs durability across
restarts.
- Preserve a clear store interface so persistent storage can replace it later.
### Memory Model
- Store learner profile.
- Store concept mastery with evidence.
- Store misconception records linked to answer evidence.
- Store intervention history and review schedule placeholders.
- Do not promote temporary session context unless workflow output includes
evidence.
### Integration
- Diagnostic answer submission should invoke memory extraction after typed
grading.
- The workflow runner should emit `MemoryUpdateCandidate` values.
- Memory service should apply only updates with evidence.
</decisions>
<canonical_refs>
## Canonical References
- `docs/planning/PRD.md` - learner memory product goals.
- `docs/planning/ARCHITECTURE.md` - memory strategy.
- `docs/planning/WORKFLOW_CONTRACTS.md` - memory update contract.
- `.planning/REQUIREMENTS.md` - MEM-01 through MEM-05.
- `.planning/ROADMAP.md` - Phase 3 success criteria.
- `openspec/changes/bootstrap-job-tutor-platform/specs/learner-memory/spec.md`
- learner memory requirements.
</canonical_refs>
<specifics>
## Specific Ideas
- Add `internal/learnermemory`.
- Add `GET /api/v1/learners/{userID}/memory`.
- Wire diagnostic answer submission to memory ingestion.
- Keep memory extraction deterministic in the workflow stub.
</specifics>
<deferred>
## Deferred Ideas
- Database persistence.
- Cross-session ranking/decay.
- UI readiness map.
- Spaced repetition scheduling details.
</deferred>
---
*Phase: 003-learner-memory*
*Context gathered: 2026-04-26*

View File

@@ -0,0 +1,58 @@
# Phase 3 Plan: Learner Memory
**Status:** Ready for execution
**Phase Goal:** Convert graded answer evidence into structured learner memory.
## Requirements Covered
- MEM-01: System stores learner profile with role, stack, timeline, and
preferences.
- MEM-02: System stores concept mastery states with evidence.
- MEM-03: System stores recurring misconceptions with supporting answers.
- MEM-04: System stores intervention history and review schedule.
- MEM-05: Temporary session context does not become durable memory without
evidence.
## Tasks
### 1. Add learner memory package
- Create `internal/learnermemory`.
- Define profile, concept mastery, misconception, intervention, review schedule,
and snapshot types.
- Add in-memory store with clear interface.
### 2. Add memory extraction workflow output
- Extend `workflows.StubRunner.ExtractLearningMemory` to return evidenced
memory update candidates from a graded answer.
- Ensure candidates without evidence are not applied.
### 3. Wire diagnostic answers to memory
- Inject learner memory service into interview service.
- After grading an answer, extract and apply memory updates.
- Keep diagnostic session records and learner memory records separate.
### 4. Add memory read endpoint
- Add `GET /api/v1/learners/{userID}/memory`.
- Return learner profile, mastery, misconceptions, interventions, and review
schedule.
### 5. Add tests and verification
- Test memory applies only evidenced updates.
- Test diagnostic answer submission updates learner memory.
- Test memory HTTP read endpoint.
- Run Go tests, OpenSpec validation, and line-count check.
## Out of Scope
- Persistent database.
- Memory ranking/decay.
- Progression readiness map.
- Frontend UI.
---
*Plan created: 2026-04-26*

View File

@@ -0,0 +1,33 @@
# Phase 3 Research
## Question
How should learner memory be added without turning the diagnostic session store
into durable product truth?
## Findings
### Keep memory separate from interview sessions
Diagnostic sessions contain raw interaction records. Learner memory should be a
separate derived state built from graded evidence. This preserves the boundary
between temporary/session context and durable learning claims.
### Apply only evidenced updates
The memory service should ignore update candidates that do not include evidence.
This directly enforces the OpenSpec rule that inferred memory requires evidence.
### In-memory is still enough
The current product does not yet need restart durability. A store interface plus
tests gives the shape of persistence without adding database complexity early.
## Recommendation
1. Add `internal/learnermemory` with profile, mastery, misconception,
intervention, and review schedule records.
2. Extend workflow runner memory extraction to return evidenced candidates.
3. Wire diagnostic answer submission to memory ingestion.
4. Add HTTP read endpoint for learner memory snapshot.
5. Verify with tests and live smoke.

View File

@@ -0,0 +1,36 @@
# Phase 3 Summary
**Status:** Complete
**Completed:** 2026-04-26
## Delivered
- Added `internal/learnermemory` for profile, concept mastery,
misconceptions, interventions, review schedule, and snapshots.
- Added in-memory learner memory store and service.
- Extended `GradedAnswer` with `user_id`.
- Implemented `ExtractLearningMemory` in the workflow stub.
- Wired diagnostic answer submission to memory extraction and evidence-backed
memory application.
- Added `GET /api/v1/learners/{userID}/memory`.
- Added unit and HTTP tests for memory application and readback.
## Verification
```powershell
gofmt -w cmd internal
go test ./...
openspec validate bootstrap-job-tutor-platform --strict
```
Additional smoke check:
- Diagnostic create/answer followed by learner memory read returned 1 mastery
entry for `user-1`.
## Deferred
- Durable database persistence.
- Memory decay and ranking.
- Repeated-mistake clustering beyond the current evidenced candidate writes.
- Progression readiness map UI/API.

View File

@@ -0,0 +1,27 @@
# Phase 3 Verification
## Verdict
PASS
## Requirement Coverage
- MEM-01: PASS. Diagnostic session creation ensures a learner profile with
target role, stack, and timeline.
- MEM-02: PASS. Graded answer evidence creates concept mastery entries.
- MEM-03: PASS. Weak or partial answers create evidenced misconception entries.
- MEM-04: PASS. Weak or partial answers create intervention history and review
schedule entries.
- MEM-05: PASS. Memory service ignores update candidates without evidence.
## Evidence
- `go test ./...` passed.
- `openspec validate bootstrap-job-tutor-platform --strict` passed.
- Live diagnostic create/answer plus learner memory read smoke passed.
- Go source line-count check passed.
## Residual Risk
Learner memory is intentionally in-memory for the MVP proof. Data is lost on
process restart until a persistence phase is planned.