diff --git a/tests/agent/test_learning_mutations.py b/tests/agent/test_learning_mutations.py index 79afa4d1379..dc2f562d02f 100644 --- a/tests/agent/test_learning_mutations.py +++ b/tests/agent/test_learning_mutations.py @@ -112,3 +112,17 @@ def test_edit_skill_rewrites_and_validates(home): def test_missing_skill_detail(home): assert not lm.node_detail("nonexistent-skill")["ok"] + + +def test_memory_writes_match_memory_tool_format(home): + """A journey mutation must leave the file byte-identical to what the memory + tool itself writes — same §-join, no trailing-newline drift — so the two + surfaces never fight over format and indices stay aligned.""" + from tools.memory_tool import ENTRY_DELIMITER, MemoryStore + + assert lm.edit_node("memory:memory:0", "alpha rewritten")["ok"] + path = home / "memories" / "MEMORY.md" + entries = MemoryStore._read_file(path) + + assert entries == ["alpha rewritten", "beta note"] + assert path.read_text(encoding="utf-8") == ENTRY_DELIMITER.join(entries)