Skip to content

fix(update): avoid copying unrelated dependencies during updates - #168927

Merged
steipete merged 1 commit into
mainfrom
upd/upd-l1547
Oct 11, 2026
Merged

steipete merged 1 commit into
mainfrom
upd/upd-l1547

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes minute-scale update runtime retention when optional peers resolve from an ancestor installation. A tiny two-agent state could make the updater retain hundreds of thousands of unrelated development files, and unrelated cache writes could then fail the update.

User Impact

Future updates keep retained runtime dependency discovery inside the package manager's installation owner. Genuine hoisted dependencies and explicitly linked dependencies remain available. Backup, rollback, file-integrity checks, and writer settlement are unchanged. There are no new settings, options, dependencies, or schemas.

The installed updater runs this phase before the candidate takes over, so an older updater cannot benefit on the first update that installs this fix.

Why This Change Was Made

A 2026.10.1 updater copied 394,203 entries with a 9.23 GB estimated footprint while retaining a runtime for two agents, two sessions, and one disabled cron job. Missing optional peers in transitive dependencies found an enclosing checkout's node_modules; discovering one peer retained the entire module owner and its unrelated siblings.

Pass the already-resolved package manager owner into retained runtime discovery and stop ancestor lookups there. Generic plugin rehearsal and explicit links outside that owner keep their existing discovery behavior. The regression exercises npm and pnpm 11 through runtime retention, removes the original installation, and proves a legitimate hoisted dependency still imports while unrelated ancestor packages stay absent.

Evidence

  • Built and validated package artifacts from initial main c1ae5fb and this PR head. Synthetic state and a free loopback port; no operator Gateway or state was used. Artifact versions were relabeled using the existing published-driver helper.
  • The published-driver run activated the candidate and recorded succeeded / finished. Its old CLI subsequently returned exit 1 after a removed cleanup-chunk import; that first-hop limitation is outside this change. The activated Gateway returned readyz 200 and listed both preserved sessions.
  • Unmodified current main reproduced the retention problem: 824.519 seconds before rejecting an unrelated Vitest cache file changed by concurrent verification. This is recorded as a failed baseline, not a successful update or a comparable total-duration result.
  • The two new regressions failed on the original code and passed after the fix (24 ms / 26 ms in the sibling run). All 12 importing test files passed: 136 tests, one existing skip, 85.65 seconds wall time. Focused wrapper wall time was 27.56 seconds including shared compilation. Hosted CI seconds are not yet measured.
  • Full changed-file checks passed against the initial-main base, including core/test typechecks, lint, schema guards, and zero runtime import cycles. Build and tarball integrity checks passed. The build also reports an existing Control UI startup-size advisory, unchanged by this patch.
  • Independent autoreview was attempted and returned HTTP 401; no clean review is claimed. Campaign lead review of the PR head is still required.

The isolated after run completed with exit 0, ledger succeeded / finished, readyz 200, both sessions, the injected durable message, and the authored disabled cron job preserved. Two disabled system heartbeat jobs are also present.

Measured step Released 2026.10.1 driver → initial main Fixed main driver → same target build
Package install 92.3 s 23.8 s
Retained runtime inventory 195.6 s 34.6 s
Retained runtime materialization 437.4 s 107.4 s
Retained runtime total 633.1 s 142.1 s
Retained entries 394,203 44,492
Estimated retained footprint 9.23 GB 642 MB
Canary preparation and checks 59.9 s 98.7 s
Database backup 11.6 s 7.1 s
Package publication / swap 128.4 s 92.3 s
Live Doctors and trailing lint 79.3 s 53.0 s
CLI wall time 20m22s; exit 1 after ledger success 8m54s; exit 0

These are phase observations, not an additive accounting table. The released run migrated agent schema 24 to 25; the after run started at schema 25, used a warm npm cache, and ran under changing shared-host load. The separately observed unmodified-main failure above used the same target build and restored state as the fixed run. Old-driver exit cleanup spent another 186.9 seconds after its ledger finished; candidate code cannot fix that already-running process.

The under-two-minute target is not met. The largest remaining measured costs are retained-runtime materialization (107.4 s), canary preparation/checks (98.7 s), and package publication (92.3 s). The after timer excludes installing the fixed driver (76.0 s) and removing the prior completed oversized fixture runtime (60.2 s). No backup, rollback, integrity, or live-authority gate was removed to hit a timing goal.

Scope: production +12/−1 lines, regression tests +75, documentation +6. No remote compute was used.

Keep updater runtime hoist discovery within the package manager installation owner. Preserve explicit linked dependency discovery and the existing backup, rollback, and runtime custody checks.
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Oct 11, 2026
@steipete
steipete marked this pull request as ready for review October 11, 2026 05:58
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR bounds retained updater dependency discovery to the package manager’s installation owner while preserving explicit linked dependencies.

