Commit bf0fe57c authored by 郭阔's avatar 郭阔

fix(panel): anchor disk phase evidence to heartbeat mtime, not run start

On auto-retry, attempt2 resets the heartbeat to 采集中 and refetches, but
attempt1's completion files (registry etc.) are newer than the run start —
they overrode the fresh heartbeat and showed 推送/收尾 while the browser
was actively fetching. Disk evidence must beat the heartbeat's own mtime
to override; attempt resets naturally re-anchor the baseline.
parent 6f217f2e
......@@ -592,35 +592,38 @@ def _harvest_phase(source):
except OSError:
return None, None
# 1) 真实阶段文件(进程自己写的)——但仅当它比磁盘证据新时才采信
# (会话偶尔忘记翻牌,磁盘信号(manifest/summaries/registry)是客观事实)
# 1) 真实阶段文件(进程自己写的)——磁盘证据必须比心跳最后写入时间新才能覆盖它。
# 基准锚在心跳而非任务开始:自动重试的 attempt2 会重置心跳为"采集中"重新抓取,
# attempt1 的收尾文件(registry 等)虽比任务开始新,但比新心跳旧,不得污染新阶段。
phase_file = LOG_DIR / f"{source}.phase"
hb_txt, hb_mtime = "", None
if phase_file.exists():
try:
hb_txt = phase_file.read_text(encoding="utf-8").strip()
hb_mtime = mtime(phase_file)
except OSError:
hb_txt, hb_mtime = "", None
baseline = hb_mtime or start
def disk_phase_and_mtime():
if not (day_dir and day_dir.is_dir()):
return None, None
reg = mtime(day_dir / "registry.json")
if reg and reg > start:
if reg and reg > baseline:
return "推送/收尾", reg
summ = mtime(day_dir / ".summaries.json")
if summ and summ > start:
if summ and summ > baseline:
return "摘要生成", summ
mani = mtime(day_dir / ".manifest.json")
if mani and mani > start:
if mani and mani > baseline:
return "摘要生成", mani
return None, None
phase_file = LOG_DIR / f"{source}.phase"
hb_txt, hb_mtime = "", None
if phase_file.exists():
try:
hb_txt = phase_file.read_text(encoding="utf-8").strip()
hb_mtime = mtime(phase_file)
except OSError:
hb_txt, hb_mtime = "", None
dp, dp_mtime = disk_phase_and_mtime()
if hb_txt and hb_mtime:
if not dp or hb_mtime >= dp_mtime:
return start, hb_txt
return start, dp # 心跳比磁盘证据旧:信磁盘
return start, dp # 磁盘证据比心跳新:信磁盘(会话忘翻牌的场景)
if dp:
return start, dp
# 3) 无信号:中性显示,不猜
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment