Skip to content

fix: recover interrupted npm package updates - #158491

Merged
steipete merged 35 commits into
mainfrom
codex/atomic-update-recovery-20260925
Sep 28, 2026
Merged

steipete merged 35 commits into
mainfrom
codex/atomic-update-recovery-20260925

Conversation

@steipete

@steipete steipete commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Interrupted npm updates can leave the package and launchers partly replaced, with recovery dependent on the updater surviving.

User Impact

Supported POSIX npm updates print a standalone recovery command before publication. Its status, repair, and retire operations inspect and finish the recorded package operation. Automatic rollback restores the previous package, configuration, and service when safe, preserving newer writes in compatible databases. If a candidate may have served with incompatible databases, recovery retains it and its data and explains the refusal.

After updater loss, Gateway restart remains an operator action; keep other package managers stopped during recovery. Windows, native pnpm/Bun layouts, older targets, and local override reapplication retain their existing owners. Full-state checkpoint replay and reverse database migrations remain deferred; #144005 and #145169 remain open.

Why This Change Was Made

One durable package journal owns publication and recovery; existing owners retain database, configuration, and service recovery. The installed post-core worker receives live delegated authority and reports completion only after its children settle. The unused state-generation engine, inverse migrations, private store transport, and associated tests are removed. The earlier review’s legacy-journal concern is handled by read-only inspection and guidance to the original helper; its reverse-publication concern is removed with that unused owner.

Against integrated main 9ac47355, the change is +11,065/−2,062 lines across 130 files (+9,003 net). That is about 64% less net growth than the original PR, with 4,168 net production lines and 4,754 net test/support lines. The retained implementation protects package publication, original-owner authority, crash recovery, and durable retirement.

Related: #142770. Thanks to @fuller-stack-dev (Jason) for the original recovery work and design; contributor credit is preserved.

Evidence

Real installed Crabbox testing through Blacksmith passed in run 36280374595, bound to d1621807a918617ed0f96d6a9f84130072b92d34:

  • The published 2026.9.6 updater installed the candidate and restarted the Gateway on its first attempt, including state schema 18 → 19 and agent migration (512s).
  • After acknowledged cron/transcript writes, injected service failure restored the exact previous build, launchers, configuration, and healthy Gateway; old and new data survived.
  • After updater SIGKILL and verified process extinction, the sealed helper inspected, repaired, and retired the operation. Explicit restart restored a healthy Gateway with the data intact.

Rollback and owner-loss scenarios used isolated users and real user-systemd services, with verified cleanup. Rollback used a same-schema, candidate-derived previous package. The owner-loss cut followed completed publication: it does not prove mid-rename recovery, automatic restart, full-state replay, or .clawdbot relocation. Workspace data was synthetic. These installed results remain evidence for their exact older revision.

Earlier scoped qualification combines 1,413 distinct passes and six Darwin-only skips across 57 files: 35 owner files (882 passes) and 23 shared CLI files (548 passes), with 17 overlapping npm-runtime cases counted once. These were multiple source-bound runs against production 51072c9 plus test/fixture corrections, ending at bcc03918; they were not one passing full-suite run or execution of this merge.

Focused regressions demonstrated copy durability (32/32; 37.67s), final-helper directory persistence and retry refusal (63/63; 283.88s, strengthened case 1.583s), and retained MCP fixture isolation in the original five-file order (337/337; 480.19s). All 114 MCP runtime cases and existing deadlines were preserved. Native build and pnpm check passed at 51072c9.

Current head: 83c03dc3edd0e5b4d9b9340eb2d315508dc6258d. Fresh Crabbox integration verified its published source tree and passed core typechecking (39.007s) plus 485 tests across 12 files, with six Darwin-only skips. Package/filesystem ownership and cleanup: 94 passes (55.546s); CLI staging, admission diagnostics and no-op behavior: 54 passes (50.059s); the original five-file MCP order: 337 passes (107.051s), preserving its non-isolated threads runner, setup and deadlines. Both independent integration review passes had no P0–P2 findings. Changed-file lint, formatting, diff, and line-count checks passed. Exact-head Security Review, dependency review and security-fast passed.

Broad CI is not green. CI preflight refused the existing changed-test planner’s 186 Node jobs against its 130-job limit before tests ran. Build Artifacts failed on duplicate dataImageClipboardFile exports in later-main UI source: tested merge cefc767d2c12de0b9b5f56af2857e46273266bd9 contains the exact UI blob from its main parent 3c1a919bb919d24f996106090533668045e343fa; this PR’s own head has neither export in that file. These are separate from the successful scoped checks; source equality is not presented as a passing baseline execution.

