"""Deterministic candidate screening, without deleting original rows.""" from common import * def exclusions(audits, originals): test_ids={r['id'] for split,r in originals if split=='test'} test_families={norm(r['scenario_family']) for split,r in originals if split=='test'} # Exclude both sides of candidate pairs, rather than claiming one is correct. neighbors=set() for filename in ['v3_lexical_pairs.json','v3_semantic_pairs.json']: for p in load(ROOT/'reports'/filename): if {p['id_a'],p['id_b']}&test_ids:neighbors.update([p['id_a'],p['id_b']]) result={} for a in audits: r=next(r for _,r in originals if r['id']==a['id']);why=[] if a['original_split']=='test':why.append('historical_test_reserved') if a['decision']=='review':why+=a['reasons'] if norm(r['scenario_family']) in test_families:why.append('historical_test_family_reserved') if r['id'] in neighbors:why.append('historical_test_neighbor_reserved') if why:result[a['id']]=sorted(set(why)) return result if __name__=='__main__': print('Deduplication is a build stage; see reports/v4_disposition.parquet. No originals deleted.')