Repository navigation
feat(gateway): send presence deltas to capable operator clients - #175508
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
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. |
Keep connection snapshot types with the connection contract to avoid a static import cycle. Encode full-roster mock inputs as resets for opted-in browser clients, reusing the recorded handshake capabilities.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesThis PR adds negotiated presence deltas and snapshot recovery for the Control UI while preserving legacy clients’ full rosters. Example: One projected row changes in the supplied synthetic 24-row roster.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it provides a useful, maintainer-approved bandwidth improvement absent from current main, with no actionable patch findings; the CI gate remains pending with an inherited failure. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway’s in-memory presence owner feeds recipient-filtered WebSocket events and RPC snapshots; the Control UI reconstructs delta events before publishing full rosters to existing consumers. flowchart LR
A[Presence mutations] --> B[Presence owner]
B --> C[Recipient projection]
C --> D[Connection delivery baseline]
D --> E[WebSocket reset or delta]
E --> F[UI presence observer]
F --> G[Existing roster consumers]
F --> H[Snapshot recovery RPC]
H --> C
Technical reviewBest possible solution: Land negotiated deltas through the existing presence projection and connection lifecycle after the CI gate is resolved through the native landing workflow. Do we have a high-confidence way to reproduce the issue? Current main visibly serializes full projected rosters for each publication, and the supplied synthetic measurement demonstrates the bandwidth opportunity; this review ran no target code. Is this the best way to solve the issue? The implementation fits the existing owners, preserves recipient filtering and legacy payloads, and handles dropped-frame recovery without introducing persistent state or another authorization policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1a6e911e32b8. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +284, Tests +559, Docs +65. Total +908 across 25 files. Added test files: 3. View PR surface stats
LabelsLabel 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 Reviewed October 17, 2026, 8:41 AM ET / 12:41 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
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: #175508
…claw#175508) * feat(gateway): send presence deltas to capable operator clients * fix(test): honor negotiated presence in browser fixtures Keep connection snapshot types with the connection contract to avoid a static import cycle. Encode full-roster mock inputs as resets for opted-in browser clients, reusing the recorded handshake capabilities.
…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
A reported production roster of 24 presence rows produces ~23 KB full snapshots for each change, fanned out to ~20 sockets at 1–2 changes per minute: roughly 0.5 MB/minute and ~50 MiB over two hours, usually for one changed row.
User Impact
The web Control UI opts into
presence-deltasand receives changed rows instead of repeated full rosters. Native clients retain the existing fullpresencepayload byte-for-byte, and ordinarysystem-presencecalls still return an array. There is no protocol-version bump or configuration change.Why This Change Was Made
Presence delivery compares each connection's last sent projected roster with its current recipient projection, using opaque keys from the presence owner and the existing presence version. Deltas carry whole-row upserts, removals, and the complete roster order. A reset replaces the roster when there is no base or a delta would not save bytes. The hello snapshot stays unchanged; the first post-hello event establishes an explicit reset baseline.
Only a frame accepted by the socket advances the baseline. Backpressure drops invalidate it; synchronous/asynchronous send failures and disconnects clear it. The next send after a drop is a full reset. Per-recipient watched-session visibility remains authoritative before diffing. Retained connection state holds row references, not copies or serialized rosters.
The Gateway store reconstructs ordinary full presence events for all downstream web consumers. A base mismatch requests
system-presencewith{snapshot:true}, available only to opted-in readers; the response replaces the list and retires the server event base. Recovery is deduplicated and cannot overwrite a newer event or another hello.Recipient policy stays in the existing projection, and delivery state stays on the connection. The tests exercise the actual WebSocket lifecycle without production test hooks.
Evidence
pnpm tsgo:core, allpnpm tsgo:core:testshards,pnpm tsgo:ui, type-aware oxlint and oxfmt on all touched files,pnpm -s check:assertion-safety,pnpm -s check:line-cap-ratchet, docs MDX sanity, andgit diff --check. The UI owner tests and UI typecheck also pass after lint cleanup.ui/AGENTS.md's explicit Gateway Coupling contract. Native compatibility is retained and proven. No accepted actionable findings remain.The real-path test releases simulated pressure before its RPC barrier because RPC replies also enforce backpressure. It compares fresh recovery snapshots at a fixed clock instant because snapshot reads refresh the Gateway self timestamp. No production gates were bypassed. PR CI supplies the broad test proof.
Related: #175352
CI follow-up
The first PR run exposed a static type-import cycle and browser fixtures still emitting legacy presence events after the UI negotiated deltas. The connection snapshot type now lives with the connection contract, and the existing mock presence owner encodes negotiated reset frames using recorded handshake capabilities.
After the repairs, all 11 selected test files pass: 15 Gateway tests, 33 UI/fixture tests, and 59 browser E2E tests (154.92 seconds total wall time). Core/UI typechecks, touched-file lint and formatting, the import-cycle check, and the line-growth guard pass. A fresh isolated Codex review through P2 found no actionable findings in the corrections.
Release note: The Control UI now receives presence changes as deltas instead of full rosters, cutting a typical presence update from ~20 KB to ~1.5 KB; native apps keep full snapshots.
The original
checks-node-changed-3failure is inherited: the focusedagent-terminal-delivery.e2e.test.tsreproduces the same line-409 assertion (['no_reply']expected,[]received) on the exact CI main baseline04ed62b9c8718be572cf83615d316846e13c6c7c. The test and terminal-reply/token owners are byte-identical in the baseline and this PR. Main's #170972 made whole-replyNO_REPLYmatching case-insensitive, while that E2E still expects lowercase delivery. No unrelated terminal-reply behavior was changed.An additional full-tree max-lines check reports existing suppressions in three unchanged files (
chat-message.test.tsx,config-page-state.ts, andsessions-page-state.ts). The diff-scoped line-growth guard passes; those unrelated baseline entries were left untouched.Final landing evidence for
8ae224f1b7fac698b27cd9bf8a075ca458a3bbef: CI run 39032881506 completed with 77 successful jobs and 20 intentionally skipped jobs. The only root failure ischecks-node-changed-3(the stale lowercaseno_replyassertion above), plus its downstreamopenclaw/ci-gate. CI labels it unknown because the scheduled-main comparison has no matching job; independent exact-main reproduction supplies the attribution. The current tested merge isfea03a0b1aeef603bdc913c911e8d579d78857d6, with main parent9ee09dbaba4a5c56bda57c909c9f76dbb74e12f7; the four relevant test/terminal-reply/token source blobs also match that baseline. The scoped land order authorizes the native inherited-failure exception, subject to its live authority, policy, security, and review checks. CI is not being represented as green.ClawSweeper and GitHub Codex completed review of the final head with no findings. No unresolved review threads remain.