Skip to content

fix(update): prevent missing-module failures during source updates - #174867

Merged
steipete merged 2 commits into
mainfrom
upd/upd-l1658
Oct 17, 2026
Merged

steipete merged 2 commits into
mainfrom
upd/upd-l1658

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #174687. Source updates can fail with ERR_MODULE_NOT_FOUND when the running updater lazily loads an old hashed chunk after activating the replacement build.

User Impact

The updater can finish activation, Doctor, finalization, and recovery using its original runtime even after the installed build has changed.

Why This Change Was Made

Git updates already build a candidate separately, but activation replaces the installed dist while the original updater continues running. The existing retained-runtime owner preserved worker code; parent-process imports still resolved against the replaced installation. Reuse that same retained inventory for parent imports, preserving original module URLs and already-loaded singleton identity. The loader is scoped to retained importers and keeps the original generation available until process exit, including CLI resource cleanup after the update command returns. No new configuration, dependencies, or persistent retention mechanism.

Thanks to @vishnusenthil-16 for the resolver tracing that identified the core port-provider importer and its missing chunks, and for the earlier backup-helper fix in #173587. That fix prepared two backup helpers; this covers remaining lazy imports through the existing runtime-retention boundary.

Evidence

  • Regression fails without parent import retention with ERR_MODULE_NOT_FOUND for the removed old hashed chunk, and passes with the fix. It covers relative and absolute imports, cold dependencies, singleton identity, original module URLs, unrelated source tooling, and a cold CLI cleanup import after the update command returns. The cleanup case also fails when hooks are retired at command return.

  • 133 tests pass across the ten retained-runtime, publication, worker-generation, and immutable-update sibling files; one existing platform-specific test is skipped. The new regression takes 1.57 seconds of test time (3.74 seconds wall time).

  • Core typecheck, targeted oxlint/oxfmt, git diff --check, and Madge pass (zero cycles). A deliberate debugger canary fails the direct oxlint command; the real changed files are clean. The lint wrapper was stopped during unrelated plugin SDK declaration preparation, then the same installed lint engine was run directly.

  • Runtime build (node --import ./scripts/tsx.mjs scripts/build-all.mts qaRuntime) passes in 80.5 seconds. Full check:changed SQLite inventory was omitted under the campaign's local gate budget; PR CI provides broad proof.

  • Fresh Codex review is clean at P0–P2 after fixing its absolute-path and importer-scope findings. Production: +70/-0 lines; regression: +101/-0; documentation: +6/-0. Existing runtime retention still owns snapshots and cleanup.

  • Live macOS / Node 26.12.0 proof used an isolated Git checkout, HOME, state directory, and loopback port. The local fixture updated 751fad28a6d3bfc0bb3267cf7507894f052224aa → f4d53c052dfba6519783c2a4dcfc8c51c2827025; the starting revision contains this exact production patch, and the target changes a core runtime chunk. The native updater performed dependency installation, full build, copied-state Doctor/config/plugin/recovery/startup checks, activation, finalization, and foreground Gateway restart. The run finished succeeded; the CLI exited 0; the new Gateway's build identity matched the target, health was OK, and the synthetic workspace marker survived.

  • After activation, 3,165 old root chunks were absent from the installed dist. The old parent performed 1,849 retained-module loads after the observed swap, including five absent chunks (registry-CP3x1tRD.mjs and memory-state-DRwbuuah.mjs among them). The complete handoff log contains no ERR_MODULE_NOT_FOUND, missing-module exception, or CLI cleanup failure. Conservative backup-retention warnings from native process inspection, plus expected custom-state/credential-free fixture warnings, remained nonblocking.

Live entry points (paths and token omitted):

HOME=<isolated-home> OPENCLAW_STATE_DIR=<isolated-state> pnpm openclaw gateway run --allow-unconfigured --port <free-port>
GatewayClient.request("update.run", { target: { kind: "git", upstreamRef: "origin/main", upstreamSha: "f4d53c052dfba6519783c2a4dcfc8c51c2827025" } })
update.status: lastRun.status=succeeded, verification.versionMatch=true, verification.pluginErrors=[]
health: ok=true
CLI exit: 0; missing-module / CLI-cleanup errors: 0

The fixture revisions are local proof commits, not published release refs. This proves the updated driver's next update; it does not retrofit already-running older updaters.

Reuse the retained updater runtime for parent module imports while keeping
original module identity. Retain the loader through process exit because CLI
resource cleanup can import old hashed chunks after the update command returns.

Fixes #174687. Thanks to @vishnusenthil-16 for the resolver tracing that identified
the missing core chunks and their importer.
@clawsweeper

clawsweeper Bot commented Oct 17, 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 size: S labels Oct 17, 2026
Preserve both the retained-runtime update contract and the migration-integrity
guidance added on main. The live-proven production and test patch is unchanged.
@steipete
steipete marked this pull request as ready for review October 17, 2026 00:11
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T00:14:31.765189Z 8d88086 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR preserves the running updater’s lazy module imports after an update replaces its installed build.

