File size: 2,183 Bytes
1d9bd9b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | """CP-A regression test: the render-from-ledger gate drops hallucinated / un-loaded / fabricated claims.
Imports serve (loads the index/models) but only exercises verify_claims (pure)."""
import serve
cases = [
{"case_name": "A v B", "neutral_citation": "2020 INSC 1",
"chunk": "The dying declaration can be the sole basis of conviction if it inspires full confidence of the court."},
{"case_name": "C v D", "neutral_citation": "2020 INSC 2",
"chunk": "Corroboration of a dying declaration is only a rule of prudence."},
]
arr = [
{"claim": "A dying declaration can be the sole basis of conviction.", "n": 1,
"quote": "sole basis of conviction if it inspires full confidence"}, # VALID — verbatim substring of case 1
{"claim": "Corroboration is mandatory in every case.", "n": 2,
"quote": "corroboration is mandatory and always required"}, # HALLUCINATED quote — not in case 2
{"claim": "Some invented holding from a case that was never loaded.", "n": 5,
"quote": "anything"}, # OUT-OF-RANGE [n]
{"claim": "A fabricated proposition.", "n": 1,
"quote": "this exact sentence does not appear in the loaded text"}, # FABRICATED quote
]
arr += [
{"claim": "Bool-n bypass attempt.", "n": True,
"quote": "sole basis of conviction if it inspires full confidence"}, # BOOL n — isinstance(True,int) is True; must drop
{"claim": "Trivial-substring bypass.", "n": 1, "quote": "the court"}, # SHORT quote (<4 words) — substring of almost anything; must drop
]
verified, dropped = serve.verify_claims(arr, cases)
print("verified claims:", [v["claim"] for v in verified])
print("dropped:", dropped)
assert len(verified) == 1 and verified[0]["n"] == 1, "FAIL: gate did not keep exactly the one grounded claim"
assert dropped == 5, f"FAIL: expected 5 dropped (hallucinated quote, out-of-range n, fabricated quote, bool-n, short-quote), got {dropped}"
print("PASS: hallucinated quote, out-of-range n, fabricated quote, bool-n, and trivial short-quote ALL dropped; only the verbatim-grounded claim survives.")
|