T10: gatewayRPCError marks OPENCLAW_GATEWAY_SOCKET_CLOSED with retryable=true, poll=true so the client degrades to "background/reconnecting" + keeps polling instead of hard-failing (feeds App T5). T11: runId-tagged warn logs at the tasks.get unconfirmed-fallback and run-deadline-interrupt sites, so a runId can be joined across App→bridge→plugin→gateway. T12: process-level stability counters (gatewaySocketClosed, taskGetUnconfirmedFallback, runDeadlineInterrupt) exposed via /api/ping.metrics. Revert S1 (default expectedArtifactDirs): it set requiresExport=true / default dirs for any artifact-inferring task, which made a gateway run that succeeds with NO artifact hang "waiting for artifact export" (TestHTTPHandlerGatewayOpenClawHandlesFive ConcurrentE2ECases + ...WithoutPromptHeuristic went red). The blocking is tied to expectedArtifactDirs presence in openClawTaskGetRequiresArtifactExport; decoupling scan-hint from block-on-export needs a careful, separately-tested change. Reverted to keep main green; S1 to be redesigned (see docs/cases/06 §7). Full internal/acp suite green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.4 KiB
Go
30 lines
1.4 KiB
Go
package acp
|
||
|
||
import "sync/atomic"
|
||
|
||
// 关键稳定性指标(T12,docs/cases/06 §5)。
|
||
//
|
||
// 进程内累计计数,经 /api/ping 暴露,用于把「网关抖动 / run 超时」从靠用户截图
|
||
// 变为可监控。三个计数对应三类已知的不稳定来源:
|
||
// - gatewaySocketClosed : gatewayRPCError 命中 OPENCLAW_GATEWAY_SOCKET_CLOSED(连接断)
|
||
// - taskGetUnconfirmedFallback: tasks.get 走持久 run 仓兜底(gateway 无法确认 run,T7)
|
||
// - runDeadlineInterrupt : run 超过 DeadlineAt 且 gateway 无法确认,回 interrupted(T9)
|
||
var bridgeStabilityMetrics struct {
|
||
gatewaySocketClosed atomic.Int64
|
||
taskGetUnconfirmedFallback atomic.Int64
|
||
runDeadlineInterrupt atomic.Int64
|
||
}
|
||
|
||
func metricGatewaySocketClosedInc() { bridgeStabilityMetrics.gatewaySocketClosed.Add(1) }
|
||
func metricTaskGetUnconfirmedFallbackInc() { bridgeStabilityMetrics.taskGetUnconfirmedFallback.Add(1) }
|
||
func metricRunDeadlineInterruptInc() { bridgeStabilityMetrics.runDeadlineInterrupt.Add(1) }
|
||
|
||
// bridgeStabilityMetricsSnapshot 返回当前计数快照,供 /api/ping 输出。
|
||
func bridgeStabilityMetricsSnapshot() map[string]any {
|
||
return map[string]any{
|
||
"gatewaySocketClosed": bridgeStabilityMetrics.gatewaySocketClosed.Load(),
|
||
"taskGetUnconfirmedFallback": bridgeStabilityMetrics.taskGetUnconfirmedFallback.Load(),
|
||
"runDeadlineInterrupt": bridgeStabilityMetrics.runDeadlineInterrupt.Load(),
|
||
}
|
||
}
|