Skip to content

fix(postinstall): preserve other installs' runtime dependencies - #134099

Merged
steipete merged 10 commits into
mainfrom
codex/postinstall-operator-files
Sep 4, 2026
Merged

steipete merged 10 commits into
mainfrom
codex/postinstall-operator-files

Conversation

@steipete

@steipete steipete commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Related: #128782 (installation migrated an older Gateway's database; already closed). Follow-up to #129475, the Doctor-owned plugin-registry migration merged as 5f714ef, with @BryanTegomoh's contribution and @obviyus's co-authorship. This PR fixes the remaining dependency-cleanup boundary.

What Problem This Solves

Installing another OpenClaw copy or running Doctor could delete shared runtime dependency caches, mirrors, and valid global aliases still used by another installation or profile. An existing Node consumer could keep running until its next uncached import failed with MODULE_NOT_FOUND. A separate npm prefix does not isolate inherited home, config, or state paths.

Why This Change Was Made

Postinstall now cleans only its installed package and completes the existing lifecycle marker. Doctor's shared-root pruning owner is deleted. Doctor removes genuinely dangling runtime aliases by following the actual symlink with fs.stat(fullPath); lexical path normalization could otherwise erase an intermediate directory symlink and misclassify a live target.

The shipped core/doctor/legacy-plugin-dependencies lint selector remains informational and default-off. Existing lifecycle completion, recovery, package-local cleanup, and genuine dangling-link repair remain supported. There are no new dependencies, configuration options, runtime compatibility readers, or SQLite/schema changes.

The branch was integrated with current main while preserving the newer Gateway profile repair and survivor phase wrapper. The existing child-process readiness fix and meaningful survivor regressions remain; redundant prepared-vision fixture coverage was removed because main already tests that behavior.

User Impact

Package install/update and Doctor preserve shared dependency roots, versioned caches, mirrors, unknown consumer files, and valid aliases used by other installations or profiles, including roots selected through STATE_DIRECTORY and OPENCLAW_PLUGIN_STAGE_DIR. Installation-local stale artifacts are still removed. The Doctor, update, testing, and plugin dependency-resolution guides describe this ownership boundary.

Production: +33/-723 (net -690). Tests: +421/-658. Test support: +395/-294. Docs: +60/-27. Ratchets: +1/-2. No changelog, version, or release publication change.

Evidence

Current source: 54a796827b8145b22df2d27275d7ed893927fc29; integration base: 82d2c992a25bc38336e1a5d49e1ef15d03798f19. The dependency-preservation patch is identical to the reviewed pre-audit patch (stable patch ID b8bd5646d22b6c8d3d7f2fff29c63471af528f2b). Final native proof passed after the necessary mainline conflict resolution. Current-head CI passed every selected lane except the production advisory audit. Two attempts obtained no audit result from npm. Peter explicitly waived this npm outage for landing the exact reviewed head; no successful audit is claimed.

  • The focused preservation regression fails against the pre-fix postinstall owner with ENOENT for the deleted shared root, and passes with the candidate. The complete focused selection passed 259 tests in 7 files across 4 shards; the rebase-sensitive package workflow check passed separately.
  • The final-head local changed-file checks passed, including formatting, core/test typechecks, lint, export checks, database guards, import cycles, and the 498/498 environment-name ratchet.
  • Fresh managed Codex review of the complete candidate, explicitly through P2, returned scoped-clean, no actionable findings, confidence 0.90.
  • The canonical full build and package integrity check passed. Final tarball and native results are recorded below.
node scripts/run-vitest.mjs test/scripts/postinstall-bundled-plugins.test.ts src/commands/doctor/shared/plugin-runtime-symlinks.test.ts src/commands/doctor/repair-sequencing.test.ts src/flows/doctor-health-contributions.test.ts test/scripts/upgrade-survivor-plugin-dependencies.test.ts test/scripts/upgrade-survivor-assertions.test.ts src/cli/completion-cli.runner.process.test.ts
node scripts/run-vitest.mjs test/scripts/package-acceptance-workflow.test.ts -t 'lets reusable Docker E2E consume an already resolved package artifact'
node scripts/check-changed.mjs --base 82d2c992a25b --timed
node scripts/package-openclaw-for-docker.mjs --output-dir /tmp/pr-134099-native/rebased-package --output-name openclaw-fixed.tgz

Best-fix judgment: repair the cleanup owner, rather than add downstream retries or try to infer whether every external consumer is idle. The package owns its files; cache names do not establish exclusive ownership. Direct Node filesystem behavior and the POSIX symlink regression support the alias check; see Node's filesystem contract.

CI integration correction: the first refreshed run exposed a stale phase name in the companion guard test. The same targeted test failed locally before the one-line correction; all 24 tests in that file, its changed-file checks, and a fresh P0–P2 review passed afterward. The guard itself and runtime behavior are unchanged.

A second CI shard exposed a fractional-backoff defect in the audit owner. Main subsequently landed the canonical fix in #137989 (e63a41414fa). The PR now uses those audit files unchanged; the temporary overlapping branch repair was dropped during rebase. This keeps the final change focused on install/Doctor ownership.

Native update and Doctor proof

Passed on the final source commit, macOS, Node 26.8.1 / npm 12.0.2. The real installed [email protected] CLI performed a supported update --tag <target> --no-restart --yes --json, followed by doctor --fix --non-interactive twice. The negative target was the released [email protected]; the fixed target was the final source tarball. Every update and Doctor command exited 0, including the negative controls.

Shared-root selector Existing consumer Released-package control Final candidate Package-local debris
STATE_DIRECTORY Separate installation Shared root deleted; late imports fail Preserved through all three phases Removed by update
OPENCLAW_PLUGIN_STAGE_DIR Separate installation Shared root deleted; late imports fail Preserved through all three phases Removed by update
STATE_DIRECTORY Same installation, separate reader profiles Shared root deleted; late imports fail Preserved through all three phases Removed by update
OPENCLAW_PLUGIN_STAGE_DIR Same installation, separate reader profiles Shared root deleted; late imports fail Preserved through all three phases Removed by update

Two original Node reader processes stayed alive throughout each case. At every phase, nonce-bound acknowledgements exercised previously unloaded direct/relative/mirror CJS modules and filesystem reads through the intermediate-directory-symlink/.. alias. Fixed runs preserved the shared root, unknown-consumer sentinel, live alias bytes, open synthetic schema-8 SQLite handles, tokens, and database hashes. Negative runs required the exact root loss with MODULE_NOT_FOUND/ENOENT, so a generic command failure could not satisfy the control.

The final fixed refresh also seeded four synthetic debris paths physically inside the old installed package and verified they disappeared during the real update. This proves update-level cleanup; the focused regression separately proves postinstall's cleanup ownership. Each fixed installation matched 125 postinstall/build-info/compiled Doctor member hashes from the candidate. All readers exited normally and all isolated state, package prefixes, baseline template, and npm cache were removed.

Final tarball SHA-256: 9263a7b7b152a318eb6cfdf4abdce8dc21bf4dc844b90497b9d2c5dccfd09e6c. Build identity: 54a796827b8145b22df2d27275d7ed893927fc29. Final runner SHA-256: 9d40534ed61e552966df35fcf75513df798eb430bfeacd7ce6be8a7b42e1a72b; reader SHA-256: fd261f4c9b9fa75a6616557f209bedf392ad6766eb8c79e560af5171fa866992. The released-package controls are retained from the completed earlier eight-case run; all four fixed configurations were refreshed after the mechanical rebase onto main's canonical audit fix.

Scope: native package update and Doctor with synthetic long-lived dependency/SQLite readers. This is not a running Gateway, cross-platform service-restart matrix, or live provider/channel test. Earlier incomplete managed-service attempts are not claimed as proof. Isolated state/config paths and an unused loopback port prevented host-service interaction. npm lifecycle permission covered the exact baseline, negative, and candidate identities; three unrelated transitive install scripts remained blocked. No SQLite schema, migration, persistent representation, or runtime database ownership changed in this PR; the earlier database repair remains #129475.

This completes the latest ClawSweeper native-survivor and rank-up request. The data-model flag is addressed by the unchanged storage contract and observed preservation, rather than a new migration.

Current-head CI: npm advisory outage explicitly waived by Peter for landing, run 33847990653, attempt 2. Every other selected lane passed. In attempt 1, all four production-advisory requests timed out. The exact security-fast retry on the same head timed out three times, then received HTTP 503 Service Unavailable; the strict audit exited 2 without clearance. The same local audit also exhausted its budget, and npm's own installed client returned HTTP 503 on a one-package bulk request. No audit-policy or source change was made. Peter explicitly instructed "ignore npm stuff" after these two attempts. Code review, final package/native proof, local changed-file checks and every other selected CI lane are complete. Landed f584661fac60 with Peter's explicit waiver, preserving the failed audit and aggregate gate as recorded; no repository rules or audit policy were changed. The landed patch ID matches the reviewed source exactly, and the three runtime owner files are byte-identical to the verified candidate.

@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.

@steipete
steipete marked this pull request as ready for review August 31, 2026 12:28
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: M maintainer Maintainer-authored PR labels Aug 31, 2026
steipete added a commit that referenced this pull request Sep 1, 2026
Preserve legacy plugin-runtime dependency roots and sibling global links
while installing a new package because another installed Gateway may still
use them. Keep package-local dist pruning, source-checkout protection, the
existing cleanup opt-out, and root lifecycle completion intact. Doctor
remains the explicit owner of operator-state migration and legacy cleanup.

Carry the bounded CI fixture regressions needed to prove this upgrade path:
settle PowerShell completion test-runner readiness and queued requests when
a real child exits before READY, and cover default/overridden prepared
follow-up model metadata without catalog discovery. These are test-only
repairs, not a production catalog or real PowerShell coverage claim.

Preserve the already-landed media fixture preparation and canonical installed-
CLI recovery, staged rollback, and interrupted legacy-marker retry behavior.
The earlier database-postinstall migration removal remains upstream work.

Related: #134099 (postinstall isolation across installed versions).
@steipete
steipete force-pushed the codex/postinstall-operator-files branch from 565cb5e to ddda232 Compare September 1, 2026 01:41
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: L and removed size: M labels Sep 1, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 4, 2026, 2:49 AM ET / 06:49 UTC.

ClawSweeper review

What this changes

This PR confines package postinstall cleanup to its installed package and changes Doctor to preserve shared plugin runtime caches while removing only dangling global runtime aliases.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. Current main still invokes the broad Doctor cleanup that can remove shared runtime roots, while this PR replaces it with dangling-alias-only repair; no introduced correctness defect was found. The remaining blocker is exact-head native upgrade proof, and this maintainer-labeled PR must not be auto-closed.

Priority: P1
Reviewed head: cb682dccd02b36763c8b5901d3fd80bcd2f68bea

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The source repair and focused regression coverage are coherent, but current-head upgrade confidence remains limited without the required native survivor result.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; however, the available native package-update evidence is from earlier heads or incomplete, so exact-head survivor proof remains a merge risk.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is exempt from the external-contributor proof gate; however, the available native package-update evidence is from earlier heads or incomplete, so exact-head survivor proof remains a merge risk.
Evidence reviewed 6 items Current-main destructive Doctor path: Current main calls the legacy dependency cleanup from the Doctor repair sequence; that cleanup removes every prepared legacy dependency target, including state-selected shared roots.
Introduced owner-boundary repair: The PR deletes the shared-root cleanup call and retains only runtime aliases whose filesystem path itself fails stat with ENOENT or ENOTDIR.
Boundary regression coverage: The introduced Doctor fixture starts a reader using a shared dependency and mirror, runs Doctor under a separate installation/profile, then verifies the reader can resolve late-loaded files and the alias remains present.
Findings None None.
Security None None.

How this fits together

Package postinstall runs during npm installation, while Doctor performs explicit repair afterward. Both touch plugin dependency artifacts, so their cleanup boundary determines whether another OpenClaw installation can keep resolving its runtime dependencies.

flowchart LR
  A[Package update] --> B[Package postinstall]
  B --> C[Installed package artifacts]
  D[Doctor repair] --> E[Global runtime aliases]
  F[Shared runtime caches] --> E
  C --> G[Updated OpenClaw install]
  E --> G
Loading

Before merge

  • Resolve merge risk (P1) - No complete exact-head native package-update followed by Doctor survivor trace is available. The retained attempts target earlier heads or ended incomplete, so upgrade safety for a real existing installation/profile remains unproven.
  • Complete next step (P2) - Before merge, attach a redacted exact-head native package-update then Doctor survivor trace proving that a shared runtime dependency and valid alias remain usable while package-local debris is removed.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source -488, Tests -61, Docs +33, Other -278. Total -794 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 4 29 517 -488
Tests 17 630 691 -61
Docs 5 60 27 +33
Config 0 0 0 0
Generated 0 0 0 0
Other 7 191 469 -278
Total 33 910 1704 -794

Review metrics

Metric Value Why it matters
Production versus test delta production +33/-723; tests and test support +816/-952; docs +60/-27; ratchets +1/-2 Production is net -690, reflecting removal of the broad cleanup owner rather than additive runtime complexity.

Stored data model

Persistent data-model change detected: migration/backfill/repair: config/assertion-safety-baseline.txt, migration/backfill/repair: scripts/e2e/lib/upgrade-survivor/assertions.mjs, migration/backfill/repair: scripts/e2e/lib/upgrade-survivor/plugin-dependency-fixtures.sh, migration/backfill/repair: scripts/e2e/lib/upgrade-survivor/run.sh, migration/backfill/repair: scripts/e2e/lib/upgrade-survivor/update-restart-auth.sh, migration/backfill/repair: src/commands/doctor/shared/plugin-dependency-cleanup.ts, and 9 more. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Capture exact-head survivor proof (recommended)
    Run the package-update then Doctor survivor scenario on this head, showing a shared dependency and valid alias remain usable while package-local debris is removed.
  2. Pause the upgrade-sensitive merge
    Do not merge until the survivor result exists, because existing installations may otherwise discover a lifecycle regression only after update.

Technical review

Best possible solution:

Preserve the proposed ownership split, then land only after an exact-head package update and Doctor run demonstrates that shared dependencies and a valid alias remain usable while package-local debris is removed.

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

Yes. Current-main source invokes broad legacy cleanup, and the introduced fixtures define a focused multi-install/shared-reader scenario that would expose removal of the shared root or alias.

Is this the best way to solve the issue?

Yes. Separating package-local cleanup from shared operator-state repair and checking the actual alias with filesystem stat is the narrowest owner-boundary repair; the outstanding need is real upgrade proof, not another implementation path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P1: The PR addresses an upgrade path that can break runtime dependency resolution for an existing installation.
  • merge-risk: 🚨 compatibility: Changing postinstall and Doctor cleanup semantics can affect existing package installs, shared caches, and global runtime aliases.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; 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: This maintainer-authored PR is exempt from the external-contributor proof gate; however, the available native package-update evidence is from earlier heads or incomplete, so exact-head survivor proof remains a merge risk.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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.

  • Capture a redacted exact-head package-update and Doctor survivor result with an existing shared runtime dependency and valid alias.

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-01T01:52:52.473Z sha ddda232 :: found issues before merge. :: [P1] Preserve sibling dependencies during automatic Doctor repair
  • reviewed 2026-09-03T00:52:06.554Z sha ead36b6 :: blocked before merge. :: none
  • reviewed 2026-09-03T02:02:35.547Z sha cf883fe :: blocked before merge. :: [P2] Update the legacy cleanup documentation
  • reviewed 2026-09-03T07:50:46.965Z sha d04ccb9b63939ee66dcd8f23727d817eade157a1 :: blocked before merge. :: none
  • reviewed 2026-09-03T09:06:46.554Z sha adf158d :: blocked before merge. :: none
  • reviewed 2026-09-03T09:28:32.715Z sha adf158d :: blocked before merge. :: none

@steipete
steipete force-pushed the codex/postinstall-operator-files branch from ddda232 to ead36b6 Compare September 3, 2026 00:43
steipete added a commit that referenced this pull request Sep 3, 2026
Preserve legacy plugin-runtime dependency roots and sibling global links
while installing a new package because another installed Gateway may still
use them. Keep package-local dist pruning, source-checkout protection, the
existing cleanup opt-out, and root lifecycle completion intact. Doctor
remains the explicit owner of operator-state migration and legacy cleanup.

Carry the bounded CI fixture regressions needed to prove this upgrade path:
settle PowerShell completion test-runner readiness and queued requests when
a real child exits before READY, and cover default/overridden prepared
follow-up model metadata without catalog discovery. These are test-only
repairs, not a production catalog or real PowerShell coverage claim.

Preserve the already-landed media fixture preparation and canonical installed-
CLI recovery, staged rollback, and interrupted legacy-marker retry behavior.
The earlier database-postinstall migration removal remains upstream work.

Related: #134099 (postinstall isolation across installed versions).
steipete added a commit that referenced this pull request Sep 3, 2026
Stop deleting shared cache roots or valid runtime aliases during Doctor
repair. Keep genuine dangling-link repair, the shipped legacy health
selector, and installer-owned package-local cleanup.

Cover live readers and cache-preservation fixtures, and retire stale test
wiring and ratchet entries. Installer upgrade-safety follow-up for #134099.

Validated 339 primary and 68 supplemental tests, 31 staged checks, and
P0-P2 autoreview. Fresh packages and the native update matrix remain pending.
steipete added a commit that referenced this pull request Sep 3, 2026
Check runtime aliases through the filesystem instead of lexically
normalizing stored targets. A directory symlink followed by .. can
otherwise make a live alias appear missing and cause Doctor to unlink it.

Retain recorded targets for diagnostics and genuine ENOENT/ENOTDIR repair.
Add a POSIX health/removal regression. Installer upgrade-safety follow-up
for #134099.

Validated 270 tests, 29 changed checks, and P0-P2 source reviews.
Package production and the native update matrix remain pending.
steipete added a commit that referenced this pull request Sep 3, 2026
Complete the current-install sibling of the published-upgrade fixture
repair. Use managed service-token auth without creating conflicting legacy
device identity or pairing files after setup Doctor has initialized SQLite.
Preserve setup Doctor, its child-only markers, config parking/restoration,
service ownership and readiness, and intentional migration specimens.

Extend the existing marker test to reject retired identity files and remove
obsolete seeder stubs. Add braces to two pre-existing lifecycle-test loops
required by the touched-file lint gate. Clarify package-local debris versus
shared runtime preservation in the update testing guide.

Related: #134099 (preserve other installations' runtime dependencies).
No product authentication, migration, configuration, or SQLite change.
Native restart-unhealthy and cleanup failure remain unproven by this fixture
repair; fresh complete native update/Doctor proof is still required.
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime commands Command implementations size: XL and removed size: L labels Sep 3, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 3, 2026
steipete added a commit that referenced this pull request Sep 3, 2026
Assert the canonical sourced dependency fixture and the ordered cleanup phases around Doctor instead of moved inline helpers or deleted diagnostic text. Keep detailed dependency ownership coverage in the existing fixture behavior suite.

Refs #134099 (preserve other installations' runtime dependencies).
steipete added a commit that referenced this pull request Sep 4, 2026
Assert the canonical sourced dependency fixture and the ordered cleanup phases around Doctor instead of moved inline helpers or deleted diagnostic text. Keep detailed dependency ownership coverage in the existing fixture behavior suite.

Refs #134099 (preserve other installations' runtime dependencies).
@steipete

steipete commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor Author

Landed f584661fac60 from reviewed source 54a796827b81.

The PR body now contains completed native survivor proof for final head 54a796827b8145b22df2d27275d7ed893927fc29 and tarball SHA-256 9263a7b7b152a318eb6cfdf4abdce8dc21bf4dc844b90497b9d2c5dccfd09e6c.

All four final fixed configurations passed real package update → Doctor → Doctor: both shared-root selectors, each with same-install and separate-install consumers. Every command exited 0. The original reader processes retained uncached dependency/mirror reads, valid aliases, synthetic SQLite bytes/handles, and the unknown-consumer sentinel. Seeded package-local debris disappeared during update. The four released-package controls reproduced shared-root loss and late-import errors despite exit-0 update/Doctor commands. All isolated readers and state were cleaned up.

This is native macOS --no-restart CLI proof with synthetic long-lived readers; the body explicitly limits the claim and does not claim a running Gateway or a cross-platform restart matrix. No storage schema, migration, or persistent representation changes are introduced. The latest native-proof and rank-up requests are addressed.

The final mechanical rebase uses main's canonical audit repair from #137989 unchanged and drops the superseded branch repair. The dependency-preservation patch is identical, the final package/native proof was refreshed, and a fresh full P0–P2 review is clean. Local changed-file checks and every non-audit CI lane passed.

Peter explicitly instructed "ignore npm stuff" after both production-advisory attempts failed with timeouts/HTTP 503. The PR was merged under that npm-only waiver; no successful advisory result is claimed and the failed checks remain recorded. Repository rules and audit policy are unchanged.

Post-merge verification: the landed patch ID exactly matches the reviewed patch (b8bd5646d22b6c8d3d7f2fff29c63471af528f2b); postinstall and both Doctor runtime owners are byte-identical to the verified candidate. The task checkout is clean and synchronized to main at the merge commit.

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

Preserve legacy plugin-runtime dependency roots and sibling global links
while installing a new package because another installed Gateway may still
use them. Keep package-local dist pruning, source-checkout protection, the
existing cleanup opt-out, and root lifecycle completion intact. Doctor
remains the explicit owner of operator-state migration and legacy cleanup.

Carry the bounded CI fixture regressions needed to prove this upgrade path:
settle PowerShell completion test-runner readiness and queued requests when
a real child exits before READY, and cover default/overridden prepared
follow-up model metadata without catalog discovery. These are test-only
repairs, not a production catalog or real PowerShell coverage claim.

Preserve the already-landed media fixture preparation and canonical installed-
CLI recovery, staged rollback, and interrupted legacy-marker retry behavior.
The earlier database-postinstall migration removal remains upstream work.

Related: #134099 (postinstall isolation across installed versions).
Stop deleting shared cache roots or valid runtime aliases during Doctor
repair. Keep genuine dangling-link repair, the shipped legacy health
selector, and installer-owned package-local cleanup.

Cover live readers and cache-preservation fixtures, and retire stale test
wiring and ratchet entries. Installer upgrade-safety follow-up for #134099.

Validated 339 primary and 68 supplemental tests, 31 staged checks, and
P0-P2 autoreview. Fresh packages and the native update matrix remain pending.
Check runtime aliases through the filesystem instead of lexically
normalizing stored targets. A directory symlink followed by .. can
otherwise make a live alias appear missing and cause Doctor to unlink it.

Retain recorded targets for diagnostics and genuine ENOENT/ENOTDIR repair.
Add a POSIX health/removal regression. Installer upgrade-safety follow-up
for #134099.

Validated 270 tests, 29 changed checks, and P0-P2 source reviews.
Package production and the native update matrix remain pending.
Declare the migrated-session fixture's no-override return as undefined to match the canonical setup callback after the upstream environment-contract tightening. Preserve the fixture body, scenario overrides and assertions.

Verified with root-test tsgo red/same-command green and 51 existing fixture tests. Managed P0-P2 review is clean for this one-line repair only.
Complete the current-install sibling of the published-upgrade fixture
repair. Use managed service-token auth without creating conflicting legacy
device identity or pairing files after setup Doctor has initialized SQLite.
Preserve setup Doctor, its child-only markers, config parking/restoration,
service ownership and readiness, and intentional migration specimens.

Extend the existing marker test to reject retired identity files and remove
obsolete seeder stubs. Add braces to two pre-existing lifecycle-test loops
required by the touched-file lint gate. Clarify package-local debris versus
shared runtime preservation in the update testing guide.

Related: #134099 (preserve other installations' runtime dependencies).
No product authentication, migration, configuration, or SQLite change.
Native restart-unhealthy and cleanup failure remain unproven by this fixture
repair; fresh complete native update/Doctor proof is still required.
Assert the canonical sourced dependency fixture and the ordered cleanup phases around Doctor instead of moved inline helpers or deleted diagnostic text. Keep detailed dependency ownership coverage in the existing fixture behavior suite.

Refs #134099 (preserve other installations' runtime dependencies).
@steipete
steipete force-pushed the codex/postinstall-operator-files branch from 99acf31 to 54a7968 Compare September 4, 2026 07:16
@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper

clawsweeper Bot commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit f584661 into main Sep 4, 2026
326 of 330 checks passed
@steipete
steipete deleted the codex/postinstall-operator-files branch September 4, 2026 07:54
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 5, 2026
…claw#134099)

Keep package postinstall cleanup inside its installed package and remove Doctor's shared runtime dependency pruning. Follow actual filesystem targets when repairing dangling aliases, preserving dependencies and mirrors used by other installations or profiles. Retain lifecycle completion, package-local cleanup, and the shipped informational Doctor selector.

Refresh survivor fixtures and documentation, remove redundant vision fixture coverage, and align the companion cleanup-phase guard. Use the canonical audit fix from current main after resolving the overlapping CI repair.

Validation includes failing/passing owner regressions, focused owner and sibling suites, full package integrity checks, native before/fixed update-and-Doctor survivor comparisons, and independent P0-P2 reviews. Detailed final package, native, and CI evidence is in the PR body.

Related to openclaw#128782; follows the separate Doctor-owned database migration repair in openclaw#129475, with prior contributions from @BryanTegomoh and @obviyus.

Maintainer override: Peter explicitly waived the npm advisory-service outage for this landing. Exact-head CI passed every other selected lane; the audit returned only timeouts/HTTP 503 and no clearance. The failed checks remain recorded, and audit/repository policy is unchanged.
obviyus added a commit that referenced this pull request Nov 23, 2026
Root cause: src/commands/backup-resource-inventory.ts:82 `MANAGED_STATE_ROOTS` left out the legacy `plugin-runtime-deps` cache, so backup archived it and wrote every absolute link inside it into the manifest's `externalSymbolicLinks`, which overflows the 1 MiB manifest cap.

Fixes #203082

Thanks @sukhdeepjohar for the diagnosis and fix, and @dygg2001 for the report and the link counts that pinned it down.

## What Problem This Solves

On installs that ran OpenClaw before 2026.5.2, `openclaw backup create` can stop with "Backup manifest exceeds 1048576 byte limit" and save no backup at all. Those releases built a bundled-plugin dependency cache at `~/.openclaw/plugin-runtime-deps`, including a mirror of OpenClaw's own program files as links into the install folder. Nothing deletes that cache today (#134099 keeps it, because another installation may still use it). Backup copies it and lists every one of those links in the archive's manifest, which has a 1 MiB limit. The reporter of #203082 has 7,464 such links, enough to overflow it.

The "19k session files" in the issue title are not the cause: the manifest has no per-file entries for sessions (live session files are reported as volatile and kept out of the manifest). The reporter's own count confirms it: 7,464 of their 7,619 outside links are in this cache; the remaining 155 fit easily.

## User Impact

Backups of long-running installs complete again. The old cache stays on disk untouched but is no longer copied into backups, and the thousands of "External link preserved" lines it caused disappear from backup and restore output. Current OpenClaw never reads that cache. An older OpenClaw restored from such a backup rebuilds it at startup, as it always did.

## Why This Change Was Made

Backup already leaves out installer-managed and rebuildable folders under the state directory (`dev/`, `git/`, `npm/`, legacy `npm-runtime/`, `tmp/`, `tools/`), and reports each as "regenerable". The old plugin cache is the same kind of folder but was missing from that list. This adds it, so backup never opens it. It is not a user exclusion switch, and links elsewhere are judged and reported exactly as before. The manifest limit is unchanged.

Nothing user-authored lives there: the cache was written only by the bundled-plugin dependency stager (package roots named `openclaw-<version>-<hash>` with `node_modules`, a `dist` mirror and stamps), documented as an OpenClaw-owned package root. The only remaining references in shipped code match the name in link targets or process command lines (`doctor` dangling-alias cleanup, ACPX process reaper); none reads the folder.

## Evidence

Both sides built in an isolated Linux container. The legacy cache was built by the published 2026.4.24, 2026.4.25, 2026.4.26 and 2026.4.27 releases themselves, run in turn on one state directory (9,883 links, 7,275 of them absolute links into the installed package's `dist`). Full proof lines: #203923 (comment)

| build | state | `backup create --output --verify` |
|---|---|---|
| main 7d0cc1e | normal + legacy cache, run 1 and 2 | rc=1, "Backup manifest exceeds 1048576 byte limit", no archive |
| this PR | normal + legacy cache, run 1 and 2 | rc=0, manifest 2,407 bytes, `plugin-runtime-deps` listed as regenerable, 0 archive entries from it |
| main and this PR | normal, no legacy cache | rc=0, identical archive entry lists, same skipped roots |
| main 7d0cc1e | normal + 19,000 session files | rc=0, manifest 2,318 bytes |

The PR's archive passed `backup verify`, restored into an empty directory, and a Gateway started on the restored state reported ready.

Test: the existing managed-root exclusion test in `backup-create.test.ts` now includes `plugin-runtime-deps`; it fails on main and passes here. The separate test file from the first commit was folded into it.

## Merge danger

Two-way door: a revert restores the old archive contents; no state, config or contract is written or migrated. Blast radius: backup create/verify of state directories that still contain `plugin-runtime-deps`.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
Root cause: src/commands/backup-resource-inventory.ts:82 `MANAGED_STATE_ROOTS` left out the legacy `plugin-runtime-deps` cache, so backup archived it and wrote every absolute link inside it into the manifest's `externalSymbolicLinks`, which overflows the 1 MiB manifest cap.

Fixes openclaw#203082

Thanks @sukhdeepjohar for the diagnosis and fix, and @dygg2001 for the report and the link counts that pinned it down.

## What Problem This Solves

On installs that ran OpenClaw before 2026.5.2, `openclaw backup create` can stop with "Backup manifest exceeds 1048576 byte limit" and save no backup at all. Those releases built a bundled-plugin dependency cache at `~/.openclaw/plugin-runtime-deps`, including a mirror of OpenClaw's own program files as links into the install folder. Nothing deletes that cache today (openclaw#134099 keeps it, because another installation may still use it). Backup copies it and lists every one of those links in the archive's manifest, which has a 1 MiB limit. The reporter of openclaw#203082 has 7,464 such links, enough to overflow it.

The "19k session files" in the issue title are not the cause: the manifest has no per-file entries for sessions (live session files are reported as volatile and kept out of the manifest). The reporter's own count confirms it: 7,464 of their 7,619 outside links are in this cache; the remaining 155 fit easily.

## User Impact

Backups of long-running installs complete again. The old cache stays on disk untouched but is no longer copied into backups, and the thousands of "External link preserved" lines it caused disappear from backup and restore output. Current OpenClaw never reads that cache. An older OpenClaw restored from such a backup rebuilds it at startup, as it always did.

## Why This Change Was Made

Backup already leaves out installer-managed and rebuildable folders under the state directory (`dev/`, `git/`, `npm/`, legacy `npm-runtime/`, `tmp/`, `tools/`), and reports each as "regenerable". The old plugin cache is the same kind of folder but was missing from that list. This adds it, so backup never opens it. It is not a user exclusion switch, and links elsewhere are judged and reported exactly as before. The manifest limit is unchanged.

Nothing user-authored lives there: the cache was written only by the bundled-plugin dependency stager (package roots named `openclaw-<version>-<hash>` with `node_modules`, a `dist` mirror and stamps), documented as an OpenClaw-owned package root. The only remaining references in shipped code match the name in link targets or process command lines (`doctor` dangling-alias cleanup, ACPX process reaper); none reads the folder.

## Evidence

Both sides built in an isolated Linux container. The legacy cache was built by the published 2026.4.24, 2026.4.25, 2026.4.26 and 2026.4.27 releases themselves, run in turn on one state directory (9,883 links, 7,275 of them absolute links into the installed package's `dist`). Full proof lines: openclaw#203923 (comment)

| build | state | `backup create --output --verify` |
|---|---|---|
| main 706c3cf | normal + legacy cache, run 1 and 2 | rc=1, "Backup manifest exceeds 1048576 byte limit", no archive |
| this PR | normal + legacy cache, run 1 and 2 | rc=0, manifest 2,407 bytes, `plugin-runtime-deps` listed as regenerable, 0 archive entries from it |
| main and this PR | normal, no legacy cache | rc=0, identical archive entry lists, same skipped roots |
| main 706c3cf | normal + 19,000 session files | rc=0, manifest 2,318 bytes |

The PR's archive passed `backup verify`, restored into an empty directory, and a Gateway started on the restored state reported ready.

Test: the existing managed-root exclusion test in `backup-create.test.ts` now includes `plugin-runtime-deps`; it fails on main and passes here. The separate test file from the first commit was folded into it.

## Merge danger

Two-way door: a revert restores the old archive contents; no state, config or contract is written or migrated. Blast radius: backup create/verify of state directories that still contain `plugin-runtime-deps`.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
Root cause: src/commands/backup-resource-inventory.ts:82 `MANAGED_STATE_ROOTS` left out the legacy `plugin-runtime-deps` cache, so backup archived it and wrote every absolute link inside it into the manifest's `externalSymbolicLinks`, which overflows the 1 MiB manifest cap.

Fixes #203082

Thanks @sukhdeepjohar for the diagnosis and fix, and @dygg2001 for the report and the link counts that pinned it down.

On installs that ran OpenClaw before 2026.5.2, `openclaw backup create` can stop with "Backup manifest exceeds 1048576 byte limit" and save no backup at all. Those releases built a bundled-plugin dependency cache at `~/.openclaw/plugin-runtime-deps`, including a mirror of OpenClaw's own program files as links into the install folder. Nothing deletes that cache today (#134099 keeps it, because another installation may still use it). Backup copies it and lists every one of those links in the archive's manifest, which has a 1 MiB limit. The reporter of #203082 has 7,464 such links, enough to overflow it.

The "19k session files" in the issue title are not the cause: the manifest has no per-file entries for sessions (live session files are reported as volatile and kept out of the manifest). The reporter's own count confirms it: 7,464 of their 7,619 outside links are in this cache; the remaining 155 fit easily.

Backups of long-running installs complete again. The old cache stays on disk untouched but is no longer copied into backups, and the thousands of "External link preserved" lines it caused disappear from backup and restore output. Current OpenClaw never reads that cache. An older OpenClaw restored from such a backup rebuilds it at startup, as it always did.

Backup already leaves out installer-managed and rebuildable folders under the state directory (`dev/`, `git/`, `npm/`, legacy `npm-runtime/`, `tmp/`, `tools/`), and reports each as "regenerable". The old plugin cache is the same kind of folder but was missing from that list. This adds it, so backup never opens it. It is not a user exclusion switch, and links elsewhere are judged and reported exactly as before. The manifest limit is unchanged.

Nothing user-authored lives there: the cache was written only by the bundled-plugin dependency stager (package roots named `openclaw-<version>-<hash>` with `node_modules`, a `dist` mirror and stamps), documented as an OpenClaw-owned package root. The only remaining references in shipped code match the name in link targets or process command lines (`doctor` dangling-alias cleanup, ACPX process reaper); none reads the folder.

Both sides built in an isolated Linux container. The legacy cache was built by the published 2026.4.24, 2026.4.25, 2026.4.26 and 2026.4.27 releases themselves, run in turn on one state directory (9,883 links, 7,275 of them absolute links into the installed package's `dist`). Full proof lines: #203923 (comment)

| build | state | `backup create --output --verify` |
|---|---|---|
| main 7d0cc1e | normal + legacy cache, run 1 and 2 | rc=1, "Backup manifest exceeds 1048576 byte limit", no archive |
| this PR | normal + legacy cache, run 1 and 2 | rc=0, manifest 2,407 bytes, `plugin-runtime-deps` listed as regenerable, 0 archive entries from it |
| main and this PR | normal, no legacy cache | rc=0, identical archive entry lists, same skipped roots |
| main 7d0cc1e | normal + 19,000 session files | rc=0, manifest 2,318 bytes |

The PR's archive passed `backup verify`, restored into an empty directory, and a Gateway started on the restored state reported ready.

Test: the existing managed-root exclusion test in `backup-create.test.ts` now includes `plugin-runtime-deps`; it fails on main and passes here. The separate test file from the first commit was folded into it.

Two-way door: a revert restores the old archive contents; no state, config or contract is written or migrated. Blast radius: backup create/verify of state directories that still contain `plugin-runtime-deps`.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit f6fca13)

Companion audit: 8cff45e is selected later in this lane for startup races; e3dd914 is separate Git backup commit validation. Neither is required for excluding an installer-owned cache.

Release adaptation: Extend the stable compact managed-root list with only the legacy plugin dependency cache; preserve the stable root set otherwise.

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

cli CLI command changes commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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