Repository navigation
fix(voice-call): prevent stale runtimes after gateway restart - #120289
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 7, 2026, 4:47 PM ET / 20:47 UTC. ClawSweeper reviewWhat this changesThe PR assigns Voice Call runtime startup, use, and teardown to a specific plugin generation so stale closures cannot create, reuse, clear, or stop a successor runtime after gateway restart. Merge readinessKeep open for maintainer review. Current main still has the ownerless global runtime slots described by the linked bug, while this PR adds a plugin-local exact-generation coordinator; no concrete patch defect was found, but its protected maintainer label requires human handling. Priority: P1 Review scores
Verification
How this fits togetherVoice Call registers gateway services and tools that share one process-wide runtime. Gateway reload can attach a successor registry while old service shutdown remains in flight, so the plugin must fence delayed closures from retired generations. flowchart LR
Gateway[Gateway reload] --> Old[Retiring Voice Call generation]
Gateway --> New[Successor Voice Call generation]
Old --> Coordinator[Generation-owned runtime coordinator]
New --> Coordinator
Tools[Retained tool closure] --> Coordinator
Coordinator --> Runtime[Voice Call runtime]
Coordinator --> Result[Call succeeds or lifecycle error]
Decision needed
Why: The patch is correct by source and focused regression evidence, but the protected maintainer label requires an explicit human decision on accepting the absence of an operational restart trace. Before merge
Agent review detailsSecurityNone. PR surfaceSource +104, Tests +213. Total +317 across 3 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. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the plugin-local exact-owner coordinator and land it once a maintainer accepts the deterministic lifecycle proof for the gateway reload ordering. Do we have a high-confidence way to reproduce the issue? Yes—current main’s ownerless runtime slots establish the reported stale-closure path, and the PR’s controlled-promise tests encode the gateway replacement interleaving; this read-only review did not run the scenario. Is this the best way to solve the issue? Yes—the plugin-local coordinator is the best fix because the gateway deliberately permits old service disposal to outlive registry retirement, while Voice Call owns the shared runtime being protected. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 588d8bb85388. 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
History |
Prevent retained plugin closures from recreating, adopting, or stopping successor runtimes across shutdown and restart. Add deterministic lifecycle regressions for pending startup, exact-owner stop, retained tools, and generation restart.
a7b6a25 to
1424170
Compare
|
@clawsweeper re-review Rebased onto current |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Retrying the exact-head review request because the prior worker lease ( |
|
Land-ready verification for exact head
Maintainer decision: accept the controlled deferred-promise lifecycle suite as sufficient proof for this plugin-local ownership repair. It reproduces the gateway replacement order, pending-start continuation, exact-owner teardown, retained-tool behavior, and successor restart boundary without requiring a live telephony provider. No remaining proof gap blocks landing. |
|
Merged via squash.
|
Prevent retained plugin closures from recreating, adopting, or stopping successor runtimes across shutdown and restart. Add deterministic lifecycle regressions for pending startup, exact-owner stop, retained tools, and generation restart.
…-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.
…-ends (#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 #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.
…-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.
Closes #120288
What Problem This Solves
Fixes an issue where operators restarting or reloading a gateway with the Voice Call plugin could end up with stale runtime state when an older plugin generation finished startup or cleanup after its successor was already attached. That timing could recreate a runtime from old configuration, let old cleanup disrupt the new runtime, or leave Voice Call unavailable after restart.
Why This Change Was Made
Voice Call now owns its process-global runtime through an explicit plugin-generation coordinator. Startup, running, and stopping slots carry an exact owner; activation advances a monotonic epoch only when a staged generation actually starts or is used, so failed/staged registrations do not disturb the active generation and retired closures cannot revive later.
The fix stays inside the plugin boundary. Gateway shutdown grace and registry-bound tool retention remain unchanged; retained tools now receive a visible lifecycle error instead of adopting or mutating successor state. A focused lifecycle suite uses controlled promises to prove the original execution order and exact-owner cleanup.
AI-assisted: implementation and review used Claude Code and Codex. The final diff was manually inspected and passed the repository autoreview gate.
User Impact
Voice Call restarts and plugin configuration reloads now keep runtime ownership deterministic. A successor generation waits for the predecessor's actual stop barrier where appropriate, while delayed startup, stale service cleanup, and retained tool closures cannot recreate or interfere with another generation's runtime.
Evidence
node scripts/run-vitest.mjs extensions/voice-call/index.test.ts extensions/voice-call/index.lifecycle.test.ts— 55 tests passed.node scripts/run-tsgo.mjs -p tsconfig.extensions.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions.tsbuildinfo— passed.node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.extensions.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/extensions-test.tsbuildinfo— passed.node scripts/run-oxlint.mjs extensions/voice-call/index.ts extensions/voice-call/index.test.ts extensions/voice-call/index.lifecycle.test.ts— passed.node_modules/.bin/oxfmt --check extensions/voice-call/index.ts extensions/voice-call/index.test.ts extensions/voice-call/index.lifecycle.test.ts— passed.git diff --check— passed.--mode uncommitted— clean; no accepted/actionable findings.node scripts/check-changed.mjs -- ...classified the extension production/test lanes but remote Crabbox/Testbox providers were unavailable; the exact extension typecheck, lint, format, focused test, and diff checks above were run locally as the documented trusted-source fallback.The production delta is the new runtime ownership boundary (
+170/-66); tests are separate (+285/-72) and move the prior lifecycle cases into a dedicated deterministic suite.