Repository navigation
perf(presence): enable compact updates for native clients - #177520
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. |
Negotiate presence deltas in native operator sockets. Reconstruct ordered rosters at the shared Swift channel before bounded subscribers, reuse reconnect recovery for missing baselines, and retain released Gateway snapshots. Android ignores rosters and only needs capability negotiation. Add a shared web/native stream fixture and native cohort replay evidence.
868121a to
a030ec5
Compare
|
The baseline-ratchet failure is inherited. On this PR head The scheduled main job 118204795044, at |
The compact presence decoder from #177520 intentionally reconnects on an invalid presence baseline. The sequence-gap test emitted an empty presence payload and waited forever for it to be delivered, exhausting the native CI job deadline. Use ordinary synthetic events for both sequence numbers. Preserve the gap, held callback, forced disconnect, reconnect, and dropped-event assertion. Validation: all seven disconnect tests pass with Swift Testing parallelism width 3 and coverage instrumentation. The original fixture hangs in the same run. Native test build, formatting, CI-mode lint, and independent P2 review pass; strict local lint retains the existing large_tuple finding.
…77520) * perf(presence): enable compact updates for native clients Negotiate presence deltas in native operator sockets. Reconstruct ordered rosters at the shared Swift channel before bounded subscribers, reuse reconnect recovery for missing baselines, and retain released Gateway snapshots. Android ignores rosters and only needs capability negotiation. Add a shared web/native stream fixture and native cohort replay evidence. * test(presence): pair native replay fixtures and refresh event coverage * test(presence): mark shared fixture import as JSON
The compact presence decoder from openclaw#177520 intentionally reconnects on an invalid presence baseline. The sequence-gap test emitted an empty presence payload and waited forever for it to be delivered, exhausting the native CI job deadline. Use ordinary synthetic events for both sequence numbers. Preserve the gap, held callback, forced disconnect, reconnect, and dropped-event assertion. Validation: all seven disconnect tests pass with Swift Testing parallelism width 3 and coverage instrumentation. The original fixture hangs in the same run. Native test build, formatting, CI-mode lint, and independent P2 review pass; strict local lint retains the existing large_tuple finding.
What Problem This Solves
Native operator connections keep receiving complete presence rosters when only a few fields change. This completes native adoption of the compact opaque-key presence protocol from #177471.
User Impact
Updated macOS, iOS, and Android apps receive smaller presence updates. macOS/iOS subscribers still receive the same complete, ordered rosters; old apps retain the server's legacy snapshots. This reaches users through native app releases and requires no Gateway restart or protocol bump.
Why This Change Was Made
The shared Swift channel owns capability negotiation and reconstructs keyed resets and field patches before bounded subscriber queues. It clears keyed state with the socket and reuses existing reconnect recovery on a missing presence baseline or transport gap. Full snapshots from released Gateways remain supported. Android ignores presence rosters, so it only advertises the capability; it needs no unused reducer or cache. Node-only connections have no read-scoped presence delivery. Ordinary TypeScript CLI calls remain legacy; Swift operator helpers inherit the shared channel support.
Handshake versions come from the Swift bundle, Android build version, and CLI package version. The replay uses synthetic
devmetadata and aggregate client-kind counts; it does not claim an inventory of deployed app versions.Evidence
Acceptance: identical synthetic presence workload and client identities, same ordered final rosters, no recovery or delivery failures, and fewer presence bytes per native socket. Two simultaneous A/B pairs under the sandbox quiet lock, with CPU halves swapped for the second pair. Bytes and frame counts are the decision metrics; host load is context.
Two concurrent pairs passed with identical byte results (16 CPUs per side, CPU halves swapped):
Each replay lasted about 60.5 seconds with 96 RPCs. Legacy native frames averaged 36,593 bytes, close to the reported ~38 KB shape. All 42 admitted sockets matched their negotiated format and final authoritative roster; both candidate runs reconstructed 40 native rosters with zero recovery requests. The two unchanged CLI controls each received exactly 1,352,575 bytes on both sides. Admitted synthetic
devcohorts: 14 macOS, 13 iOS, 13 Android, and 2 CLI controls.Ran
scripts/perf/presence-churn-measure.ts --client-profile native --clients 42 --scenario traffic --rounds 12 --interval-ms 1000, with--legacy-clients 42for A and--legacy-clients 2for B. Each side had its own state directory and loopback port, a common--start-at, and the pair held the exclusive measurement lock. Source capsule:69bef1a7611423fb9c8529fd4a3d757bbbd1fffaplus this PR's measurement script; measured server/reducer files were hash-matched to the rebased PR. Both sides audited 8,470 imports from that capsule with no foreign source. Outside load was recorded per pair; dirty pages stayed below 2 GiB.These are UTF-8 presence-event JSON bytes, excluding WebSocket framing/compression, initial hello/reset, setup, and the final correctness flush. The live replay uses the web reducer as the decoder; native equivalence is proven by the shared-fixture tests below. No CPU/latency improvement or production installed-version census is claimed.
Independent Codex autoreview: scoped-clean, no actionable P0–P2 findings on the implementation and CI follow-ups. The simplification pass shares the existing stream-baseline reconnect branch; no new recovery coordinator. The synthetic native replay pairs its own fixture devices through the existing owner before signed connect.
ConnectionManagerTest: 37/37 passed (5.549-second tests; 1m47s including prerequisites), throughscripts/run-android-gradle.mts --proof --no-daemon --max-workers=1 :app:testPlayDebugUnitTest --tests ai.openclaw.app.node.ConnectionManagerTest.with { type: "json" }; the focused web test remains 6/6 passing.pnpm tsgo:ui(tsrs), changed TypeScript lint/format, Swift source lint/format, and Android lint passed. Android's attempted lint filter was ineffective and scanned app source sets; it was not rerun. TypeScript lint prepared its normal plugin declarations.Application production code grows by 88 lines; the measurement tool grows by 99 lines. The production increase is necessary to decode an existing wire contract before Swift subscribers; there is no duplicate roster owner or new configuration. Legacy server delivery remains for released clients and legacy decoding remains for released Gateways.
Current exact-head CI:
a030ec55e899. Completed: Android tests/emulator checks, UI/Node tests, typechecks, lint, protocol coverage, iOS simulator build/screenshot capture, and screenshot evidence pass. Only the inherited baseline-ratchet failure and its aggregate CI gate are red. The current-head Codex review also completed without findings.The remaining baseline-ratchet failure is inherited:
check-test-mock-exports.mtsasks to remove the staleextensions/acpx/register.runtime.test.ts/openclaw/plugin-sdk/acp-runtime-backendtuple fromconfig/test-mock-exports-baseline.txt. This PR job and the scheduled main job on4ec61b4ed2a8a5f05f041372726fe62f2706584cfail with the identical tuple/hash. None of those files is changed here. Both logs were inspected; no CI rerun was requested.Landing uses the authorized inherited-failure exception. The native wrapper requires a separate PR review worktree; this lane explicitly prohibits extra worktrees, so the authorized exact-head REST squash-merge fallback is used. No native app release or Gateway restart is part of this PR.