V10.392 guard multi-component bundle matches
All checks were successful
CD Pipeline / deploy (push) Successful in 1m3s

This commit is contained in:
OoO
2026-05-24 10:38:40 +08:00
committed by AiderHeal Bot
parent 6d4b188787
commit 4da4a07a78
4 changed files with 35 additions and 3 deletions

View File

@@ -1241,6 +1241,18 @@ def _has_multi_component(identity: ProductIdentity) -> bool:
)
def _multi_component_count(identity: ProductIdentity) -> int:
text = identity.normalized_name
if not ("+" in text or "" in text):
return 1
parts = [
part.strip()
for part in re.split(r"[+]", text)
if part.strip() and not re.fullmatch(r"[\s\d-]+", part.strip())
]
return len(parts) if len(parts) > 1 else 1
def _has_refill_pack(identity: ProductIdentity) -> bool:
text = identity.normalized_name
return bool(
@@ -1563,6 +1575,7 @@ def _build_evidence_flags(
"count_conflict",
"bundle_offer_conflict",
"multi_component_conflict",
"multi_component_count_conflict",
"accessory_case_conflict",
"refill_pack_conflict",
"price_ratio_extreme",
@@ -1658,6 +1671,13 @@ def score_marketplace_match(
reasons.append("bundle_offer_conflict")
if _has_multi_component(left) != _has_multi_component(right):
reasons.append("multi_component_conflict")
multi_component_count_conflict = (
_has_multi_component(left)
and _has_multi_component(right)
and _multi_component_count(left) != _multi_component_count(right)
)
if multi_component_count_conflict:
reasons.append("multi_component_count_conflict")
if _has_refill_pack(left) != _has_refill_pack(right):
reasons.append("refill_pack_conflict")
accessory_case_conflict = _has_accessory_case(left) != _has_accessory_case(right)
@@ -1683,6 +1703,8 @@ def score_marketplace_match(
hard_veto = True
if _has_multi_component(left) != _has_multi_component(right):
hard_veto = True
if multi_component_count_conflict:
hard_veto = True
if _has_refill_pack(left) != _has_refill_pack(right):
hard_veto = True
if accessory_case_conflict: