Files
blog-app/.review-tmp/build2-summary.md
2026-08-17 17:11:27 +08:00

3.7 KiB

Build2 Verification Summary — Flask /watchdog page + manual trigger

What was added / changed

app.py (additive to existing routes; watchdog section lines 225-320)

  • WATCHDOG_DB = os.path.expanduser("~/opencode-blog-showcase/data/watchdog.db") — line 23
  • WATCHDOG_RUN_LOG — lines 27-29
  • get_watchdog_db() — line 234: opens watchdog.db read-only via sqlite3.connect(f"file:{WATCHDOG_DB}?mode=ro", uri=True) (line 237)
  • _load_watchdog_reports(days=7) — line 243: returns [] when db/table missing (never 500); parses meta_json into meta
  • GET /watchdog (page_watchdog) — line 267: renders watchdog.html with up to 7 reports
  • _is_watchdog_running() — line 273: pgrep guard against duplicate runs
  • POST /watchdog/run (watchdog_run) — line 294:
    • 60s single-flight via module-level _last_watchdog_trigger_ts (line 230); repeat within 60s → 429 "操作太频繁, 请稍后再试" (line 299)
    • timestamp set before the running-check so the cooldown engages even when the script is already running (fix applied during this build)
    • os.makedirs(os.path.dirname(WATCHDOG_RUN_LOG), exist_ok=True) (line 308) before opening the run log
    • subprocess.Popen(["/usr/bin/python3", scripts/daily_watchdog.py], cwd=BASE_DIR, env HOME=/home/yi, stdout=log_f, stderr=STDOUT, start_new_session=True) — no wait
    • flash "已触发, 约 1-2 分钟后刷新页面查看新报告" (line 317) → redirect /watchdog

templates/watchdog.html

  • Title <h1>升级迭代日报</h1> (line 7)
  • "立即运行" form POST /watchdog/run (lines 10-12)
  • Empty state: alert alert-info "暂无报告, 点击立即运行生成第一份日报" (line 17)
  • Report cards: header = date + created_at, body = <pre class="watchdog-md"> of markdown (lines 21-45)

templates/base.html

  • Nav link <li class="nav-item"><a class="nav-link" href="/watchdog">日报</a></li> after 全局搜索 (line 22)

Verification evidence (verbatim key lines)

1. py_compile

PY_COMPILE_OK

2. deploy

local:200

3. GET /watchdog

http:200
升级迭代日报
2026-08-16
sst/opencode
立即运行
href="/watchdog">日报

4. POST /watchdog/run (first) + immediate repeat

http:200
已在运行中, 本次触发被忽略
http:429
操作太频繁, 请稍后再试
  • The "已触发" spawn path was proven earlier: run log line 1 2026-08-16 17:05:19 [INFO] Starting daily watchdog for 2026-08-16 was spawned by the first POST (script self-locks; left running per spec).

5. Regression

/ -> 200
/projects -> 200
/search -> 200
/analyze -> 200
{"total_issues":14,"total_projects":3,"total_releases":14,"total_stars":430166}

6. LAN

lan:200

Issues encountered

  1. curl -X POST -L returns 405 on the redirect follow: -X POST forces curl to re-send POST on the 302 → /watchdog only accepts GET → 405. The POST itself succeeded (spawned the script). Used -d '' -L (follows 302 with GET) for correct verification.
  2. Sibling build1 agent ran concurrently: it kept POSTing /watchdog/run for its own verification, re-triggering the script and resetting the 60s cooldown (causing intermittent 429s on the "first" POST) and overwrote templates/base.html at 17:06:48 (reverting the nav label to "Watchdog"). Re-applied the 日报 label and redeployed; final state verified.
  3. Cooldown gap fixed: when the script was already running, the "已在运行中" branch returned before setting _last_watchdog_trigger_ts, so repeated POSTs never hit 429. Moved the timestamp assignment before the running-check.
  4. GitHub API rate limit: the sibling's repeated script runs exhausted the GitHub commits API (403 in run log) — unrelated to this build's code.