#!/usr/bin/env python3 """An independent probe of receipt_gate v5.6: does a citation prefix hide a broken value? The published claim is a rule, not a list: "the marker no longer changes the gate — it changes only what is cut; the scan of the remainder gives the full verdict". So the property to test is over the product of prefixes and broken values, not over the eleven prefixes the author listed. A cell is a concealment when a line carrying a value their own grammar rejects is reported clean. The inverse controls are the honest lines: prose that names a word and carries no broken value must stay clean, or the rule is a blanket refusal rather than a check. """ from __future__ import annotations import importlib.util import pathlib import sys HERE = pathlib.Path(__file__).resolve().parent spec = importlib.util.spec_from_file_location("receipt_gate_v56", HERE / "receipt_gate_v56.py") gate = importlib.util.module_from_spec(spec) spec.loader.exec_module(gate) # Their eleven, for parity, plus shapes that a writer reaches for as naturally. PREFIXES = [ "", "'", '"', "«", "`", "цитата: ", "#12 ", "#12 " + "слово ", '#12 "', "«#12 ", '#12 "слово ', # beyond their list "[12] ", "№12 ", "12. ", "12) ", "(12) ", "• ", "— ", "> ", ">> ", "- ", "* ", "**#12** ", "#12: ", "#12, ", "#12 — ", "##12 ", "№12: ", "см. #12 ", "пост #12 ", "\t", " ", "#12 ", "цитата из #12: ", "см. «", '#12 ' + "=" , "[12] ", "#12→ ", ] # (word, broken value, the class their grammar must report, a clean honest control line) CLASSES = [ ("bytes", "abc", "receipt-bad-count", "bytes: 4096"), ("размер", "abc", "receipt-bad-count", "размер: 4096"), ("retrieved_at", "мусор", "receipt-bad-time", "retrieved_at: 2026-09-10T20:09:57Z"), ("итог retrieved_at", "мусор", "receipt-bad-time", "итог retrieved_at: 2026-09-10T20:09:57Z"), ("sha256", "xyz123", "receipt-bad-hash", "sha256: " + "a" * 64), ("адрес", "notaurl", "receipt-bad-url", "адрес: https://paste.rs/jL4bx"), ] def verdict(line: str) -> str: got = gate.receipt_gate(line) return got[0][0] if got else "чисто" def main() -> int: concealed, wrong_class, controls_dirty = [], [], [] cells = 0 for prefix in PREFIXES: for word, bad, expected, good in CLASSES: cells += 1 line = f"{prefix}{word}: {bad}" seen = verdict(line) if seen == "чисто": concealed.append((line, expected)) elif seen != expected: wrong_class.append((line, seen, expected)) # the honest line under the same prefix: a word and a value of the right shape for word, _bad, _expected, good in CLASSES: cells += 1 line = f"{prefix}{word}: {good.split(': ', 1)[1]}" if verdict(line) != "чисто": controls_dirty.append((line, verdict(line))) print(f"cells: {cells} prefixes: {len(PREFIXES)} classes: {len(CLASSES)}") print(f"concealments (broken value reported clean): {len(concealed)}") for line, expected in concealed[:20]: print(f" CONCEALED {line!r} — expected {expected}") print(f"wrong class: {len(wrong_class)}") for line, seen, expected in wrong_class[:20]: print(f" {line!r} → {seen}, expected {expected}") print(f"honest lines refused: {len(controls_dirty)}") for line, seen in controls_dirty[:20]: print(f" {line!r} → {seen}") return 0 if not concealed else 1 if __name__ == "__main__": sys.exit(main())