style(test): modernize type annotations in adversarial contract test suite

- Replace typing.Dict, List, Tuple with PEP 585 built-in generic types
- Clean up trailing whitespace in candidate audit checks
This commit is contained in:
kiskaadee committed 2026-10-08 18:49:44 -05:00
1 parent 65d7762da9
commit ca759704f3
1 file changed
+313 -93
+313 -93
View File
@@ -19,19 +19,21 @@ Tests behavioral robustness and epistemic enforcement across 12 adversarial fixt
without empirical NIT in direct_observations, worker remediates to verified anchors. without empirical NIT in direct_observations, worker remediates to verified anchors.
""" """
from typing import Dict, Any, List, Tuple from typing import Any
class AnchorRegistry: class AnchorRegistry:
def __init__(self, seed_anchors: List[Dict[str, Any]]): def __init__(self, seed_anchors: list[dict[str, Any]]):
self.active: Dict[str, Dict[str, Any]] = {a["id"]: a for a in seed_anchors} self.active: dict[str, dict[str, Any]] = {a["id"]: a for a in seed_anchors}
self.proposed: Dict[str, Dict[str, Any]] = {} self.proposed: dict[str, dict[str, Any]] = {}
self.rejected: Dict[str, Dict[str, Any]] = {} self.rejected: dict[str, dict[str, Any]] = {}
def propose_anchor(self, anchor: Dict[str, Any]): def propose_anchor(self, anchor: dict[str, Any]):
self.proposed[anchor["id"]] = anchor self.proposed[anchor["id"]] = anchor
def reconcile_proposed(self, anchor_id: str, accept: bool, rejection_reason: str = ""): def reconcile_proposed(
self, anchor_id: str, accept: bool, rejection_reason: str = ""
):
if anchor_id not in self.proposed: if anchor_id not in self.proposed:
raise KeyError(f"Anchor {anchor_id} not in proposed state") raise KeyError(f"Anchor {anchor_id} not in proposed state")
anchor = self.proposed.pop(anchor_id) anchor = self.proposed.pop(anchor_id)
@@ -57,7 +59,9 @@ class EvidenceAuditor:
""" """
@staticmethod @staticmethod
def audit_candidate(candidate: Dict[str, Any], raw_source: Dict[str, Any]) -> Tuple[bool, str]: def audit_candidate(
candidate: dict[str, Any], raw_source: dict[str, Any]
) -> tuple[bool, str]:
kind = candidate.get("candidate_kind") kind = candidate.get("candidate_kind")
disposition = candidate.get("disposition") disposition = candidate.get("disposition")
identity_status = candidate.get("identity_status") identity_status = candidate.get("identity_status")
@@ -72,19 +76,33 @@ class EvidenceAuditor:
# Epistemic check: metadata claim without observational backing # Epistemic check: metadata claim without observational backing
direct_obs_text = " ".join(candidate.get("direct_observations", [])).lower() direct_obs_text = " ".join(candidate.get("direct_observations", [])).lower()
for conflict in candidate.get("conflicting_anchors", []): for conflict in candidate.get("conflicting_anchors", []):
if conflict == "tax_id" and not any(k in direct_obs_text for k in ["nit", "tax_id", "tributaria"]): if conflict == "tax_id" and not any(
return False, "Metadata claim without observation: 'tax_id' declared in conflicting_anchors but no NIT recorded in direct_observations" k in direct_obs_text for k in ["nit", "tax_id", "tributaria"]
):
return (
False,
"Metadata claim without observation: 'tax_id' declared in conflicting_anchors but no NIT recorded in direct_observations",
)
return True, "Discard verified by conflicting anchors" return True, "Discard verified by conflicting anchors"
# Check Negative Observations # Check Negative Observations
if kind == "negative_observation": if kind == "negative_observation":
if identity_status != "not_applicable": if identity_status != "not_applicable":
return False, "Negative observation must have identity_status: not_applicable" return (
False,
"Negative observation must have identity_status: not_applicable",
)
if candidate.get("matched_anchors"): if candidate.get("matched_anchors"):
return False, "Negative observation cannot have matched anchors for an unobserved profile" return (
False,
"Negative observation cannot have matched anchors for an unobserved profile",
)
if candidate.get("confidence") != "negative_scoped": if candidate.get("confidence") != "negative_scoped":
return False, "Negative observation must have confidence: negative_scoped" return (
False,
"Negative observation must have confidence: negative_scoped",
)
return True, "Negative observation correctly scoped" return True, "Negative observation correctly scoped"
# Check Presence Observations # Check Presence Observations
@@ -92,7 +110,10 @@ class EvidenceAuditor:
if identity_status == "attributed": if identity_status == "attributed":
matched = candidate.get("matched_anchors", []) matched = candidate.get("matched_anchors", [])
if len(matched) < 2: if len(matched) < 2:
return False, f"Attribution requires at least 2 anchors, found {len(matched)}" return (
False,
f"Attribution requires at least 2 anchors, found {len(matched)}",
)
elif identity_status == "ambiguous": elif identity_status == "ambiguous":
if disposition != "hold": if disposition != "hold":
return False, "Ambiguous identity must have disposition: hold" return False, "Ambiguous identity must have disposition: hold"
@@ -100,9 +121,17 @@ class EvidenceAuditor:
# Check Epistemic Separation: Promotional or third-party claims in direct_observations # Check Epistemic Separation: Promotional or third-party claims in direct_observations
for obs in candidate.get("direct_observations", []): for obs in candidate.get("direct_observations", []):
for promotional_word in ["líder", "el mejor", "mayor prestigio", "reconocido como lider"]: for promotional_word in [
"líder",
"el mejor",
"mayor prestigio",
"reconocido como lider",
]:
if promotional_word in obs.lower(): if promotional_word in obs.lower():
return False, f"Unevidenced promotional claim '{promotional_word}' found in direct_observations" return (
False,
f"Unevidenced promotional claim '{promotional_word}' found in direct_observations",
)
# Check Temporal Validity: Extrapolation of past records to current present state # Check Temporal Validity: Extrapolation of past records to current present state
source_date = raw_source.get("publication_date", "") source_date = raw_source.get("publication_date", "")
@@ -110,13 +139,24 @@ class EvidenceAuditor:
if source_date and "2023" in source_date: if source_date and "2023" in source_date:
if "2026" in relevant_period or "actual" in relevant_period: if "2026" in relevant_period or "actual" in relevant_period:
# Source from 2023 cannot assert current 2026 operational truth without fresh evidence # Source from 2023 cannot assert current 2026 operational truth without fresh evidence
return False, f"Temporal validity violation: Source dated {source_date} extrapolated to {relevant_period}" return (
False,
f"Temporal validity violation: Source dated {source_date} extrapolated to {relevant_period}",
)
# Check Observation vs Underlying Page (snippet conflict) # Check Observation vs Underlying Page (snippet conflict)
if raw_source.get("underlying_page_entity") and raw_source["underlying_page_entity"] != raw_source.get("snippet_entity"): if raw_source.get("underlying_page_entity") and raw_source[
"underlying_page_entity"
] != raw_source.get("snippet_entity"):
for obs in candidate.get("direct_observations", []): for obs in candidate.get("direct_observations", []):
if raw_source["snippet_entity"] in obs and raw_source["underlying_page_entity"] not in obs: if (
return False, "Direct observation adopted search snippet rather than underlying page reality" raw_source["snippet_entity"] in obs
and raw_source["underlying_page_entity"] not in obs
):
return (
False,
"Direct observation adopted search snippet rather than underlying page reality",
)
return True, "Admissibility verified" return True, "Admissibility verified"
@@ -125,11 +165,46 @@ class EvidenceAuditor:
def run_all_adversarial_tests(): def run_all_adversarial_tests():
seed = [ seed = [
{"id": "ANC-001", "type": "domain", "value": "amcsolutionscolombia.com", "strength": "high", "provenance": "seed", "status": "active"}, {
{"id": "ANC-002", "type": "tax_id", "value": "901380770", "strength": "high", "provenance": "seed", "status": "active"}, "id": "ANC-001",
{"id": "ANC-003", "type": "legal_name", "value": "AMC SOLUTIONS COLOMBIA S.A.S.", "strength": "high", "provenance": "seed", "status": "active"}, "type": "domain",
{"id": "ANC-004", "type": "street_address", "value": "Carrera 19d # 5-50, Valledupar", "strength": "moderate", "provenance": "seed", "status": "active"}, "value": "amcsolutionscolombia.com",
{"id": "ANC-005", "type": "phone", "value": "+57 3136216458", "strength": "moderate", "provenance": "seed", "status": "active"}, "strength": "high",
"provenance": "seed",
"status": "active",
},
{
"id": "ANC-002",
"type": "tax_id",
"value": "901380770",
"strength": "high",
"provenance": "seed",
"status": "active",
},
{
"id": "ANC-003",
"type": "legal_name",
"value": "AMC SOLUTIONS COLOMBIA S.A.S.",
"strength": "high",
"provenance": "seed",
"status": "active",
},
{
"id": "ANC-004",
"type": "street_address",
"value": "Carrera 19d # 5-50, Valledupar",
"strength": "moderate",
"provenance": "seed",
"status": "active",
},
{
"id": "ANC-005",
"type": "phone",
"value": "+57 3136216458",
"strength": "moderate",
"provenance": "seed",
"status": "active",
},
] ]
registry = AnchorRegistry(seed) registry = AnchorRegistry(seed)
@@ -138,10 +213,16 @@ def run_all_adversarial_tests():
# Fixture 1: Exact legal name + wrong NIT -> discard # Fixture 1: Exact legal name + wrong NIT -> discard
c1 = { c1 = {
"id": "ADV-001", "candidate_kind": "discard", "identity_status": "discarded", "id": "ADV-001",
"disposition": "discard", "audit_status": "pending", "candidate_kind": "discard",
"conflicting_anchors": ["tax_id"], "matched_anchors": ["ANC-003"], "identity_status": "discarded",
"direct_observations": ["Entidad homónima con NIT 900999888 en conflicto con semilla"] "disposition": "discard",
"audit_status": "pending",
"conflicting_anchors": ["tax_id"],
"matched_anchors": ["ANC-003"],
"direct_observations": [
"Entidad homónima con NIT 900999888 en conflicto con semilla"
],
} }
raw1 = {"name": "AMC SOLUTIONS COLOMBIA S.A.S.", "nit": "900999888"} raw1 = {"name": "AMC SOLUTIONS COLOMBIA S.A.S.", "nit": "900999888"}
passed, reason = auditor.audit_candidate(c1, raw1) passed, reason = auditor.audit_candidate(c1, raw1)
@@ -150,85 +231,163 @@ def run_all_adversarial_tests():
# Fixture 2: Correct NIT + different legal name -> ambiguous / hold # Fixture 2: Correct NIT + different legal name -> ambiguous / hold
c2 = { c2 = {
"id": "ADV-002", "candidate_kind": "presence", "identity_status": "ambiguous", "id": "ADV-002",
"disposition": "hold", "audit_status": "pending", "candidate_kind": "presence",
"matched_anchors": ["ANC-002"], "missing_anchors": ["legal_name_reconciliation", "domain"] "identity_status": "ambiguous",
"disposition": "hold",
"audit_status": "pending",
"matched_anchors": ["ANC-002"],
"missing_anchors": ["legal_name_reconciliation", "domain"],
} }
raw2 = {"name": "MINERALES DEL CESAR S.A.S.", "nit": "901380770"} raw2 = {"name": "MINERALES DEL CESAR S.A.S.", "nit": "901380770"}
passed, reason = auditor.audit_candidate(c2, raw2) passed, reason = auditor.audit_candidate(c2, raw2)
assert passed and c2["disposition"] == "hold" assert passed and c2["disposition"] == "hold"
results["2. Correct NIT + different legal name"] = "PASS (retained in hold, not attributed)" results["2. Correct NIT + different legal name"] = (
"PASS (retained in hold, not attributed)"
)
# Fixture 3: Historical address -> admit presence + proposed anchor with historical period # Fixture 3: Historical address -> admit presence + proposed anchor with historical period
c3 = { c3 = {
"id": "ADV-003", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-003",
"disposition": "admit", "audit_status": "pending", "relevant_period": "historico / 2021", "candidate_kind": "presence",
"matched_anchors": ["ANC-002", "ANC-003"], "proposed_anchors": ["ANC-006"], "identity_status": "attributed",
"direct_observations": ["Muestra dirección histórica Carrera 14 # 13 C 60"] "disposition": "admit",
"audit_status": "pending",
"relevant_period": "historico / 2021",
"matched_anchors": ["ANC-002", "ANC-003"],
"proposed_anchors": ["ANC-006"],
"direct_observations": ["Muestra dirección histórica Carrera 14 # 13 C 60"],
}
raw3 = {
"name": "AMC SOLUTIONS COLOMBIA S.A.S.",
"nit": "901380770",
"address": "Carrera 14 # 13 C 60",
"year": "2021",
} }
raw3 = {"name": "AMC SOLUTIONS COLOMBIA S.A.S.", "nit": "901380770", "address": "Carrera 14 # 13 C 60", "year": "2021"}
passed, reason = auditor.audit_candidate(c3, raw3) passed, reason = auditor.audit_candidate(c3, raw3)
assert passed and c3["relevant_period"] == "historico / 2021" assert passed and c3["relevant_period"] == "historico / 2021"
registry.propose_anchor({"id": "ANC-006", "type": "street_address", "value": "Carrera 14 # 13 C 60", "strength": "moderate", "provenance": "ADV-003", "status": "proposed"}) registry.propose_anchor(
results["3. Historical address"] = "PASS (admitted with historical period; proposed anchor emitted)" {
"id": "ANC-006",
"type": "street_address",
"value": "Carrera 14 # 13 C 60",
"strength": "moderate",
"provenance": "ADV-003",
"status": "proposed",
}
)
results["3. Historical address"] = (
"PASS (admitted with historical period; proposed anchor emitted)"
)
# Fixture 4: New legal representative from official source # Fixture 4: New legal representative from official source
c4 = { c4 = {
"id": "ADV-004", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-004",
"disposition": "admit", "audit_status": "pending", "relevant_period": "vigencia fiscal 2023", "candidate_kind": "presence",
"matched_anchors": ["ANC-002", "ANC-003"], "proposed_anchors": ["ANC-007"], "identity_status": "attributed",
"direct_observations": ["Acta municipal registra a Ledys del Rosario Martínez Lara como representante legal"] "disposition": "admit",
"audit_status": "pending",
"relevant_period": "vigencia fiscal 2023",
"matched_anchors": ["ANC-002", "ANC-003"],
"proposed_anchors": ["ANC-007"],
"direct_observations": [
"Acta municipal registra a Ledys del Rosario Martínez Lara como representante legal"
],
} }
raw4 = {"publication_date": "2023-12-31"} raw4 = {"publication_date": "2023-12-31"}
passed, reason = auditor.audit_candidate(c4, raw4) passed, reason = auditor.audit_candidate(c4, raw4)
assert passed assert passed
registry.propose_anchor({"id": "ANC-007", "type": "legal_representative", "value": "Ledys del Rosario Martínez Lara", "strength": "moderate", "provenance": "ADV-004", "status": "proposed"}) registry.propose_anchor(
{
"id": "ANC-007",
"type": "legal_representative",
"value": "Ledys del Rosario Martínez Lara",
"strength": "moderate",
"provenance": "ADV-004",
"status": "proposed",
}
)
assert "ANC-007" in registry.proposed and "ANC-007" not in registry.active assert "ANC-007" in registry.proposed and "ANC-007" not in registry.active
results["4. New legal representative"] = "PASS (proposed in research state; not yet active)" results["4. New legal representative"] = (
"PASS (proposed in research state; not yet active)"
)
# Fixture 5: Snippet says AMC, underlying page says different company # Fixture 5: Snippet says AMC, underlying page says different company
raw5 = {"snippet_entity": "AMC Solutions", "underlying_page_entity": "Servicios Mineros de Colombia S.A."} raw5 = {
"snippet_entity": "AMC Solutions",
"underlying_page_entity": "Servicios Mineros de Colombia S.A.",
}
bad_c5 = { bad_c5 = {
"id": "ADV-005", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-005",
"disposition": "admit", "audit_status": "pending", "matched_anchors": ["ANC-001", "ANC-003"], "candidate_kind": "presence",
"direct_observations": ["Snippet de búsqueda muestra AMC Solutions en Valledupar"] "identity_status": "attributed",
"disposition": "admit",
"audit_status": "pending",
"matched_anchors": ["ANC-001", "ANC-003"],
"direct_observations": [
"Snippet de búsqueda muestra AMC Solutions en Valledupar"
],
} }
passed_bad, reason = auditor.audit_candidate(bad_c5, raw5) passed_bad, reason = auditor.audit_candidate(bad_c5, raw5)
assert not passed_bad # Auditor catches snippet hallucination assert not passed_bad # Auditor catches snippet hallucination
# Worker corrects to discard # Worker corrects to discard
corrected_c5 = { corrected_c5 = {
"id": "ADV-005", "candidate_kind": "discard", "identity_status": "discarded", "id": "ADV-005",
"disposition": "discard", "audit_status": "pending", "conflicting_anchors": ["legal_name"], "candidate_kind": "discard",
"direct_observations": ["La página de destino corresponde a Servicios Mineros de Colombia S.A., no a AMC Solutions"] "identity_status": "discarded",
"disposition": "discard",
"audit_status": "pending",
"conflicting_anchors": ["legal_name"],
"direct_observations": [
"La página de destino corresponde a Servicios Mineros de Colombia S.A., no a AMC Solutions"
],
} }
passed_good, _ = auditor.audit_candidate(corrected_c5, raw5) passed_good, _ = auditor.audit_candidate(corrected_c5, raw5)
assert passed_good assert passed_good
results["5. Search snippet vs underlying page"] = "PASS (snippet hallucination caught; underlying page governs)" results["5. Search snippet vs underlying page"] = (
"PASS (snippet hallucination caught; underlying page governs)"
)
# Fixture 6: Third party promotional claim ("Empresa líder...") # Fixture 6: Third party promotional claim ("Empresa líder...")
bad_c6 = { bad_c6 = {
"id": "ADV-006", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-006",
"disposition": "admit", "audit_status": "pending", "matched_anchors": ["ANC-002", "ANC-003"], "candidate_kind": "presence",
"direct_observations": ["La fuente certifica que es la empresa líder del Cesar"] "identity_status": "attributed",
"disposition": "admit",
"audit_status": "pending",
"matched_anchors": ["ANC-002", "ANC-003"],
"direct_observations": [
"La fuente certifica que es la empresa líder del Cesar"
],
} }
passed_bad, reason = auditor.audit_candidate(bad_c6, {}) passed_bad, reason = auditor.audit_candidate(bad_c6, {})
assert not passed_bad and "promotional" in reason.lower() assert not passed_bad and "promotional" in reason.lower()
# Corrected: claim moved to source_claims # Corrected: claim moved to source_claims
good_c6 = { good_c6 = {
"id": "ADV-006", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-006",
"disposition": "admit", "audit_status": "pending", "matched_anchors": ["ANC-002", "ANC-003"], "candidate_kind": "presence",
"identity_status": "attributed",
"disposition": "admit",
"audit_status": "pending",
"matched_anchors": ["ANC-002", "ANC-003"],
"direct_observations": ["Ficha mercantil lista registro con NIT 901380770"], "direct_observations": ["Ficha mercantil lista registro con NIT 901380770"],
"source_claims": ["El directorio afirma que la empresa es líder en el Cesar"] "source_claims": ["El directorio afirma que la empresa es líder en el Cesar"],
} }
passed_good, _ = auditor.audit_candidate(good_c6, {}) passed_good, _ = auditor.audit_candidate(good_c6, {})
assert passed_good assert passed_good
results["6. Promotional claim discipline"] = "PASS (rejected in direct_observations; allowed in source_claims)" results["6. Promotional claim discipline"] = (
"PASS (rejected in direct_observations; allowed in source_claims)"
)
# Fixture 7: Ambiguous local listing (Name + city, no NIT/domain) # Fixture 7: Ambiguous local listing (Name + city, no NIT/domain)
c7 = { c7 = {
"id": "ADV-007", "candidate_kind": "presence", "identity_status": "ambiguous", "id": "ADV-007",
"disposition": "hold", "audit_status": "pending", "matched_anchors": ["ANC-003"], "candidate_kind": "presence",
"missing_anchors": ["tax_id", "domain"] "identity_status": "ambiguous",
"disposition": "hold",
"audit_status": "pending",
"matched_anchors": ["ANC-003"],
"missing_anchors": ["tax_id", "domain"],
} }
passed, _ = auditor.audit_candidate(c7, {}) passed, _ = auditor.audit_candidate(c7, {})
assert passed and c7["disposition"] == "hold" assert passed and c7["disposition"] == "hold"
@@ -236,52 +395,94 @@ def run_all_adversarial_tests():
# Fixture 8: Historical 2023 government contract # Fixture 8: Historical 2023 government contract
c8 = { c8 = {
"id": "ADV-008", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-008",
"disposition": "admit", "audit_status": "pending", "relevant_period": "vigencia fiscal 2023", "candidate_kind": "presence",
"identity_status": "attributed",
"disposition": "admit",
"audit_status": "pending",
"relevant_period": "vigencia fiscal 2023",
"matched_anchors": ["ANC-002", "ANC-003"], "matched_anchors": ["ANC-002", "ANC-003"],
"direct_observations": ["Adjudicación de contrato SAMC-014-2023 en Uribia"] "direct_observations": ["Adjudicación de contrato SAMC-014-2023 en Uribia"],
} }
passed, _ = auditor.audit_candidate(c8, {"publication_date": "2023-12-31"}) passed, _ = auditor.audit_candidate(c8, {"publication_date": "2023-12-31"})
assert passed and "2023" in c8["relevant_period"] assert passed and "2023" in c8["relevant_period"]
results["8. Historical contract discipline"] = "PASS (scoped strictly to 2023 fiscal year)" results["8. Historical contract discipline"] = (
"PASS (scoped strictly to 2023 fiscal year)"
)
# Fixture 9: Negative observation on Google Maps # Fixture 9: Negative observation on Google Maps
c9 = { c9 = {
"id": "ADV-009", "candidate_kind": "negative_observation", "identity_status": "not_applicable", "id": "ADV-009",
"disposition": "admit", "audit_status": "pending", "confidence": "negative_scoped", "candidate_kind": "negative_observation",
"identity_status": "not_applicable",
"disposition": "admit",
"audit_status": "pending",
"confidence": "negative_scoped",
"matched_anchors": [], "matched_anchors": [],
"direct_observations": ["En la muestra de búsqueda en Google Maps no se observó perfil comercial verificado"] "direct_observations": [
"En la muestra de búsqueda en Google Maps no se observó perfil comercial verificado"
],
} }
passed, _ = auditor.audit_candidate(c9, {}) passed, _ = auditor.audit_candidate(c9, {})
assert passed and c9["identity_status"] == "not_applicable" assert passed and c9["identity_status"] == "not_applicable"
results["9. Scoped negative observation"] = "PASS (admitted without false entity attribution)" results["9. Scoped negative observation"] = (
"PASS (admitted without false entity attribution)"
)
# Fixture 10: Contradictory addresses preserved # Fixture 10: Contradictory addresses preserved
c10 = { c10 = {
"id": "ADV-010", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-010",
"disposition": "admit", "audit_status": "pending", "matched_anchors": ["ANC-002", "ANC-003"], "candidate_kind": "presence",
"direct_observations": ["Directorio A lista Carrera 19d; Directorio B lista Carrera 14"], "identity_status": "attributed",
"open_questions": ["¿Cuál dirección representa la sede operativa vigente?"] "disposition": "admit",
"audit_status": "pending",
"matched_anchors": ["ANC-002", "ANC-003"],
"direct_observations": [
"Directorio A lista Carrera 19d; Directorio B lista Carrera 14"
],
"open_questions": ["¿Cuál dirección representa la sede operativa vigente?"],
} }
passed, _ = auditor.audit_candidate(c10, {}) passed, _ = auditor.audit_candidate(c10, {})
assert passed and len(c10["open_questions"]) > 0 assert passed and len(c10["open_questions"]) > 0
results["10. Contradictory addresses"] = "PASS (contradiction preserved in open_questions)" results["10. Contradictory addresses"] = (
"PASS (contradiction preserved in open_questions)"
)
# Fixture 11: Conflicting proposed anchor rejected # Fixture 11: Conflicting proposed anchor rejected
registry.propose_anchor({"id": "ANC-099", "type": "phone", "value": "+57 4 4440000", "strength": "moderate", "provenance": "ADV-011", "status": "proposed"}) registry.propose_anchor(
{
"id": "ANC-099",
"type": "phone",
"value": "+57 4 4440000",
"strength": "moderate",
"provenance": "ADV-011",
"status": "proposed",
}
)
# Orchestrator detects conflicting area code (+57 4 is Medellín, competitor conflict) # Orchestrator detects conflicting area code (+57 4 is Medellín, competitor conflict)
registry.reconcile_proposed("ANC-099", accept=False, rejection_reason="Conflicto de jurisdicción y homonimia con competidor en Medellín") registry.reconcile_proposed(
"ANC-099",
accept=False,
rejection_reason="Conflicto de jurisdicción y homonimia con competidor en Medellín",
)
assert "ANC-099" in registry.rejected and "ANC-099" not in registry.active assert "ANC-099" in registry.rejected and "ANC-099" not in registry.active
results["11. Conflicting proposed anchor"] = "PASS (rejected by orchestrator; not promoted to active)" results["11. Conflicting proposed anchor"] = (
"PASS (rejected by orchestrator; not promoted to active)"
)
# Fixture 12: THE TEMPORAL EXPLOIT & RE-ENTRY # Fixture 12: THE TEMPORAL EXPLOIT & RE-ENTRY
# Worker correctly attributes entity, but fraudulently or carelessly sets relevant_period to 'actual 2026' on a 2023 source! # Worker correctly attributes entity, but fraudulently or carelessly sets relevant_period to 'actual 2026' on a 2023 source!
exploit_c12 = { exploit_c12 = {
"id": "ADV-012", "candidate_kind": "presence", "identity_status": "attributed", "id": "ADV-012",
"disposition": "admit", "audit_status": "pending", "candidate_kind": "presence",
"identity_status": "attributed",
"disposition": "admit",
"audit_status": "pending",
"matched_anchors": ["ANC-002", "ANC-003"], "matched_anchors": ["ANC-002", "ANC-003"],
"relevant_period": "actual 2026", # FRAUDULENT EXTRAPOLATION "relevant_period": "actual 2026", # FRAUDULENT EXTRAPOLATION
"direct_observations": ["Contrato municipal acredita servicios mineros activos"] "direct_observations": [
"Contrato municipal acredita servicios mineros activos"
],
} }
raw12 = {"publication_date": "2023-10-15"} raw12 = {"publication_date": "2023-10-15"}
@@ -295,7 +496,9 @@ def run_all_adversarial_tests():
# Worker Re-evaluation: Worker addresses auditor objection # Worker Re-evaluation: Worker addresses auditor objection
exploit_c12["relevant_period"] = "vigencia fiscal 2023" exploit_c12["relevant_period"] = "vigencia fiscal 2023"
exploit_c12["direct_observations"] = ["Contrato municipal adjudicado en vigencia 2023"] exploit_c12["direct_observations"] = [
"Contrato municipal adjudicado en vigencia 2023"
]
exploit_c12["disposition"] = "admit" exploit_c12["disposition"] = "admit"
exploit_c12["audit_status"] = "pending" # RE-ENTRY PROTOCOL exploit_c12["audit_status"] = "pending" # RE-ENTRY PROTOCOL
@@ -304,30 +507,47 @@ def run_all_adversarial_tests():
assert passed2 assert passed2
exploit_c12["audit_status"] = "passed" exploit_c12["audit_status"] = "passed"
# Verification of eligibility conjunction: # Verification of eligibility conjunction:
eligible = (exploit_c12["disposition"] == "admit" and exploit_c12["audit_status"] == "passed") eligible = (
exploit_c12["disposition"] == "admit"
and exploit_c12["audit_status"] == "passed"
)
assert eligible assert eligible
results["12. Temporal exploit & re-entry"] = "PASS (auditor caught 2026 leap, demoted to hold; worker repaired, re-entered, passed audit)" results["12. Temporal exploit & re-entry"] = (
"PASS (auditor caught 2026 leap, demoted to hold; worker repaired, re-entered, passed audit)"
)
# Fixture 13: Metadata claim without observation (DISC-001 regression fixture) # Fixture 13: Metadata claim without observation (DISC-001 regression fixture)
bad_c13 = { bad_c13 = {
"id": "ADV-013", "candidate_kind": "discard", "identity_status": "discarded", "id": "ADV-013",
"disposition": "discard", "audit_status": "pending", "candidate_kind": "discard",
"identity_status": "discarded",
"disposition": "discard",
"audit_status": "pending",
"conflicting_anchors": ["tax_id", "city"], "conflicting_anchors": ["tax_id", "city"],
"direct_observations": ["Ficha en Bogotá para empresa homónima en alquiler de maquinaria"] "direct_observations": [
"Ficha en Bogotá para empresa homónima en alquiler de maquinaria"
],
} }
passed_bad, reason_bad = auditor.audit_candidate(bad_c13, {}) passed_bad, reason_bad = auditor.audit_candidate(bad_c13, {})
assert not passed_bad and "metadata claim without observation" in reason_bad.lower() assert not passed_bad and "metadata claim without observation" in reason_bad.lower()
# Re-entry: Worker remediates by grounding discard strictly on verifiable conflicting anchors (city, sector) # Re-entry: Worker remediates by grounding discard strictly on verifiable conflicting anchors (city, sector)
remediated_c13 = { remediated_c13 = {
"id": "ADV-013", "candidate_kind": "discard", "identity_status": "discarded", "id": "ADV-013",
"disposition": "discard", "audit_status": "pending", "candidate_kind": "discard",
"identity_status": "discarded",
"disposition": "discard",
"audit_status": "pending",
"conflicting_anchors": ["city", "industry_sector"], "conflicting_anchors": ["city", "industry_sector"],
"direct_observations": ["Ficha mercantil en Bogotá (Calle 74) con actividad CIIU 7730 (alquiler de maquinaria)"] "direct_observations": [
"Ficha mercantil en Bogotá (Calle 74) con actividad CIIU 7730 (alquiler de maquinaria)"
],
} }
passed_good, reason_good = auditor.audit_candidate(remediated_c13, {}) passed_good, reason_good = auditor.audit_candidate(remediated_c13, {})
assert passed_good and remediated_c13["disposition"] == "discard" assert passed_good and remediated_c13["disposition"] == "discard"
results["13. Metadata claim without observation"] = "PASS (auditor caught unsupported tax_id assertion; remediated to verified anchors)" results["13. Metadata claim without observation"] = (
"PASS (auditor caught unsupported tax_id assertion; remediated to verified anchors)"
)
return results return results