feat(corroboration): aggregator — distinct positive + negative-flag (INV-COR4, X11)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-31 19:00:16 +00:00
parent dbc176ae66
commit 33f955e372
2 changed files with 37 additions and 0 deletions

View File

@@ -24,3 +24,23 @@ def test_match_rejects_below_threshold():
def test_match_rejects_empty():
assert cor.accept_match(None, floor=0.50) is None
def _link(src, treatment):
return {"source_id": src, "treatment": treatment}
def test_aggregate_counts_distinct_positive():
links = [_link("d1","followed"), _link("d1","explained"), _link("d2","followed")]
agg = cor.aggregate(links, min_cites=2)
assert agg["positive_sources"] == 2 # d1 counted once (INV-COR4 independence)
assert agg["has_negative"] is False
assert agg["corroborated"] is True
def test_aggregate_negative_blocks():
links = [_link("d1","followed"), _link("d2","followed"), _link("d3","distinguished")]
agg = cor.aggregate(links, min_cites=2)
assert agg["has_negative"] is True
assert agg["corroborated"] is False # any negative -> not corroborated (INV-COR2)
def test_aggregate_below_threshold():
agg = cor.aggregate([_link("d1","followed")], min_cites=2)
assert agg["corroborated"] is False # single source insufficient (INV-COR4)