import glob,os,re,datetime,json
KW=re.compile(r"crack|damag|\bbroke|broken|chipped|\blump|knock|gouge|scrape|scratch|smash|\bdefect|rectif|repair|patch|make good|busted",re.I)
print("=== FAULT DOMAIN 2: the WRITEUPS (.md), 2636 ===")
n=0
for f in sorted(glob.glob("/root/.hermes/wa-bridge/days/2636_*_writeup.md")):
    txt=open(f,encoding="utf-8",errors="replace").read()
    b=os.path.basename(f)
    hits=[l.strip() for l in txt.split("\n") if KW.search(l)]
    print("  %-34s %6d bytes  %d damage lines" % (b,len(txt),len(hits)))
    for h in hits[:4]: print("       > "+h[:120]); n+=1
print("  writeup damage lines total:",n)
print()
print("=== COVERAGE: which 2636 days exist, and which are EMPTY ===")
days={}
for f in sorted(glob.glob("/root/.hermes/wa-bridge/days/2636_2026-*.jsonl")):
    d=os.path.basename(f).split("_")[1].replace(".jsonl","")
    days[d]=sum(1 for _ in open(f,encoding="utf-8"))
start=datetime.date(2026,7,17); end=datetime.date(2026,8,7)
d=start; missing=[]; empty=[]
while d<=end:
    k=d.isoformat()
    wd=d.strftime("%a")
    if k not in days:
        if wd not in ("Sat","Sun"): missing.append(k+" "+wd)
    elif days[k]==0: empty.append(k+" "+wd)
    d+=datetime.timedelta(days=1)
for k in sorted(days): print("   %s %s  %3d rows" % (k, datetime.date.fromisoformat(k).strftime("%a"), days[k]))
print("  WEEKDAYS WITH NO DAY-LOG AT ALL:", missing or "none")
print("  DAY-LOGS THAT ARE EMPTY       :", empty or "none")
print()
print("=== when did the kerb go in? (kerb/curb rows in date order) ===")
for f in sorted(glob.glob("/root/.hermes/wa-bridge/days/2636_*.jsonl")):
    for l in open(f,encoding="utf-8"):
        try: r=json.loads(l)
        except: continue
        blob=" ".join(str(r.get(k) or "") for k in ("text","desc","caption"))
        if re.search(r"kerb|curb",blob,re.I):
            print("   %s %s  %s" % (os.path.basename(f).split("_")[1][:10], r.get("t"), blob.strip()[:100]))
