# -*- coding: utf-8 -*-
import json, os, re, sys, io, pathlib, datetime
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
BASE = pathlib.Path(r"D:\work buddy\2026-11-05-14-15-52")
M = BASE / "index_main.html"
mt = datetime.datetime.fromtimestamp(M.stat().st_mtime).strftime("%Y-%m-%d %H:%M:%S")
b = json.load(open(BASE / "_heartbeat_baseline.json", encoding="utf-8"))
b["round"] = 342
b["timestamp"] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
b["main_file_mtime"] = mt
b["main_file_bytes"] = M.stat().st_size
b.update({"programs": 1440, "catd": 2817, "vd": 1547, "dead_links": 0, "exclude_residue": 0,
          "details_on_disk": 3776, "http": "200 @ http://127.0.0.1:8000/index_main.html",
          "density_grade": {"A": 98, "B": 220, "C": 1122}})
b["actions_this_round"] = [
 "r342（13:58）只读基线：四脚本全绿，计数与 r341 一致（36 校 / PROGRAMS 1440 / CATD 2817 / VD 1547 / 死链 0 / node exit 0）。",
 "r342 新增 GaTech 官方口径三源：Bursar「Tuition and Fees Fall 2026」（/Fall_2026，含各学院专业费率）、Catalog「English Language Proficiency」、Catalog「Graduate Process Requirements」；可成组复用于 GaTech 其余条目。",
 "r342 闭环 8 条（全部 detail_render.py 生成、_density_check 复核 A）：gatech-cs-ms 11/11、gatech-stat-ms 11/11、gatech-hci-ms 11/11、gatech-analytics-ms 10/11、gatech-me-ms 10/11、gatech-bioinfo-ms 10/11、cornell-mps-acct 10/11、nyu-msacc 9/11。",
 "r342 主页面同字段回填：8 条 ddl / lang / test.cls / tui 由「待补」改为官网口径（GaTech 三档费率按项目分别落入 MSANLT/MSBINF/MSHCI 专业费率与标准 Graduate 费率）。",
 "r342 密度复核：A 由 90 升至 98，B 220、C 1122，需重做 1342 条；_density_report.json 已重写。",
 "r342 清理：删除 4 个误生成的孤儿页（gatech-stat-ms / gatech-me-ms / gatech-bioinfo-ms / gatech-hci-ms.html），details 磁盘数回到 3776。",
]
notes = [
 "r342 卡点：GaTech Catalog 除 MSCS（明写 February 1）外，其余项目页均未列申请截止与轮次 → 统一标「官网未披露」，不臆造。",
 "r342 卡点：GaTech 语言页把 TOEFL 档写成 Overall ≥4.5（疑为 TOEFL Essentials 口径），分项 S3.5/W4/L4/R4；已按官网原文照录并注明「以官网原文为准」。",
 "r342 卡点：JHU Carey（carey.jhu.edu）仍 Cloudflare 403，jhu-msf 本轮未能取官网数据，留待后续。",
 "r342 判定：GaTech MS Statistics 与 MSME 未列入 Graduate Professional Program Rates，按标准 Graduate（Master & PhD）费率回填；MSANLT / MSBINF / MSHCI 有单列专业费率。",
]
for n in notes:
    if n not in b["blocked_notes"]:
        b["blocked_notes"].append(n)
json.dump(b, open(BASE / "_heartbeat_baseline.json", "w", encoding="utf-8"), ensure_ascii=False, indent=2)
print("baseline r342", b["timestamp"], mt, M.stat().st_size)

# 台账追加
led = BASE / "项目库扩充方案与进度台账.md"
txt = led.read_text(encoding="utf-8")
anchor = "## 八、决策层指令"
if "r342 密度验收批次" not in txt:
    entry = (
        "- **r342 密度验收批次（2026-12-02 13:58，8 条）**：按 `_density_report.json` grade!=A + 热门优先取 8 条，全部"
        "由 `detail_render.py` + `_tpl_detail.html` 生成，`_density_check.py` 复核均达 A（全库 A 90→98）："
        "① GaTech MSCS 11/11（三毕业路径 + 11 方向课程号）；② GaTech MS Statistics 11/11；③ GaTech MS-HCI 11/11（四方向 36 学分）；"
        "④ GaTech MS Analytics 10/11（MSANLT 专业费率 $1,259/$1,862/$1,917 每学分）；⑤ GaTech MSME 10/11（主修 21+辅修 6+数学 3）；"
        "⑥ GaTech MS Bioinformatics 10/11（MSBINF 专业费率 $713/$1,686/$1,736）；⑦ Cornell MPS Management–Accounting 10/11"
        "（Est. Total Tuition $74,472、四轮截止 2026-12-01/2027-01-15/2027-03-01/2027-04-15、Class of 2025 就业 95% offer / 94% accept、"
        "美国平均 base $77,032）；⑧ NYU Stern MS Accounting 9/11（学费 $68,684、官方预算合计 $115,154、国际 2026-11-15 截止、"
        "Class of 2026 96% 四个月内 offer / 64% 四大）。"
        "同轮建立 GaTech 官方三源基线（Bursar Fall 2026 全表含 MSANLT/MSBINF/MSHCI 专业费率、Catalog 语言页、Catalog 研究生申请流程页），"
        "GaTech 其余条目可成组复用。主页面 ddl/lang/test/tui 已同字段回填；PROGRAMS 1440 / CATD 2817 / VD 1547 不变，死链 0、node exit 0、`}{` 0。"
        "卡点：GaTech 除 MSCS 外未列截止；JHU Carey 仍 403；GaTech 语言页 TOEFL 档疑为 Essentials 口径，按原文照录。\n"
    )
    txt = txt.replace(anchor, entry + "\n" + anchor, 1)
led.write_text(txt, encoding="utf-8")
print("ledger updated", led.stat().st_size)
