Skip to content

fix(install): avoid unusable checkout directories after failed clones - #124872

Merged
steipete merged 7 commits into
mainfrom
codex/autoqa-transactional-git-clone
Aug 17, 2026
Merged

steipete merged 7 commits into
mainfrom
codex/autoqa-transactional-git-clone

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users installing or switching to a Git checkout could be left with an unusable destination when the initial clone failed or was interrupted. The partial directory could contain .git without a commit, and later installer runs deliberately refused to overwrite or recover it.

This affected the hosted Unix installer, the dedicated-prefix installer used by desktop apps, the Windows installer, and the CLI's package-to-Git update path.

Why This Change Was Made

Fresh clones now happen in a unique sibling staging directory. The installer publishes the checkout with a directory rename only after git clone succeeds, cleans staging on failure, and refuses publication if the configured destination appeared while cloning. Existing checkout updates and pre-existing empty or user-owned directory behavior stay unchanged.

Keeping staging beside the destination makes publication a same-filesystem rename. Node, POSIX shell, and PowerShell do not expose one portable atomic no-replace directory primitive, so the implementation checks immediately before rename rather than claiming stronger cross-platform race semantics.

User Impact

An interrupted or failed first Git clone no longer poisons the configured install directory. Users can retry without manually finding and removing a commitless partial checkout, while concurrently created destination content is preserved.

Evidence

Pre-fix fault injection exited with the clone's status while leaving the durable partial checkout:

status=42 destination=present partial_git=present

Post-fix validation on exact head:

  • node scripts/run-vitest.mjs test/scripts/install-sh.test.ts test/scripts/install-cli.test.ts test/scripts/install-ps1.test.ts src/cli/update-cli/shared.command-runner.test.ts src/cli/update-cli.test.ts — 5 files, 421 tests passed
  • pnpm tsgo:core and pnpm tsgo:test:root — passed
  • pnpm check:changed in an isolated clone — passed, including core-test type shards, lint, formatting, policy ratchets, and dead-export scans
  • bash -n scripts/install.sh and bash -n scripts/install-cli.sh — passed
  • PowerShell parser validation for scripts/install.ps1 under pwsh 7.6.5 — passed
  • Real local-repository clone smoke passed through all four production owners: hosted shell installer, dedicated-prefix shell installer, PowerShell helper, and ensureGitCheckout

Regression coverage proves successful publication, failed-clone cleanup, destination-appearance preservation, existing-checkout updates, and preservation of pre-existing commitless/user-owned directories.

@clawsweeper

clawsweeper Bot commented Aug 16, 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 cli CLI command changes scripts Repository scripts size: M maintainer Maintainer-authored PR labels Aug 16, 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 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

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

ClawSweeper review

What this changes

The PR stages fresh Git clones and publishes them only after success across Unix, Windows, and CLI package-to-Git update flows.

Regression provenance

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

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

No blocking correctness finding. This PR fixes a source-proven retry failure across the installer and CLI owners; it remains open for maintainer review because it carries the protected maintainer label and compatibility-sensitive installation behavior.

Priority: P2
Reviewed head: b279853c7adf39fb552b4446d5770be696a747db

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused boundary coverage and recorded real-owner smoke evidence, with compatibility-sensitive installer scope left for normal maintainer gating.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body supplies after-fix local-repository clone smoke across all four production owners and a recorded pre-fix fault-injection result.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies after-fix local-repository clone smoke across all four production owners and a recorded pre-fix fault-injection result.
Evidence reviewed 6 items Current-main defect path: Current main passes the requested destination directly to git clone, so an interrupted clone can leave a partial directory at the later-protected destination.
Transactional repair: The PR clones into a staging directory, removes it in finally on failure, and publishes only after destination checks; existing empty destinations use the same canonical target.
Caller consumes canonical path: The Git update owner replaces its requested path with the published canonical checkout before gateway update and global installation.
Findings None None.
Security None None.

How this fits together

OpenClaw’s installers and updater create local Git checkouts before building or running the product from them. The change prevents a failed clone from becoming a durable, unusable destination while preserving existing directories and aliases.

flowchart LR
A[Install or update request] --> B[Resolve checkout destination]
B --> C[Clone into sibling staging directory]
C --> D{Clone succeeds?}
D -->|No| E[Remove staging directory]
D -->|Yes| F{Destination unchanged?}
F -->|Yes| G[Publish canonical checkout]
F -->|No| H[Preserve destination and stop]
G --> I[Build or update from checkout]
Loading

Before merge

  • Resolve merge risk (P1) - The PR changes four persistent installer/update owners and adds net 358 production lines; compatibility for existing empty destinations and aliases must remain aligned across POSIX shell, PowerShell, and Node.
  • Complete next step (P2) - The protected maintainer label keeps this as a human merge-review item rather than a repair-lane candidate.
Agent review details

Security

None.

PR surface

Source +98, Tests +618, Other +260. Total +976 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 2 110 12 +98
Tests 5 663 45 +618
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 3 268 8 +260
Total 10 1041 65 +976

Review metrics

Metric Value Why it matters
Production versus test LOC production +378/-20 (net +358); tests +663/-45 (net +618) The production growth is a bounded cross-runtime implementation of the same staging invariant; the accompanying tests cover each owner boundary.

Merge-risk options

Maintainer options:

  1. Confirm exact-head compatibility coverage (recommended)
    Merge after required exact-head checks validate retryable empty destinations, alias retargeting, and preservation of concurrently created directories across all owners.

Technical review

Best possible solution:

Keep the owner-local staging implementations and merge only after exact-head checks confirm the covered retry, alias, and pre-existing-directory behaviors.

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

Yes: current main’s direct clone-to-destination path is source-proven, and the PR records matching pre-fix fault injection; this read-only review did not execute it.

Is this the best way to solve the issue?

Yes: staging beside the destination and publishing only after clone success repairs the producer path; direct clone-to-destination would retain the poisoned-checkout failure.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Failed Git clones make affected installation or update retries require manual directory recovery, with limited blast radius.
  • merge-risk: 🚨 compatibility: The PR changes how existing Git install destinations, empty directories, and aliases are handled during setup and update.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies after-fix local-repository clone smoke across all four production owners and a recorded pre-fix fault-injection result.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies after-fix local-repository clone smoke across all four production owners and a recorded pre-fix fault-injection result.

Evidence

What I checked:

  • Current-main defect path: Current main passes the requested destination directly to git clone, so an interrupted clone can leave a partial directory at the later-protected destination. (src/cli/update-cli/shared.ts:261, e3d553b73419)
  • Transactional repair: The PR clones into a staging directory, removes it in finally on failure, and publishes only after destination checks; existing empty destinations use the same canonical target. (src/cli/update-cli/shared.ts:254, b279853c7adf)
  • Caller consumes canonical path: The Git update owner replaces its requested path with the published canonical checkout before gateway update and global installation. (src/cli/update-cli/update-command-git.ts:140, b279853c7adf)
  • Sibling-owner coverage: Shell, dedicated-prefix shell, PowerShell, and CLI tests cover clone failure cleanup, destination appearance, empty-directory retry, and alias retargeting. (src/cli/update-cli/shared.command-runner.test.ts:139, b279853c7adf)
  • Regression provenance: Blame ties the direct clone call in current main to the prior checkout-flow commit; the PR’s fault-injection description matches that path. (src/cli/update-cli/shared.ts:261, a3eb8787ffc1)
  • Real behavior proof: The PR body records a failed-clone fault injection and an after-fix local-repository smoke through all four production owners, in addition to focused tests. (b279853c7adf)

Likely related people:

  • steipete: Peter Steinberger authored the current-main checkout flow and recent adjacent installer lifecycle work, and authored the PR head’s final regression coverage. (role: current checkout-flow contributor; confidence: high; commits: a3eb8787ffc1, 05bbd48c514a, b279853c7adf; files: src/cli/update-cli/shared.ts, src/cli/update-cli/update-command-git.ts, scripts/install.sh)

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-16T22:31:57.535Z sha ddaf208 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-17T03:04:26.147Z sha ddaf208 :: found issues before merge. :: [P2] Protect the accepted empty --git-dir path | [P2] Protect accepted empty OPENCLAW_GIT_DIR values
  • reviewed 2026-08-17T07:19:21.343Z sha 7fda9f5 :: found issues before merge. :: [P2] Propagate the canonical checkout path through the hosted installer | [P2] Propagate the canonical checkout path through the prefix installer | [P2] Remove shell staging before checking the published checkout
  • reviewed 2026-08-17T08:00:20.538Z sha 1e835a6 :: found issues before merge. :: [P2] Propagate the canonical checkout path through the CLI updater
  • reviewed 2026-08-17T08:43:19.437Z sha 743e797 :: needs maintainer review before merge. :: none

@steipete steipete self-assigned this Aug 17, 2026
@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 17, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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. labels Aug 17, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. labels Aug 17, 2026
@clawsweeper clawsweeper Bot added the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Aug 17, 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. 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 Aug 17, 2026
@steipete
steipete merged commit 076a8cc into main Aug 17, 2026
557 of 563 checks passed
@steipete
steipete deleted the codex/autoqa-transactional-git-clone branch August 17, 2026 09:40

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. 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.

2 participants