Repository navigation
fix(qqbot): add heartbeat-ACK liveness watchdog - #114902
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 8:17 PM ET / August 2, 2026, 00:17 UTC. ClawSweeper reviewWhat this changesThis PR tracks QQBot gateway heartbeat acknowledgements and terminates a socket after two unanswered heartbeat sends so the existing reconnect path can restore delivery. Merge readinessThis PR remains necessary: current main receives QQBot heartbeat ACKs but records no liveness state. The implementation and supplied real-channel proof are strong, with no concrete patch defect found; merge should pause only for the QQBot owner to accept the two-unanswered-send recovery policy. Likely related people: steipete (high confidence) and Masato Hoshino (medium confidence). Priority: P2 Review scores
Verification
How this fits togetherThe QQBot plugin owns a gateway WebSocket that receives protocol frames and routes user messages into durable ingress. The watchdog observes heartbeat ACK frames before that serialized ingress queue and uses missing ACKs to trigger the existing reconnect lifecycle. flowchart LR
Gateway[QQ Bot gateway] --> Socket[QQBot WebSocket]
Socket --> Frame[Inbound gateway frame]
Frame --> Ack[Heartbeat ACK check]
Frame --> Ingress[Durable message ingress]
Ack --> Watchdog[Missed-ACK watchdog]
Watchdog --> Close[Socket termination]
Close --> Reconnect[Existing reconnect flow]
Decision needed
Why: The protocol says Op 11 follows a successful heartbeat but provides no client-side timeout or tolerance policy, while this value directly changes the balance between faster recovery and reconnect churn. Before merge
Agent review detailsSecurityNone. PR surfaceSource +35, Tests +129. Total +164 across 2 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the synchronous ACK handling in the QQBot gateway owner and merge the focused watchdog after the QQBot owner explicitly accepts the two-unanswered-send recovery threshold. Do we have a high-confidence way to reproduce the issue? Yes — source inspection shows current main sends heartbeats while its ACK case has no liveness state, and the branch’s focused tests cover the no-ACK recovery path. The PR body also provides redacted live QQBot fault-injection output showing ACK suppression followed by watchdog-triggered reconnection. Is this the best way to solve the issue? Unclear — recognizing ACKs synchronously before durable ingress is the right owner boundary, but the exact two-send tolerance is not dictated by the QQBot protocol and needs an owner decision. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e9d70a5345e5. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (13 earlier review cycles; latest 8 shown)
|
|
Real QQBot runtime evidence — connected a QQ bot (appId The connection came up cleanly and the QQ gateway sent Why this matters for this PR: on Endpoints/IPs/appId redacted from the live log. |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
305e504 to
89cc6eb
Compare
The gateway sent heartbeats but never verified that op:11 ACKs arrived,
so a half-open connection (silent packet loss) stayed OPEN indefinitely
and inbound messages were lost with no status change.
Adds a counter-based watchdog: each heartbeat sent increments an
outstanding count, each op:11 resets it. When the count reaches the
missed-ACK threshold (2 unanswered sends), the socket is terminated so
handleClose -> scheduleReconnect re-establishes delivery.
ACKs are recognized synchronously in ws.on('message') before
socketMessageTail, so a slow ingress.receive() cannot mask an arrived
ACK. The raw frame is decoded/parsed once and carried as {rawData,
payload}; non-object frames are guarded to stay within the error path.
Closes openclaw#114885
handleHello has no local log binding; the overdue-ACK error log must read this.ctx.log to match the existing GatewayConnection logging convention and pass check-prod-types.
89cc6eb to
840bf73
Compare
|
Maintainer decision: accept two consecutive unanswered heartbeat sends as the QQBot recovery threshold. This tolerates one missed ACK and uses the existing reconnect path; QQ's ACK contract does not prescribe a threshold. The original author documented live ACK suppression and reconnection on historical head 305e504; required CI succeeds on current head 840bf. |
* origin/main: (59 commits) fix(agents): reject false success from delegated file mutations (openclaw#117938) fix(macos): reopen AI choice, fix daemon error text, hand onboarding off to the dashboard custodian (openclaw#117921) fix(qa): tolerate expected Matrix sync long-poll deadlines (openclaw#117807) feat(cli): support --json across reporting commands (openclaw#117928) perf(cli): keep read-only commands on cold paths (openclaw#117932) fix: prevent fractional chunk limits from stalling text splitting (openclaw#117727) fix(qqbot): add heartbeat-ACK liveness watchdog (openclaw#114902) chore(openai): defer release note to release flow fix(pr): join worktree discovery subprocesses test(gateway): widen aggregate event-loop budget (openclaw#117931) fix: refresh Buzz room targets after reconnect (openclaw#117927) fix: invalidate removed Buzz mention members fix: align Buzz explicit mention semantics test: split Buzz mention delivery coverage fix: preserve Buzz reply session threads refactor: keep Buzz mention helpers internal fix: invalidate stale Buzz room targets fix: tighten Buzz mention disambiguation perf: keep Buzz plain sends on the fast path fix: reject unresolved Buzz mention text ...
* fix(qqbot): add heartbeat-ACK liveness watchdog
The gateway sent heartbeats but never verified that op:11 ACKs arrived,
so a half-open connection (silent packet loss) stayed OPEN indefinitely
and inbound messages were lost with no status change.
Adds a counter-based watchdog: each heartbeat sent increments an
outstanding count, each op:11 resets it. When the count reaches the
missed-ACK threshold (2 unanswered sends), the socket is terminated so
handleClose -> scheduleReconnect re-establishes delivery.
ACKs are recognized synchronously in ws.on('message') before
socketMessageTail, so a slow ingress.receive() cannot mask an arrived
ACK. The raw frame is decoded/parsed once and carried as {rawData,
payload}; non-object frames are guarded to stay within the error path.
Closes openclaw#114885
* style(qqbot): oxfmt heartbeat liveness tests
* fix(qqbot): use this.ctx.log in heartbeat watchdog terminate path
handleHello has no local log binding; the overdue-ACK error log must
read this.ctx.log to match the existing GatewayConnection logging
convention and pass check-prod-types.
* chore: retrigger CI to clear stale checks
Closes #114885
What Problem This Solves
Fixes an issue where the QQBot gateway WebSocket sent heartbeats but never verified that the server's
op:11Heartbeat ACK arrived, so a connection that stopped receiving ACKs was not detected client-side and could remainOPENuntil the transport emitted close.Why This Change Was Made
The QQ Bot gateway contract defines
op:11Heartbeat ACK as the message received after a heartbeat is sent successfully (event-emit.html). The client should use its absence to detect an unhealthy connection. This adds a counter-based liveness watchdog: each heartbeat sent increments an outstanding count; eachop:11resets it. When the count reaches the missed-ACK threshold (2 unanswered sends), the socket is terminated so the existinghandleClose→scheduleReconnectpath re-establishes delivery.Key design decisions, driven by review:
socketMessageTail. Slow async ingress is not a stall — the heartbeat timer keeps firing while aningress.receive()promise is pending. Op 11 resets the counter synchronously inws.on("message")and returns, never enqueued behind the serialized queue, so a backlogged ACK cannot look overdue.{rawData, payload}into the serialized handler (avoids double-parsing every inbound frame on the hot path; preserves the exactrawDatafor durableingress.receive).ws.sendthrows, the counter is not inflated by a heartbeat that was never sent.User Impact
A QQBot connection whose heartbeats go unanswered is now detected and terminated for reconnect (via Resume) instead of remaining
OPENuntil the transport emits close. Whether such half-open states occur in practice, and how long they persist, was not observed (see #114885NOT_ENOUGH_INFO); the fix closes the client-side detection gap regardless. Tolerates one missed ACK before tearing down, so transient latency does not reconnect a healthy session.Evidence
extensions/qqbot/src/engine/gateway/gateway-connection.ts—outstandingHeartbeatscounter, sync ACK reset inws.on("message"), threshold check in the heartbeat tick.extensions/mattermost/src/mattermost/monitor-websocket.ts:138-209(pong-timeout watchdog).node scripts/run-vitest.mjs extensions/qqbot/src/engine/gateway/gateway-connection.test.ts— 14 tests passed on305e504c4347e89b153d83092929dbea633addd1(Node 25.9.0, isolated remote checkout).Exact-head real-channel fault-injection proof — 2026-07-29
A built checkout of exact head
305e504c4347e89b153d83092929dbea633addd1started a real QQBot gateway with an isolated state directory. A loopback-only TLS CONNECT relay was selected solely throughHTTPS_PROXY; it allowed only the QQBot token/API hosts, forwarded all traffic, and suppressed only server WebSocket Op 11 ACK frames. The relay used a temporary host-valid certificate trusted only by this proof process. It logged no credentials, endpoint authorities, payloads, or messages; the temporary credentials, config, key, certificate, state, logs, and relay were removed at process exit.The first live WebSocket sent two real heartbeat frames whose real Op 11 ACKs were intentionally withheld. On the next tick, the production code logged the two-unanswered-ACK condition, terminated that socket, and completed a second WebSocket upgrade through the existing reconnect path. This proves the changed production behavior—not a mocked transport—while leaving normal ACK traffic and all application messages unmodified.
Maintainer decision still needed
The proof establishes the behavior and reconnection path. The explicit
2-unanswered-ACK threshold remains a product/reliability policy choice for the QQBot owner: whether to tolerate a single missed ACK before reconnecting is not determined by the QQBot protocol itself.This is AI-assisted.