# -*- coding: utf-8 -*-
import io, sys, os, re, json, datetime
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8")
os.chdir(r"D:\work buddy\2026-11-05-14-15-52")

b=json.load(open("_heartbeat_baseline.json",encoding="utf-8"))
idx=open("index_main.html",encoding="utf-8").read()
seg=idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
lvl=re.findall(r'lvl:"([^"]+)"',seg)
vd=re.findall(r'"([^"]+\.html)"',idx[idx.find("const VERIFIED_DETAILS="):])
details=len([f for f in os.listdir("details") if f.endswith(".html")])
mt=datetime.datetime.fromtimestamp(os.path.getmtime("index_main.html")).strftime("%Y-%m-%d %H:%M:%S")
b["updated_at"]=mt; b["index_main_mtime"]=mt
b["programs"]=len(lvl); b["programs_master"]=lvl.count("m"); b["programs_phd"]=lvl.count("d")
b["vd_set"]=len(set(vd)); b["details_html"]=details; b["node_check"]="exit 0"
for d in ["gatech-nuclear-engineering-ms","gatech-environmental-engineering-ms","gatech-chemistry-ms","gatech-management-ms","gatech-digital-media-ms"]:
    b["pending_browser_check"].append(f"details/{d}.html 浏览器实开待后端会话恢复后补核")
b["blocked_notes"].append("第五十轮：GaTech 核工程/环境工程/化学/管理/数字媒体 5 条硕士核验入库；Psychology MS 系 PhD 通道附带硕士（不接受 terminal master's），留批次5 博士补齐，本轮排除。")
b["note"]="第五十轮：GaTech 5 条入库（+5）。批次4 升级 / 批次5 博士补齐与终检未完成。"
json.dump(b,open("_heartbeat_baseline.json","w",encoding="utf-8"),ensure_ascii=False,indent=2)
print("基线:",b["programs"],"master",b["programs_master"],"phd",b["programs_phd"],"vd",b["vd_set"],"details",b["details_html"],"mtime",mt)
