test(review): memory prompts name both stores and forbid dual writes

Two behaviour contracts: both memory-writing prompts name target='user' and target='memory' so facts
are routed rather than defaulted, and the combined prompt no longer instructs writing a preference
lesson to both a skill and memory. Both red on main's prompt file.
This commit is contained in:
kshitijk4poor
2026-09-19 15:22:37 +05:30
committed by kshitij
parent f02be54d73
commit 697d1596a8

View File

@@ -216,3 +216,33 @@ def test_curator_prompt_consolidates_by_distilling():
lower = CURATOR_REVIEW_PROMPT.lower()
assert "distill" in lower, "curator must distill absorbed content, not file it"
assert "verbatim" in lower and "per-incident" in lower, "curator must not copy siblings verbatim into references/"
# ---------------------------------------------------------------------------
# Memory store routing. The memory tool writes to two files — USER.md
# (target='user': who the user is) and MEMORY.md (target='memory': environment
# facts). A prompt that just says "save it using the memory tool" lets
# user-profile data land in the environment store and vice versa, and the
# combined prompt used to instruct writing preference lessons to BOTH a skill
# and memory, which is how MEMORY.md ends up restating SKILL.md content until
# both stores hit their size limits.
# ---------------------------------------------------------------------------
def test_memory_prompts_name_both_memory_targets():
"""Both memory-writing prompts must name the two targets so facts are routed, not defaulted."""
for label, prompt in (
("_MEMORY_REVIEW_PROMPT", AIAgent._MEMORY_REVIEW_PROMPT),
("_COMBINED_REVIEW_PROMPT", AIAgent._COMBINED_REVIEW_PROMPT),
):
assert "target='user'" in prompt, f"{label}: must name the USER.md target"
assert "target='memory'" in prompt, f"{label}: must name the MEMORY.md target"
def test_combined_review_prompt_forbids_dual_store_writes():
"""A user-preference lesson lives in one place; the prompt must not ask for both."""
prompt = AIAgent._COMBINED_REVIEW_PROMPT
assert "Both should carry" not in prompt, (
"must not instruct writing the same preference lesson to both a skill and memory"
)
assert "never both" in prompt, "must state the one-store rule for preference lessons"