Repository navigation
refactor(gateway): centralize connect failure classification - #120505
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 6:46 PM ET / 22:46 UTC. ClawSweeper reviewWhat this changesCentralizes Gateway connection-failure classification so probes, health checks, Doctor, and the terminal UI show consistent recovery guidance. Merge readinessKeep open. The current head resolves the prior rate-limit ordering blocker at the request owner, but the useful change is neither on current main nor shipped and this maintainer-labeled PR needs normal landing review. Priority: P2 Review scores
Verification
How this fits togetherGateway clients receive structured connection failures and pass them to status probes, CLI diagnostics, Doctor, and the terminal UI. The shared protocol classifier converts those facts into safe, actionable operator outcomes. flowchart LR
Gateway[Gateway connect response] --> Client[Gateway client]
Client --> Details[Structured failure details]
Details --> Classifier[Shared failure classifier]
Classifier --> Probe[Status probe]
Classifier --> Diagnostics[Health and Doctor]
Classifier --> TUI[Terminal UI guidance]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +264, Tests +803. Total +1067 across 22 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Land the shared protocol classifier with the request-owner rate-limit preservation intact after exact-head validation confirms the additive status projection and Health-process regression. Do we have a high-confidence way to reproduce the issue? Yes—source establishes the pre-hello request-error-then-close ordering, and the added isolated WebSocket-to-Health CLI regression provides a high-confidence reproduction path; it was not executed during this read-only review. Is this the best way to solve the issue? Yes. The protocol classifier and request owner are the narrowest shared boundaries, replacing independent consumer regexes while retaining a constrained legacy text fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cdaea2d6b67c. 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 (5 earlier review cycles)
|
1b7f848 to
6aff416
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
6aff416 to
d6dba12
Compare
|
@clawsweeper re-review |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
ab129ca to
c47df08
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…w#120505) * refactor(gateway): centralize connect failure classification * fix(gateway): project connect failure into status JSON * fix(protocol): restore remote-auth context in pairing remediation * fix(gateway): classify generic probe failures by close reason * fix(gateway): keep transport closes unreachable * fix(gateway): preserve rate-limit diagnostics * fix(gateway): preserve typed rate-limit failures
Related: #120492
What Problem This Solves
Gateway connect failures were classified independently by the probe, health diagnostics, and TUI using different regular expressions over close-reason text. Modern Gateways already send structured
details.codevalues, so the three surfaces could disagree about pairing, device identity, scope upgrades, and rejected credentials or miss the most actionable recovery command.Why This Change Was Made
This adds one structured-first classifier to the existing gateway protocol connect-error owner and routes all three consumers through it. Probe and daemon status preserve structured connect details, the TUI classifies its existing structured request error before formatting it, and one centralized text fallback preserves older/string-only Gateway behavior.
The classifier distinguishes shared Gateway token mismatch from paired-device token mismatch: shared tokens point operators back to matching
gateway.remote.tokenwithgateway.auth.token, while device tokens show the validopenclaw devices rotate --device <deviceId> --role operatorcommand. Pairing and scope-upgrade failures use the documentedopenclaw devices approve --latestpreview flow.Production LOC is +122/-32 (net +90), tests are +166/-14, and generated API metadata is +1/-1. The positive production delta is the new shared ownership boundary and its actionable remediation contract; the three local regex/policy copies and duplicated TUI help text are removed.
User Impact
CLI health/status and the TUI now agree on the class of a Gateway connect failure. Pairing, scope-upgrade, and token failures produce consistent next steps, while probe capability remains
pairing_pendingfor the same legacy close reasons and now also recognizes structured pairing codes with generic close text.Evidence
node scripts/run-vitest.mjs packages/gateway-protocol/src/connect-error-details.test.ts packages/gateway-client/src/reconnect-policy.test.ts src/gateway/probe.test.ts src/cli/daemon-cli/probe.test.ts src/commands/health.test.ts src/commands/doctor-gateway-health.test.ts src/commands/gateway-readiness.test.ts src/tui/gateway-chat.test.ts src/tui/tui.test.ts— 5 shards, 9 files, 262 tests passed.OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 node scripts/check-changed.mjs— passed allcore,coreTests, and generated API manifest checks locally. The normal Testbox route could not start because no remote provider was ready, so this is the documented trusted-source local fallback..agents/skills/autoreview/scripts/autoreview --mode uncommitted ...— clean; no accepted/actionable findings.AI-assisted: yes.