Repository navigation
fix(sandbox): retire plugin backends with registry lifecycle - #130662
Conversation
Bind the explicit backend disposer to the plugin service lifetime so disabling or reloading OpenShell retires its factory, manager, and workdir hooks together. Preserve the core registry's stale and repeated disposer semantics.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 3:28 PM ET / 19:28 UTC. ClawSweeper reviewWhat this changesMoves OpenShell and MXC sandbox-backend disposal from service lifetime to plugin-registry lifecycle cleanup, with regression coverage for registry retirement before services start. Merge readinessKeep open for maintainer handling: current main still lacks registry-owned cleanup for these explicit sandbox registrations, while the proposed lifecycle callbacks match the registry’s cleanup ownership and generation semantics. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherSandbox plugins register process-wide backend factories, managers, and workspace resolvers that the CLI and agent sandbox consume. Plugin-registry replacement or shutdown must retire those registrations without allowing an older generation to remove a newer one. flowchart LR
A[Plugin registration] --> B[Sandbox backend registry]
B --> C[CLI and agent sandbox lookup]
D[Registry replacement or shutdown] --> E[Plugin lifecycle cleanup]
E --> F[Generation-aware disposer]
F --> B
Decision needed
Why: The patch changes process-wide backend availability and carries the protected maintainer label, so the final merge decision belongs to the responsible maintainer despite a clean source review. Before merge
Agent review detailsSecurityNone. PR surfaceSource +13, Tests +277. Total +290 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep explicit backend disposal in each owning plugin’s runtime lifecycle and land only after the maintainer confirms the exact-head lifecycle and platform validation records. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main registers the hooks eagerly while lacking registry-lifecycle disposal, and the introduced tests drive registry retirement before services start. This read-only review did not execute the regression locally. Is this the best way to solve the issue? Yes: the plugin registry already owns retirement and invokes runtime lifecycle cleanup, so retaining and disposing the registration callback there is narrower and more maintainable than service-only cleanup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b9d01e71270e. LabelsLabel changes:
Label 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 (3 earlier review cycles)
|
|
Merged via squash.
|
…w#130662) * fix(openshell): unregister sandbox backend on plugin stop Bind the explicit backend disposer to the plugin service lifetime so disabling or reloading OpenShell retires its factory, manager, and workdir hooks together. Preserve the core registry's stale and repeated disposer semantics. * fix(sandbox): retire plugin backends with registry lifecycle
Follow-up to #130518, which separated built-in sandbox defaults from explicit backend registrations.
What Problem This Solves
Fixes stale OpenShell and MXC sandbox backend registrations after their owning plugin registry retires. Gateway startup can be cancelled after eager plugin registration but before plugin services start; a service-only cleanup hook never runs in that case. The initial draft fixed normal OpenShell hot reload but missed this cancellation boundary.
Why This Change Was Made
Both plugins now retain the existing backend disposer in the existing plugin-runtime lifecycle. Registry replacement and shutdown own cleanup independently of whether services ever started. The no-op cleanup services are removed, leaving one cleanup owner.
Registration stays eager because sandbox CLI commands load full plugins without starting Gateway services. Only unscoped plugin disable/restart retires the global backend; session/run cleanup and reset/delete leave it available. The core registry's generation-aware, idempotent disposer remains unchanged, so a late old cleanup cannot erase a newer backend.
No core SDK/API, configuration, storage, backend default, platform readiness, or provider transport change is introduced. Production LOC is +24/-11 (net +13); the growth retains OpenShell's previously discarded disposer and expresses the necessary global-versus-scoped cleanup boundary in both plugins. Tests add a net 277 lines.
User Impact
OpenShell and MXC backend availability follows the active plugin generation, including interrupted startup. Retired registrations cannot remain available after disable or reappear when later generations retire. CLI backend discovery remains available before service startup.
Release-note intent: fix stale OpenShell/MXC sandbox backend availability after plugin disable, reload, or cancelled startup. This does not revoke already-created backend handles or change sandbox execution.
Evidence
Both new native public-SDK registry-retirement regressions failed before the runtime-owner correction and passed afterward. They register the real plugin API and retire the actual registry without ever starting services. OpenShell covers factory, manager, and workdir hooks; MXC covers factory/manager and its absent workdir hook. Entry tests also cover eager availability, global disable/restart, scoped cleanup for all four reasons including defined empty IDs, repeated disposal, both stale-generation orders, non-full modes, and MXC platform/binary-failure controls.
Final local tests pass: 110 OpenShell tests across seven files, 66 MXC tests across nine passing files, and 13 core sandbox-registry ownership tests. MXC's 56 Windows-only tests are skipped on this macOS host and are not counted as Windows proof. Tests use the repository wrapper, one worker, and this checkout's own frozen-lockfile dependencies. The full changed-file typecheck/lint/guard gate passes, including zero runtime import cycles. The fresh isolated Codex P0–P2 review reports no actionable findings.
The corrected candidate
aa0f5049aebd7e718369235866098e0c3123e8f8passes the canonical full build (8m23s), including all 63 external plugin local-dist builds and the existing UI performance budget. Actual compiled Gateway testing passes the complete same-boot enabled/disabled/re-enabled/workdir-change/disabled cycle. A fresh disabled Gateway exposes no hooks. Both owned processes exit normally and their ports close; all 11,784 compiled files and dependency identities remain unchanged. This run uses Node 24.20.0.The separately reproduced cancellation gap also passes against this exact compiled candidate: the real loader eagerly registers all hooks, the real startup owner is cancelled before services start, and normal registry clear removes all hooks. Require-factory then reports not registered, and repeated clear remains safe. No provider command is invoked. The old failing pre-service cancellation receipt is preserved; a normal reload-only result is not substituted for this boundary.
Native Windows registration validation passes all 16 MXC entry tests on Node 24.20.0 / pnpm 11.22.0, from an exact-head fresh checkout and frozen lockfile on Azure Crabbox (
run_819c6e85bd20). Readiness, binary resolution, and backend factories are declared test fixtures. The machine has no IsoEnvBroker service, so compiled MXC/container execution was not run. The run exited 0 and its lease was released. Earlier launcher failures occurred before product tests and are not counted as proof.Exact-head hosted CI run 33105489824 is green, including
openclaw/ci-gate: 33 successful jobs, 20 path-selected skips, no failures. The earlier automated cancellation finding is addressed by the runtime-owner correction and the actual compiled cancellation regression. No earlier draft-skipped CI is counted as validation.Proof scope is plugin registration lifecycle, not authenticated OpenShell/MXC provider execution, Windows container execution, existing-handle revocation, or managed plugin installation. Both plugins remain external packages; compiled local proof must use the canonical external-plugin local-dist build output and its declared dependencies, not a copied source plugin.