From c1bf28f15b16b908debdfbc0a3326e341a4a4e2e Mon Sep 17 00:00:00 2001 From: zizi Date: Wed, 24 Jun 2026 12:57:14 +0000 Subject: [PATCH] =?UTF-8?q?fix(tier2):=20C1=20trace=20=E5=8A=A0=20workdir?= =?UTF-8?q?=20=E5=AD=98=E5=9C=A8=E5=AE=88=E5=8D=AB(=E5=85=8D=20scaffold=20?= =?UTF-8?q?=E5=89=8D=E5=88=B7=20FileNotFoundError)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 008 实证:首轮 scaffold_init 之前会有早期 SSE 事件,此时工程 workdir 还没建 → trace 追加写刷 FileNotFoundError(best-effort 已吞、但刷屏)。加守卫:dirname 不存在即静默跳过(不抢先建目录、 免干扰 scaffold 的"已存在不覆盖"逻辑)。scaffold 后正常落 trace。 Co-Authored-By: Claude Opus 4.8 (1M context) --- tier2/gen-worker/service/control_plane.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tier2/gen-worker/service/control_plane.py b/tier2/gen-worker/service/control_plane.py index 8a5d26a1..09151918 100644 --- a/tier2/gen-worker/service/control_plane.py +++ b/tier2/gen-worker/service/control_plane.py @@ -258,6 +258,11 @@ def _trace_sse_event(trace_path: Any, event: dict, elapsed_s: float, attempt: in return try: import json as _json # noqa: PLC0415 + import os as _os # noqa: PLC0415 + # 工程 workdir 尚未建(scaffold_init 之前的早期事件)→ 静默跳过,不抢先建目录(免干扰 scaffold 的 + # "已存在不覆盖" 逻辑),也免刷 FileNotFoundError(008 实证:首轮 scaffold 前会有这类早期事件)。 + if not _os.path.isdir(_os.path.dirname(trace_path)): + return rec = {"t": round(elapsed_s, 1), "attempt": attempt, **_compact_sse_event(event)} with open(trace_path, "a", encoding="utf-8") as f: f.write(_json.dumps(rec, ensure_ascii=False) + "\n")