fix(agent): reconcile deployment from runtime status on read

真实生产模拟暴露:runtime 完成极快时,artifact.created/status callback 会与
runtime_swarm_id 映射的异步持久化竞态——callback 先到、按 swarm_id 匹配不到
deployment 而成孤儿,导致 deployment 永远停在 accepted、/artifacts 为空,
尽管 runtime 已 completed 且可直查到。

修复:detail / timeline / workflow / artifacts 读取时,对非终态且有 runtime
映射的 deployment 调 reconcileDeploymentFromRuntime——复用 diagnostics 的
runtime 状态直查,把终态 + 真实 artifact 反写落库,不再单依赖会丢/会竞态的 callback。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 00:05:43 +08:00
co-authored by Claude Opus 4.8
parent 0fe1d20d67
commit 443f552917
4 changed files with 103 additions and 0 deletions
@@ -1176,6 +1176,7 @@ func AgentGetDeployment(c *gin.Context) {
agentError(c, "DEPLOYMENT_CONFLICT", "deployment not found")
return
}
record = reconcileDeploymentFromRuntime(c.Request.Context(), record)
common.ApiSuccess(c, withDisplayStatus(record))
}
@@ -1184,6 +1185,7 @@ func AgentGetUserDeployment(c *gin.Context) {
if !ok {
return
}
record = reconcileDeploymentFromRuntime(c.Request.Context(), record)
common.ApiSuccess(c, withDisplayStatus(record))
}