fix(7883): a lesson recorded for reply.report reaches the turn before the reply, and reply.ask is not offered to a lesson
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / integration (push) Successful in 2m0s
CI & Build / Python tests (push) Successful in 3m48s
CI & Build / Build & push image (push) Successful in 20s
CI & Build / Python lint (push) Successful in 2s
CI & Build / Plugin hooks (push) Successful in 13s
CI & Build / TypeScript typecheck (push) Successful in 32s
CI & Build / integration (push) Successful in 2m0s
CI & Build / Python tests (push) Successful in 3m48s
CI & Build / Build & push image (push) Successful in 20s
Situated lessons arrived only at tool acts and in MCP replies, so a lesson given a reply moment was accepted and never shown. The per-turn delivery now carries lessons confirmed on reply.report, once per session, between the turn's rules and its reply shape. reply.ask is known only after the reply is written, so lesson_situations refuses it and leaves it out of the catalog the pass and the lesson page offer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""A situated lesson reaches the work through the moment doors: the plugin's
|
||||
door shows it once per session, and an MCP reply, which has no session,
|
||||
carries it every time its act happens."""
|
||||
act door and the turn's delivery before a reply show it once per session,
|
||||
and an MCP reply, which has no session, carries it every time its act
|
||||
happens. A moment no door reaches is not offered to a lesson."""
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
@@ -41,6 +42,41 @@ async def test_an_mcp_reply_carries_the_lessons_for_its_act_every_time():
|
||||
ledger.assert_not_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_turn_carries_the_lessons_recorded_for_the_reply_before_it_is_written():
|
||||
found = AsyncMock(return_value=ARRIVALS[:1])
|
||||
with patch.object(moment_delivery, "deliver_moments", AsyncMock(return_value=rp.RuleResult())), \
|
||||
patch.object(lesson_situations, "for_act", found), \
|
||||
patch("grimoire.services.record_deliveries.delivered_this_session",
|
||||
AsyncMock(return_value=set())):
|
||||
out = await moment_delivery.deliver_for_turn(1, record=False)
|
||||
assert found.await_args.args[1] == ["reply.report"]
|
||||
assert out["lesson_ids"] == [41]
|
||||
assert [p.block for p in out["lesson_parts"]] == ["lessons"]
|
||||
assert lesson_situations.line(ARRIVALS[0]) in out["context"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_a_turn_leaves_out_a_reply_lesson_the_session_already_has():
|
||||
with patch.object(moment_delivery, "deliver_moments", AsyncMock(return_value=rp.RuleResult())), \
|
||||
patch.object(lesson_situations, "for_act", AsyncMock(return_value=ARRIVALS[:1])), \
|
||||
patch("grimoire.services.record_deliveries.delivered_this_session",
|
||||
AsyncMock(return_value={41})):
|
||||
out = await moment_delivery.deliver_for_turn(1, record=False)
|
||||
assert out["lesson_ids"] == [] and out["lesson_parts"] == []
|
||||
|
||||
|
||||
def test_a_lesson_is_offered_only_the_moments_a_door_brings_it_to():
|
||||
offered = {m["name"] for m in lesson_situations.lesson_moments()}
|
||||
assert "reply.report" in offered and "work.deliver" in offered
|
||||
assert offered.isdisjoint(lesson_situations.NO_LESSON_DOOR)
|
||||
# Whether a reply asks is known only after it is written: refused, with
|
||||
# the moment that does arrive in time named in the reason.
|
||||
with pytest.raises(ValueError, match="reply.report"):
|
||||
lesson_situations._values(["reply.ask"], [])
|
||||
assert lesson_situations._values(["reply.report"], []) == [("moment", "reply.report")]
|
||||
|
||||
|
||||
def test_a_situation_reads_as_what_the_act_carries():
|
||||
assert lesson_situations.describe("moment", "work.finish") == "moment `work.finish`"
|
||||
assert lesson_situations.describe("trigger", "path\tmigrations/**\t") == "path `migrations/**`"
|
||||
|
||||
Reference in New Issue
Block a user