Skip to content

fix(update): complete package lifecycle outside dist inventory - #133908

Merged
obviyus merged 8 commits into
mainfrom
codex/fix-pnpm11-upgrade-guard
Aug 31, 2026
Merged

obviyus merged 8 commits into
mainfrom
codex/fix-pnpm11-upgrade-guard

Conversation

@obviyus

@obviyus obviyus commented Aug 31, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A pnpm 11 global update from OpenClaw 2026.7.1-2 to 2026.8.1 fails verification and rolls back. The 2026.8.1 package puts openclaw-install-guard inside dist/, but the old updater treats every uninventoried dist/ file as invalid.

Root cause

Package lifecycle state was stored inside the closed dist/ inventory. That made a valid pending lifecycle marker look like package corruption to an older updater.

Fix

  • Store pending lifecycle state at package root as .openclaw-lifecycle-pending.
  • Let postinstall remove the marker only after all lifecycle work succeeds.
  • Use one lifecycle completion owner from the updater, dist/index.js, and openclaw.mjs.
  • Keep the lifecycle lock valid beyond the full preinstall and postinstall timeout budget.
  • Keep temporary recovery support for the 2026.8.1 dist/openclaw-install-guard path.
  • Keep source package preparation and worker package generation aligned with the new marker contract.

Product proof

  • Red: a published 2026.7.1-2 pnpm 11 install rejected the published 2026.8.1 package with unexpected packaged dist file dist/openclaw-install-guard, exited nonzero, and remained on 2026.7.1-2.
  • Green: the built candidate passes the old-updater upgrade path, the pnpm 11 lifecycle-repair path, a forced postinstall failure and retry, and native npm controls.
  • Anti-cheat: the proof checks the installed CLI version before and after the update.

Validation

  • node scripts/run-vitest.mjs src/infra/package-lifecycle.test.ts src/infra/package-update-steps.pnpm11-guard.test.ts src/index.entrypoint.test.ts
  • Focused lifecycle, updater, tarball, postinstall, inventory, and entrypoint suites: 176 tests passed.
  • Exact-head lifecycle lock suite: 4 tests passed, including the old 20-minute expiry boundary.
  • Remote core and scripts checks passed.
  • git diff --check
  • GitHub CI is the full release and platform gate.

Scope

  • Production and release-tooling delta: +370/-162, net +208.
  • Test and CI support delta: +370/-84, net +286.
  • The production growth adds the shared lifecycle owner, crash-safe retry marker, and concurrent-launch lock. It removes the updater-only lifecycle sequence and keeps the closed dist/ verifier unchanged.
  • Sibling coverage: updater, package launcher, legacy package entrypoint, installers, tarball validator, worker bootstrap package, and Docker package preparation.

ClawSweeper

  • No actionable code findings.
  • Rank-up skip: the package-upgrade trace came from an internal isolated runner and is not suitable for a public log attachment. Exact-head GitHub CI and the focused regression commands above remain the public proof.

@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime scripts Repository scripts docker Docker and sandbox tooling size: L maintainer Maintainer-authored PR labels Aug 31, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. 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 Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 31, 2026, 5:35 AM ET / 09:35 UTC.

ClawSweeper review

What this changes

The PR moves package lifecycle state out of the closed dist inventory and adds shared recovery for skipped lifecycle scripts across package updates, launchers, installers, and packaging validation.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

No introduced blocking correctness defect was identified. The prior lifecycle-lock finding is addressed by threading the caller timeout into the shared coordinator; this member-authored, upgrade-sensitive PR remains for maintainer review and exact-head package acceptance.

Priority: P2
Reviewed head: a6d500caa28014f16c25c6f0238c60a0a4119d5d
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The focused recovery design addresses the prior blocker and has coherent owner-boundary coverage; exact-head package acceptance remains the material merge check.
Proof confidence 🌊 off-meta tidepool Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied focused test claims remain supplemental evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied focused test claims remain supplemental evidence.
Evidence reviewed 7 items Shared lifecycle owner: The coordinator derives both its owner deadline and waiter budget from the caller-provided per-script timeout, then executes the two lifecycle scripts while holding the lock.
Updater caller: The pnpm update path passes its active timeout into the coordinator and runs both package scripts through the existing update-step owner.
Entrypoint coverage: Both the package-root launcher and legacy package entrypoint check for either marker and invoke the same completion owner before CLI startup.
Findings None None.
Security None None.

How this fits together

Package updates install a new OpenClaw package, verify its dist inventory, and then expose the global CLI. The lifecycle coordinator detects a pending package, serializes preinstall/postinstall repair, and hands control back to the updater or launcher.

flowchart LR
  Package[Packed package] --> Marker[Pending lifecycle marker]
  Marker --> Entry[Updater or CLI launcher]
  Entry --> Coordinator[Lifecycle coordinator]
  Coordinator --> Scripts[Preinstall and postinstall]
  Scripts --> Verify[Package verification]
  Verify --> CLI[Usable OpenClaw CLI]
Loading

Decision needed

Question Recommendation
Should this member-authored package-update recovery change proceed once exact-head package acceptance validates the built artifact? Proceed after package acceptance: Merge once exact-head package acceptance confirms the packed artifact and supported npm/pnpm update paths.

Why: The change intentionally alters upgrade-time lifecycle recovery and can prevent a global CLI from starting when recovery fails; protected maintainer handling requires an explicit judgment.

Before merge

  • Resolve merge risk (P1) - This changes shipped package-update recovery: if lifecycle completion fails, a package launcher now stops before command dispatch until repair succeeds. Exact-head package acceptance should verify the packed npm artifact and npm/pnpm upgrade paths.
  • Resolve merge risk (P1) - Current-main source blobs were unavailable in the read-only partial clone, so this review cannot establish whether later main work overlaps the candidate.
  • Complete next step (P2) - This member-authored PR carries a protected maintainer label and upgrade-sensitive behavior, so it needs normal maintainer handling rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Source +170, Tests +312, Docs 0, Config +4, Other +63. Total +549 across 40 files.

View PR surface stats
Area Files Added Removed Net
Source 4 258 88 +170
Tests 17 392 80 +312
Docs 1 1 1 0
Config 2 6 2 +4
Generated 0 0 0 0
Other 16 140 77 +63
Total 40 797 248 +549

Review metrics

Metric Value Why it matters
Production versus test delta production/tooling +400/-164; tests/support +396/-83; docs +1/-1 The bug fix adds a shared package-lifecycle owner and recovery flow, so artifact-level validation matters more than unit coverage alone.

Stored data model

Persistent data-model change detected: serialized state: scripts/lib/package-bundled-plugins.mts, serialized state: src/gateway/worker-environments/node-bootstrap-artifact.ts, unknown-data-model-change: scripts/preinstall-package-manager-warning.mjs, unknown-data-model-change: src/gateway/worker-environments/node-bootstrap-artifact.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate the exact packaged upgrade path (recommended)
    Wait for exact-head package acceptance to exercise the built tarball and lifecycle completion before merge.

Technical review

Best possible solution:

Land one package-root marker contract only after exact-head package acceptance verifies both normal lifecycle completion and fail-closed recovery across supported package managers.

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

No live reproduction was run in this read-only review. The reported upgrade path is concretely encoded in focused lifecycle and updater tests, but current-main source could not be fully inspected from the partial clone.

Is this the best way to solve the issue?

Yes: a package-root marker avoids treating lifecycle state as unverified dist content, while one shared coordinator keeps updater and launcher recovery consistent.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied focused test claims remain supplemental evidence.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The change repairs a bounded global package-update failure with meaningful but limited user impact.
  • merge-risk: 🚨 compatibility: The marker and recovery behavior affect upgrades from packages that may carry the legacy dist sentinel.
  • merge-risk: 🚨 availability: An incomplete lifecycle now deliberately prevents CLI command dispatch until repair succeeds.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The repository state identifies the author as a member, so the external-contributor proof gate does not apply; the supplied focused test claims remain supplemental evidence.

