feat(7836): a lesson arrives at the situation confirmed for it, once per session
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / Python lint (push) Successful in 2s
CI & Build / TypeScript typecheck (push) Successful in 33s
CI & Build / Python tests (push) Failing after 1m41s
CI & Build / integration (push) Successful in 2m8s
CI & Build / Build & push image (push) Skipped

Each lesson can carry its situation: a moment of work (work.deliver,
work.finish, ...) or a typed trigger on the act (path, command, tool,
keyword, matched as rule triggers are). A pass proposes, a person judges:

- lesson_situations (migration 0137): one row per lesson, kind and value,
  suggested / confirmed / rejected; `none` records that no situation fits;
- MCP: lessons_to_situate, propose_lesson_situations,
  lesson_situation_proposals, judge_lesson_situations;
- Settings > Moments lists waiting proposals with Apply / Not this /
  Apply all; a lesson page lists its situations and lets a writer add one
  or take one off (kept as rejected, never proposed again).

Delivery: the moment doors (the plugin catch-all hook and MCP replies) add
the lessons whose confirmed moment the act reached or whose trigger it
matches. The plugin door shows each once per session, using the record
ledger, and records it as pushed (source lesson_situation); the tool filter
now includes the tools a lesson trigger listens on.

The edit door no longer finds lessons by meaning: lesson leaves the
work.change default kinds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-25 06:10:23 -05:00
co-authored by Claude Opus 5.5
parent ff3fca6a94
commit c22e8e1844
24 changed files with 1506 additions and 8 deletions
+19
View File
@@ -425,3 +425,22 @@ def _ungated_doors(request):
with patch.object(plugin_context, "_gate_for", AsyncMock(return_value=None)), \
patch.object(plugin_context, "_routed_for", AsyncMock(return_value=frozenset())):
yield
@pytest.fixture(autouse=True)
def _no_lesson_situations(request):
"""Stub the lesson-situation lookups (`lesson_situations`) to find none.
Every moment door asks which lessons are recorded for the act, and the
plugin's tool filter asks which tools a lesson listens on; a unit test of
those doors has written no lessons. A test about situated lessons patches
its own answer. The integration lane runs the real queries.
"""
if request.node.get_closest_marker("integration"):
yield
return
from grimoire.services import lesson_situations
with patch.object(lesson_situations, "for_act", AsyncMock(return_value=[])), \
patch.object(lesson_situations, "reachable", AsyncMock(return_value=(set(), set()))):
yield