fix(7836): lesson situations travel in backups, and the edit door test states the new intent
CI & Build / TypeScript typecheck (push) Successful in 35s
CI & Build / Plugin hooks (push) Successful in 12s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Python tests (push) Successful in 2m5s
CI & Build / integration (push) Successful in 2m12s
CI & Build / Build & push image (push) Successful in 33s

- backup v31 carries lesson_situations (full and per-user export, restored
  through the note map);
- the lesson surfacing test now pins that the edit door's search leaves
  lessons to their situation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 06:18:45 -05:00
co-authored by Claude Opus 5.5
parent c22e8e1844
commit 5bde619511
3 changed files with 69 additions and 11 deletions
+6 -8
View File
@@ -84,11 +84,11 @@ async def test_the_prompt_menu_looks_beyond_the_bound_project_for_a_lesson():
@pytest.mark.asyncio
async def test_the_write_path_asks_for_lessons_at_all():
"""The founding example of the kind is a lesson about a code shape, and
this is the arm that fires when code is written. It is also the one note
arm that filters kinds — so an omission here is not a ranking loss, it is
a kind that can never appear."""
async def test_the_write_path_leaves_lessons_to_their_situation():
"""An edit's words resemble a lesson far more often than the edit is its
situation, so the edit door's search by meaning leaves lessons out; a
lesson reaches an edit through a situation confirmed for it
(`lesson_situations`). The kinds the door does consider stay."""
search = AsyncMock(return_value=[])
with patch.object(pc, "get_writepath_config",
AsyncMock(return_value=writepath_cfg(threshold=0.6))), \
@@ -101,9 +101,7 @@ async def test_the_write_path_asks_for_lessons_at_all():
await pc.build_write_path_hint(1, "src/ui/Badge.vue", code="x" * 400)
kw = search.await_args.kwargs
assert LESSON_NOTE_TYPE in kw["record_kinds"]
# The kinds it already carried must survive the addition — a set rewritten
# rather than extended would trade one unreachable kind for another.
assert LESSON_NOTE_TYPE not in kw["record_kinds"]
assert {"snippet", "note"} <= set(kw["record_kinds"])
assert kw["include_global_kinds"] is True
+6 -1
View File
@@ -22,7 +22,7 @@ def test_backup_version_is_current():
"""The bump is the point of the test — a payload section added without
moving the version produces backups that are structurally different and
indistinguishable by inspection."""
assert backup.BACKUP_VERSION == 30
assert backup.BACKUP_VERSION == 31
def _exportable_note(**over):
@@ -141,6 +141,7 @@ def _column_guard_targets():
)
from grimoire.models.code_shape import CodeShape, CodeShapeEvent, CodeShapeUse
from grimoire.models.lesson_rule_link import LessonNoRule, LessonRuleLink
from grimoire.models.lesson_situation import LessonSituation
from grimoire.models.rule_moment_judgment import RuleMomentJudgment
from grimoire.models.rule_field_judgment import RuleFieldJudgment
from grimoire.models.design_system import DesignSystem, DesignToken
@@ -183,6 +184,7 @@ def _column_guard_targets():
"rule_relations": (RuleRelation, backup._rule_relation_rows),
"lesson_rule_links": (LessonRuleLink, backup._lesson_rule_link_rows),
"lesson_no_rule": (LessonNoRule, backup._lesson_no_rule_rows),
"lesson_situations": (LessonSituation, backup._lesson_situation_rows),
"rule_moment_judgments": (RuleMomentJudgment, backup._rule_moment_judgment_rows),
"rule_field_judgments": (RuleFieldJudgment, backup._rule_field_judgment_rows),
"note_usage_events": (NoteUsageEvent, backup._usage_event_rows),
@@ -315,6 +317,7 @@ def _import_guard_targets():
"rule_relations": backup._build_rule_relation,
"lesson_rule_links": backup._build_lesson_rule_link,
"lesson_no_rule": backup._build_lesson_no_rule,
"lesson_situations": backup._build_lesson_situation,
"rule_moment_judgments": backup._build_rule_moment_judgment,
"rule_field_judgments": backup._build_rule_field_judgment,
"note_usage_events": backup._build_usage_event,
@@ -595,6 +598,8 @@ async def test_export_full_backup_contains_every_declared_section():
"rule_triggers",
# v30: the weighed enforcement, salience and triggers.
"rule_field_judgments",
# v31: the moments and triggers each lesson arrives at.
"lesson_situations",
# v25: family canon.
"platforms", "project_platforms", "family_ideas",
"family_idea_platforms", "family_idea_references",