test(journey): lock memory write format-parity with the memory tool

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.
This commit is contained in:
Brooklyn Nicholson 2026-06-30 15:16:25 -05:00
parent 2fc67a3a5b
commit 6241cc54e3

View file

@ -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)