@dataclass class AutoMergeGuard: """ Name-only high-confidence matches route to review instead of auto-merge. At least one structural attribute must agree before auto-merge triggers. """ structural_keys = [ "registration_number_prefix", # first 6 chars of company reg number "jurisdiction_code", # ISO country + subdivision "address_locality", # city-level normalized ] def check(self, candidate_pair: dict) -> bool: name_sim = candidate_pair.get("name_similarity", 0) if name_sim < 0.95: return True # not name-only structural_agreement = any( candidate_pair.get(f"{key}_match", False) for key in self.structural_keys ) return structural_agreement