"""Checks for the LumenDesk 2.0 editorial package (Python standard library only). Run from anywhere; expects article.md and metadata.json beside this script. The citation check also needs the task's inputs/ folder one level above output/; if it is not there, that check is reported as SKIPPED rather than passed. """ import json, re, os base = os.path.dirname(os.path.abspath(__file__)) art = open(os.path.join(base, "article.md"), encoding="utf-8").read() meta = json.load(open(os.path.join(base, "metadata.json"), encoding="utf-8")) def wc(text): return len(re.findall(r"[A-Za-z0-9][A-Za-z0-9.'’\-]*", text)) lines = art.splitlines() h1 = [l for l in lines if l.startswith("# ")][0][2:].strip() body_no_h1 = "\n".join(l for l in lines if not l.startswith("# ")) body_no_heads = "\n".join(l for l in lines if not l.startswith("#")) cite_re = re.compile(r"\((S\d-[a-z\-]+\.md), \"([^\"]+)\"\)") no_cites = cite_re.sub("", art) no_cites_no_heads = cite_re.sub("", body_no_heads) counts = { "whole file incl. H1, subheads, citations": wc(art), "excluding H1": wc(body_no_h1), "excluding all headings": wc(body_no_heads), "whole file excluding inline citations": wc(no_cites), "excluding headings and inline citations": wc(no_cites_no_heads), "whitespace-split whole file": len(art.split()), "whitespace-split, no headings, no citations": len(no_cites_no_heads.split()), } print("WORD COUNTS (article.md; need 600-800)") for k, v in counts.items(): print(" %-46s %d %s" % (k, v, "ok" if 600 <= v <= 800 else "OUT OF RANGE")) print("METADATA") print(" keys:", sorted(meta.keys())) hl, ex, sd = len(meta["headline"]), len(meta["excerpt"].split()), len(meta["search_description"]) print(" headline chars:", hl, "ok" if 50 <= hl <= 70 else "OUT OF RANGE") print(" headline matches article H1:", meta["headline"] == h1) print(" excerpt words:", ex, "ok" if ex <= 45 else "OUT OF RANGE") print(" search_description chars:", sd, "ok" if 140 <= sd <= 160 else "OUT OF RANGE") print("CITATIONS") cites = cite_re.findall(art) inp = os.path.join(base, "..", "inputs") if os.path.isdir(inp): headings = {} for fn in os.listdir(inp): txt = open(os.path.join(inp, fn), encoding="utf-8").read() headings[fn] = [l[3:].strip() for l in txt.splitlines() if l.startswith("## ")] ok = True for fn, sec in cites: good = fn in headings and sec in headings[fn] ok = ok and good if not good: print(" BAD CITATION:", fn, sec) print(" inline citations:", len(cites), "| all resolve to a real file + section heading:", ok) else: print(" SKIPPED: inputs/ not found at", os.path.normpath(inp)) print(" files cited:", sorted(set(f for f, _ in cites))) paras = [p for p in art.split("\n\n") if p.strip() and not p.startswith("#")] print(" body paragraphs:", len(paras), "| with a citation:", sum(1 for p in paras if cite_re.search(p))) print("EXCLUDED-CLAIM SCAN (article + metadata; expect all absent)") blob = (art + " " + json.dumps(meta)).lower() for term in ["gdpr", "offline", "60%", "60 percent", "hallucinat", "fired", "paperwork department", "certified", "we tested", "i tested", "in my testing", "in our testing", "hands-on", "annual plan", "free trial", "s5-internal"]: print(" %-22s %s" % (term, "FOUND" if term in blob else "absent")) print(" 'USD 19' occurrences:", blob.count("usd 19"), "(expected 1, in the correction paragraph only)") print(" 'USD 29' occurrences:", blob.count("usd 29")) print("FIGURES PRESENT IN ARTICLE (each should appear)") for fig in ["USD 29", "three-seat minimum", "500 document uploads", "USD 0.08", "USD 12", "50 MB", "40 procurement packets", "50 minutes to 20", "six searchable", "Five answers", "30 days", "24 hours", "30 further days", "Q1 2027", "October 16, 2026", "October 17, 2026", "October 18, 2026", "USD 87", "USD 99", "waitlist"]: print(" %-24s %s" % (fig, "present" if fig in art else "MISSING")) print("ARITHMETIC") print(" 3 seats x 29 =", 3 * 29, "| + OCR 12 =", 3 * 29 + 12) print(" vendor draft-time change: 50 -> 20 min =", 50 - 20, "min,", round((50 - 20) / 50 * 100), "% of median draft time (percentage kept out of article)") orig = os.path.join(base, "original-submission") print("ORIGINAL SUBMISSION PRESERVED:", sorted(os.listdir(orig)) if os.path.isdir(orig) else "NOT FOUND")