Example: An npm installation depends on fixture, whose optional ambient-peer exists only in an enclosing checkout.

  • Before: Retention discovers ambient-peer and copies its entire node_modules owner, including an unrelated package.
  • After: Retention excludes those ancestor packages, and fixture still imports after the original installation is removed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with useful production-flow observations and meaningful regressions; reported timings are qualified observations rather than a controlled total-speedup benchmark.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied isolated update observations exercise the retained-runtime owner through the CLI: the fixed driver completed successfully, the activated Gateway answered readyz, and sessions, a durable message, and authored cron state survived; the released-driver run separately records its unchanged first-hop cleanup failure.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Updates can spend minutes retaining unrelated development dependencies and then fail when those unrelated files change.
Reason: A measured failure and focused regression justify the small repair; the existing feature owner authored the direction.

Merge readiness

✅ Ready for maintainer review

Keep open: this PR addresses a concrete update failure still present on current main with a focused repair; no actionable correctness or security findings were identified.

Priority: P2
Reviewed head: ed2f0fa7bbf6d09c25a5c5f17c8db7d03af58070

Before merge

None.

Findings

None.

Agent review details

How this fits together

Before replacing an installation, the update CLI retains its running worker code; package-manager ownership and dependency paths enter the shared copier, which produces a private runtime used until worker settlement.

flowchart TD
A[Update CLI] --> B[Installation owner]
B --> C[Retained runtime planner]
C --> D[Bounded dependency discovery]
D --> E[Private runtime materialization]
E --> F[Retained workers]
F --> G[Settlement and cleanup]
Loading

Technical review

Best possible solution:

Land the bounded discovery repair through normal repository gates while retaining explicit links and existing integrity, rollback, and worker-settlement guarantees.

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

Current-main source shows the unbounded lookup and whole-owner expansion; the supplied baseline observation records failure on an unrelated cache file, but this review ran no reproduction.

Is this the best way to solve the issue?

The patch fixes dependency selection at its existing owner, preserves explicit external links, and leaves plugin rehearsal callers unchanged.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Hoisted dependency discovery changes intended behavior with a stated reason (fd3ae9a: Preserve workspace plugin hoists, shared module owners, aliases, and staged-host identity.)
  • Retained updater generation keeps the original intent (dd7d596: Keep the running updater’s worker code available through installation replacement and settlement.)
  • Package-manager installation ownership keeps the original intent (317054d: Carry the actual installation owner into retention and place scratch outside complete replacement boundaries.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

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

PR surface

Source +11, Tests +75, Docs +6. Total +92 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 12 1 +11
Tests 1 75 0 +75
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 93 1 +92

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +12/−1 lines; tests +75 lines The small production change reuses the existing copier; the parameterized regression proves both dependency survival and ancestor exclusion across npm and pnpm 11.

Labels

Label changes:

  • add P2: The fix prevents excessive retention work and unrelated-file update failures in specific installation layouts.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The fix prevents excessive retention work and unrelated-file update failures in specific installation layouts.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

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

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

Reviewed October 11, 2026, 2:05 AM ET / 06:05 UTC.

@steipete
steipete merged commit 01b25a9 into main Oct 11, 2026
193 checks passed
@steipete
steipete deleted the upd/upd-l1547 branch October 11, 2026 06:08
RomneyDa pushed a commit that referenced this pull request Oct 12, 2026
…tion (#168927)

Update runtime retention resolved missing optional peers by walking past the installation into ancestor node_modules, retaining entire unrelated dependency trees (394k entries / ~9.2 GB in the measured run). Lookup now stops at the package manager's owning project; linked dependency owners and backup/rollback checks are unchanged. Measured: retention 633 s -> 142 s, update 20m22s (failed) -> 8m54s.

(cherry picked from commit 01b25a9)
RomneyDa added a commit that referenced this pull request Oct 12, 2026
Re-apply the retainedDependencyRoot hunk of #169292 (032a58b) that was
dropped from the earlier #169292 backport because #168927 (01b25a9)
was not yet on the branch. With #168927 now applied, the retained dependency
root uses resolveIdentityPathViaExistingAncestorSync like the other
mutation boundaries, so Windows 8.3 names and case-insensitive volumes do
not hide that the update replaces this runtime.

Backport notes: follow-up to the backports of #168927 (01b25a9) and
#169292 (032a58b); single-line change in
src/infra/update-retained-runtime.ts.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…tion (openclaw#168927)

Update runtime retention resolved missing optional peers by walking past the installation into ancestor node_modules, retaining entire unrelated dependency trees (394k entries / ~9.2 GB in the measured run). Lookup now stops at the package manager's owning project; linked dependency owners and backup/rollback checks are unchanged. Measured: retention 633 s -> 142 s, update 20m22s (failed) -> 8m54s.
RomneyDa pushed a commit that referenced this pull request Oct 13, 2026
…tion (#168927)

Update runtime retention resolved missing optional peers by walking past the installation into ancestor node_modules, retaining entire unrelated dependency trees (394k entries / ~9.2 GB in the measured run). Lookup now stops at the package manager's owning project; linked dependency owners and backup/rollback checks are unchanged. Measured: retention 633 s -> 142 s, update 20m22s (failed) -> 8m54s.

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

Labels

docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant