Skip to content

fix(update): preserve dirty checkouts by installing dev separately - #147629

Open
RomneyDa wants to merge 5 commits into
mainfrom
fix/update-dirty-relocation
Open

RomneyDa wants to merge 5 commits into
mainfrom
fix/update-dirty-relocation

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

Installer support: #147677. Windows launcher support: #147653.

Depends on #147621. Part of #144836's smaller follow-ups.

What Problem This Solves

Explicit openclaw update --channel dev currently refuses a dirty Git checkout. For verified npm-linked installs on macOS and Linux, stage a fresh checkout and move the invoking npm exposure through the existing update transaction. Preserve the original checkout and local edits; retain rollback and report the settled runtime for recovery and triage.

Why This Change Was Made

Bind admission to the actual npm launcher and prefix. Recheck launcher ownership before activation, reject custom/replaced launchers, and avoid selecting an unrelated globally installed package manager. Honor an empty OPENCLAW_GIT_DIR; otherwise choose a fresh default destination. Keep JSON output machine-readable.

User Impact

Local edits stay in the original checkout while the managed dev installation updates separately. This requires the running updater to contain this change; selecting a newer target cannot retrofit an older updater that already refuses the dirty checkout. Install a version containing this fix through an existing supported installation path first.

Evidence

Current repair integrates main 1f01f4944d45 and reuses its package activation, source staging, recovery, and schema-admission owners. Relocation admission lives in one target-preparation helper; the original checkout stays untouched and launcher ownership is checked again before activation. No new persistence format or configuration is introduced.

Current local proof: four targeted suites passed, 111 tests total (Git service, update execution, shared command runner, Git snapshot admission). Core production typechecking and targeted lint passed. The candidate diff passes git diff --check. Fresh independent P0–P2 review found no actionable issues in the supplied code diff; surrounding transaction/integrity implementations were not included in its isolated bundle. Historical counts below are not current-head CI evidence. Exact-head CI must complete after publication.

Earlier production-path CLI fixtures covered dirty-checkout preservation, npm launcher movement, package state, and custom-launcher refusal. Those unchanged-input results are retained; no new full managed-service end-to-end run was performed in this repair.

The service transition reuses the existing package-to-Git owner. Existing CLI/service tests cover refreshing the owned service to the settled root, preserving foreign services, and restarting the original root after rollback. The new filesystem relocation cases run with restart disabled, so a full managed-service relocation/rollback run remains unqualified.

This slice covers npm-linked POSIX installs. Canonical installer wrappers and Windows launcher support follow separately; no native Windows or full-service rollback proof is claimed here.

CI follow-up: type-import cycle

The architecture job on 06bbc302d05c exposed a type-only cycle through the Git update implementation, recovery, and execution contracts. Moved the unchanged GitInstallRelocation contract into a leaf type module and migrated all three consumers; runtime behavior is unchanged. The Madge cycle check now reports zero cycles, and core typechecking passes. Prior behavioral proof remains applicable; new exact-head CI is pending.

@clawsweeper

clawsweeper Bot commented Sep 14, 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 cli CLI command changes size: M maintainer Maintainer-authored PR labels Sep 14, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review September 14, 2026 00:54
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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 Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

For npm-linked installations on macOS and Linux, explicit dev updates install into a fresh checkout while preserving the original checkout and local edits.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The implementation and repaired regressions provide useful confidence, but required installed-update qualification remains incomplete.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Merge readiness

⛔ Blocked before merge - 3 items remain

This remains useful work absent from current main. Prior actionable findings are resolved, but update qualification remains incomplete and GitHub currently reports merge conflicts. The member-authored, maintainer-labeled PR also requires explicit maintainer handling.

Likely related people: RomneyDa and Peter Steinberger, as routing candidates based on merged update work.

Priority: P2
Reviewed head: 01270f23cf996e949e39b50dce4e59fd8b7feffd

Before merge

  • Resolve merge risk - The documented bootstrap from a published updater into the relocation-capable updater has not been demonstrated; existing installed updaters continue refusing the dirty checkout.
  • Resolve merge risk - Managed-service relocation and injected rollback remain unqualified, leaving uncertainty that the Gateway resumes from the settled runtime while the original checkout and edits remain intact.
  • Complete next step - Resolve the current merge conflicts and validate the resulting head.

Findings

None.

Agent review details

How this fits together

The CLI updater selects and validates an installation, then uses the existing package transaction to activate it and recover failures. Relocation changes the npm launcher’s destination and feeds the settled installation into Gateway restart and recovery.

flowchart TD
  A[Explicit dev update] --> B[Inspect dirty checkout and npm launcher]
  B --> C{Verified installation and fresh destination}
  C -->|Accepted| D[Build and validate fresh checkout]
  C -->|Refused| E[Preserve original installation]
  D --> F[Activate npm exposure]
  F --> G[Restart Gateway or recover original runtime]
Loading

Technical review

Best possible solution:

Keep relocation within the existing npm transaction and service owners, with a demonstrated bootstrap path and verified recovery to the correct runtime.

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

Not applicable as a new relocation capability: current main and v2026.9.8 lack this path. No runtime execution was performed during this read-only review.

Is this the best way to solve the issue?

Yes, reusing the existing npm exposure transaction is a maintainable approach; installed-updater bootstrap and managed-service recovery still need qualification.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Qualify bootstrap and service recovery (recommended)
    Provide the published-updater bootstrap transcript and managed-service relocation/rollback evidence before landing the existing implementation.

Security

None.

Evidence

What I checked:

  • Pinned introduction scope: Reviewed the merge-base-to-head production, documentation, and test hunks. Base-only proxy and assertion-baseline changes were excluded from PR ownership. (01270f23cf99)
  • Current-main necessity: Current main selects package-to-Git switching only when the existing installation is not Git; it does not contain the branch’s dirty-Git relocation selection. (src/cli/update-cli/update-command-target.ts:305, b1697e2ae8f6)
  • Published-updater boundary: The target-selection source at v2026.9.8 also lacks relocation. Its unavailable local blob was inspected through the read-only GitHub blob API. The captured PR body explicitly acknowledges that selecting a newer candidate cannot retrofit the running updater. (src/cli/update-cli/update-command-target.ts:284, fc23bc864e45)
  • Launcher ownership and activation: Relocation derives the prefix from the invoking npm launcher, checks the package link and launcher, rejects overlapping destinations, and supplies a fresh ownership check to the existing exposure activation gate. No concrete unauthorized activation was established. (src/cli/update-cli/update-command-relocation.ts:97, 01270f23cf99)
  • Prior findings resolved: The clone owner now receives requireFresh; execution uses the selected relocation root for artifact admission; snapshot refusal selects Git recovery for the original Git installation. The corresponding regressions are present. The September 30 test-cost comment reports 107.49 seconds wrapper wall time, resolving the previous documentation finding. (src/cli/update-cli/update-command-git.ts:511, 01270f23cf99)
  • Qualification gap retained honestly: The captured body and September 30 comments explicitly leave published-updater bootstrap and full managed-service relocation/rollback unqualified. The changed filesystem scenario invokes updateCommand with restart disabled and mocked command/install owners; it demonstrates useful boundary assertions but does not establish the omitted installed-service flow. (src/cli/update-cli.git-service.test.ts:570, 01270f23cf99)

PR surface

Source +172, Tests +250, Docs +6. Total +428 across 18 files.

View PR surface stats
Area Files Added Removed Net
Source 12 191 19 +172
Tests 5 261 11 +250
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 18 458 30 +428

Review metrics

Metric Value Why it matters
Production versus test growth production +172 net, tests +250 net The discussion justifies production growth as relocation admission and activation wiring; tests target destination, artifact-root, recovery, and triage contracts.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This adds bounded update recovery for npm-linked development installations while preserving local edits.
  • merge-risk: 🚨 compatibility: Published updaters cannot acquire this behavior through candidate selection alone, and the required bootstrap remains unqualified.
  • merge-risk: 🚨 availability: The changed installation-root transition lacks complete managed-Gateway activation and rollback proof.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rank-up moves

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

  • Capture the published-updater bootstrap into the relocation-capable updater.
  • Demonstrate managed-service relocation and injected rollback, including the active runtime and preserved original edits.

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 execution lanes are retired.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-14T01:23:31.191Z sha 85454fe :: blocked before merge. :: none
  • reviewed 2026-09-14T01:47:11.690Z sha 85454fe :: blocked before merge. :: none
  • reviewed 2026-09-14T02:31:22.124Z sha 51f8892 :: blocked before merge. :: [P2] Preserve the fresh-destination requirement until checkout creation
  • reviewed 2026-09-30T01:27:51.816Z sha f96e804 :: needs real behavior proof before merge. :: [P1] Use the selected relocation root for artifact admission
  • reviewed 2026-09-30T02:39:20.356Z sha ec1ce524c507934f90739048ab9591f532845452 :: blocked before merge. :: [P2] Verify the original Git checkout on snapshot refusal
  • reviewed 2026-09-30T04:33:40.372Z sha 87282c8c6a9af3ed08950a475e1dca283fa298ac :: blocked before merge. :: none
  • reviewed 2026-09-30T05:03:39.015Z sha bfde7be :: blocked before merge. :: [P3] Document the measured cost of the added updater tests
  • reviewed 2026-09-30T05:26:40.912Z sha 01270f2 :: blocked before merge. :: none

