diff --git a/tests/integration/test_conflict_resolver_ch.py b/tests/integration/test_conflict_resolver_ch.py index 8be366cf3c5..ce70f2fbb17 100644 --- a/tests/integration/test_conflict_resolver_ch.py +++ b/tests/integration/test_conflict_resolver_ch.py @@ -3139,10 +3139,14 @@ async def clear(**kw: Any) -> ConflictResult: assert rows["office_location"]["superseded_by"] == rows["office_city"]["id"] -async def test_an_attest_of_a_retired_row_keeps_its_first_assertion(ch, wired, monkeypatch) -> None: - """Paris retired by Rome, Berlin written; a person attests the retired Paris row (a - copy, still retired), then undoes it. Paris was stated before Berlin, and Berlin's - update retires it.""" +@pytest.mark.parametrize( + "attest_successor", [True, False], ids=["equal-standing", "lower-standing"] +) +async def test_an_attest_of_a_retired_row_keeps_its_first_assertion( + ch, wired, monkeypatch, attest_successor: bool +) -> None: + """The restored Paris row predates Berlin even when attested later. Berlin retires + Paris at equal standing and flags it at lower standing.""" from server.memory.api.models_crud import MemoryVerifyInput from server.memory.app import after_write, conflicts from server.memory.app.verify import handle_memory_verify @@ -3162,6 +3166,18 @@ async def clear(**kw: Any) -> ConflictResult: await _set(org, "s3", "office_site", "The office is in Berlin") await after_write.drain() await _place(ch, org, "s3", "office_site", _vec((2140, 0.9), (2142, 0.436)), owed=False) + if attest_successor: + await handle_memory_verify( + MemoryVerifyInput( + org=org, + namespace=NS, + agent="bot", + user_id=USER, + session_id="s3", + memory_key="office_site", + actor="human:alice", + ) + ) await _later() await handle_memory_verify( MemoryVerifyInput( @@ -3181,7 +3197,13 @@ async def clear(**kw: Any) -> ConflictResult: monkeypatch.setitem(_SCRIPT, "office_site", ("update", 0.98)) out = await run_pass() rows = await _rows(ch, org) - assert rows["office_city"]["superseded_by"] == rows["office_site"]["id"], out + paris, berlin = rows["office_city"], rows["office_site"] + if attest_successor: + assert paris["superseded_by"] == berlin["id"], out + else: + assert paris["status"] == berlin["status"] == "conflicted", out + assert paris["superseded_by"] == "" + assert berlin["id"] in {str(peer) for peer in paris["conflict_with"]} async def test_an_undo_whose_insert_answer_was_lost_finishes(ch, wired, monkeypatch) -> None: