fix(8139): a shape the agent walked past at the end-of-turn check is named again in its next notes

The after phase answers `left`, the asked lines still unjudged; the Stop hook
carries them as `earlier=` into the next checks, each up to two more asks, and
the note names them apart from the last turn's writes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 09:41:09 -05:00
co-authored by Claude Opus 5.5
parent 69f3adae2c
commit 55f53de92d
7 changed files with 260 additions and 40 deletions
+34
View File
@@ -91,3 +91,37 @@ def test_the_window_counts_turns_asks_and_asks_walked_past():
# A window that spans the end-of-turn hold this check once was still sums.
mixed = summarise(["blocked", "left_after_block", "noted", "judged_after_note"])
assert mixed == {"checked": 2, "asked": 2, "left": 1}
def test_the_note_names_walked_past_shapes_apart_from_this_turns():
from grimoire.services.shape_check import note_text
fresh = [{"path": "a.py", "kind": "sym", "symbol": "new_one", "status": "new", "evidence": {}}]
old = [{"path": "b.py", "kind": "sym", "symbol": "old_one", "status": "unclassified",
"evidence": {}}]
both = note_text(fresh, project_id=2, repo="", earlier=old)
assert "last turn wrote 1 definition " in both
assert "Also: 1 definition you wrote earlier in this session is still unjudged" in both
assert both.index("a.py · new_one") < both.index("b.py · old_one")
alone = note_text([], project_id=2, repo="", earlier=old + old)
assert "last turn" not in alone
assert alone.startswith("2 definitions you wrote earlier in this session are still unjudged")
assert "classify_shapes(project_id=2" in alone
def test_the_after_phase_hands_back_ledger_lines():
from grimoire.services.shape_check import ledger_lines
items = [{"path": "a.py", "kind": "sym", "symbol": "f"},
{"path": "w/A.svelte", "kind": "file", "symbol": "A"}]
assert ledger_lines(items) == "a.py\tsym\tf\nw/A.svelte\tfile\tA"
assert ledger_lines([]) == ""
async def test_a_repeat_is_counted_apart_in_the_outcome_record():
from grimoire.services.shape_check import record_shape_check
session = make_mock_session()
with patch("grimoire.services.shape_check.async_session", return_value=session):
await record_shape_check(7, "noted", written=3, unjudged=2, project_id=2, earlier=1)
assert json.loads(session.add.call_args.args[0].details)["earlier"] == 1