Reviewed October 7, 2026, 4:45 PM ET / 20:45 UTC (Revision 10).

@RomneyDa
RomneyDa force-pushed the fix/update-source-launcher-identity branch from ab218c6 to 6710b10 Compare September 14, 2026 02:23
@RomneyDa
RomneyDa force-pushed the fix/update-dirty-relocation branch from 85454fe to 51f8892 Compare September 14, 2026 02:23
@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 Sep 14, 2026
Base automatically changed from fix/update-source-launcher-identity to main September 22, 2026 16:00
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and 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 Sep 25, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 30, 2026
@RomneyDa

RomneyDa commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Addressed the exact-head P2 finding on 87282c8c6a9af3ed08950a475e1dca283fa298ac:

  • Git-to-Git relocation snapshot refusal now verifies the unchanged original checkout with the Git recovery owner instead of the package verifier.
  • Added a boundary regression that failed on the prior head with serviceRestartSafe: false and now proves Git recovery is selected while package recovery is not called.

Validation:

  • node scripts/run-vitest.mjs src/cli/update-cli/update-command-git-snapshot.test.ts — 4 passed
  • node scripts/check-changed.mjs -- src/cli/update-cli/update-command-git.ts src/cli/update-cli/update-command-git-snapshot.test.ts — changed gate completed through the selected core lanes
  • Autoreview — clean, no accepted/actionable findings

Production delta for this repair: +3/-1. Test delta: +65/-0.

Mechanical refresh: rebased cleanly onto main f7b2f3a after the unrelated Gateway pairing shard failure. New exact head bfde7be. Post-rebase proof: updater snapshot regression 4/4 passed; changed gate passed; fresh branch autoreview clean. No updater behavior changed in the rebase.

@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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 30, 2026
@RomneyDa
RomneyDa force-pushed the fix/update-dirty-relocation branch from 87282c8 to bfde7be Compare September 30, 2026 04:58
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 30, 2026
@RomneyDa

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Addressing the remaining P3 test-cost finding on exact head bfde7be:

  • One-worker focused command: node scripts/run-vitest.mjs src/cli/update-cli/update-command-git-snapshot.test.ts
  • Result: 4/4 passed.
  • Vitest duration: 85.28 seconds.
  • Repository wrapper wall time: 107.49 seconds, including compiler preparation and cleanup.
  • The exact-head CI run did not complete, so it has no valid end-to-end CI duration to report; its only test failure is an unrelated Gateway pairing test and the branch was already mechanically rebased for that failure.

No production or test code changed after the reviewed finding repair.

@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@roboclaw-bot roboclaw-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Cancellation after exposure preparation can overwrite valid recovery for the untouched original Git installation. With a verified npm-linked dirty Git install and an existing empty selected destination, let exposure preparation succeed and a later preflight check fail (for example dependency-link validation). The staged-root branch correctly obtains readOriginalUpdateRecovery, but prepareGitPackageExposure().cancel() uses package-only verifyPackageUpdateRecovery, which rejects the source checkout. Because both owners resolve and the service uses the original npm installation, this branch replaces the valid Git recovery with that false unsafe verdict.

Please retain or recheck predecessor recovery through its actual Git owner after cancellation, and cover failure after exposure is prepared with an owned service and an existing empty destination. The snapshot-refusal regression runs before this path. This finding concerns incorrect recovery classification; the final service backstop may still recover a stopped Gateway, so it is not a claim of a permanently stranded service.

Sources at this reviewed head: original Git recovery, cancellation verifier, later overwrite. Source review only; installed-service qualification remains separate.

This branch has not been deployed

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

Labels

cli CLI command changes docs Improvements or additions to documentation 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants