mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
* fix(dedup): never merge entities with different explicit types (fixes #1137) The duplicate candidate confidence scoring only rewarded same-type pairs but never penalized different-type pairs, so a Person 'Alice' and an Organization 'Acme' (different id, type, and name) passed the confidence threshold and were merged, silently dropping one entity. Add a type guard: when both entities carry a non-empty type and they differ, the pair is never a duplicate candidate (confidence 0, reason 'type_mismatch'). Untyped entities and genuinely duplicate same-type pairs keep their previous behavior. Regression tests cover all three cases. * fix(dedup): honor Entity.type and exclude mismatch structurally (review fixes) Two gaps from code review (#1149): 1. _get_entity_value mapped object 'type' exclusively to .label, which Entity objects never have — their type lives on .type. The mismatch guard therefore never saw the type of Entity objects, and differently typed objects could still merge. Read .type first, fall back to .label. 2. The mismatch branch returned a normal candidate with confidence 0.0, but detection filters with >= confidence_threshold, and 0.0 is a documented valid threshold, so mismatches slipped through. Exclude type_mismatch candidates structurally at both filter sites regardless of threshold. Adds tests for Entity objects with different types and for confidence_threshold=0.0. 94 dedup tests pass. ---------