Skip to content

refactor: consolidate plugin reload ownership and startup overlays - #146275

Merged
steipete merged 2 commits into
mainfrom
codex/plugin-reload-consolidation-146072
Sep 12, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/plugin-reload-consolidation-146072

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Independent full-diff review through P2 completed three clean passes; the subsequent overlay correction received a separate clean P2 review.
  • Config/restart baseline: 814 tests passed; final: 816, extending the source-publication table for acceptance and rollback failures.
  • CLI update/selection baseline: 85 tests passed; final: 86. Old and new selectors agree across 325,800 differential cases.
  • Module/SDK baseline and final: 393 tests passed. The existing Windows-only application-data cache-root test is skipped on macOS. Actual Bun 1.4.2 generation fixture passed.
  • Sidecar ownership, startup, and shutdown: 287 tests passed across 17 suites, including generated real Gateway lifetime fixtures; 122 startup tests passed again after lint cleanup.
  • Real-kernel startup/candidate equality reproduced three failures before the overlay correction. All 127 focused kernel, startup-auth, origin, and startup-secret tests pass afterward. The existing scenario now covers explicit token, auth:none, generated-token, and Tailscale-only startup, including a later explicit mode change.
  • The source-publication failure was also reproduced through a real Gateway on both the first candidate and clean pre-refactor baseline. Read-only inspector evidence pinpointed the empty Tailscale object difference. The fixture retains its original CLI flags and assertions for final verification.

Final verification on 76f41cfa7ada5f3a52d0cdb868bf07e9def69c25:

  • Full candidate build and check-changed passed, 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.
  • All six isolated live Gateway cells passed on Node 26.5.0, Bun 1.4.2, and Bun 1.4.0: generation replacement and failure recovery, read-only refresh, late-start cleanup, watcher contention, pending-stop custody, and source-only publication. The original source-publication fixture retained --auth none and 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.
  • The contention harness initially retried after 601 ms despite the server advertising 1,000 ms. The corrected harness honors that advertised delay before its one explicit retry, within the original 15-second deadline; all original assertions remain. Both results were retained.
  • Canonical package integrity/import checks passed. A fresh published 2026.9.4 updater upgraded its own isolated npm prefix to the final candidate in 123.5 seconds. All 12 update steps and plugin convergence passed; existing synthetic plugin policy, config, paths, slots, Gateway settings, model/workspace settings, and workspace bytes were preserved, with expected canonical roster/model-plugin normalization. The installed Gateway passed health and exact-build RPC checks, orderly shutdown, and four CLI lock scenarios.
  • Upgrade proof used a verified task-owned npm cache. An earlier candidate's cold native-package download took 458 seconds and exceeded the existing 298-second canary deadline; the updater refused before activation and preserved the published installation/config. No deadline or assertion was changed. Proof covers an isolated npm installation and separately launched candidate Gateway; managed-service restart and provider inference were not exercised.

Candidate tarball SHA-256: 3513b00089cf13b61da658c607e6a9b1d93f6ce38d875e48d2fbc3e87674108b.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes size: XL maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 18:00
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 12, 2026, 3:59 PM ET / 19:59 UTC (Revision 4).

ClawSweeper review

What this changes

The 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
Reviewed head: 76f41cfa7ada5f3a52d0cdb868bf07e9def69c25

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent repair with relevant runtime and upgrade observations, retained regression coverage, and no blocking findings.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured final-head observations exercise real Gateway reload, recovery, cleanup, contention, and source-only publication on Node and both Bun versions, plus a published-2026.9.4 upgrade preserving existing synthetic state. Coverage matches the changed owners; managed-service restart and provider inference are expressly outside the demonstrated scope.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured final-head observations exercise real Gateway reload, recovery, cleanup, contention, and source-only publication on Node and both Bun versions, plus a published-2026.9.4 upgrade preserving existing synthetic state. Coverage matches the changed owners; managed-service restart and provider inference are expressly outside the demonstrated scope.
Evidence reviewed 9 items Current main still has the configuration-shape mismatch: At fetched main, startup always constructs both auth and Tailscale properties when either override exists, while reload conditionally constructs them. The reviewed branch shares the sparse merger and preserves generated-token mode only when the candidate omits it.
Source publication has one rollback owner: The reload transaction retains the publication handle, rolls it back on acceptance or checkpoint failure, and commits it after successful baseline acceptance. The managed restart adapter no longer duplicates that rollback.
Metadata refactor does not change stored formats: The changed scope cache stores lazy functions in a Map and reuses the existing parsed manifest record. Existing captured-file copying, manifest bytes, source-boundary checks, and disposal remain in their established owners; the patch adds no schema or serialized-format change.
Findings None None.
Security None None.

How this fits together

The 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]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -197, Tests +24, Docs +1. Total -172 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 21 298 495 -197
Tests 21 541 517 +24
Docs 1 6 5 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 43 845 1017 -172

Review metrics

Metric Value Why it matters
Published-updater compatibility 2026.9.4 → final candidate: 12 steps passed in 123.5 seconds The supplied existing-state upgrade result addresses the previous review's compatibility-proof request.

Stored data model

Persistent data-model change detected: serialized state: src/plugins/plugin-package-metadata-capture.ts, unknown-data-model-change: src/plugins/plugin-package-metadata-capture.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best 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.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured final-head observations exercise real Gateway reload, recovery, cleanup, contention, and source-only publication on Node and both Bun versions, plus a published-2026.9.4 upgrade preserving existing synthetic state. Coverage matches the changed owners; managed-service restart and provider inference are expressly outside the demonstrated scope.
  • remove merge-risk: 🚨 compatibility: Current PR review selected no merge-risk labels.

Label justifications:

  • P2: The PR repairs source-only configuration publication under startup overrides and simplifies the associated reload lifecycle.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured final-head observations exercise real Gateway reload, recovery, cleanup, contention, and source-only publication on Node and both Bun versions, plus a published-2026.9.4 upgrade preserving existing synthetic state. Coverage matches the changed owners; managed-service restart and provider inference are expressly outside the demonstrated scope.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured final-head observations exercise real Gateway reload, recovery, cleanup, contention, and source-only publication on Node and both Bun versions, plus a published-2026.9.4 upgrade preserving existing synthetic state. Coverage matches the changed owners; managed-service restart and provider inference are expressly outside the demonstrated scope.

Evidence

What I checked:

  • Current main still has the configuration-shape mismatch: At fetched main, startup always constructs both auth and Tailscale properties when either override exists, while reload conditionally constructs them. The reviewed branch shares the sparse merger and preserves generated-token mode only when the candidate omits it. (src/gateway/server-startup-config-helpers.ts:216, 63bafe6492ec)
  • Source publication has one rollback owner: The reload transaction retains the publication handle, rolls it back on acceptance or checkpoint failure, and commits it after successful baseline acceptance. The managed restart adapter no longer duplicates that rollback. (src/gateway/config-reload.ts:730, 76f41cfa7ada)
  • Metadata refactor does not change stored formats: The changed scope cache stores lazy functions in a Map and reuses the existing parsed manifest record. Existing captured-file copying, manifest bytes, source-boundary checks, and disposal remain in their established owners; the patch adds no schema or serialized-format change. (src/plugins/plugin-package-metadata-capture.ts:581, 76f41cfa7ada)
  • Cleanup ownership and caller cutover: The stop owner now holds its own inventory while retaining single-flight stopping, late publication, bounded retries, and failed-handle retention. Startup producers publish through that owner; searches found no remaining references to the removed setters, npm-record helper, or merged-alias cache. (src/gateway/server-sidecar-owners.ts:5, 76f41cfa7ada)
  • Regression coverage preserves meaningful contracts: The kernel scenario checks explicit-token, auth-none, generated-token, and Tailscale-only startup against reload candidates, including source-byte preservation and a later explicit mode change. Publication coverage extends the existing scenario to acceptance and rollback failures. (src/gateway/server-kernel.test.ts:350, 76f41cfa7ada)
  • Final-head runtime and published-updater evidence: The captured PR body and refactor: consolidate plugin reload ownership and startup overlays #146275 (comment) report six isolated real-Gateway scenarios on Node 26.5.0 and Bun 1.4.2/1.4.0. Source-only publication completed in 545 ms with runtime identity, PID, socket, registration, and listener preserved. The published 2026.9.4 updater completed all 12 steps to this candidate in 123.5 seconds, preserved synthetic operator state, and passed installed-Gateway health, exact-build RPC, shutdown, and CLI lock checks. Proof explicitly excludes managed-service restart and provider inference and records the earlier cold-cache timeout without weakening its deadline. These are supplied observations, not executions performed by this review. (76f41cfa7ada)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-12T18:07:55.295Z sha eb0fa4e3d444fce318ac3123c2cd02c05c3b7452 :: blocked before merge. :: none
  • reviewed 2026-09-12T19:14:21.364Z sha 02de894f9b03f9100d012350db4e0288b5d19589 :: blocked before merge. :: none
  • reviewed 2026-09-12T19:53:33.529Z sha 76f41cf :: blocked before merge. :: none

@steipete steipete changed the title refactor: consolidate plugin reload ownership and caches refactor: consolidate plugin reload ownership and startup overlays Sep 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Sep 12, 2026
@steipete
steipete force-pushed the codex/plugin-reload-consolidation-146072 branch from 02de894 to 76f41cf Compare September 12, 2026 19:41
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Final evidence is now in the PR body for 76f41cfa7ada5f3a52d0cdb868bf07e9def69c25. The conflict is resolved and GitHub reports mergeable. Full build and changed checks passed. All six real Gateway cells passed on Node and both Bun versions. A fresh published 2026.9.4 updater completed all 12 steps to the final package in 123.5 seconds, preserving existing synthetic state; the installed Gateway and CLI lock cases passed. The body records the cold-cache limitation and exact tarball hash. Package metadata changes remain in-memory only; no persisted format or migration changes.

@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Confirmed the remaining compatibility checkbox for 76f41cfa7ada5f3a52d0cdb868bf07e9def69c25.

The plugin-package-metadata-capture.ts delta consolidates two in-memory maps into one map of lazy parsed records. It retains the existing package copy, manifest parsing, alias preparation, and capture lifecycle; it introduces no persisted schema, serialized fields, or new storage path. The automated data-model classification is a false positive, so there is no migration to add.

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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 12, 2026
@steipete
steipete merged commit ad08bd7 into main Sep 12, 2026
190 checks passed
@steipete
steipete deleted the codex/plugin-reload-consolidation-146072 branch September 12, 2026 20:09
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Sep 12, 2026
* 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
steipete added a commit that referenced this pull request Sep 12, 2026
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.
obviyus added a commit that referenced this pull request Sep 13, 2026
…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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…penclaw#146275)

* refactor: consolidate plugin reload ownership and caches

* fix(gateway): preserve startup config shape during reload
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
* 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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant