"""Measure the pinned OKF corpus against the CURRENT parser. No src/ changes.""" import os, sys, collections sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src")) from llm_ingestion_guard import okf ROOT = os.path.join(os.path.dirname(__file__), "corpus", "okf", "bundles") def docs(): out = [] for dirpath, _dirnames, filenames in os.walk(ROOT): for fn in sorted(filenames): if not fn.endswith(".md"): continue if fn in ("index.md", "log.md"): continue out.append(os.path.join(dirpath, fn)) return sorted(out) def main(): paths = docs() ok, fail = [], [] reasons = collections.Counter() for p in paths: with open(p, encoding="utf-8") as fh: text = fh.read() try: okf.parse_frontmatter(text) ok.append(p) except okf.OKFFrontmatterError as exc: fail.append((p, str(exc))) reasons[str(exc).split(":")[0]] += 1 print("denominator: %d documents" % len(paths)) print("parse OK : %d" % len(ok)) print("parse FAIL : %d" % len(fail)) print("--- failure classes ---") for r, c in reasons.most_common(): print("%4d %s" % (c, r)) print("--- passing documents (positive control) ---") for p in ok: print(" " + os.path.relpath(p, ROOT)) print("--- first 8 failures verbatim ---") for p, e in fail[:8]: print(" %s\n %s" % (os.path.relpath(p, ROOT), e)) main()