Repository navigation
refactor: consolidate plugin reload ownership and startup overlays - #146275
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 12, 2026, 3:59 PM ET / 19:59 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR makes Gateway startup and reload apply configuration overrides consistently, consolidates plugin cleanup and loader caches, and shares CLI update selection and rollback. Merge readiness⛔ Blocked before merge - 1 item remains The PR remains useful and has no actionable correctness findings. The final-head upgrade evidence resolves the earlier compatibility-proof blocker; source inspection confirms no persisted-format migration is introduced. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway turns saved configuration and startup overrides into the runtime used by plugins and connected clients. Its reload and cleanup owners coordinate replacement, rollback, and shutdown while preserving active connections. flowchart TD
A[Saved configuration] --> C[Shared startup overlays]
B[Startup overrides] --> C
C --> D[Reload transaction]
E[Plugin package metadata] --> D
D --> F[Publish or roll back runtime]
F --> G[Plugins and connected clients]
F --> H[Owned background cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -197, Tests +24, Docs +1. Total -172 across 43 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Use the shared sparse overlay merger and lifecycle-owned publication, cleanup, and metadata caches while preserving explicit operator choices. Do we have a high-confidence way to reproduce the issue? Yes: current-main startup and reload construct different override shapes, and the supplied real-Gateway reproduction identifies source-only publication rejection. This review verified the mechanism from source without executing it. Is this the best way to solve the issue? Yes: sharing the existing overlay helper and consolidating transaction ownership repairs the mismatch without adding configuration or migration machinery. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 63bafe6492ec. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
02de894 to
76f41cf
Compare
|
@clawsweeper re-review Final evidence is now in the PR body for |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Confirmed the remaining compatibility checkbox for The Upgrade compatibility is also verified: the published 2026.9.4 updater upgraded a fresh isolated prefix to this exact candidate in 123.5 seconds, passing all 12 steps, existing-state preservation, plugin convergence, installed Gateway health/build RPC, shutdown, and CLI lock checks. The PR body records the exact package hash and the cold-cache limitation. This satisfies the requested confirmation; the review reports no actionable code or security findings and accepts the same-head live proof. |
|
Merged via squash.
|
* fix(gateway): register TLS renewal with its sidecar owner Pass the renewal handle directly to the variadic gateway lifetime owner. This completes the integration between TLS renewal (#146267) and the sidecar ownership refactor (#146275), repairing TS2741 and retaining working TLS watcher cleanup. * perf(worktrees): accelerate APFS directory cloning
Protect clean TLS-enabled Gateway shutdown by covering registration of certificate renewal with the Gateway lifetime owner through real startup and close. #146267 added TLS renewal registration using an array; #146275 changed sidecar registration to variadic handles and missed that caller. Passing the renewal handle directly prevents failed production typechecks and shutdown errors (sidecar.stop is not a function). Current main already carries the one-line correction; this landing preserves the integrated regression that detects the caller-contract mismatch. The test uses isolated synthetic TLS material, closes the real Gateway, and observes the real renewal cleanup. The recorded regression failed before the repair and passed afterward; focused sibling coverage passed 22 tests. Exact-head CI and lead Codex review passed. No configuration, storage, or protocol changes. Refs #146267, #146275, #144587, #146246.
…146291) ## What Problem This Solves Fixes root config write regressions introduced by #145983: failed config saves could remove the root and recommend a destructive retry, or discard recovery backups before staging succeeded. ## Why This Change Was Made Root and included-file saves share staged publication and safe restoration. Backup bytes are prepared asynchronously; rotation follows successful staging. Partial failures report the original error, recovery status, and backup location. The writer rechecks captured include path identities during publication and restoration. Backup permissions change only through admitted regular-file descriptors. The decision `which backup files may be mutated` is made by exactly one mechanism at `src/config/backup-rotation.ts:78`. The decision `whether captured include paths are unchanged` is made by exactly one mechanism at `src/config/io.write-safety.ts:80`. ## User Impact Failed staging preserves all five recovery generations. Interrupted saves restore the original file when safe. Gateway clients receive complete recovery details. Cancelled login and setup writes retain the cancellation reason. ## Evidence Before: permission-denied fallback plus a concurrent include edit removed the root; following retry advice lost Gateway settings and cold startup failed. Five disk-full saves consumed the backup history. The same CLI scenarios now restore the root, preserve all five root and include backups, and retain Gateway settings on the next save. Authenticated cold health passes; a wrong token is rejected. All three Gateway save methods return complete structured recovery failures. Aliased includes survive denied rename, validate, and cold-start; linked backup targets retain their bytes and permissions. Detailed consumer coverage is retained in `proof/consumers.md`. ## Compatibility No config keys, stored formats, protocol schema, or protocol version change. Partial publication failures use the existing `UNAVAILABLE` outcome. Plain-root legacy mutation adapters retain their supplied revision; include-bearing adapters without a committed snapshot use the existing unknown revision and can refresh before their next edit. ## Consumers - Config CLI saves preserve root and include recovery backups, including through symlinked includes, and report restoration outcomes. - Gateway `config.set`, `config.patch`, and `config.apply` preserve complete recovery messages and structured details. - Login and service-install writers check live authority immediately before file effects. - Deferred chat and Telegram native login consent recheck retained flow and caller authority at publication. - Gateway setup activation carries cancellation through the shared config writer. - Legacy include mutation adapters receive an unknown revision when no committed composite revision is available. <details> <summary>Internal call migration</summary> The counts below refer to retired adapters and synthetic test-fixture fields. Filesystem options, the public authority callback, and real token/version contracts remain supported. census: generic assertConfigPathForWrite reviewed — 0 callers listed census: generic chmod reviewed — 0 callers listed census: generic copyFallbackOnPermissionError reviewed — 0 callers listed census: generic copyFile reviewed — 0 callers listed census: generic dirMode reviewed — 0 callers listed census: generic fileSystem reviewed — 0 callers listed census: generic maintainConfigBackups reviewed — 0 callers listed census: generic mkdir reviewed — 0 callers listed census: generic open reviewed — 0 callers listed census: generic overwrite reviewed — 0 callers listed census: generic promises reviewed — 0 callers listed census: generic rename reviewed — 0 callers listed census: generic tempPrefix reviewed — 0 callers listed census: generic to reviewed — 0 callers listed census: generic token reviewed — 0 callers listed census: generic unlink reviewed — 0 callers listed census: generic version reviewed — 0 callers listed </details> ## Invalidation Existing config watchers and runtime refresh remain unchanged. Captured path facts are scoped to one write and its restoration. Failed saves publish no success acknowledgement. ## Contention Backup preparation yields to unrelated Gateway requests. With a 2,000 ms injected preparation delay, an unrelated health request completed in 90 ms (limit: 1,000 ms). Candidate staging, backup renames, and final checks stay synchronous. ## Tests 374 targeted config-owner and CLI tests passed, including linked backup slots, alias fallback, alias replacement, and missing-parent repair. Registered `openclaw config set`, `config.set`, `config.patch`, `config.apply`, `models.authLogin`, and `wizard.next` cover config writes. Provider login is synthetic. Service-token/install tests use a mocked writer and prove forwarding and refusal, not native service effects. Package-entry consumers cover legacy revision compatibility. CI hits the same `server-startup-finish.ts:416` type error as [main run 34718269980](https://github.com/openclaw/openclaw/actions/runs/34718269980), introduced by #146275. The config tests, formatting, line limits, assertions, and unused-export checks pass. Follow-up: Settings reload/save after a missing root can create defaults; that existing UI behavior is tracked separately. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#146275) * refactor: consolidate plugin reload ownership and caches * fix(gateway): preserve startup config shape during reload
* fix(gateway): register TLS renewal with its sidecar owner Pass the renewal handle directly to the variadic gateway lifetime owner. This completes the integration between TLS renewal (openclaw#146267) and the sidecar ownership refactor (openclaw#146275), repairing TS2741 and retaining working TLS watcher cleanup. * perf(worktrees): accelerate APFS directory cloning
…46504) Protect clean TLS-enabled Gateway shutdown by covering registration of certificate renewal with the Gateway lifetime owner through real startup and close. openclaw#146267 added TLS renewal registration using an array; openclaw#146275 changed sidecar registration to variadic handles and missed that caller. Passing the renewal handle directly prevents failed production typechecks and shutdown errors (sidecar.stop is not a function). Current main already carries the one-line correction; this landing preserves the integrated regression that detects the caller-contract mismatch. The test uses isolated synthetic TLS material, closes the real Gateway, and observes the real renewal cleanup. The recorded regression failed before the repair and passed afterward; focused sibling coverage passed 22 tests. Exact-head CI and lead Codex review passed. No configuration, storage, or protocol changes. Refs openclaw#146267, openclaw#146275, openclaw#144587, openclaw#146246.
…penclaw#146291) ## What Problem This Solves Fixes root config write regressions introduced by openclaw#145983: failed config saves could remove the root and recommend a destructive retry, or discard recovery backups before staging succeeded. ## Why This Change Was Made Root and included-file saves share staged publication and safe restoration. Backup bytes are prepared asynchronously; rotation follows successful staging. Partial failures report the original error, recovery status, and backup location. The writer rechecks captured include path identities during publication and restoration. Backup permissions change only through admitted regular-file descriptors. The decision `which backup files may be mutated` is made by exactly one mechanism at `src/config/backup-rotation.ts:78`. The decision `whether captured include paths are unchanged` is made by exactly one mechanism at `src/config/io.write-safety.ts:80`. ## User Impact Failed staging preserves all five recovery generations. Interrupted saves restore the original file when safe. Gateway clients receive complete recovery details. Cancelled login and setup writes retain the cancellation reason. ## Evidence Before: permission-denied fallback plus a concurrent include edit removed the root; following retry advice lost Gateway settings and cold startup failed. Five disk-full saves consumed the backup history. The same CLI scenarios now restore the root, preserve all five root and include backups, and retain Gateway settings on the next save. Authenticated cold health passes; a wrong token is rejected. All three Gateway save methods return complete structured recovery failures. Aliased includes survive denied rename, validate, and cold-start; linked backup targets retain their bytes and permissions. Detailed consumer coverage is retained in `proof/consumers.md`. ## Compatibility No config keys, stored formats, protocol schema, or protocol version change. Partial publication failures use the existing `UNAVAILABLE` outcome. Plain-root legacy mutation adapters retain their supplied revision; include-bearing adapters without a committed snapshot use the existing unknown revision and can refresh before their next edit. ## Consumers - Config CLI saves preserve root and include recovery backups, including through symlinked includes, and report restoration outcomes. - Gateway `config.set`, `config.patch`, and `config.apply` preserve complete recovery messages and structured details. - Login and service-install writers check live authority immediately before file effects. - Deferred chat and Telegram native login consent recheck retained flow and caller authority at publication. - Gateway setup activation carries cancellation through the shared config writer. - Legacy include mutation adapters receive an unknown revision when no committed composite revision is available. <details> <summary>Internal call migration</summary> The counts below refer to retired adapters and synthetic test-fixture fields. Filesystem options, the public authority callback, and real token/version contracts remain supported. census: generic assertConfigPathForWrite reviewed — 0 callers listed census: generic chmod reviewed — 0 callers listed census: generic copyFallbackOnPermissionError reviewed — 0 callers listed census: generic copyFile reviewed — 0 callers listed census: generic dirMode reviewed — 0 callers listed census: generic fileSystem reviewed — 0 callers listed census: generic maintainConfigBackups reviewed — 0 callers listed census: generic mkdir reviewed — 0 callers listed census: generic open reviewed — 0 callers listed census: generic overwrite reviewed — 0 callers listed census: generic promises reviewed — 0 callers listed census: generic rename reviewed — 0 callers listed census: generic tempPrefix reviewed — 0 callers listed census: generic to reviewed — 0 callers listed census: generic token reviewed — 0 callers listed census: generic unlink reviewed — 0 callers listed census: generic version reviewed — 0 callers listed </details> ## Invalidation Existing config watchers and runtime refresh remain unchanged. Captured path facts are scoped to one write and its restoration. Failed saves publish no success acknowledgement. ## Contention Backup preparation yields to unrelated Gateway requests. With a 2,000 ms injected preparation delay, an unrelated health request completed in 90 ms (limit: 1,000 ms). Candidate staging, backup renames, and final checks stay synchronous. ## Tests 374 targeted config-owner and CLI tests passed, including linked backup slots, alias fallback, alias replacement, and missing-parent repair. Registered `openclaw config set`, `config.set`, `config.patch`, `config.apply`, `models.authLogin`, and `wizard.next` cover config writes. Provider login is synthetic. Service-token/install tests use a mocked writer and prove forwarding and refusal, not native service effects. Package-entry consumers cover legacy revision compatibility. CI hits the same `server-startup-finish.ts:416` type error as [main run 34718269980](https://github.com/openclaw/openclaw/actions/runs/34718269980), introduced by openclaw#146275. The config tests, formatting, line limits, assertions, and unused-export checks pass. Follow-up: Settings reload/save after a missing root can create defaults; that existing UI behavior is tracked separately. Co-authored-by: Ayaan Zaidi <[email protected]>
Related: #145484, #145816, #146072
What Problem This Solves
Gateway reload could reject source-only config edits as superseded after startup auth overrides or automatic token generation. Startup and reload built different runtime config shapes. The plugin reload path also retained duplicate rollback ownership, sidecar inventories, alias caches, and CLI update settlement.
Why This Change Was Made
Startup and reload now use the same sparse overlay merger. Generated auth mode fills only an omitted candidate mode, preserving explicit CLI and later source choices. The config transaction owns source publication through commit or rollback, and accepted source-only state is one record.
The sidecar stop owner holds its own inventory; producers publish directly into it and startup no longer returns duplicate handle inventories. Prepared SDK contexts own alias composition, captured package scopes share one lazy metadata record, and CLI updates share target matching, integrity confirmation, and deferred rollback. The obsolete npm-record extractor file is removed.
The full diff removes 172 lines overall: 197 production lines removed, 24 test/support lines added, and one documentation line added.
User Impact
Source-only edits can publish while runtime overrides keep the effective configuration unchanged. Startup/reload auth selection, explicit later auth-mode changes, source isolation, consent, runtime receipts, warnings, cancellation, and cleanup remain supported.
There are no database schema, stored-format, dependency, configuration-option, or public SDK/RPC changes. The package-metadata change replaces in-memory caches; captured manifest bytes and their file format are unchanged. No migration is required.
Evidence
Final verification on
76f41cfa7ada5f3a52d0cdb868bf07e9def69c25:check-changedpassed, including core/test types, lint, all dead-export scans, import cycles, and ownership guards. The rebase preserved the upstream cron getter and the new sidecar owner in the only conflict; all 79 affected reload/kernel tests passed afterward.--auth noneand accepted the authored edit in 545 ms while preserving runtime object/hash, PID, socket, registration, and listener. Every Gateway stopped and all ports were reusable.Candidate tarball SHA-256:
3513b00089cf13b61da658c607e6a9b1d93f6ce38d875e48d2fbc3e87674108b.