Repository navigation
fix(heartbeat): Control UI completion replies leak to an explicit heartbeat channel - #161006
Patrick-Erichsen merged 7 commits into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 2, 2026, 5:58 PM ET / 21:58 UTC (Revision 9). ClawSweeper reviewWhat this changesKeeps eligible internal-session command completions and restart continuations in their originating conversation, retaining restart events until successful publication. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main still routes eligible completion replies to an explicit heartbeat destination. The prior queue-loss defect and conflict blocker are resolved, the destination change has explicit acceptance, and no actionable patch defects remain. Likely related people: Peter Steinberger (area-history routing candidate, medium confidence) and Patrick-Erichsen (verified repository writer and current reviewer, high confidence). Priority: P1 Review scores
Verification
How this fits togetherOpenClaw’s heartbeat runner processes queued background events and periodic alerts. It chooses between publishing a reply into the originating session and delivering it to a configured channel. flowchart TD
A[Command completion or restart event] --> B[Session event queue]
B --> C[Heartbeat routing]
D[Session ownership and destination settings] --> C
C --> E[Originating session publication]
C --> F[Configured channel delivery]
E --> G[Settle accepted occurrences]
E --> H[Retain failed occurrences for retry]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +53, Tests +473, Docs +1, Other -1. Total +526 across 15 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing session publisher for eligible completion replies and preserve queue custody until publication succeeds, while retaining ordinary heartbeat routing. Do we have a high-confidence way to reproduce the issue? Yes: an eligible internal session with an explicit heartbeat channel exposes the routing failure in current source, and the supplied validation reports failing current-main regressions. This read-only review did not rerun them. Is this the best way to solve the issue? Yes: the patch repairs routing and settlement in their existing owners, with no competing publisher or queue; the intentional destination exception is explicitly accepted. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0356bacb8c66. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
3ce9441 to
bfe6ed3
Compare
|
@clawsweeper re-review The PR description now links the completed isolated public Gateway restart proof: authenticated public non-main session creation, initial chat establishing internal delivery, actual Gateway stop/start and startup recovery, structured heartbeat_respond notification, exactly one public-history marker after a later same-session turn, no marker in sibling/main histories or outbound recorder, and a positive channel-send control. The trace, selected evidence, and reproducible harness state the fixture boundaries explicitly (seeded restart sentinel; synthetic inference/channel transport, not production or external Discord/Telegram proof). Maintainer acceptance of the destination exception remains required. |
|
🦞👀 Re-review progress:
|
…rget A background command finishing in a WebChat session wakes a heartbeat turn. With an explicit heartbeat target (e.g. discord #heartbeat, cadence 0m), the reply was sent to that channel instead of publishing into the session that ran the command. When the pending queue is only exec completions and a WebChat projection exists, deliver by projection only; target:none is still respected and ordinary heartbeat output keeps its configured target.
…ver mixed batches Address review: the override uses the existing internal-projection eligibility (not WebChat only), so say so in code and docs; document that a failed session write retries on a later wake with no channel fallback; assert a genuine poll writes nothing into the session; add a mixed-batch test that keeps the explicit target.
|
Maintainer decision: accepted. Patrick explicitly requested landing this PR, including its documented destination change: eligible internal-session exec completions and restart continuations belong in the originating conversation, even with an existing explicit heartbeat destination. Rejected session publication retains the occurrence for retry; there is no channel fallback. Ordinary heartbeat alerts, mixed batches, external-route sessions, untagged restart wakes, and target suppression keep their existing routing. This resolves the remaining maintainer decision and the latest review's rank-up request. Landing work is in progress: reconcile the branch with current main, rerun the focused regression/owner-boundary checks and isolated public-Gateway fixture, complete fresh autoreview, and require green CI on the final head before the native merge workflow. I directly inspected the publication and queue settlement owners, the supplied public Gateway evidence/harness, and sibling Codex completion provenance ( @clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…t of the heartbeat target A turn interrupted by a Gateway restart resumes through a restart-sentinel heartbeat wake. With an explicit heartbeat target, that continuation reply was sent to the heartbeat channel. On a restart-sentinel wake, events carrying the sentinel's task:restart-sentinel: context key now count as session-owned alongside exec completions: they publish into the owning session through the internal projection and join the publication idempotency key. The sentinel reads the prefix from the shared constant.
85f3fcd to
30086eb
Compare
|
Landing validation for the rebased candidate 30086eb0cc76. The heartbeat runner previously let an explicit heartbeat destination capture work owned by an internal session; reply admission also consumed restart occurrences before session publication committed. The fix keeps routing and event custody with their existing owners: internal session-owned batches publish to that session, and restart occurrences settle only after accepted publication. There is no channel fallback after a failed session write. Ordinary heartbeat polls, mixed batches, untagged wakes, target-none suppression, and externally routed sessions retain their routes. Before/after evidence:
Production LOC: +67/-14 (net +53). Tests/test support: +520/-47 (net +473, including an existing-case move). Docs: +2/-1. Tooling: -1 obsolete max-lines baseline entry. Production growth preserves occurrence identity and custody across admission/publication using the existing queue and publisher. Merely suppressing channel sends would omit transcript delivery; consuming at admission would still lose retries after publication failure. No new queue, storage, configuration, or fallback path is introduced. The rebase preserves upstream heartbeat failure-copy behavior. The only maintainer additions split oversized test coverage and remove an inherited stale baseline entry for the already-shortened Discord native-command module. ClawSweeper's policy/rank-up decision is accepted in the earlier maintainer comment; the new Gateway evidence independently covers its recovery boundary. Full local changed-file validation passed. Exact-head CI and the required aggregate gate are green on the published candidate. Native review/prepare/merge verification is the remaining landing step. |
|
Merged via squash.
|
…rtbeat channel (openclaw#161006) * fix(heartbeat): keep WebChat exec completions out of the heartbeat target A background command finishing in a WebChat session wakes a heartbeat turn. With an explicit heartbeat target (e.g. discord #heartbeat, cadence 0m), the reply was sent to that channel instead of publishing into the session that ran the command. When the pending queue is only exec completions and a WebChat projection exists, deliver by projection only; target:none is still respected and ordinary heartbeat output keeps its configured target. * fix(heartbeat): document session-owned exec completion routing and cover mixed batches Address review: the override uses the existing internal-projection eligibility (not WebChat only), so say so in code and docs; document that a failed session write retries on a later wake with no channel fallback; assert a genuine poll writes nothing into the session; add a mixed-batch test that keeps the explicit target. * fix(heartbeat): keep restart continuations for Control UI sessions out of the heartbeat target A turn interrupted by a Gateway restart resumes through a restart-sentinel heartbeat wake. With an explicit heartbeat target, that continuation reply was sent to the heartbeat channel. On a restart-sentinel wake, events carrying the sentinel's task:restart-sentinel: context key now count as session-owned alongside exec completions: they publish into the owning session through the internal projection and join the publication idempotency key. The sentinel reads the prefix from the shared constant. * fix(heartbeat): retain restart occurrences until session publication commits * test(heartbeat): name captured occurrence invariants * test(heartbeat): split system-event admission coverage * chore: remove stale Discord max-lines baseline entry --------- Co-authored-by: Marvin <marvin@local> Co-authored-by: Patrick Erichsen <[email protected]>
Related: #147387
What Problem This Solves
Fixes: background-command completions and post-restart continuations from Control UI/WebChat sessions leak to an explicitly configured heartbeat channel.
User Impact
User impact: eligible session-owned replies stay in the session that started the work, rather than also appearing in the heartbeat channel.
This intentionally changes existing explicit-target configurations. Maintainer acceptance of that destination change is still required. Ordinary heartbeat alerts, mixed event batches, external-route sessions, untagged restart wakes, and target:none retain their existing behavior. No config or stored-data migration is introduced.
Why This Change Was Made
Use the existing internal-session publisher for session-owned completions. Restart continuations use the sentinel's existing task:restart-sentinel: key, only on restart-sentinel wakes.
The review's P1 queue-loss defect is repaired: prompt admission formats captured restart occurrences without consuming them. The canonical queue owner still checks current membership and preserves selection order. Delivery settlement consumes those exact occurrences only after accepted session publication; a rejected write, thrown write, or failed model turn leaves them available for retry. Late arrivals are not consumed, and an occurrence already handled by another turn is not re-admitted.
Eligibility remains the existing internal-projection gate: an internal-delivery, client-owned session, excluding internally created/internal-effects sessions. A failed session write does not fall back to the channel.
Evidence
Review repair
Gateway proof
Existing real-Gateway exec-completion observations remain valid (Discord transport): before the first commit, the same replies appeared in the session and heartbeat channel; after it, tested completions appeared only in the session. The restart leak was observed with the first commit but without restart handling.
After-fix isolated public Gateway restart proof: PASS on head
9b3b46cad9c. Redacted terminal trace, selected public-history/outbound evidence, and reproducible harness.sessions.createcreated a non-main session; initial publicchat.sendnaturally established internal delivery (no session-row mutation).heartbeat_respondwithnotify:true; publicchat.historycontained exactly one recovery marker.Limits: restart-sentinel input is manually seeded through its canonical writer; inference and channel transport are synthetic loopback fixtures. The rest of the public Gateway/recovery/publication path is real. This does not establish production deployment, lifecycle-produced sentinel creation, or external Discord/Telegram API behavior. This harness was not run against stock; earlier fixture failures are not stock results. Ordinary-heartbeat and mixed-batch retention are established by the focused regressions, not by the explicit-send control.
Existing-configuration impact: the isolated proof reuses the unchanged explicit destination across both Gateway starts; no migration or new option is needed. The destination exception is deliberate, with no channel fallback after rejected publication. Maintainer acceptance remains outstanding.
Previously captured real-Gateway observations (UTC; text and identifiers omitted)
Source: originating-session transcript timestamps and Gateway channel-history reads. Configuration: disabled periodic cadence and an explicit Discord heartbeat destination.
CI test-typecheck repair
The fresh CI run on
9b3b46cad9cpassed runtime, production-typecheck and lint checks but failed infra test typecheck: two newly addedexpectDefinedcalls omitted the required diagnostic argument (TS2554). Test-only follow-up85f3fcd83bcsupplies those contexts. The CI-equivalent infra test-typecheck config now exits 0 locally; all 80 queue tests and scoped lint pass. Production source is unchanged from the head used for the Gateway proof. Fresh CI is pending.Existing CI failures
The previous CI run failed in five files outside the changed routing path. Eight failures in service.failure-alert-notifications, service.heartbeat-busy-poll and update-candidate-canary reproduce with matching signatures on clean PR base 2a0a65c as well as the patched checkout. The other two restart/private-completion cases pass when isolated on both. Relevant upstream fixes have since landed, including #161455; this push requests fresh merged-base CI. No unrelated test fixes were added.
AI-assisted implementation and verification using OpenClaw and Codex. The intentional destination change still needs a maintainer decision; code checks cannot supply that acceptance.