Example: A Git update replaces dist while the old updater still needs registry-CP3x1tRD.mjs.

  • Before: The removed old chunk can cause ERR_MODULE_NOT_FOUND during finalization or cleanup.
  • After: The old updater loads retained bytes under its original module URL, while the new Gateway uses the activated build.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused owner-approved repair with shipped-entry-point proof, a meaningful process regression, and no actionable correctness or security findings; CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied isolated macOS/Node Gateway update.run output exercises the patched starting updater across activation with changed chunk names: retained parent imports continue after old files disappear, finalization and CLI teardown complete, and the new Gateway reports the target build and healthy status.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A source update can fail after activation because the still-running updater imports a chunk removed by the replacement build.
Reason: The confirmed incident and recorded owner direction justify a focused extension of the existing retained-runtime mechanism.

Merge readiness

✅ Ready for maintainer review

Keep this PR: it addresses a confirmed source-update failure through the existing retained-runtime owner, with relevant live proof and no actionable findings.

Priority: P1
Reviewed head: 8d880860622246e443de075349b2c44442883fa0

Before merge

None.

Findings

None.

Agent review details

How this fits together

The update command retains its runtime before replacing installation files; this change extends that inventory from background workers to parent-process module resolution and loading.

flowchart TD
  A[Update command] --> B[Retained runtime inventory]
  B --> C[Parent module hooks]
  C --> D[Old updater finalization and cleanup]
  A --> E[Replacement build activation]
  E --> F[New Gateway]
Loading

Technical review

Best possible solution:

Use the existing retained inventory for old parent imports through process teardown while starting the replacement Gateway from the activated build.

Do we have a high-confidence way to reproduce the issue?

The reporter’s resolver trace, current-main retention boundary, and process regression establish the stale-chunk path; this read-only review ran no target code.

Is this the best way to solve the issue?

The repair addresses the shared runtime boundary instead of adding more individual preloads, preserves singleton identity, and leaves unrelated importers on their normal resolution path.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f6bcd2cc92b8.

Provenance checked

  • Retained updater runtime keeps the original intent (dd7d596: Preserve running worker code while installation files are replaced; later hardlink and lifecycle changes keep that retention inexpensive and safely settled.)
  • Retained-runtime lifecycle integration keeps the original intent (5f8e15a: The creating generation owns worker settlement and retained-runtime cleanup, including failure paths and checkout plugin safety.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 5f8e15a adds src/infra/update-retained-runtime.ts:205 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5f8e15abdef4; files: src/infra/update-retained-runtime.ts)
  • Dallin Romney: Raw commit 032a58b adds src/infra/update-retained-runtime.ts:93 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 032a58bf34d6; files: src/infra/update-retained-runtime.ts)
  • Vincent Koc: Raw commit 317054d adds src/infra/update-retained-runtime.ts:13 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: 317054d42739; files: src/infra/update-retained-runtime.ts)

PR surface

Source +70, Tests +101, Docs +6. Total +177 across 4 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 70 0 +70
Tests 1 101 0 +101
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 177 0 +177

Labels

Label changes:

  • add P1: A confirmed failure interrupts the real Gateway-managed source-update workflow after runtime replacement.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P1: A confirmed failure interrupts the real Gateway-managed source-update workflow after runtime replacement.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 16, 2026, 8:26 PM ET / October 17, 2026, 00:26 UTC.

@steipete
steipete merged commit 714e589 into main Oct 17, 2026
203 of 205 checks passed
@steipete
steipete deleted the upd/upd-l1658 branch October 17, 2026 00:32
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
… rebuild (openclaw#174867)

Git-checkout updates could fail with ERR_MODULE_NOT_FOUND and roll back: the updater kept running from <checkout>/dist while git-update rebuilt dist in place, and later lazy imports in the old process (e.g. dist/port-provider importing targets, agent-db registry listing and config chunks) resolved hashed chunk names the new build had replaced. The existing updater runtime-retention owner now serves the parent process's imports from its retained bytes through process exit, including CLI cleanup after the update returns, while preserving original module URLs so singletons keep their identity. Live: an isolated git-checkout update loaded five chunks already absent from the replacement build and finished with a healthy target Gateway and a clean CLI exit. Root-cause analysis by @vishnusenthil-16.

Fixes openclaw#174687
RomneyDa added a commit that referenced this pull request Oct 28, 2026
… rebuild (#174867)

Git-checkout updates could fail with ERR_MODULE_NOT_FOUND and roll back: the updater kept running from <checkout>/dist while git-update rebuilt dist in place, and later lazy imports in the old process (e.g. dist/port-provider importing targets, agent-db registry listing and config chunks) resolved hashed chunk names the new build had replaced. The existing updater runtime-retention owner now serves the parent process's imports from its retained bytes through process exit, including CLI cleanup after the update returns, while preserving original module URLs so singletons keep their identity. Live: an isolated git-checkout update loaded five chunks already absent from the replacement build and finished with a healthy target Gateway and a clean CLI exit. Root-cause analysis by @vishnusenthil-16.

Fixes #174687

(cherry picked from commit 714e589)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S 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.

Update failure: git-update (2026.10.4)

1 participant