Просмотр исходного кода

修复(可视化): 从 Root Trace 元数据识别 Build

优先读取 meta.json 受保护上下文中的 script_build_id,使 explicit 编排不依赖已取消生成的 goal.json。\n\n保留 GoalTree mission 和早期消息解析,仅用于旧持久化运行的兼容回退。
SamLee 7 часов назад
Родитель
Сommit
9a7e328b13
1 измененных файлов с 9 добавлено и 0 удалено
  1. 9 0
      visualization/backend/app/real_runs.py

+ 9 - 0
visualization/backend/app/real_runs.py

@@ -66,6 +66,15 @@ def _messages(root: Path, trace_id: str) -> list[dict[str, Any]]:
 
 
 def _build_id_for_root(root: Path, root_trace_id: str) -> int | None:
+    meta_path = root / "traces" / root_trace_id / "meta.json"
+    if meta_path.exists():
+        context = _read_json(meta_path).get("context")
+        if isinstance(context, dict):
+            build_id = context.get("script_build_id")
+            if isinstance(build_id, int) and not isinstance(build_id, bool):
+                return build_id
+
+    # Legacy traces may only expose the Build ID through GoalTree or early messages.
     goal_path = root / "traces" / root_trace_id / "goal.json"
     if goal_path.exists():
         match = BUILD_ID_PATTERN.search(str(_read_json(goal_path).get("mission", "")))