chore(corpus-origin): address Copilot review on #1223

- cli.py: stringify each evidence entry exactly once before the
  startswith check (was calling str(e) twice per element).
- tests: replace brittle `confidence != 0.90` assertion with an
  equality check against detect_origin_heuristic on the same samples.
  The original would have spuriously fired if the heuristic ever
  legitimately produced 0.90 for these samples; the new form pins the
  contract directly.
This commit is contained in:
Igor Lins e Silva
2026-04-26 18:43:19 -03:00
parent c92256f08f
commit 5e33592ba2
2 changed files with 15 additions and 10 deletions
+11 -6
View File
@@ -1484,12 +1484,17 @@ def test_merge_tier_fields_heuristic_yes_llm_no_keeps_heuristic_bool():
f"Got: {res}"
)
# The bool and the confidence are paired — both must come from the
# heuristic. The mocked LLM returned 0.90; if the merge accidentally
# took LLM's confidence, this would equal 0.90.
assert res["confidence"] != 0.90, (
f"Merged confidence equals the mocked LLM's 0.90 — looks like "
f"LLM's confidence leaked through the merge. Heuristic's confidence "
f"must be preserved alongside its bool. Got: {res}"
# heuristic. Compare to detect_origin_heuristic on the same samples
# so this stays correct regardless of what the heuristic computes
# for these samples (avoids brittleness vs. a hardcoded sentinel).
from mempalace.corpus_origin import detect_origin_heuristic
expected_confidence = detect_origin_heuristic(_ai_dialogue_samples()).confidence
assert res["confidence"] == expected_confidence, (
f"Merged confidence {res['confidence']} did not match the heuristic's "
f"{expected_confidence} for these samples. The mocked LLM returned "
f"0.90; if the merge accidentally took the LLM's confidence, the "
f"merged value would not equal the heuristic's. Got: {res}"
)
# Persona/user/platform from LLM should still be merged in.
assert res["agent_persona_names"] == [