Repository navigation
fix(voice-call): survive gateway in-process restart and stop CLI dead-ends - #125458
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 17, 2026, 9:55 PM ET / August 18, 2026, 01:55 UTC. ClawSweeper reviewWhat this changesThe PR hardens Voice Call runtime ownership across Gateway restarts and replaces CLI Gateway-error string matching with typed error handling. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open: the lifecycle repair is coherent, but the new typed Gateway-error classifier drops Voice Call’s existing ECONNRESET local fallback. Priority: P1 Review scores
Verification
How this fits togetherVoice Call CLI commands first contact the running Gateway, then may use a local telephony runtime when the Gateway is unavailable. Gateway error normalization drives that fallback, while the plugin generation coordinator owns runtimes during reloads. flowchart LR
A[Voice Call CLI command] --> B[Gateway client call]
B --> C[Gateway error normalization]
C --> D{Gateway unavailable?}
D -->|yes| E[Local Voice Call runtime]
D -->|no| F[Visible CLI diagnostic]
G[Gateway reload] --> H[Plugin generation coordinator]
H --> E
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +67, Tests +237, Docs +8, Other +2. Total +314 across 15 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Normalize ECONNRESET at the shared Gateway error producer so typed CLI fallbacks retain their intended recovery behavior. Do we have a high-confidence way to reproduce the issue? Yes—source inspection shows current main falls back on connect-time ECONNRESET, while this branch accepts only typed errors that the shared producer does not create for ECONNRESET. Is this the best way to solve the issue? No—the generation-coordinator repair is coherent, but the new classifier is incomplete until shared producer normalization covers ECONNRESET. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b5b17c654b2d. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What 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 (3 earlier review cycles)
|
…-ends The gateway's in-process restart (SIGUSR1 config reload) reuses the cached plugin registry, so service stop/start run on the same retained voice-call registration. Generation fencing from #120289 treated that restart as a stale actor: stop retired the generation forever, the next start silently bailed, and every voicecall.* RPC answered UNAVAILABLE "runtime generation is retired" while the webhook never rebound. - Registrations now hold a replaceable generation: service start after stop mints a fresh generation, takes over a running slot owned by a retired predecessor, and reports start failures to service health instead of silently returning. - The voicecall CLI classifies gateway failures with typed guards instead of message substrings: standalone/store fallback only when the gateway is genuinely absent; reachable-but-failed (request errors, auth, timeout) exits with actionable text; a standalone webhook port collision explains that a running Gateway probably owns the port instead of raw EADDRINUSE. - Plugin SDK gateway-runtime exports structural isGatewayTransportError / isGatewayClientRequestError guards (+2 documented surface budget). - Regression coverage: same-registration stop/start restart, retired-owner takeover, typed CLI fallback classification, and a real token-auth gateway server routing voicecall.status through callGatewayFromCli.
Collapse the four duplicated gateway-or-runtime command blocks (speak, dtmf, end, continue fallback) into one generic runGatewayManagerCommand helper — the continue command owns its legacy-method fallback and operation polling via a gatewayCall closure, so the helper carries no per-command policy. Smoke reuses the shared initiateVoiceCall path instead of a bespoke fallback. Split the 988-line cli.ts into concept modules (cli-gateway-call, cli-call-log, cli-command-io) and drop its grandfathered max-lines suppression plus the now-stale max-lines and assertion-safety baseline entries (shrink-only ratchet maintenance). Behavior-frozen: stdout/exit semantics unchanged; net -2 production LOC.
ClawSweeper P1: the operational-error formatter interpolated the raw connectionDetails.url, so a configured gateway URL with userinfo or query tokens would print credentials into terminal output. Redact the composed message once with the canonical net-policy redactor (also covers remote-controlled close-reason text), exported through the plugin SDK gateway-runtime subpath (+1 documented surface budget). Regression test covers a credential-bearing URL in both the URL and message fields.
bcb7035 to
7e29c32
Compare
|
Merged via squash.
|
…tead of message matching Replaces the message-substring classifier in the Meet CLI's gateway-unavailable local fallback with the structural isGatewayTransportError/isGatewayClientRequestError guards (seam shared verbatim with #125458). Decision surface chosen per Meet semantics: uncoded transport closes (unreachable sockets, now incl. ETIMEDOUT/ ENETUNREACH) fall back; coded closes incl. 1006 deliberately do not, since a live gateway may still own Meet browser sessions; unknown-method fallback stays but requires a structural gateway request error. Adds ECONNRESET to GATEWAY_UNREACHABLE_SOCKET_CODES so connect-time resets wrap into the typed unreachable error instead of escaping raw.
…tead of message matching (#125495) * fix(google-meet): classify gateway CLI fallback with typed guards instead of message matching Replaces the message-substring classifier in the Meet CLI's gateway-unavailable local fallback with the structural isGatewayTransportError/isGatewayClientRequestError guards (seam shared verbatim with #125458). Decision surface chosen per Meet semantics: uncoded transport closes (unreachable sockets, now incl. ETIMEDOUT/ ENETUNREACH) fall back; coded closes incl. 1006 deliberately do not, since a live gateway may still own Meet browser sessions; unknown-method fallback stays but requires a structural gateway request error. Adds ECONNRESET to GATEWAY_UNREACHABLE_SOCKET_CODES so connect-time resets wrap into the typed unreachable error instead of escaping raw. * test(process): treat Linux zombies as terminated
…-ends (openclaw#125458) * fix(voice-call): survive gateway in-process restart and stop CLI dead-ends The gateway's in-process restart (SIGUSR1 config reload) reuses the cached plugin registry, so service stop/start run on the same retained voice-call registration. Generation fencing from openclaw#120289 treated that restart as a stale actor: stop retired the generation forever, the next start silently bailed, and every voicecall.* RPC answered UNAVAILABLE "runtime generation is retired" while the webhook never rebound. - Registrations now hold a replaceable generation: service start after stop mints a fresh generation, takes over a running slot owned by a retired predecessor, and reports start failures to service health instead of silently returning. - The voicecall CLI classifies gateway failures with typed guards instead of message substrings: standalone/store fallback only when the gateway is genuinely absent; reachable-but-failed (request errors, auth, timeout) exits with actionable text; a standalone webhook port collision explains that a running Gateway probably owns the port instead of raw EADDRINUSE. - Plugin SDK gateway-runtime exports structural isGatewayTransportError / isGatewayClientRequestError guards (+2 documented surface budget). - Regression coverage: same-registration stop/start restart, retired-owner takeover, typed CLI fallback classification, and a real token-auth gateway server routing voicecall.status through callGatewayFromCli. * refactor(voice-call): split CLI modules and dedupe gateway fallbacks Collapse the four duplicated gateway-or-runtime command blocks (speak, dtmf, end, continue fallback) into one generic runGatewayManagerCommand helper — the continue command owns its legacy-method fallback and operation polling via a gatewayCall closure, so the helper carries no per-command policy. Smoke reuses the shared initiateVoiceCall path instead of a bespoke fallback. Split the 988-line cli.ts into concept modules (cli-gateway-call, cli-call-log, cli-command-io) and drop its grandfathered max-lines suppression plus the now-stale max-lines and assertion-safety baseline entries (shrink-only ratchet maintenance). Behavior-frozen: stdout/exit semantics unchanged; net -2 production LOC. * fix(voice-call): redact gateway URLs in CLI operational errors ClawSweeper P1: the operational-error formatter interpolated the raw connectionDetails.url, so a configured gateway URL with userinfo or query tokens would print credentials into terminal output. Redact the composed message once with the canonical net-policy redactor (also covers remote-controlled close-reason text), exported through the plugin SDK gateway-runtime subpath (+1 documented surface budget). Regression test covers a credential-bearing URL in both the URL and message fields.
…tead of message matching (openclaw#125495) * fix(google-meet): classify gateway CLI fallback with typed guards instead of message matching Replaces the message-substring classifier in the Meet CLI's gateway-unavailable local fallback with the structural isGatewayTransportError/isGatewayClientRequestError guards (seam shared verbatim with openclaw#125458). Decision surface chosen per Meet semantics: uncoded transport closes (unreachable sockets, now incl. ETIMEDOUT/ ENETUNREACH) fall back; coded closes incl. 1006 deliberately do not, since a live gateway may still own Meet browser sessions; unknown-method fallback stays but requires a structural gateway request error. Adds ECONNRESET to GATEWAY_UNREACHABLE_SOCKET_CODES so connect-time resets wrap into the typed unreachable error instead of escaping raw. * test(process): treat Linux zombies as terminated
What Problem This Solves
On a gateway host with the voice-call plugin enabled,
openclaw voicecalloperational commands dead-ended after the Gateway went through an in-process restart (SIGUSR1, triggered by any restart-class config change such as editinggateway.auth.token):voicecall.*RPC permanently answeredUNAVAILABLE "Voice call runtime generation is retired; use the current plugin registration", the runtime/webhook never restarted, and the failure was completely silent (no log line, no health signal);voicecall call/smokefell back to a standalone runtime that died with rawlisten EADDRINUSE: address already in use 127.0.0.1:3334when the Gateway still held the webhook port.The reported "
voicecall status --jsonhangs indefinitely" is the same fallback on builds before #125354 (status started the full telephony runtime and the one-shot CLI process never exited); that specific hang is already fixed on main, and the RPC transport itself always settles within its 5s wrapper timer.Why This Change Was Made
Root cause: the in-process restart reuses the cached plugin registry and bypasses
register()(src/plugins/loader-runtime-load.ts:97), soservice.stop/service.startrun on the same retained voice-call registration. The generation fencing from #120289 was designed to fence stale retained closures, but it treated this legitimate host stop→start sequence as a stale actor:stopretired the generation forever, and the nextstartswallowed the lifecycle error with a barereturn— the worst bug class (silent failure). A plain plugin-config hot reload re-registers and was never affected.Fixes, at their owners:
extensions/voice-call/index.ts— registrations now carry a replaceable generation: service start after stop mints a fresh generation; start takes over a running slot owned by a retired predecessor (covers the still-bound-webhook variant); start failures report to service health and log instead of silently returning. The fix(voice-call): prevent stale runtimes after gateway restart #120289 stale-closure fencing is preserved (all prior lifecycle tests unchanged and green). Net −1 line in the lifecycle owner.extensions/voice-call/src/cli.ts— gateway failures are classified with typed guards instead of message substrings. Standalone/store fallback only when the gateway is genuinely absent (transportclosedwith no close code, or 1006). Reachable-but-failed (request errors incl. UNAVAILABLE, credentials, timeout) exits non-zero with actionable text pointing atopenclaw gateway status. A standalone webhook port collision (EADDRINUSE, detected viacode) explains that a running Gateway probably owns the port.src/plugin-sdk/gateway-runtime.ts/src/gateway/call.ts— exports structuralisGatewayTransportError/isGatewayClientRequestErrorguards (the request-error formatter is refactored around the new guard, behavior-preserving). +2 documented plugin-SDK surface budget.serviceHealth.reportFailure) instead of a warn-only log; default installs (mock provider) are unaffected.User Impact
Operational voicecall commands keep working across gateway config reloads/restarts. When something is genuinely wrong, operators get a next step instead of an internal lifecycle error, a hang, or a raw
EADDRINUSEstack.Evidence
Live repro + verification on an isolated dev gateway (
OPENCLAW_STATE_DIRscratch, token auth, mock provider):gateway.auth.token→[reload] … restarting gateway now→[gateway] restart mode: in-process restart→ noWebhook server listening/Runtime initializedafterwards, port unbound, and[ws] ⇄ res ✗ voicecall.status 0ms errorCode=UNAVAILABLE errorMessage=Voice call runtime generation is retired…on every call.16:42:08 restarting gateway now→16:42:10 Webhook server listening … / Runtime initialized;voicecall status --jsonandvoicecall callroute via WS (res ✓ voicecall.initiate 140ms).Gateway responded but voicecall failed: unauthorized: gateway token mismatch … checkopenclaw gateway status``; absent gateway + held webhook port →Voice-call webhook port 3435 is already in use. A running Gateway probably already serves it….node scripts/run-vitest.mjs extensions/voice-call→ 61 files / 654 tests green; new same-registration restart + retired-owner takeover lifecycle regressions fail pre-fix with the wedge error;src/gateway/gateway-cli-plugin-routing.test.ts(real gateway server, token auth, realcallGatewayFromCli, wrong-token typed assertion) green;node scripts/check-changed.mjs -- <touched files>exit 0;pnpm plugin-sdk:surface:checkgreen;pnpm buildgreen.Follow-up commit: CLI refactor (behavior-frozen)
4d9e84ccollapses the four duplicated gateway-or-runtime command blocks into one genericrunGatewayManagerCommandhelper (thecontinuecommand owns its legacy-method fallback + operation polling via agatewayCallclosure; no per-command policy inside the helper), letssmokereuse the sharedinitiateVoiceCallpath, and splits the 988-linecli.tsinto concept modules (cli-gateway-call.ts,cli-call-log.ts,cli-command-io.ts) — deleting the grandfatheredmax-linessuppression plus the now-stalemax-lines/assertion-safetybaseline entries (shrink-only ratchet maintenance). stdout/exit semantics unchanged; net −2 production LOC; 654 extension tests +check-changed+pnpm build(noINEFFECTIVE_DYNAMIC_IMPORT) green; fresh Codex autoreview clean (0.99).ClawSweeper findings response (head
bcb7035)gatewayOperationalErrornow redacts the composed operator-visible text once via the canonicalredactSensitiveUrlLikeString(newly exported throughopenclaw/plugin-sdk/gateway-runtime, +1 documented surface budget). This covers the interpolated URL, URLs embedded informatErrorMessageoutput, and remote-controlled close-reason text. Regression test asserts awss://user:secret@host?token=...URL prints aswss://***:***@hostwith no secret or token in the message.cli-command-io.tsandcli-call-log.tsare CLI output/log-follow modules; no persisted data model changed.