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:
@@ -237,3 +237,61 @@ def test_an_unreachable_instance_keeps_the_question_for_later(tmp_path):
|
||||
ledger = _write_ledger(tmp_path, ["a.py\tsym\thelper"])
|
||||
assert _stop(env, _repo(tmp_path)) == ""
|
||||
assert ledger.exists()
|
||||
|
||||
|
||||
# ── what the agent walked past is asked again, a bounded number of times ──
|
||||
|
||||
def _earlier_file(tmp_path, session="s1"):
|
||||
return tmp_path / "grimoire-shapecheck" / f"{session}.earlier"
|
||||
|
||||
|
||||
def test_a_walked_past_shape_is_named_again_then_dropped(tmp_path):
|
||||
"""The after phase's `left` becomes the carried set: the next check sends
|
||||
it as `earlier` even on a turn that wrote nothing, and a shape walked
|
||||
past more than GRIMOIRE_EARLIER_MAX times stops being asked."""
|
||||
reply = json.dumps({"status": "ok", "outcome": "noted", "note": NOTE,
|
||||
"left": "a.py\tsym\tfirst"}).encode()
|
||||
with http_sink(reply) as (port, seen):
|
||||
env = _env(tmp_path, f"http://127.0.0.1:{port}")
|
||||
repo = _repo(tmp_path)
|
||||
_write_ledger(tmp_path, ["a.py\tsym\tfirst"])
|
||||
_stop(env, repo)
|
||||
assert seen[-1]["phase"] == ["check"] and "earlier" not in seen[-1]
|
||||
|
||||
for walked_past in (1, 2):
|
||||
_prompt(env, repo)
|
||||
_stop(env, repo)
|
||||
after, check = seen[-2], seen[-1]
|
||||
assert after["phase"] == ["after"]
|
||||
assert check["phase"] == ["check"]
|
||||
assert check["earlier"] == ["a.py\tsym\tfirst"]
|
||||
assert "written" not in check, "this turn wrote nothing; the repeat is named apart"
|
||||
assert _earlier_file(tmp_path).read_text() == f"{walked_past}\ta.py\tsym\tfirst\n"
|
||||
|
||||
_prompt(env, repo)
|
||||
_stop(env, repo)
|
||||
assert seen[-1]["phase"] == ["after"], "walked past a third time: not asked again"
|
||||
assert seen[-1]["earlier"] == ["a.py\tsym\tfirst"]
|
||||
assert not _earlier_file(tmp_path).exists()
|
||||
|
||||
|
||||
def test_a_carried_shape_this_turn_rewrote_is_this_turns(tmp_path):
|
||||
reply = json.dumps({"status": "ok", "outcome": "noted", "note": NOTE}).encode()
|
||||
with http_sink(reply) as (port, seen):
|
||||
env = _env(tmp_path, f"http://127.0.0.1:{port}")
|
||||
_earlier_file(tmp_path).parent.mkdir(parents=True, exist_ok=True)
|
||||
_earlier_file(tmp_path).write_text("1\ta.py\tsym\tfirst\n1\tb.py\tsym\tother\n")
|
||||
_write_ledger(tmp_path, ["a.py\tsym\tfirst"])
|
||||
_stop(env, _repo(tmp_path))
|
||||
assert seen[-1]["written"] == ["a.py\tsym\tfirst"]
|
||||
assert seen[-1]["earlier"] == ["b.py\tsym\tother"]
|
||||
|
||||
|
||||
def test_a_check_with_nothing_unjudged_forgets_the_carried_set(tmp_path):
|
||||
with http_sink(b'{"status":"ok","outcome":"passed","unjudged":[]}') as (port, seen):
|
||||
env = _env(tmp_path, f"http://127.0.0.1:{port}")
|
||||
_earlier_file(tmp_path).parent.mkdir(parents=True, exist_ok=True)
|
||||
_earlier_file(tmp_path).write_text("1\ta.py\tsym\tfirst\n")
|
||||
_stop(env, _repo(tmp_path))
|
||||
assert seen[-1]["earlier"] == ["a.py\tsym\tfirst"]
|
||||
assert not _earlier_file(tmp_path).exists(), "judged since: nothing left to carry"
|
||||
|
||||
Reference in New Issue
Block a user