Evidence

What I checked:

  • Shared lifecycle owner: The coordinator derives both its owner deadline and waiter budget from the caller-provided per-script timeout, then executes the two lifecycle scripts while holding the lock. (src/infra/package-lifecycle.ts:71, a6d500caa280)
  • Updater caller: The pnpm update path passes its active timeout into the coordinator and runs both package scripts through the existing update-step owner. (src/infra/package-update-steps.ts:1112, a6d500caa280)
  • Entrypoint coverage: Both the package-root launcher and legacy package entrypoint check for either marker and invoke the same completion owner before CLI startup. (openclaw.mjs:15, a6d500caa280)
  • Lock regression coverage: The new lifecycle tests cover concurrent callers and 30-, 45-, and 75-minute script budgets, including the automatic-update timeout class. (src/infra/package-lifecycle.test.ts:66, a6d500caa280)
  • Prior-review follow-up: The exact head commit follows the prior reviewed head and is explicitly the timeout-binding follow-up; its raw recorded parent is the prior review head. (src/infra/package-lifecycle.ts:73, a6d500caa280)
  • Release scope: No locally available release tag contains the candidate head, so this remains unshipped PR work. (a6d500caa280)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Bryan Tegomoh, MD, MPH: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Let exact-head package acceptance validate the built artifact through npm and pnpm lifecycle paths.

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 (5 earlier review cycles)
  • reviewed 2026-08-31T07:29:20.964Z sha 0a14590 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-31T07:57:59.184Z sha 0a14590 :: found issues before merge. :: [P2] Wait for the lifecycle callback before releasing the test | [P3] Document the package-root pending marker
  • reviewed 2026-08-31T08:18:57.247Z sha 3fd8ace :: found issues before merge. :: [P2] Derive stale-lock TTL from the actual lifecycle timeout
  • reviewed 2026-08-31T08:40:46.488Z sha 18dda4b :: found issues before merge. :: [P2] Derive both lifecycle lock bounds from the caller timeout
  • reviewed 2026-08-31T09:05:09.738Z sha 03887c4 :: found issues before merge. :: [P2] Derive lifecycle lock bounds from the caller timeout

@clawsweeper clawsweeper Bot added 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. and removed 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 Aug 31, 2026
@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 133908
head: 0a14590
breaking: 5888c38
check: openclaw/ci-gate

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL and removed size: L labels Aug 31, 2026
…ade-guard

# Conflicts:
#	scripts/postinstall-bundled-plugins.mjs
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Aug 31, 2026
@clawsweeper clawsweeper Bot added 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 Aug 31, 2026
@clawsweeper clawsweeper Bot removed 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 Aug 31, 2026
@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

landpr-approve-unrelated-red
pr: 133908
head: a6d500c
breaking: 9b4c3d5
check: openclaw/ci-gate

@obviyus
obviyus merged commit ae3aff5 into main Aug 31, 2026
267 of 272 checks passed
@obviyus
obviyus deleted the codex/fix-pnpm11-upgrade-guard branch August 31, 2026 09:42
@obviyus

obviyus commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks @obviyus!

Proof: A pnpm 11 global install can upgrade from 2026.7.1-2 through the package lifecycle marker without old dist-inventory rejection; focused lifecycle, updater, launcher, tarball, postinstall, Docker-package, and Windows fixture checks passed.

  • Bug: 2026.8.1 stored lifecycle state inside the closed dist/ inventory, so older updaters rejected the valid package and rolled back.
  • Fix: Package lifecycle state now lives at package root, one coordinator completes skipped scripts, and its cross-process lock follows the caller timeout.
Before After
Upgrade rejects dist/openclaw-install-guard and stays on 2026.7.1-2 Upgrade completes lifecycle outside dist/ and activates the candidate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docker Docker and sandbox tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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