# -*- 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=[
 ("vandy-mscs","details/vanderbilt-engineering-departments-computer-science-graduate.html","Vandy MS CS 在校"),
 ("vandy-mscee","details/vanderbilt-engineering-departments-civil-environmental-engineering.html","Vandy MS CEE"),
 ("vandy-msmse","details/vanderbilt-engineering-materials-science.html","Vandy MS IMS"),
 ("jhu-ams-mse","details/jhu-c467c7b.html","JHU MSE AMS"),
 ("jhu-bme-mse","details/jhu-c77beb0.html","JHU MSE BME"),
]
for _,det,_ in new:
    tag=det+" 浏览器实开待后端会话恢复后补核（六卡静态核对已通过）"
    if det not in b["pending_browser_check"]:
        b["pending_browser_check"].append(tag)

notes=[
 "Vanderbilt MS Computer Science（vandy-mscs）：核验入库。新 College of Connected Computing 在校 MS；30cr；1.5–2 年；Thesis/Portfolio 两 track，1:1 advisor；Spring 10/15、Fall priority 1/15、regular 3/1；TOEFL 约 90（单项≥4.0）/IELTS 7.0（单项≥6.0）/DET 130；境外学位需 WES/NACES 认证；MS 打包学费待补；方向 AI/ML、机器人自主系统、软件云、医学影像计算。排除 Online CS MS、Online AI MS、CS PhD、part-time。",
 "Vanderbilt MS Civil and Environmental Engineering（vandy-mscee）：核验入库。CEE 系；Thesis/Non-thesis；方向 M&S、Environmental、CIS；Thesis 最快三学期+一夏；GRE notreq；总站语言 89/7.0/130；MS priority 1/8、final 3/15；学费待补。排除 CEE MEng（含 Construction Management）、CEE PhD、在线 part-time。",
 "Vanderbilt MS Interdisciplinary Materials Science（vandy-msmse）：核验入库。IMS 跨学科项目；24 课程学分+thesis+≥6 研究学分，公开答辩无资格考试；跨 Chem/Phys/Medicine/各工程系；GRE notreq；总站语言 89/7.0/130；MS 截止走总站口径（系站仅列 PhD 截止）；学费待补。排除 IMS PhD、在线 part-time。",
 "JHU MSE Applied Mathematics and Statistics（jhu-ams-mse）：半核验入库。Whiting AMS 系；至少两学期全日制；8 门研究生课，系外≤3 门，研究/实习课不计入；catalogue 未列截止/语言/GRE/学费，均待补；STEM 未明示标 0。排除同系 DS MSE、FinMath MSE、AMS PhD、在线 part-time。",
 "JHU MSE Biomedical Engineering（jhu-bme-mse）：半核验入库。BME 系；course-based 30cr 或 thesis 30cr+thesis 第二年；面向 R&D 或 PhD/MD-PhD 跳板；无系内资助，外部资助可申；截止通常 1 月上旬（每年更新）；语言/GRE/学费打包 catalogue 未列待补；STEM 未明示标 0。排除 BME 系 Innovation and Design MSE、BME PhD、MD 临床执业、在线 part-time。",
 "卡点待复核（本轮更新）：JHU AMS/BME 系站 bme.jhu.edu 等不可达，硬指标仅来自 e-catalogue，截止/语言/GRE/学费待系站恢复回填；Vandy 工程 MS/IMS 打包学费官网未单列待补；Vandy CS MS 项目页未列 GRE，暂按工程学院 notreq 口径待确认。",
]
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 条：Vandy CS/CEE/IMS MS + JHU AMS/BME MSE。重探：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"]))
