Keep confirmed detect cues from opening a second type-conflict review.
Deploy Development / deploy (push) Successful in 54s
Test Suite / pytest-backend (push) Successful in 3m7s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 16s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-12 13:28:08 +02:00
1 parent 011cc9dd81
commit 0277039b07
7 files changed
+33 -7

No files matched your search

+12 -5
View File
@@ -209,10 +209,9 @@ def main() -> None:
json={"body": "Hanna aß mit uns."},
)
status_ok(hanna_again, "second Hanna turn")
hanna_conflict = hanna_again.json().get("pending_mask_review") or {}
expect(
bool(hanna_conflict.get("id")),
"teacher PERSON versus stored not_identity cue stays a visible type conflict",
not hanna_again.json().get("pending_mask_review"),
"stored Hanna cue is not re-asked against teacher PERSON",
)
record_sense(profile_id, "Clarissa", identity=True)
@@ -382,9 +381,17 @@ def main() -> None:
wrapped = MentionSpan("Frau Sushi", 15, 25, "PERSON", "identity", "teacher", False, "frau")
expect(same_mention(person, wrapped), "contained Sushi matches Frau Sushi")
expect(map_entity_type("person") == "PERSON", "GLiNER person maps to PERSON")
review, counters = compare_mentions(profile_id, dish_line, [person], [food], dish_line)
guessed = MentionSpan("Sushi", 20, 25, "PERSON", "identity", "candidate", False, "aß")
review, counters = compare_mentions(profile_id, dish_line, [guessed], [food], dish_line)
expect(counters["diff_type_conflict"] >= 1, "FOOD versus PERSON is a type conflict")
expect(any(item.get("reason") == "type_conflict" for item in review), "type conflict is offered")
expect(any(item.get("reason") == "type_conflict" for item in review), "unconfirmed type conflict is offered")
confirmed_dish = MentionSpan("Sushi", 20, 25, "FOOD", "not_identity", "cue", True, "rohan")
teacher_person = MentionSpan("Sushi", 20, 25, "PERSON", "identity", "teacher", False, "rohan")
kept, kept_counters = compare_mentions(
profile_id, dish_line, [confirmed_dish], [teacher_person], dish_line
)
expect(kept_counters["diff_type_conflict"] >= 1, "confirmed cue still counts the type conflict")
expect(not kept, "confirmed cue is not re-asked on type conflict")
compact = compact_diff_counters(counters)
dumped = str(compact)
expect("Sushi" not in dumped and "Frau" not in dumped, "compact diff counters carry no plaintext")
+11
View File
@@ -16,6 +16,7 @@ from detect_learning import canonicalize_detect_mode, decision_for_mention
from detect_pipeline import (
MentionSpan,
compact_diff_counters,
compare_mentions,
map_entity_type,
protects,
same_mention,
@@ -38,6 +39,16 @@ def main() -> None:
expect(protects("PERSON") and not protects("FOOD"), "PERSON protects, FOOD does not")
expect(types_equivalent("PERSON", "PLACE"), "similar protectable types are equivalent")
expect(not types_equivalent("FOOD", "PERSON"), "FOOD versus PERSON is never equivalent")
guessed = MentionSpan("Sushi", 20, 25, "PERSON", "identity", "candidate", False, "aß")
teacher_food = MentionSpan("Sushi", 20, 25, "FOOD", "not_identity", "teacher", False, "aß")
offered, offered_counters = compare_mentions("p", "Ich aß Sushi.", [guessed], [teacher_food])
expect(offered_counters["diff_type_conflict"] == 1, "unconfirmed FOOD versus PERSON is counted")
expect(any(item.get("reason") == "type_conflict" for item in offered), "unconfirmed type conflict is offered")
confirmed = MentionSpan("Sushi", 20, 25, "FOOD", "not_identity", "cue", True, "rohan")
teacher_person = MentionSpan("Sushi", 20, 25, "PERSON", "identity", "teacher", False, "rohan")
kept, kept_counters = compare_mentions("p", "Rohan Sushi essen", [confirmed], [teacher_person])
expect(kept_counters["diff_type_conflict"] == 1, "confirmed cue still counts FOOD versus PERSON")
expect(not kept, "confirmed cue is not re-asked on type conflict")
inner = MentionSpan("Sushi", 20, 25, "PERSON", "identity", "cue", True, "frau")
outer = MentionSpan("Frau Sushi", 15, 25, "PERSON", "identity", "teacher", False, "frau")
expect(same_mention(inner, outer), "contained span is the same mention")