Repository navigation
fix: restore Gateway restarts after Git updates - #138781
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: needs maintainer review before merge. Reviewed September 4, 2026, 10:54 PM ET / September 5, 2026, 02:54 UTC. ClawSweeper reviewWhat this changesThe PR loads Gateway activation helpers before an update replaces its build files and adds regression coverage for launching the updated command afterward. Merge readiness✅ Ready for maintainer review This remains a useful, focused repair: current main and v2026.9.1 retain the failing imports. No blocking correctness or security findings were identified, and the supplied emitted-code proof covers the changed activation boundary. Priority: P1 Review scores
Verification
How this fits togetherOpenClaw’s updater stops the managed Gateway, replaces the installation, and launches the updated CLI to restart it. The activation helper connects update finalization to that new process, after which existing checks verify Gateway readiness. flowchart TD
A[Update requested] --> B[Preload execution helpers]
B --> C[Stop Gateway and replace build]
C --> D[Resolve updated CLI]
D --> E{Candidate available?}
E -->|Yes| F[Launch install or restart command]
E -->|No| G[Existing fallback or explicit rejection]
F --> H[Verify Gateway readiness]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0, Tests +103. Total +103 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. Technical reviewBest possible solution: Keep activation dependencies loaded before build replacement, then launch the candidate under the existing service-ownership and readiness rules. Do we have a high-confidence way to reproduce the issue? Yes: current source retains imports that can request removed build files after replacement, matching the incident trace and reported failing-before regression. This review did not execute a current-main reproduction. Is this the best way to solve the issue? Yes: the patch repairs the existing preload boundary without changing activation policy. Supplying only a Node runner would leave the other delayed imports exposed, while retries would still request deleted files. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b78612ac3ac0. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Maintainer pre-merge review is complete for head Validation:
Fresh autoreview was scoped-clean through P2 with no findings or incomplete scope (confidence 0.96). Exact-head CI run https://github.com/openclaw/openclaw/actions/runs/33939582103 is green, including required Before: after a Git update replaced the running installation's generated files, activation could fail before candidate spawn with After: the activation owner eagerly loads all dependencies inside the existing preload closure. The focused process regression and disposable emitted-build proof delete the old module files, then successfully launch restart/install candidates while retaining explicit missing-candidate rejection. Production LOC is Known proof gap: no native systemd, launchd, or Scheduled Task end-to-end execution was run. The observed failure and repaired boundary occur before service-manager invocation; existing integration coverage retains ownership and readiness checks. |
|
Merged via squash.
|
* origin/main: fix(gateway): keep webhook ingress retryable during hot reload (openclaw#138627) fix: restore Gateway restarts after Git updates (openclaw#138781) fix(gateway): stop repeated teardown after WebSocket failures (openclaw#138818) fix(gateway): abort exact live runs when cancelling tasks (openclaw#118358) refactor(memory): share typed embedding-cache writes (openclaw#138827) fix(a2a): preserve tasks while reserving commands for users (openclaw#138731) feat: tune inbound batching without reconnecting channels (openclaw#138780)
Retain the released updater node-runner facade and keep post-core children out of top-level run admission. The parent owns the update result, so finalization cannot leave an independent requested/running record after service recovery. Preserves the eager preload fix from #138781. Incorporates the frozen-package bridge from #139615; reported in #139383 by @coygeek. Co-authored-by: Alex Naidis <[email protected]>
* fix: restore Gateway restarts after Git updates * test: align update installer mock with eager import
Retain the released updater node-runner facade and keep post-core children out of top-level run admission. The parent owns the update result, so finalization cannot leave an independent requested/running record after service recovery. Preserves the eager preload fix from openclaw#138781. Incorporates the frozen-package bridge from openclaw#139615; reported in openclaw#139383 by @coygeek. Co-authored-by: Alex Naidis <[email protected]>
* fix: restore Gateway restarts after Git updates * test: align update installer mock with eager import (cherry picked from commit 24d8119)
* fix(update): restore Gateway after partial stop failure Adapt the service-mutation recovery invariant to the 2026.8 updater owner. (cherry picked from commit ad682b4) * fix(update): replace unsupported service Node runtimes Adapt the recorded-service runtime probe to the 2026.8 daemon install plan. (cherry picked from commit fe79d36) * fix(gateway): gateway stays offline after agent restart on Windows (#134549) * fix(gateway): keep agent restart alive on Windows * docs(gateway): clarify Windows agent restart routing --------- Co-authored-by: Josh <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 3a0a623) * fix: published Linux upgrades leave unchanged gateways stopped (#151049) * fix(update): preserve service fingerprints across published upgrades Keep known-empty systemd override metadata out of the fingerprint retained by published updaters through 2026.9.4. Preserve full command metadata for runtime pinning and reject actual protected service changes. * test: group silence failures with error payload coverage Keep the required sealed-answer fixture field while moving its related failure-policy cases into the existing error payload test module. Preserve every case and assertion without growing the over-cap payload test file. (cherry picked from commit 4475640) * fix(doctor): preserve explicitly configured profile workspaces (#145976) * fix(doctor): preserve configured profile workspaces * fix(doctor): avoid assuming workspace ownership Co-authored-by: ericcaiwx-star <[email protected]> (cherry picked from commit 1e8ba48) * fix(plugins): stop relocated install records from shadowing bundled plugins (#144843) * fix(plugins): stop relocated install records from shadowing bundled plugins A `path` install record stores an absolute directory. When that directory is another OpenClaw installation's bundled plugin tree, the record survives the installation move and is rediscovered as an `origin: "global"` candidate. `global` outranks `bundled`, so the stale pin won the duplicate-id contest and the plugin resolved from the old installation. `resolvePluginTrust` then saw `record.source === "path"` and downgraded it to `origin-path`, which revokes trusted plugin state and fails trusted-only APIs mid-turn. `isIntentionalInstalledBundledDuplicate` also suppressed the duplicate warning, because installed-shadows-bundled is normally deliberate, so the swap was silent. Treat a plugin directory inside a *different* installation's bundled roots as stale: it no longer outranks the current bundled copy, and it no longer counts as an intentional shadow, so the existing duplicate warning reports it. * fix(plugins): name the stale install record instead of a generic duplicate The duplicate-id warning reported "global plugin will be overridden by bundled plugin", which describes the mechanism but gives an operator nothing to act on. A pin into another installation's bundled tree is a stale record rather than a deliberate override, so report it as one and name the remedy. * docs(agents): record that a stored absolute path is not provenance The stale-pin defect this branch fixes came from a persisted absolute path that kept conferring bundled status after the installation it named was replaced. Record the invariant so the next record type does not repeat it. * fix(plugins): narrow the stale-pin gate to relocated compiled trees Review of the preceding guard found two ways it misfired. It answered "foreign" by negating a membership test against the running package roots, so an install whose root resolves from neither argv nor the module URL saw every bundled tree as foreign, including its own. Compiled sibling trees and the module walk-up fallback resolve exactly that way, so the gate now fails open when the running root is unknown. It also accepted `<root>/extensions/<id>`, the documented `plugins install --link` development target, which made a deliberate local override report as a stale record and told the developer to delete it. Only compiled `dist`/`dist-runtime` trees travel with an installation, so the shape check is limited to those, and a plugin inside the configured dev source root is excluded at the call site, where importing it raises no cycle. * test(auth): pin external credential refresh timing (#152771) --------- Co-authored-by: Peter Steinberger <[email protected]> (cherry picked from commit 5ec3614) * fix(plugins): archive updates fail on development-only dependencies (#143350) * fix(plugins): isolate npm manifest resolution * fix(plugins): preserve hook host dependencies * test(plugins): align npm isolation coverage with CI limits * fix(plugins): link optional-only OpenClaw host dependencies * test(gateway): settle companion databases before fixture cleanup * test(plugins): cover optional hosts in native import preparation * test(skills): close status watchers before retiring fixture roots --------- Co-authored-by: Gio Della-Libera <[email protected]> Co-authored-by: Jason (Json) <[email protected]> (cherry picked from commit cbf935b) * fix(gateway): release agent leases when shutdown completes (#151435) Drain the existing agent database lifecycle during final Gateway retirement before shared state closes. Preserve sibling ownership and surface native-close failures without dropping their lease. Four new regressions fail on the original code. The repair passes 92 focused cases and an isolated four-case rerun, changed checks, and independent P0-P2 review. (cherry picked from commit 3381de9) * fix: restore Gateway restarts after Git updates (#138781) * fix: restore Gateway restarts after Git updates * test: align update installer mock with eager import (cherry picked from commit 24d8119) --------- Co-authored-by: josh <[email protected]> Co-authored-by: Josh <[email protected]> Co-authored-by: Peter Steinberger <[email protected]> Co-authored-by: Eric Cai <[email protected]> Co-authored-by: Gio Della-Libera <[email protected]> Co-authored-by: Gio Della-Libera <[email protected]> Co-authored-by: Jason (Json) <[email protected]> Co-authored-by: Jason O'Neal <[email protected]>
Closes #138760 — Git updates can leave the Gateway stopped after loading a removed restart bundle.
Additional instructions
Allow edits from maintainers is enabled.
What Problem This Solves
Fixes an issue where users updating a Git installation would be left with a stopped Gateway even though the new version built successfully and passed Doctor. Finalization failed before it could launch the new version's restart command, reporting
restart-unhealthy/runtime-verification-failed.Why This Change Was Made
The activation command still dynamically imported dependencies after the updater had replaced its own generated files. This change makes those dependencies eager within the existing preload-before-replacement boundary, covering the Node resolver, update-mode check, and legacy service-install helper without changing restart, ownership, environment, version, or health policy.
User Impact
Git updates can proceed to restart and verify the newly installed Gateway instead of failing on a removed bundle. No new settings, migrations, retries, version rollback, or database changes are introduced; supplied Node runners, service-definition preservation, and safe missing-candidate rejection remain intact.
Evidence
The completed proof below used this patch applied to base
dcdbd055c7b4d2c96b7ca96adf6b9ab6fd9ef617; that source tree is recorded by published commit99aa2f15e2749fd9a9d4657097be22e1f42f3a3d. These local results are separate from subsequent merge-ref CI.Observed failure
The documented Linux/Node 24.19.0 update went from 2026.8.1 (
c6f6055a527e91c5d17b166b81d0023581318526) to 2026.9.1 (0229a108fee749327b2cc60c4d228299dfe2f889). Sanitized local output:The exception occurs in
runUpdatedInstallGatewayCommand()while resolving Node, before spawning the candidate. The old implementation can already be cached while its separately emitted namespace facade is not. Fresh-process validation and starting the verified candidate restored Gateway health/RPC without rollback or database repair; that recovery is incident evidence, not a deployment of this patch.Regression and sibling coverage
The new native-Node process test loads real helper implementations, maps the owner's imports to physical namespace facade files, loads the actual activation owner, deletes/recreates the fixture build directory, then invokes it without an injected Node runner. Restart and install spawn real candidate Node processes and assert their argv, executable, configuration selector, and compile-cache isolation. A missing package-manager candidate must still be rejected safely.
Before the production change, all three new cases failed with
ENOENTfor removed facade files. Afterward:Sibling coverage includes preserved service definitions, candidate version guards, expected Git build identity, stale-launcher recovery, failed-update recovery safety, and macOS/Windows decision paths. These tests do not claim native macOS/Windows service-manager execution.
Real behavior proof
runUpdatedInstallGatewayCommand()from the actual emittedpnpm buildoutput for patch commit99aa2f15e2749fd9a9d4657097be22e1f42f3a3d. The exact reviewed PR head is2dc5b10ec533ed70245a03a3f05fb61a8e0c2fc8; its only later change is the test mock correction described below, with no production change to this owner.dist, installed a recording candidate entrypoint, and invoked restart, install, and missing-candidate paths through real Node subprocesses.pnpm build:node /tmp/openclaw-update-restart-built-proof.mjs. The script ran from the checkout root and removed its temporary fixture on exit.gateway restart --preserve-definition --jsonandgateway install --force --json, the isolated config selector, and disabled compile cache. The missing-candidate case rejected as expected.Reproduce the emitted-code check on Linux after pnpm build
Save this as
/tmp/openclaw-update-restart-built-proof.mjs, then run it with Node from the checkout root. It creates and removes only a temporary fixture.Build and review
Fresh independent
autoreviewof the full patch againstdcdbd055c7b4d2c96b7ca96adf6b9ab6fd9ef617: scoped-clean through P2, no findings. Review included the unchanged preload boundary and dependency implementations, not just the diff.pnpm buildpassed, including native built plugin control-plane loading, CLI bootstrap import guards, plugin SDK export validation, and the Control UI build. NoINEFFECTIVE_DYNAMIC_IMPORTwarnings were emitted.Production typechecking, formatting, dependency guards, plugin boundaries, and deprecation checks passed. The full test-typecheck and remaining canonical changed-plan guards have now passed as well. The interrupted serial test-typecheck was resumed using
pnpm tsgo:core:test --stripe 1/1 --concurrency 4, which selects all 16 graphs; subsequent guards ran in their canonical order. This is combined local validation evidence, not a claim that the original interrupted wrapper completed.Production delta: +6/-6 lines (net zero). Test delta: +104/-1 lines; no new production test seam.
CI follow-up
The first merge-ref run for head
99aa2f15e2749fd9a9d4657097be22e1f42f3a3dfailed only inchecks-node-compact-small-51: three existing service-refresh tests insrc/cli/update-cli.test.tsexpected installer-stub calls but observed none. The suite still mockeddaemon-cli/install.runtime.js, while the repaired activation owner now importsdaemon-cli/install.jseagerly.The same three assertion failures reproduced locally with
node scripts/run-vitest.mjs src/cli/update-cli.test.ts -t 'updateCommand service refresh behavior'(3 failed, 2 passed). The follow-up targets the implementation owner with a partial mock: onlyrunDaemonInstallis replaced, while real exports such asmergeInstallInvocationEnvremain available to the existing explicit-wrapper test. Retargeting a whole-module mock initially exposed that sibling dependency; the partial mock preserves it. No assertions, production behavior, or restart safety policy change.After the final partial-mock correction in
2dc5b10ec533ed70245a03a3f05fb61a8e0c2fc8:The complete owner and restart/recovery run also passed on the same final source tree:
Targeted formatting and lint pass. Fresh independent review of the final combined fixture correction is scoped-clean through P2 with no findings. CI run 33939582103 passed for head
2dc5b10ec533ed70245a03a3f05fb61a8e0c2fc8, including the previously failing shard and aggregate CI gate. The final observed rollup had no pending or failed checks.Proof boundary: both the source regression and emitted-code check exercise the native module loader and subprocess boundary, not a real systemd/launchd update end to end. Repeating the operator's real update would replace their installation and disrupt their running Gateway; PR validation deliberately used disposable fixtures instead. The operator's running Gateway, configuration, session history, and databases were not changed for this validation. Native cross-platform service-manager E2E remains untested by this PR.