refactor(gateway): extract protocol core owners - #1095
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 14, 2026, 2:57 PM ET / 18:57 UTC. ClawSweeper reviewWhat this changesThe PR extracts signed gateway connect-envelope construction and operator pending-request tracking into dedicated shared protocol owners, with compatibility and lifecycle tests. Merge readinessKeep open. This collaborator-owned, actively landing refactor is not on current main, and the rebased head is based on main with substantial current-head proof; it requires maintainer merge judgment rather than backlog cleanup. Priority: P2 Review scores
Verification
How this fits togetherGateway clients create signed connect requests and manage in-flight operator calls before responses or disconnects reach connection, chat, wizard, and approval workflows. The new owners centralize these protocol mechanics while credential selection and transport policy remain in the clients. flowchart LR
A[Gateway challenge] --> B[Connect envelope builder]
B --> C[Operator or node client]
C --> D[Pending request registry]
D --> E[Responses or disconnects]
E --> F[Connection chat wizard approvals]
Decision needed
Why: The change is intentionally large on a connection-critical boundary, and collaborator-authored items require explicit maintainer judgment rather than automated cleanup. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land only after confirming the rebased registry retains current main's typed remote-close propagation and exact signed-envelope compatibility. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a behavior-preserving refactor PR, and the relevant evidence is contract and real-path validation rather than a user bug reproduction. Is this the best way to solve the issue? Unclear: dedicated protocol owners are a maintainable design, but this review environment could not independently materialize the rebased source for the final line-level confirmation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 17a8b0363a82. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (15 earlier review cycles; latest 8 shown)
|
df74c4e to
2a5fafb
Compare
|
Rebased unchanged B0 protocol layer onto latest main |
Exact-head confidence transcriptValidated PR head
Inspectable coverage:
Redacted TRX outputs: Maintainer judgment remains whether to require one composite real-gateway test with every pending category active during the same socket sever. The constituent behavior is already covered by all-category registry races, loopback shutdown/dispose tests, and gateway restart/recovery E2E. No correctness defect was found. @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0a17604d-e1a5-47ae-bdb5-54ff34887ae7
ValidationFinal local rebased HEAD: Remote update: the rebased branch was force-pushed with lease from
Real behavior proofThe screenshots were captured from Connection settings, isolated MCP-only runtime Diagnostics and gateway state Copied local MCP proof from the same app instance: Sanitized real WSL Gateway -> Windows node -> No gateway blocker remains: the real gateway path was exercised successfully. The rebased branch is pushed and GitHub reports the PR mergeable; CI is running on this exact head. |
2a5fafb to
beed12a
Compare


Summary
ConnectEnvelopeBuilder.OpenClawGatewayClientwith one generation-safePendingRequestRegistry.Ownership transfer
ConnectEnvelopeBuilderPendingRequestRegistryCredential precedence remains outside the builder: paired device token, then shared token, then bootstrap according to the existing client/Connection policy.
WindowsNodeClientdoes not use the pending registry.Validation
Validated exact published head
2a5fafb89a8c8bafcdda0a6f82d9c55c3257cd5e. Every focused and real-gateway test below executed; none skipped or no-op'd.The 34 signed-envelope tests cover the complete operator/node profile matrix under both v2 and v3 signing, exact auth-field and signature-token equality, deterministic signature/payload formats, canonical metadata, protocol 3/4, property/null shape, nonce and timestamp semantics, initial signature-version selection, fallback on signature rejection, operator signing failure propagation, node soft signing failure, and default-formatting redaction.
The 28
CredentialResolverTestscover operator and node precedence independently: device token, then shared token, then bootstrap token, including missing, corrupt, unreadable, and detailed fallback classifications. Precedence remains outsideConnectEnvelopeBuilder.The 31 pending-lifecycle tests cover tracked, chat, wizard, and approval registration and typed resolution; exactly-once complete/fault; duplicate and late response handling; closed/reopen behavior; generation-safe stale handles; exact cancellation taxonomy; idempotent drain; response-vs-drain, error-vs-response, timeout-remove-vs-response, and 100-iteration register-vs-drain races. Five of these use a real loopback WebSocket to verify in-flight chat and approval shutdown classification, real dispose during an approval wait, response-first priority, and timeout classification.
Real behavior proof
All real gateway/client proof ran at the exact published head with isolated WSL/tray state:
Redacted result artifacts:
TestResults/PR1095Confidence/setup-connect.trxTestResults/PR1095Confidence/revocation-recovery.trxTestResults/PR1095Confidence/network-recovery.trxTestResults/E2E/<run-id>/setup-engine.jsonl,e2e-fixture.log, anduninstall-engine.jsonlCredential values, setup codes, nonces, signatures, and keys are intentionally omitted from public proof.
Remaining maintainer judgment: there is no single real-gateway test that severs the socket while every pending category is simultaneously active and then asserts every category-specific exception. The constituent behavior is covered by deterministic all-category registry tests, real loopback chat/approval shutdown and dispose tests, and real gateway restart/recovery E2E. This audit found no correctness defect requiring a code change.
Review
Architecture
Adds authoritative and closed ledger rows for
connect-envelopeandgateway-pending-requests. Source guards prevent reintroducing inline connect envelopes, auth helpers, pending maps, or the old Track/Take/Clear helper family.