From 6241cc54e3ecae97b98b10e1bb1c1b1c4363759b Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Tue, 30 Jun 2026 15:16:25 -0500 Subject: [PATCH] test(journey): lock memory write format-parity with the memory tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Assert a journey edit leaves MEMORY.md byte-identical to MemoryStore's own §-join (no trailing-newline drift) and round-trips through MemoryStore._read_file, so the two surfaces can never diverge on format. --- tests/agent/test_learning_mutations.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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)