DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(mastery): persist v2 metadata for migrated topics
Bingxi Zhao (Frank)3f8644d6e982
diff --git a/deeptutor/learning/storage.py b/deeptutor/learning/storage.pyindex 856e8ff80..2f5e9c2e7 100644--- a/deeptutor/learning/storage.py+++ b/deeptutor/learning/storage.py@@ -447,6 +447,33 @@ class LearningStore:ON mastery_topic_sources(path_id, position);""")+ # V2 metadata is a persisted part of every topic, not a+ # runtime-only fallback. Existing V1 paths receive neutral,+ # deterministic metadata during schema initialization; their+ # learning state and session bindings remain untouched.+ legacy_topics = conn.execute(+ """+ SELECT path_id, created_at, updated_at+ FROM mastery_paths+ WHERE path_id NOT IN (SELECT path_id FROM mastery_topic_meta)+ """+ ).fetchall()+ for row in legacy_topics:+ path_id = str(row["path_id"])+ conn.execute(+ """+ INSERT INTO mastery_topic_meta (+ path_id, goal, description, emoji, map_seed, status,+ created_at, updated_at+ ) VALUES (?, '', '', '🧭', ?, 'active', ?, ?)+ """,+ (+ path_id,+ self._default_map_seed(path_id),+ float(row["created_at"]),+ float(row["updated_at"]),+ ),+ )conn.commit()self._initialized = True_initialized_db_paths.add(db_path)diff --git a/deeptutor/learning/tests/test_v2_migration.py b/deeptutor/learning/tests/test_v2_migration.pyindex 46fde37f0..9d016ccf3 100644--- a/deeptutor/learning/tests/test_v2_migration.py+++ b/deeptutor/learning/tests/test_v2_migration.py@@ -3,6 +3,7 @@ from __future__ import annotationsimport hashlibimport jsonfrom pathlib import Path+import sqlite3from deeptutor.learning.migration import prepare_mastery_v2_rootfrom deeptutor.learning.models import LearningProgress, MasteryInteraction, PendingQuestion@@ -70,6 +71,12 @@ def test_workspace_v1_is_archived_then_copied_into_v2_store(tmp_path: Path) -> Nassert migrated.load("topic-one").name == "Calculus"assert migrated.list_session_ids("topic-one") == ["session-one"]assert migrated.get_interaction("topic-one", "q-one") is not None+ migrated_topic = migrated.get_topic("topic-one")+ assert migrated_topic is not None+ assert migrated_topic.metadata.status == "active"+ assert migrated_topic.metadata.map_seed > 0+ with sqlite3.connect(migrated.db_path) as conn:+ assert conn.execute("SELECT COUNT(*) FROM mastery_topic_meta").fetchone()[0] == 1def test_v2_initialization_is_idempotent_and_never_reads_archive(tmp_path: Path) -> None: