| """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"}, |
| {"claim": "Corroboration is mandatory in every case.", "n": 2, |
| "quote": "corroboration is mandatory and always required"}, |
| {"claim": "Some invented holding from a case that was never loaded.", "n": 5, |
| "quote": "anything"}, |
| {"claim": "A fabricated proposition.", "n": 1, |
| "quote": "this exact sentence does not appear in the loaded text"}, |
| ] |
| arr += [ |
| {"claim": "Bool-n bypass attempt.", "n": True, |
| "quote": "sole basis of conviction if it inspires full confidence"}, |
| {"claim": "Trivial-substring bypass.", "n": 1, "quote": "the court"}, |
| ] |
| 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.") |
|
|