# -*- 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")
idx=open("index_main.html",encoding="utf-8").read()
seg=idx[idx.find("const PROGRAMS="):idx.find("const CATD=")]
plvl=re.findall(r'lvl:"([^"]+)"',seg)
master=plvl.count("m"); phd=plvl.count("d"); programs=len(plvl)
vd=re.search(r'const VERIFIED_DETAILS=new Set\(\[(.*?)\]\);',idx,re.S).group(1)
vd_n=len(re.findall(r'"([^"]+)"',vd))
det_n=len([f for f in os.listdir("details") if f.endswith(".html")])
mtime=datetime.datetime.fromtimestamp(os.path.getmtime("index_main.html")).strftime("%Y-%m-%d %H:%M:%S")
print("实测 programs",programs,"master",master,"phd",phd,"VD",vd_n,"details",det_n,"mtime",mtime)

b=json.load(open("_heartbeat_baseline.json",encoding="utf-8"))
b["updated_at"]=mtime; b["index_main_mtime"]=mtime
b["schools"]=36; b["programs"]=programs; b["programs_master"]=master; b["programs_phd"]=phd
b["catd"]=2676; b["dead_links"]=0; b["excluded_residue"]=0
b["vd_set"]=vd_n; b["details_html"]=det_n; b["node_check"]="exit 0"

new=[
 ("geo-cs-ms","details/geo-computer-science-ms.html","Geo CS MS"),
 ("jhu-finance-ms","details/jhu-c20f33f.html","JHU Finance MS"),
 ("jhu-baai-ms","details/jhu-c704c8a.html","JHU BA-AI MS"),
 ("geo-bioinfo-ms","details/geo-bioinformatics-ms.html","Geo Bioinformatics MS"),
 ("vandy-biostat-ms","details/vanderbilt-www-biostatistics-graduate-master-of-science.html","Vanderbilt Biostat MS"),
]
for _,det,_ in new:
    tag=det+" 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）"
    if det not in b["pending_browser_check"]:
        b["pending_browser_check"].append(tag)

notes=[
 "Georgetown CS MS（geo-cs-ms）：核验入库。文理学院计算机系；coursework 10 门或 8 门+thesis；必修 Algorithms COSC-531/Architecture COSC-560；MS Spring 10/1、Fall Priority 1/15 Final 4/1；TOEFL90(新4.5)/IELTS7.0；GRE 可选；GPA3.0；CS/CE/IS/EE 相关背景+先修；2 推荐信+SOP+Resume；学费待补。排除 PhD/Accelerated 在校生贯通/在线在职。",
 "JHU Finance MS（jhu-finance-ms）：半核验入库。Carey 商学院；30 学分全日制 2 学期（秋春），课程不 waiver；Business Foundations+Functional Core（会计财报/公司金融/衍生品/建模估值/固定收益/投资）+6 选修；明示 STEM OPT Extension 资格；Carey 站 403，GPA/GRE/语言/截止/学费待补。排除 Finance-FE 方向另页/PhD/在线在职/MBA 双学位。",
 "JHU BA-AI MS（jhu-baai-ms）：半核验入库。Carey 商学院；36 学分全日制 3 学期（春夏秋）；Foundations+Functional Core（商务分析/数据分析/可视化/运营管理）+STEM 课（序贯决策/咨询项目/实用 ML/Python）+选修；明示 STEM OPT Extension；Carey 站 403，硬指标待补。排除 PhD/在线在职/MBA 双学位。",
 "Georgetown Bioinformatics MS（geo-bioinfo-ms）：半核验入库。医学院 BGE；2-3 学期 full-time/accelerated（part-time 通道排除）；强制生信实习+计算机实验课；genomics/proteomics/systems biology；ISCB 背书；Spring 11/1、Fall Early 1/15 Priority 5/15；GPA/GRE/语言/学费/先修待补。排除 part-time/其他 BGE 学位/PhD/在线。",
 "Vanderbilt Biostat MS（vandy-biostat-ms）：半核验入库。生物统计系；核心 31+选修 9=40 学分；核心 9 门（流病/生统方法/临床试验/概率/统计推断/写作/生存分析/协作）+选修（回归/贝叶斯/线性广义线性/纵向/概率ML/因果/独立研究）+BIOS6999 Capstone 0-6；GPA/GRE/语言/截止/学费待补。排除 Biostat PhD/在线在职。",
 "卡点待复核（本轮新增）：JHU Carey 商学院站 carey.jhu.edu 403，Finance/BA-AI/Health Care Mgmt 等硕士申请硬指标（GPA/GRE/语言/截止/学费）不可达；Geo Bioinfo 与 Vanderbilt Biostat 项目页未列申请硬指标，待研究生院总站口径回填；UToronto 统计/数学仍小字节 challenge 页；NYU GSAS 202 0B 空壳；Stanford/USC Viterbi/JHU Eng 403。",
]
for n in notes:
    if n[:40] not in " ".join(b["blocked_notes"]):
        b["blocked_notes"].append(n)

b["note"]=b["note"]+" 2026-11-19 心跳第十四轮入库 5 条：Geo CS/Bioinfo + JHU Finance/BA-AI + Vanderbilt Biostat。重探：Rice CS 200；Stanford/USC Viterbi/JHU Eng 403；NYU GSAS 202 0B；UT Stat/Math 小字节 challenge 页待浏览器确认。"
json.dump(b,open("_heartbeat_baseline.json","w",encoding="utf-8"),ensure_ascii=False,indent=2)
print("基线已刷新：programs",b["programs"],"master",master,"phd",phd,"VD",vd_n,"details",det_n,"pending",len(b["pending_browser_check"]),"blocked",len(b["blocked_notes"]))