Broader validation limits

The native full test run was interrupted after twelve state-lease mock failures (missing throwSqliteLifecycleErrors; matching compared-main source, without baseline execution) and an unresolved UI-fixture subprocess failure. Its replay failed during ENOTEMPTY cleanup, leaving the original cause unknown.

Two full remote attempts lost SSH without completed results. Session-fixture WAL/SHM cleanup also raised ENOTEMPTY; a passing replay established no repair. An MCP release wrapper exceeded its deadline; private-cache changes establish ownership, not a timing fix. A macOS memory batch timeout and initialization failure did not reproduce in a 70/70 Linux run. Six Darwin-only symlink cases remain skipped in Linux. Full-suite success is not claimed.

steipete and others added 10 commits September 25, 2026 07:13
Preserve current rows for same-version recovery copies, refuse permission-bearing schema downgrades, and bind inverse preparation to explicit migration versions. Stage each SQLite copy before exclusive publication and clean incomplete outputs on every failure.

Co-authored-by: Jason (Json) <[email protected]>
Verify bound baseline and candidate manifests, prepare a private recovery generation through isolated SQLite workers, and route the original rollback controller through that preparation without claiming publication. Reuse current config, durability, status, and snapshot-sanitizer owners while preserving schema-19 refusal and immutable B/C evidence.

Co-authored-by: Jason (Json) <[email protected]>
Persist reverse preparation before staging, resume interrupted publication through the sealed helper, and commit terminal rollback only after the restored state is readmitted. Keep old runtime preflight read-only, preserve schema-19 authority, and refuse incompatible reverse preparation.

Co-authored-by: Jason (Json) <[email protected]>
Keep prepublication failures on the untouched-package recovery path, support stable Unix npm symlink launchers, and retire a publication whose first displacement was refused.

Co-authored-by: Jason (Json) <[email protected]>
Move shared recovery and handoff types to leaf modules so runtime owners remain acyclic, and document the three read-only raw SQLite recovery primitives.

Co-authored-by: Jason (Json) <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 26, 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 app: web-ui App: web-ui cli CLI command changes scripts Repository scripts commands Command implementations size: XL labels Sep 26, 2026
@steipete
steipete marked this pull request as ready for review September 26, 2026 00:35
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 28, 2026, 2:39 AM ET / 06:39 UTC (Revision 7).

ClawSweeper review

What this changes

The branch adds a durable journal and standalone helper for recovering supported POSIX npm package updates, with updater handoff, status output, tests, and documentation.

Merge readiness

⛔ Blocked before merge - 9 items remain

Keep open. Current main does not provide the branch’s standalone interrupted-package recovery, and the related full-state PRs address broader work.

Priority: P0
Reviewed head: 83c03dc3edd0e5b4d9b9340eb2d315508dc6258d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The branch has meaningful installed evidence and extensive fault coverage, while current-head authority and released-journal compatibility remain unresolved.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: Authority-chain proof required: The linked older-revision installed run shows a published updater, rollback, and repair after updater loss, but it does not exercise this head’s initial publication cut or a revoked owner through the final package and service effects. The new stored layout has synthetic legacy-journal coverage; an existing released-journal upgrade run is still needed for data-model compatibility. A redacted terminal trace or logs of these paths would help; redact private addresses, keys, phone numbers, and endpoints. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: Authority-chain proof required: The linked older-revision installed run shows a published updater, rollback, and repair after updater loss, but it does not exercise this head’s initial publication cut or a revoked owner through the final package and service effects. The new stored layout has synthetic legacy-journal coverage; an existing released-journal upgrade run is still needed for data-model compatibility. A redacted terminal trace or logs of these paths would help; redact private addresses, keys, phone numbers, and endpoints. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Current-main boundary: At the fetched main revision, the activation module reads or rejects an existing in-directory journal but has no standalone package repair entrypoint.
Introduced recovery path: The pinned base-to-head diff adds recovery admission, a fresh executor fence, and package publication or retirement through the recorded journal.
Prior finding addressed in source: The current reader inspects released in-directory journals without granting write authority and reports their original helper command; the added test checks that repair and retirement through the new owner are refused.
Findings None None.
Security Needs attention Verify retained authority at the final effect: The introduced helper can resume package effects after updater loss. Current-head evidence does not establish that a replaced or revoked original owner is denied before those effects.

How this fits together

The CLI updater stages an npm package, then replaces the installed package and launchers before checking the Gateway. The new recovery journal records that publication so a separate helper can inspect or finish it if the updater stops.

flowchart LR
A[Installed updater] --> B[Staged npm package]
B --> C[Recovery journal]
C --> D{Owner and data checks}
D -->|safe| E[Publish or restore package]
D -->|unsafe| F[Retain data and explain refusal]
E --> G[Gateway restart and status]
Loading

Decision needed

Question Recommendation
Should the new external control-directory journal and read-only treatment of released in-directory journals become the supported upgrade and retention contract? Accept after upgrade proof: Retain the single-journal design once an installed released-journal upgrade demonstrates safe status, recovery, retirement, and next-update admission.

Why: The branch materially changes durable recovery layout and the behavior of installations carrying older journals; repository storage policy calls for an accepted contract, which the supplied discussion does not establish.

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: Authority-chain proof required: The linked older-revision installed run shows a published updater, rollback, and repair after updater loss, but it does not exercise this head’s initial publication cut or a revoked owner through the final package and service effects. The new stored layout has synthetic legacy-journal coverage; an existing released-journal upgrade run is still needed for data-model compatibility. A redacted terminal trace or logs of these paths would help; redact private addresses, keys, phone numbers, and endpoints. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security concern: Verify retained authority at the final effect - The introduced helper can resume package effects after updater loss. Current-head evidence does not establish that a replaced or revoked original owner is denied before those effects.
  • Resolve merge risk (P1) - The relocated journal and retained receipt change the stored recovery contract. Synthetic legacy-journal tests cover inspection, but no captured released-journal upgrade and retirement run establishes how an existing interrupted installation proceeds.
  • Resolve merge risk (P1) - The helper and delegated worker can retain recovery authority after the original updater exits. Available current-head evidence does not show a replaced or revoked owner rejected before final package, configuration, or service I/O.
  • Resolve merge risk (P1) - The linked installed owner-loss run cuts after publication on an older revision; it does not observe a current-head interruption during the initial control-directory or package rename.
  • Complete next step (P2) - Provide current-head installed upgrade and revoked-owner final-effect evidence, then obtain a maintainer decision on the durable journal contract.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [medium] Verify retained authority at the final effect — src/infra/package-update-activation.ts:193
Agent review details

Security

Needs attention: No new dependency or workflow-permission change was found; retained recovery authority still needs final-effect verification.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production and test growth production +4,168 net; tests/support +4,754 net The PR body attributes the production growth to durable publication and custody, with substantial fault coverage alongside it.
Stored recovery contract 1 journal layout relocated; 1 completion receipt retained Existing interrupted installations and later updates depend on the new retention and legacy-inspection rules.

Stored data model

Persistent data-model change detected: unknown-truncated-pull-files. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Prove the installed recovery boundary (recommended)
    Exercise a published updater against this head with an existing released journal, an initial publication interruption, and a revoked original owner; record the final package, data, and service effects before merge.

Technical review

Best possible solution:

Keep one journal and original-owner recovery path, with a guided Doctor or Fix launcher for users stranded after an interrupted update and an explicit refusal when existing data cannot safely roll back.

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

Yes. Interrupting a supported POSIX npm update during package publication exposes the recovery boundary in current source; the linked installed run demonstrates updater loss on an older branch revision, but this review did not execute current main.

Is this the best way to solve the issue?

Unclear. A single journal and sealed helper fit the existing updater owner, but the stored-contract upgrade and retained-authority effects need current-head proof before this can be judged the safest complete fix.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8ab43884177d.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P0: An interrupted update can leave the installed package partly replaced and the Gateway unavailable.
  • merge-risk: 🚨 compatibility: The journal moves to a new layout while released in-directory journals remain inspection-only and can block a later update.
  • merge-risk: 🚨 session-state: Rollback decisions must preserve newer database and transcript writes when the previous runtime is compatible.
  • merge-risk: 🚨 security-boundary: A retained helper and delegated executor carry authority across updater loss into final filesystem and service effects.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: Authority-chain proof required: The linked older-revision installed run shows a published updater, rollback, and repair after updater loss, but it does not exercise this head’s initial publication cut or a revoked owner through the final package and service effects. The new stored layout has synthetic legacy-journal coverage; an existing released-journal upgrade run is still needed for data-model compatibility. A redacted terminal trace or logs of these paths would help; redact private addresses, keys, phone numbers, and endpoints. Updating the PR body should trigger re-review, or a maintainer can request @clawsweeper re-review. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

