Repository navigation
fix(install): avoid unusable checkout directories after failed clones - #124872
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 5:04 AM ET / 09:04 UTC. ClawSweeper reviewWhat this changesThe PR stages fresh Git clones and publishes them only after success across Unix, Windows, and CLI package-to-Git update flows. Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessNo 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 Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’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]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +98, Tests +618, Other +260. Total +976 across 10 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest 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. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
|
Merged via squash.
|
…openclaw#124872) * fix(install): publish fresh git clones transactionally Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * fix(installer): preserve empty clone destinations transactionally Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * fix(update): satisfy transactional clone lint Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * test(update): type recovery directory assertion * fix(installer): retain canonical clone checkout Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * fix(update): retain published checkout root Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae * test(update): cover package preflight before clone Amp-Thread-ID: https://ampcode.com/threads/T-01a00ae0-190d-718b-8a76-b75f3e8d1fae --------- Co-authored-by: Amp <[email protected]>
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
.gitwithout 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 clonesucceeds, 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:
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 passedpnpm tsgo:coreandpnpm tsgo:test:root— passedpnpm check:changedin an isolated clone — passed, including core-test type shards, lint, formatting, policy ratchets, and dead-export scansbash -n scripts/install.shandbash -n scripts/install-cli.sh— passedscripts/install.ps1under pwsh 7.6.5 — passedensureGitCheckoutRegression coverage proves successful publication, failed-clone cleanup, destination-appearance preservation, existing-checkout updates, and preservation of pre-existing commitless/user-owned directories.