---
type: "Source File"
title: "!/usr/bin/env python3"
description: "#!/usr/bin/env python3 \"\"\"Final live verification after the 410 change and Tier 1+2 noindexing.\"\"\" import concurrent.futures as cf import os import re import sqlite3 import sys import time import urllib.error import."
resource: "https://www.copecheck.com"
tags: ["copecheck", "main", "source-file", "py"]
timestamp: "2026-09-25T21:08:54Z"
site: "main"
source_path: "copecheck/verify_final.py"
---

# !/usr/bin/env python3

Source path: `copecheck/verify_final.py`  
Index snapshot generated: `2026-11-24T13:42:54Z`  
File modified: `2026-09-25T21:08:54Z`

```py
#!/usr/bin/env python3
"""Final live verification after the 410 change and Tier 1+2 noindexing."""
import concurrent.futures as cf
import os
import re
import sqlite3
import sys
import time
import urllib.error
import urllib.request

HERE = os.path.dirname(os.path.abspath(__file__))
DB = os.path.join(HERE, "data", "copecheck.db")
BASE = "http://localhost:8096"
c = sqlite3.connect(f"file:{DB}?mode=ro", uri=True)
c.row_factory = sqlite3.Row
PASS, FAIL = [], []


def check(n, cond, d=""):
    (PASS if cond else FAIL).append(n)
    print(f"  [{'PASS' if cond else 'FAIL'}] {n} {d}")


def get(path):
    req = urllib.request.Request(BASE + path,
                                 headers={"User-Agent": "CopeCheckProbe/1.0"})
    try:
        r = urllib.request.urlopen(req, timeout=30)
        return r.status, r.read().decode("utf-8", "replace")
    except urllib.error.HTTPError as e:
        return e.code, ""
    except Exception as e:
        return f"ERR:{type(e).__name__}", ""


def code(slug):
    return get(f"/v/{slug}")[0]


def sample(label, sql, n, expect):
    slugs = [r["slug"] for r in c.execute(sql + f" LIMIT {n}").fetchall()]
    if not slugs:
        print(f"  [SKIP] {label} (no rows)")
        return
    counts = {}
    with cf.ThreadPoolExecutor(4) as ex:
        for st in ex.map(code, slugs):
            counts[st] = counts.get(st, 0) + 1
    bad = {k: v for k, v in counts.items() if k not in expect}
    check(f"{label} (n={len(slugs)})", not bad,
          f"{dict(sorted(counts.items(), key=str))}")
    time.sleep(1)


print("=" * 68)
print("SITEMAP")
print("=" * 68)
st, sm = get("/sitemap.xml")
locs = re.findall(r"<loc>([^<]+)</loc>", sm)
vslugs = {u.rsplit("/v/", 1)[1] for u in locs if "/v/" in u}
check("sitemap returns 200", st == 200)
check("sitemap is well-formed XML", sm.strip().startswith("<?xml")
      and sm.strip().endswith("</urlset>"))
print(f"       total URLs: {len(locs)} ({len(vslugs)} article pages)")

demoted = [r["slug"] for r in c.execute(
    "SELECT slug FROM prune_batches WHERE rolled_back_at IS NULL")]
leaked = [s for s in demoted if s in vslugs]
check("NO demoted article appears in the sitemap", not leaked,
      f"{len(leaked)} leaked" if leaked else f"checked {len(demoted)} demoted")

allidx = {r["slug"] for r in c.execute(
    "SELECT slug FROM articles WHERE index_status IN ('index','trial_index')")}
nonidx = [s for s in vslugs if s not in allidx]
check("every sitemap article is currently indexable", not nonidx,
      f"{len(nonidx)} stale" if nonidx else "")

print("\n" + "=" * 68)
print("ROBOTS META — demoted pages must now say noindex")
print("=" * 68)
ok = 0
for s in demoted[:12]:
    _, html = get(f"/v/{s}")
    if 'content="noindex,follow"' in html:
        ok += 1
check("demoted pages emit noindex,follow", ok == 12, f"{ok}/12")

live = [r["slug"] for r in c.execute(
    "SELECT slug FROM articles WHERE index_status='index' LIMIT 12")]
noidx_leak = 0
for s in live:
    _, html = get(f"/v/{s}")
    if 'content="noindex' in html:
        noidx_leak += 1
check("still-indexed pages do NOT emit noindex", noidx_leak == 0,
      f"{noidx_leak} leaked")

print("\n" + "=" * 68)
print("READER-FACING: demoted pages must remain fully usable")
print("=" * 68)
codes, short = {}, 0
for s in demoted[:20]:
    st, html = get(f"/v/{s}")
    codes[st] = codes.get(st, 0) + 1
    if st == 200 and len(html) < 5000:
        short += 1
check("demoted articles still return 200", set(codes) == {200}, str(codes))
check("demoted articles still render the full verdict", short == 0,
      f"{short} short pages")

_, feed = get("/feed.xml")
infeed = sum(1 for s in demoted[:40] if s in feed)
print(f"       (informational) demoted slugs present in RSS feed: "
      f"{infeed}/40 — noindex does not remove them from the feed")

print("\n" + "=" * 68)
print("HTTP STATUS BY CLASS")
print("=" * 68)
sample("indexable -> 200",
       "SELECT slug FROM articles WHERE index_status IN "
       "('index','trial_index') ORDER BY RANDOM()", 120, {200, 301})
sample("demoted (now noindex) -> 200",
       "SELECT a.slug FROM articles a JOIN prune_batches p ON p.slug=a.slug "
       "WHERE p.rolled_back_at IS NULL ORDER BY RANDOM()", 100, {200})
sample("quarantined -> 410",
       "SELECT slug FROM articles WHERE status='quarantined' "
       "ORDER BY RANDOM()", 80, {410})
sample("never-analysed -> 410",
       "SELECT slug FROM articles WHERE status='pending' AND "
       "(verdict_md IS NULL OR trim(verdict_md)='') ORDER BY RANDOM()",
       80, {410})

print("\n" + "=" * 68)
print("SITE HEALTH")
print("=" * 68)
for p in ("/", "/about", "/instant", "/search?q=AI",
          "/figure/sam-altman", "/feed.xml", "/robots.txt", "/sitemap.xml"):
    st, _ = get(p)
    check(f"{p} -> {st}", st == 200)
check("unknown slug still 404s (not 410)",
      get("/v/__no-such-article-xyz")[0] == 404)

print("\n" + "=" * 68)
print(f"PASSED {len(PASS)}  FAILED {len(FAIL)}")
if FAIL:
    print("FAILURES:", FAIL)
c.close()
sys.exit(1 if FAIL else 0)
```