Security concerns:

  • [medium] Verify retained authority at the final effect — src/infra/package-update-activation.ts:193
    The introduced helper can resume package effects after updater loss. Current-head evidence does not establish that a replaced or revoked original owner is denied before those effects.
    Confidence: 0.78

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • fuller-stack-dev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Show current-head final-effect proof for a replaced original owner before package, configuration, or service I/O.
  • Capture a published-updater upgrade carrying an interrupted released journal through status, recovery, retirement, and next-update admission.

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 (6 earlier review cycles)
  • reviewed 2026-09-26T00:58:09.208Z sha 191f04e :: blocked before merge. :: [P1] Preserve read-only status for shipped recovery journals
  • reviewed 2026-09-26T01:15:51.446Z sha 155ccb7 :: blocked before merge. :: [P1] Preserve read-only status for shipped recovery journals
  • reviewed 2026-09-26T01:54:32.743Z sha 2fc268a :: blocked before merge. :: [P1] Keep shipped activation journals readable in update status
  • reviewed 2026-09-26T02:47:10.890Z sha 11d6baa :: blocked before merge. :: [P1] Keep shipped activation journals readable in update status
  • reviewed 2026-09-26T03:33:50.782Z sha 11d6baa :: blocked before merge. :: [P1] Keep shipped activation journals readable for recovery guidance
  • reviewed 2026-09-26T04:33:54.264Z sha 11d6baa :: needs real behavior proof before merge. :: [P1] Keep released activation journals readable for recovery guidance

Complete the shared task-content projection cutover for asynchronous finalization and delivery. Preserve the captured Incognito policy and exact task-assignment fences.

The unchanged worker suite reproduced six ReferenceError failures before the fix and passes all seven cases afterward; the sibling SDK runtime suite passes all 30 cases. Independent review is clean through P2.
steipete added a commit that referenced this pull request Oct 1, 2026
…act bigint identities (#162245)

A Windows 2026.9.6 -> 2026.9.7 update passed every candidate check, published 9.7, then rolled back because the first delegated live Doctor reported "Candidate executor binding does not match its parent": #158491 switched the managed-update lease-directory identity to bigint lstat while keeping an exact string compare, so a 9.6 parent's numeric (precision-lost) identity never matched, and the identity read error was swallowed into an unreadable-lease classification. The shared identity owner now accepts the legacy numeric spelling once at initial admission when it equals the candidate's bigint identity rounded through the same serialization (an accepted one-hop tradeoff recorded at the comparer), pins exact bigint identities for every subsequent operation, and surfaces underlying read errors.

Closes #162130
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…act bigint identities (openclaw#162245)

A Windows 2026.9.6 -> 2026.9.7 update passed every candidate check, published 9.7, then rolled back because the first delegated live Doctor reported "Candidate executor binding does not match its parent": openclaw#158491 switched the managed-update lease-directory identity to bigint lstat while keeping an exact string compare, so a 9.6 parent's numeric (precision-lost) identity never matched, and the identity read error was swallowed into an unreadable-lease classification. The shared identity owner now accepts the legacy numeric spelling once at initial admission when it equals the candidate's bigint identity rounded through the same serialization (an accepted one-hop tradeoff recorded at the comparer), pins exact bigint identities for every subsequent operation, and surfaces underlying read errors.

Closes openclaw#162130
RomneyDa pushed a commit that referenced this pull request Oct 6, 2026
…act bigint identities (#162245)

A Windows 2026.9.6 -> 2026.9.7 update passed every candidate check, published 9.7, then rolled back because the first delegated live Doctor reported "Candidate executor binding does not match its parent": #158491 switched the managed-update lease-directory identity to bigint lstat while keeping an exact string compare, so a 9.6 parent's numeric (precision-lost) identity never matched, and the identity read error was swallowed into an unreadable-lease classification. The shared identity owner now accepts the legacy numeric spelling once at initial admission when it equals the candidate's bigint identity rounded through the same serialization (an accepted one-hop tradeoff recorded at the comparer), pins exact bigint identities for every subsequent operation, and surfaces underlying read errors.

Closes #162130

(cherry picked from commit f885caa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui cli CLI command changes commands Command implementations docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants