Repository navigation
fix(gateway): keep presence deltas compact during activity - #175668
Conversation
Patch changed presence fields against each connection's delivered projection so heartbeat and activity churn retain compact deltas. Keep ordered full snapshots, insertion upserts, and recovery behavior intact. Add bounded delivery-mode counters and a real multi-client Gateway regression with equivalent rosters. Related: #175508
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3c3712f784
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex review: needs maintainer review before merge. What this changesThis PR sends changed presence fields instead of whole rows and adds traffic counters by delivery mode. Example: The reported eight-client Gateway reproduction advances heartbeat, activity, and watched-session state.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a concrete bandwidth problem on current main, and no actionable correctness or security defects were found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway projects its presence roster for each recipient, encodes updates against that connection's delivered baseline, and sends WebSocket frames that the Control UI reconstructs into complete ordered lists. flowchart LR
A[Presence owner] --> B[Recipient projection]
B --> C[Connection baseline and encoder]
C --> D[WebSocket transport]
D --> E[Control UI presence store]
D --> F[Traffic diagnostics]
Technical reviewBest possible solution: Land the field-patch encoder and matching UI decoder after the exact-head CI gate passes. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the whole-row size fallback, and the supplied regression exercises heartbeat and activity churn through real WebSockets; no target code was executed during this review. Is this the best way to solve the issue? Field patches address the repeated metadata at its existing encoder owner while the existing UI owner reconstructs complete rows without another cache or competing policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against b68f99ea4532. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +111, Tests +452, Docs +27. Total +590 across 24 files. Added test files: 2. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 17, 2026, 12:29 PM ET / 16:29 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash auto-merge.
|
…175668) Presence deltas now send only changed fields per row, so heartbeat and activity updates stay compact instead of falling back to full rosters; new metrics count presence frames by delta, reset and legacy. Keep browser reconstruction atomic, retain snapshot recovery and legacy delivery, and apply validated upserts in one pass within the existing chat-boot bundle budget. Related: openclaw#175508
What Problem This Solves
Presence updates for capable Control UI clients often fell back to full resets during normal heartbeat and activity churn. Whole-row upserts resent unchanged metadata, making the candidate delta larger than a reset.
User Impact
Control UI presence keeps the same ordered rows and freshness timestamps with smaller updates. In the isolated real-Gateway reproduction, capable-client frames fell from an average 6,503 bytes to 2,120 bytes (67.4% smaller). Native and other non-capable clients keep full frames.
Why This Change Was Made
Existing rows now carry changed top-level fields and explicitly removed fields. New rows still carry full contents. Comparison uses the existing per-connection projected baseline; no hashes or additional cache state. The web presence owner applies patches before publishing complete lists. First delivery, recovery, backpressure, and size-based reset behavior remain intact.
The existing batched event metrics now expose
openclaw_gateway_ws_presence_frames_total{mode}andopenclaw_gateway_ws_presence_bytes_total{mode}, withdelta,reset, andlegacymodes. OpenTelemetry exports the corresponding counters. Classification and byte recording add constant work without parsing payloads or scanning rows.Evidence
The regression starts an isolated real Gateway and eight signed WebSocket clients: six advertise the browser connect plan's capabilities and two are legacy readers. Three rounds exercise actual WebSocket pong renewals, activity RPCs, and watched-session changes with advanced owner wall time. Every publication reconstructs exactly the same roster as the legacy readers.
All nine rows changed, predominantly
ts,lastActivityAt,connectionLastActivityAt, andwatchedSessions. The before run fails onexpected reset to be delta. The complete after trace has six initial resets and 30 deltas across capable sockets; the two legacy sockets receive seven full frames each. No backpressure, reconnect, or recovery RPC was needed to reproduce the reset-heavy steady state. Legacy frame sizes remain 5,949 / 6,397 / 5,949 bytes.Focused proof covers field application/clearing, new rows and ordering, unknown-row recovery, transport drops/send errors, reconnect and snapshot recovery, and both metrics exporters. The new real-Gateway regression takes 9.894 seconds of test time (9.915 seconds before); its cold wrapper run takes 50.04 seconds. Exact-head CI has completed; see CI follow-up below.
Validation passed: the real-Gateway regression, UI presence tests, existing Gateway delta/recovery/backpressure tests, broadcaster and transport tests, both metrics exporters,
pnpm tsgo:core,pnpm tsgo:core:test,pnpm tsgo:ui, type-aware oxlint and oxfmt on all touched files, assertion safety, line-cap ratchet, andgit diff --check. Oxlint found one redundant return in the extracted recorder; it was removed and the affected lint and Prometheus tests passed. Isolated Codex autoreview at P0/P1 completed scoped-clean on the final candidate against the pinned merge base. A refresh against the movingorigin/mainalso reported a Kimi change from main outside this PR; verified as out of scope, then reviewed the actual PR diff against its pinned merge base. The pr-simplify pass retains the existing baseline owner and full-row insertion path; small exporter/test extractions preserve line caps. Net change against the merge base: +111 production, +452 test, and +27 documentation lines. The required real-Gateway regression accounts for most of the new test code.Related: #175508
CI follow-up
The initial exact-head CI run (39048071337) failed the hard chat-boot JavaScript budget at 1,490,053 bytes (limit 1,490,000). The browser presence owner now validates and applies each upsert in one pass on its private candidate map, reuses the validated key and patch fields, and retains atomic publication and snapshot recovery. Rebuilding the exact CI merge tree with this repair measures 1,489,994 bytes. The pre-existing startup-size diagnostic remains advisory under the repository's CI policy; no budgets or baselines changed.
The repair passed the five store-boundary presence tests, UI typecheck, targeted type-aware lint, formatting, and a fresh isolated P0/P1 review. Final-head CI passed in run 39049228343, attempt 2, with all 76 jobs complete and no failures. The first attempt stopped before Android Access tests because Maven Central returned HTTP 403 for unchanged build dependencies; one diagnosed infrastructure retry recovered it. Both required openclaw/ci-gate checks passed. No inherited-failure exception was used.
Release-note context
Presence deltas now send only changed fields per row, so heartbeat and activity updates stay compact instead of falling back to full rosters; new metrics count presence frames by delta, reset and legacy.