Repository navigation
refactor(gateway): share connection lifecycle across transports - #145950
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 September 13, 2026, 9:19 AM ET / 13:19 UTC (Revision 6). ClawSweeper reviewWhat this changesMoves Gateway connection admission, request dispatch, and disconnect cleanup into a shared owner while retaining physical WebSocket handling in its adapter. Merge readiness✅ Ready for maintainer review This remains a useful, distinct extraction that current main does not provide. No actionable introduced defect was found, and the refreshed production files match the previously reviewed head. The maintainer-authored PR should remain open for normal landing checks. Priority: P2 Review scores
Verification
How this fits togetherGateway connections carry requests from operator clients, nodes, and workers into OpenClaw. The connection lifecycle handles registration and cleanup, while the WebSocket adapter supplies receive limits, heartbeat monitoring, and transport events. flowchart TD
A[Operator and node clients] --> B[WebSocket adapter]
B --> C[Shared connection lifecycle]
C --> D[Authentication and registration]
D --> E[Gateway request dispatch]
B --> F[Worker admission and dispatch]
C --> G[Disconnect and shutdown cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +94, Tests +211, Other 0. Total +305 across 25 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Technical reviewBest possible solution: Keep one shared connection lifecycle with transport-specific I/O adapters, leaving additional endpoints and watch capabilities to separately reviewed work. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR extracts an existing lifecycle rather than reporting a behavioral defect; runtime tests were not executed during this read-only review. Is this the best way to solve the issue? Yes. The diff moves the existing owner and injects transport operations without duplicating authentication, changing wire contracts, or adding a competing registration path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 0a7b7fecfd7f. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
d44f664 to
f7279d8
Compare
|
@clawsweeper re-review The branch was reconstructed as one signed commit on current
Please review the exact replacement head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
* temp/pr-145950: (101 commits) refactor(memory-wiki): share freshness result construction (#146935) improve(gateway): use metadata projection for presence (#146817) test(agents): reuse complete Responses model fixtures (#147015) fix(sessions): align the reclamation-memory test with the archive session owner (#147028) refactor(terminal): simplify copy-sensitive token checks (#146934) refactor(media): remove duplicate spaced path fallback (#146933) refactor(cli): reuse command-group names (#146893) improve(plugins): reduce JavaScript generation capture work (#146993) test: align plugin fixtures with current runtime contracts (#147000) refactor(browser): separate session tab tracking from cleanup (#146973) fix(tests): make systemd clock fixtures private (#146990) fix(linux): retire sleep guards when logind disconnects (#146046) refactor(matrix): share draft fallback delivery (#144840) fix(sessions): preserve cross-agent replies after reload (#146799) test(models): cover quota recovery during catalog discovery (#146708) fix(macos): recover browser sign-in when no browser opens (#146787) fix(process): prevent one-shot agents exiting while polling (#144268) fix(status): label the session inventory as stored (#146979) fix: avoid repeated background reads while loading chat (#146953) refactor(ui): narrow Skill Workshop proposal context (#146977) ...
|
Merged via squash.
|
* temp/pr-137049: (110 commits) improve: reduce GitHub OAuth maintenance work for large agent rosters (#147021) fix(test): avoid settings lock writer startup timeouts (#147029) fix(update): correct backup guidance and cover incident regressions (#147023) refactor(gateway): share connection lifecycle across transports (#145950) refactor(telegram): share HTML text escaping (#146936) perf(build): reduce disk use in UI performance checks (#146687) refactor(memory-wiki): share freshness result construction (#146935) improve(gateway): use metadata projection for presence (#146817) test(agents): reuse complete Responses model fixtures (#147015) fix(sessions): align the reclamation-memory test with the archive session owner (#147028) refactor(terminal): simplify copy-sensitive token checks (#146934) refactor(media): remove duplicate spaced path fallback (#146933) refactor(cli): reuse command-group names (#146893) improve(plugins): reduce JavaScript generation capture work (#146993) test: align plugin fixtures with current runtime contracts (#147000) refactor(browser): separate session tab tracking from cleanup (#146973) fix(tests): make systemd clock fixtures private (#146990) fix(linux): retire sleep guards when logind disconnects (#146046) refactor(matrix): share draft fallback delivery (#144840) fix(sessions): preserve cross-agent replies after reload (#146799) ...
* commit '0ac8a700e43efceef73d92fe8e50b185819e38ad': (27 commits) test(acpx): prove targeted turn cancellation (#137049) fix(ci): honor realtime meeting live-test opt-in (#147044) improve: reduce heartbeat enrollment work for large fleets (#147055) fix(gateway): install despite stale Linux session bus addresses (#146569) chore(i18n): refresh native locales (#147025) fix: avoid Gateway reinstalls when macOS service inspection is inconclusive (#146880) fix(pairing): QR setup rejects trusted-proxy gateways without a shared secret (#147036) fix(update): bound activation and accept slow Windows identity reads (#147019) perf(accounts): avoid materializing avatars for owner checks (#147032) improve(status): report external and ArrayBuffer memory (#141902) fix(update): preserve linked plugins during post-core sync (#147009) fix(channels): keep replies working after hot config reloads (#147001) refactor(gateway): defer worker transcript runtime loading (#143495) improve: reduce GitHub OAuth maintenance work for large agent rosters (#147021) fix(test): avoid settings lock writer startup timeouts (#147029) fix(update): correct backup guidance and cover incident regressions (#147023) refactor(gateway): share connection lifecycle across transports (#145950) refactor(telegram): share HTML text escaping (#146936) perf(build): reduce disk use in UI performance checks (#146687) refactor(memory-wiki): share freshness result construction (#146935) ... # Conflicts: # src/config/sessions/session-accessor.sqlite-reclamation-memory.test.ts
…claw#145950) * refactor(gateway): share connection lifecycle across transports * chore: refresh pull request source ref
Related: #142916
Replaces: #142931
What Problem This Solves
Gateway connection admission, request dispatch, and cleanup were coupled to
WebSocket-specific I/O, preventing another transport from reusing the existing
authenticated lifecycle safely.
Why This Change Was Made
Extract the existing connection lifecycle into one transport-neutral owner while
keeping WebSocket receive, receiver limits, heartbeat, socket errors, and
physical liveness in the WebSocket adapter.
The repair preserves the keepalive behavior from
#145191, including passing the underlying
socket to
startWebSocketKeepalive. It adds no endpoint, config, protocol, orpersistence surface.
The ancestry-preserving refresh includes
#146102 and
#147028.
User Impact
No intended user-visible behavior change. The Gateway gains one reusable
connection boundary without duplicating authentication, registration, request
dispatch, or disconnect cleanup.
Evidence
ceda70dd6ce0e069ad1a6a9ab28ed4c77b008250060e856e5f9df245d63c98990fcb47e18108c6b97b0a779bb1eb1cad1f6789688ecc367ed5fa814cand060e856e5f9df245d63c98990fcb47e18108c6b9aac1da4a5893b524768c29bca2d4111847297d95patch ID changed from
d620e013d1321e228ec7d747b10c9ed51cfb47cfonly because four test/baseline files also moved on main; every per-file
addition/deletion count is unchanged.
roughly 660 WebSocket-owned lines; the remaining growth is the transport
contract, adapter wiring, and receiver extraction.
node-registry.ts5->4 andws-connection.ts3->1 reductions.git diff --checkpassed on the refreshed head.Focused proof command:
Result on source head
7b0a779b: 11 test files passed, 291 tests passed. Therefreshed head preserves the production blobs and exact per-file delta; exact-head
hosted CI and ClawSweeper remain required before landing.
Scope Boundary
This PR adds no HTTPS/watch endpoint. It does not satisfy or close
#142916 and leaves that issue's later
security/native holds untouched.