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")