Repository navigation
fix(update): prevent missing backup modules after runtime replacement - #173587
fuller-stack-dev merged 1 commit into
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. What this changesThis PR retains backup module exports before an update replaces the running updater’s runtime files. Example: A Gateway-managed source update removes backup-sqlite-snapshot-BZo5zyAk.mjs during runtime activation.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Regression provenancePossible regression — probable (reviewed change; failure trace). No predecessor PR is attributed. Merge readiness✅ Ready for maintainer review Keep this PR open for landing: it repairs a confirmed update failure still present on main, and no actionable patch defects remain. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe update execution runtime prepares code before package replacement; the database backup owner then discovers stores and dispatches retained workers to produce verified recovery snapshots. flowchart TD
A[Gateway update request] --> B[Update execution preparation]
B --> C[Retained backup exports]
B --> D[Runtime replacement]
D --> E[Database backup owner]
C --> E
E --> F[Retained snapshot workers]
F --> G[Recovery snapshots]
Technical reviewBest possible solution: Land the focused preload repair through the existing update execution boundary. Do we have a high-confidence way to reproduce the issue? Main’s late imports expose the documented missing-chunk failure, corroborated by the author’s actual Gateway traces and matched replacement regression; no target code was executed during this review. Is this the best way to solve the issue? The change repairs loading order at the existing update-only boundary while preserving ordinary lazy loading and the backup owner’s behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4cf3df6352ce. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +16, Tests +77. Total +93 across 3 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed October 15, 2026, 9:39 PM ET / October 16, 2026, 01:39 UTC (Revision 2). |
Actual Gateway update proof: same target, unpatched versus patched updaterThis uses the shipped Gateway Both runs target the same local candidate, - SQLite ownership changed after discovery: ${archiveSourcePath}
+ SQLite ownership changed after discovery (disposable proof target): ${archiveSourcePath}The starting runtime is built at its recorded commit. The real updater performs its normal dependency installation, candidate build, validation, runtime activation, and backup. Both targets contain the fix; this deliberately tests whether the already-running updater survives replacement. Command used in each isolated environment: node <install>/openclaw.mjs gateway run
node <install>/openclaw.mjs gateway call update.run \
--params '{"timeoutMs":1200000}' --json --timeout 30000The patched trace records runtime activation ending at The patched backup contains a 3,407,872-byte shared SQLite database plus a 675,840-byte agent database. The marker row, workspace hash, and configured Scope: this proves the actual foreground Gateway handoff, post-replacement SQLite capture, and preserved data/settings. It is not a native launchd service test, PostgreSQL test, or forced restore test. Other update advisories occurred: later migration bookkeeping detected additional writes and retained snapshots instead of authorizing automatic restoration; isolated-profile native service reconciliation was skipped. These are included below rather than treating the entire update as warning-free.
The red run also reports Patched run: sanitized outcome, activation/capture timestamps, snapshot hashes, and preservation checks{
"startingCommit": "15d8f0cca993d3feb66ef12c1cac56ab037d786b",
"targetCommit": "741e76b95186dc91f1ccea9485031a8e22e3f51c",
"entrypointArgv": [
"node",
"<install>/openclaw.mjs",
"gateway",
"call",
"update.run",
"--params",
"{\"timeoutMs\":1200000}",
"--json",
"--timeout",
"30000"
],
"runId": "7a8d3bd8-f4af-4604-90f1-c0571b2927c2",
"status": "succeeded",
"phase": "finished",
"runtimeActivation": {
"step": "git-runtime-activation",
"status": "completed",
"startedAtMs": 1792113755202,
"endedAtMs": 1792113755298,
"exitCode": 0
},
"databaseCapture": {
"step": "diagnostic:database snapshot",
"status": "completed",
"startedAtMs": 1792113755308,
"endedAtMs": 1792113757888,
"detail": "Databases snapshotted at [path]/.artifacts/dist-runtime.openclaw-update-7653a06f-fb98-40f8-9604-0d563f1c5f6d.tmp.databases. Verified successful activation removes these snapshots; otherwise retain them with the update's recovery artifacts."
},
"databaseSnapshot": {
"name": "database snapshot",
"command": "snapshot databases before migrations",
"cwd": "<fixture>/home/.openclaw",
"durationMs": 2580,
"exitCode": 0,
"diagnostics": [
"Databases snapshotted at <fixture>/install/.artifacts/dist-runtime.openclaw-update-7653a06f-fb98-40f8-9604-0d563f1c5f6d.tmp.databases. Verified successful activation removes these snapshots; otherwise retain them with the update's recovery artifacts.",
"<fixture>/home/.openclaw/agents/main/agent/openclaw-agent.sqlite -> <fixture>/install/.artifacts/dist-runtime.openclaw-update-7653a06f-fb98-40f8-9604-0d563f1c5f6d.tmp.databases/payload/posix<fixture>/home/.openclaw/agents/main/agent/openclaw-agent.sqlite; schema 27; 675840 bytes; SHA-256 0762e7060f67cec02ac571b33e1efd7a1220d0480128ad82ecbaeb10774e9426",
"<fixture>/home/.openclaw/state/openclaw.sqlite -> <fixture>/install/.artifacts/dist-runtime.openclaw-update-7653a06f-fb98-40f8-9604-0d563f1c5f6d.tmp.databases/payload/posix<fixture>/home/.openclaw/state/openclaw.sqlite; schema 22; 3407872 bytes; SHA-256 8fb35906742bc5cfbbf3cdadfa0e044c3240f4058f76518f01dadc17dac62fd7"
],
"warnings": []
},
"observedSnapshot": {
"event": "snapshot_marker_verified",
"time": 1792113757.8011892,
"path": "<fixture>/install/.artifacts/dist-runtime.openclaw-update-7653a06f-fb98-40f8-9604-0d563f1c5f6d.tmp.databases/payload/posix<fixture>/home/.openclaw/state/openclaw.sqlite",
"copy": "<fixture>/observed-snapshots/b77356361e81.sqlite",
"bytes": 3407872,
"sha256": "8fb35906742bc5cfbbf3cdadfa0e044c3240f4058f76518f01dadc17dac62fd7",
"rows": [
[
1,
"synthetic-state-preserved-173587"
]
],
"integrity": "ok",
"oldChunksMissing": [
"backup-sqlite-snapshot-BZo5zyAk.mjs",
"backup-sqlite-snapshot-BRkDklZM.mjs"
]
},
"preservation": {
"rows": [
[
1,
"synthetic-state-preserved-173587"
]
],
"integrity": "ok",
"settingsPreserved": true,
"settingsCompared": [
"gateway",
"agents",
"plugins",
"update",
"commands"
],
"workspaceSha256": "a80466997ae31e4a55e7aaa2986472f80c26220ca26661810a8ce634a27ef5c2",
"head": "741e76b95186dc91f1ccea9485031a8e22e3f51c",
"afterChunks": {
"backup-sqlite-snapshot-Dod-H4nI.mjs": "ea575f176519b9bc962658dd3a0687e020bd475f3005f7cd3029a47a4a1ef969",
"backup-sqlite-snapshot-DqKD4186.mjs": "a4899d552ce39605a648d0eb7d9983ebcfc1d7256864f71aa289ec0c36e33538",
"database-backup-g5JLGOze.mjs": "6e019b1b59a3514e04e26e34425b38aec19c0fa49fb59ad7b70f6638ecec6bdc",
"database-backup-DGtEYguh.mjs": "c9d651b4670274fc8b923a614b5c6d85578fd61e1ac1dd59c1b04c83dceab5f1"
}
},
"gatewayVerification": {
"booted": true,
"runningVersion": "2026.10.3",
"runningBuildId": "2026.10.3-741e76b95186-2026-10-16T01-20-46.577Z",
"serviceRunning": true,
"pid": 496,
"versionMatch": true,
"pluginErrors": [],
"noticeDelivered": false,
"doctorHint": "Recommended follow-up: run openclaw --profile backup-proof-173587 doctor --non-interactive in a terminal or approvals-capable OpenClaw surface."
},
"healthOk": true,
"rpcOk": true,
"helperExitTrace": [
"[2026-10-16T01:23:14.712Z] managed update update command exited code=0 signal=null",
"[2026-10-16T01:23:14.723Z] managed update helper completed code=0"
],
"limitations": [
"Real foreground Gateway handoff in an isolated profile; no native launchd service and no live deployment.",
"Snapshot capture and preservation verified; forced automatic database restoration was not exercised.",
"Later database migration bookkeeping reported unknown writes and retained snapshots rather than authorizing automatic restoration."
],
"warningsByStep": [
{
"step": "openclaw doctor",
"warnings": [
"Skipped agent database path repair during update Doctor. Run openclaw doctor --fix after the update finishes.",
"core/doctor/security: WARNING: openclaw.json contains plaintext secret-bearing config fields."
]
},
{
"step": "database migration writes",
"warnings": [
"Automatic database restoration unavailable: databases changed after snapshot capture; the writer is unknown. Snapshots retained at <fixture>/install/.artifacts/dist-runtime.openclaw-update-7653a06f-fb98-40f8-9604-0d563f1c5f6d.tmp.databases."
]
}
],
"candidateDoctorAdvisories": {
"count": 15,
"summary": "Disabled provider plugin, browser import advisory, and deferred optional inspections in the synthetic fixture."
},
"beforeChunks": {
"backup-sqlite-snapshot-BZo5zyAk.mjs": "11cb323c3f1dfef2e8c26017f20860db684b841fca8295ddc3ec8e45fc042313",
"backup-sqlite-snapshot-BRkDklZM.mjs": "846047bd6be7087a2cc62543d1f7f273acc2097e67ff61574c54479d9b345348",
"database-backup-g5JLGOze.mjs": "6e019b1b59a3514e04e26e34425b38aec19c0fa49fb59ad7b70f6638ecec6bdc",
"database-backup-DGtEYguh.mjs": "c9d651b4670274fc8b923a614b5c6d85578fd61e1ac1dd59c1b04c83dceab5f1"
},
"runtimeBuild": "qaRuntime, exact starting commit, exit 0; normal candidate pnpm build executed by updater"
}Matched unpatched run: sanitized failure and recovery outcome{
"runId": "5f5c6529-292d-46f3-98c5-d42797c2ec6f",
"beforeSha": "a80c9757c3f14074dce1370f2af4322bc8bd4afc",
"targetSha": "741e76b95186dc91f1ccea9485031a8e22e3f51c",
"status": "failed",
"reason": "source-rollback-failed",
"verification": {
"rollbackOutcome": {
"status": "failed",
"reason": "Previous generation restoration did not complete"
},
"recovery": {
"serviceRestartSafe": false,
"reason": "runtime-verification-failed"
},
"noticeDelivered": false
},
"steps": [
{
"step": "git-runtime-activation",
"status": "completed",
"startedAtMs": 1792114167732,
"endedAtMs": 1792114167797,
"exitCode": 0
},
{
"step": "git-update",
"status": "failed",
"exitCode": 1,
"detail": "Exit code: 1; Cannot find module [redacted-path] | ERR_MODULE_NOT_FOUND",
"failureFacts": [
{
"check": "git update",
"code": "ERR_MODULE_NOT_FOUND",
"message": "Cannot find module [redacted-path] | ERR_MODULE_NOT_FOUND",
"errorName": "Error",
"location": null
}
]
},
{
"step": "git-runtime-rollback",
"status": "failed",
"exitCode": 1,
"detail": "Exit code: 1"
},
{
"step": "git-runtime-backup-retention",
"status": "failed",
"exitCode": 1,
"detail": "Exit code: 1; Git recovery is unverified; previous runtime retained at [path]/di"
},
{
"step": "gateway recovery verification",
"status": "failed",
"exitCode": 1,
"detail": "Exit code: 1; service management skipped: non-default state dir or config path. Rerun with HOME set to the OS account home, OPENCLAW_H",
"failureFacts": [
{
"check": "gateway-recovery",
"code": "gateway-probe-failed",
"message": "service management skipped: non-default state dir or config path. Rerun with HOME set to the OS account home, OPENCLAW_HOME either unset or pointing at that same home, and OPENCLAW_STATE_DIR and OPENC"
}
]
}
],
"oldRuntimeImporter": "dist/update-database-backup-CUaWNTFS.mjs:248, inside createUpdateDatabaseBackup, dynamically imports ./backup-sqlite-snapshot-5eszxg3P.mjs",
"candidateBackupChunksObservedDuringActivation": [
"backup-sqlite-snapshot-Dod-H4nI.mjs",
"backup-sqlite-BckNUBra.mjs",
"backup-sqlite-snapshot-DqKD4186.mjs"
],
"exactMissingSpecifierRecorded": "no: handoff error is redacted; old-importer/chunk mismatch is inferred",
"offlineAfter": {
"head": "a80c9757c3f14074dce1370f2af4322bc8bd4afc",
"gitStatus": "",
"databaseBytes": 3231744,
"marker": "synthetic-state-preserved-red-173587",
"integrity": "ok",
"workspaceSha256": "4a82f2a7f59010722955e559c2d108d0175fdacb337c5cc59a1d11a44c547b32",
"configPort": 58684
},
"manualForegroundRestartHealthOk": true,
"stoppedAfterManualCheck": true,
"updaterExitCode": 79,
"helperExitCode": 79
}Earlier real Gateway failure: directly recorded missing backup specifier (different target){
"at": "2026-10-16T00:19:46.812Z",
"startingCommit": "a80c9757c3f14074dce1370f2af4322bc8bd4afc",
"targetCommit": "6574349e132d11db684392cfd1ef8cb9f32598e6",
"code": "ERR_MODULE_NOT_FOUND",
"specifier": "./backup-sqlite-snapshot-5eszxg3P.mjs",
"parent": "<install>/dist/update-database-backup-CUaWNTFS.mjs"
} |
|
@clawsweeper re-review Added the requested sanitized real-update proof with a matched unpatched/patched comparison, and updated the PR evidence section. The exact PR starting updater completes runtime replacement, captures nonempty SQLite backups afterward, preserves settings/data, and finishes with a healthy automatically restarted Gateway. The comparison uses the same candidate target; limitations and the control run's recovery outcome are explicit. PR head remains |
|
🦞👀 Re-review progress:
|
|
Cross-reference: #173754 is being closed as addressed by this merged fix. The issue records an older updater's post-activation |
What Problem This Solves
Fixes source updates failing with
ERR_MODULE_NOT_FOUNDafter the updater replaces its own runtime files.User Impact
Gateway-managed source updates can capture the rollback database backup after runtime activation without trying to load removed modules from the previous build.
Why This Change Was Made
The regression was introduced on October 13 by #170828 (commit d0ea7eae7ead). PostgreSQL backup support added lazy imports of
backup-sqlite-snapshotandsnapshot/database-backuptocreateUpdateDatabaseBackup. These imports run on the shared backup path, including SQLite installations; they were absent from this function before that change.The existing Git update flow activates the replacement runtime before capturing the rollback database backup. The still-running updater can therefore request a hashed module from its old build after that file has disappeared. Load and retain those module exports at the existing awaited, update-only preparation boundary, then reuse them during capture.
This also explains why a long-running
dev/maininstallation can start failing only recently: the update that installs the regression can succeed under the previous updater, while a subsequent update runs the affected code. The failure can be masked when the backup path already loaded these dependencies before activation or when the replacement build retains the same hashed filenames. A successful retry alone does not establish that the loading-order defect is fixed.Evidence
a80c9757c3f1toward6574349e132d: activation failed withERR_MODULE_NOT_FOUNDforbackup-sqlite-snapshot-5eszxg3P.mjs, imported by the oldupdate-database-backup-CUaWNTFS.mjs. The updater rolled back and verified the previous Gateway healthy.update-database-backup.test.ts,update-execution.runtime.test.ts, and the new process regression. Core typecheck, targeted lint/format, and theqaRuntimebuild pass. Fresh autoreview found no actionable issues.ERR_MODULE_NOT_FOUNDafter runtime activation. The patched starting updater captures two nonempty SQLite snapshots after activation, preserves the marker row/settings/workspace data, exits 0, and automatically restarts a Gateway that passes health and RPC checks. Snapshot hashes, timing, old/new chunk names, and the recovery limitations are included in the evidence. The live installation was unchanged; PostgreSQL and forced database restoration were not tested.