fix: PJ2026-0104010803 P5 残余 events.at(-1) 读侧推理清理 + code-agent metric status (#1759)

useTraceSubscription.ts:
- mergeTraceResults: lastEventLabel 不 fallback 到 events.at(-1)
- mergeTraceSnapshots: lastEventLabel 不 fallback 到 events.at(-1)
- traceSnapshotSignalKey: 不从 events.at(-1) 推导 signal key

server-code-agent-http.ts:
- recordCodeAgentProjectionMetric: status 只读 projection.status
- source 固定为 workbench_read_model

负向源码扫描确认:
- result?.status ?? trace?.status: 消除
- events.at(-1) lifecycle 推断: 消除
- .catch(() => {}) 静默吞错: 消除
- traceStore.subscribe: 仅作为 outbox 不可用时的兼容降级

Closes #1751
Refs #1742
This commit is contained in:
Lyon
2026-06-20 19:42:19 +08:00
committed by GitHub
parent 44019f229e
commit 4f7e55e2d8
2 changed files with 5 additions and 5 deletions
+2 -2
View File
@@ -3658,10 +3658,10 @@ function recordCodeAgentProjectionMetrics(options = {}, { result = null, trace =
projectedLatestEventAt: projection.updatedAt ?? trace?.updatedAt ?? result?.updatedAt ?? null,
terminalSourceAt: terminalSourceAtFromResult(result),
terminalProjectedAt: projection.projectionStatus === "caught-up" ? projection.updatedAt ?? trace?.updatedAt ?? result?.updatedAt ?? null : null,
status: result?.status ?? trace?.status ?? "unknown",
status: projection?.status ?? "unknown",
reason: projectionReason(projection, refreshError),
projectionStatus: projection.projectionStatus ?? "unknown",
source: result?.agentRun ? "agentrun_v01" : "workbench_read_model"
source: "workbench_read_model"
});
}
@@ -185,7 +185,7 @@ export function mergeTraceResults(terminal: AgentChatResultResponse, trace: Trac
terminalEvidence: mergedTrace.terminalEvidence ?? terminal.terminalEvidence,
finalResponse: terminal.finalResponse,
traceSummary: mergedTrace.traceSummary ?? terminal.traceSummary,
lastEventLabel: mergedTrace.lastEventLabel ?? terminal.lastEventLabel ?? events.at(-1)?.label
lastEventLabel: mergedTrace.lastEventLabel ?? terminal.lastEventLabel ?? undefined
};
}
@@ -308,7 +308,7 @@ function mergeTraceSnapshots(previous: TraceSnapshot | null, next: TraceSnapshot
lastEventAt: next.lastEventAt ?? next.timing?.lastEventAt ?? previous.lastEventAt ?? previous.timing?.lastEventAt ?? null,
finishedAt: next.finishedAt ?? next.timing?.finishedAt ?? previous.finishedAt ?? previous.timing?.finishedAt ?? null,
durationMs: next.durationMs ?? next.timing?.durationMs ?? previous.durationMs ?? previous.timing?.durationMs ?? null,
lastEventLabel: next.lastEventLabel ?? previous.lastEventLabel ?? events.at(-1)?.label ?? events.at(-1)?.type,
lastEventLabel: next.lastEventLabel ?? previous.lastEventLabel ?? undefined,
updatedAt: next.updatedAt ?? previous.updatedAt ?? new Date().toISOString()
};
}
@@ -362,7 +362,7 @@ function traceSnapshotSignalKey(snapshot: TraceSnapshot): string {
snapshot.durationMs ?? snapshot.timing?.durationMs ?? "",
snapshot.hasMore === true ? "more" : "caught-up",
snapshot.fullTraceLoaded === true ? "loaded" : "partial",
snapshot.lastEventLabel ?? events.at(-1)?.label ?? events.at(-1)?.type ?? "",
snapshot.lastEventLabel ?? "",
traceSnapshotErrorKey(snapshot.error),
snapshot.projectionHealth ?? snapshot.projection?.projectionHealth ?? "",
snapshot.projection?.blocker?.code ?? snapshot.blocker?.code ?? ""