Skip to content

fix(install): support linked Git worktree checkouts - #172934

Merged
steipete merged 2 commits into
mainfrom
codex/fix-installer-linked-worktrees
Oct 15, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/fix-installer-linked-worktrees

Conversation

@steipete

@steipete steipete commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Git installs that reject an existing linked worktree because its .git metadata is a file. Sibling installers also skipped commit validation for this layout and could treat a nonempty directory inside another checkout as the install root.

User Impact

All three installers validate the selected checkout’s own commit before installing checkout package dependencies. Invalid destinations receive guidance to choose the checkout root or a new empty directory, while existing files remain untouched.

The shell installers can select a branch already held by another worktree without moving that worktree’s branch or index. The selected checkout becomes detached but remains a moving-branch install. main starts at the local branch and rebases only when updates are enabled; other branch selectors use the fetched origin branch.

Why This Change Was Made

Git supports both .git directories and gitfiles. Share explicit checkout-local metadata and HEAD validation in the existing Bash installer policy, apply equivalent PowerShell admission checks, and use Git’s worktreepath fact to detect occupied branches. Ordinary branch selection, pinned commits, tag precedence, and rebase recovery retain their existing behavior. Production changes remain net neutral; no new flags or configuration are introduced.

Evidence

Real Git fixtures reproduce the original linked-worktree refusal and sibling invalid-HEAD / ancestor-directory gaps. The repaired Bash paths publish runnable wrappers from synthetic builds; both generated standalone installers were also exercised. Negative controls with an impossible expected CLI version fail as intended.

The reserved-branch regression first failed all eight new cases across both shell installers. The repaired focused Vitest run passes 27 tests: valid and invalid metadata boundaries, reserved main, updates-disabled main, latest fallback, another occupied branch, and existing ordinary selector / rebase recovery cases. Primary worktree ref, HEAD, index, and linked metadata remain unchanged. Fixtures set temporary HOME, prefix, and TMP paths plus source guards and deny sentinels before loading installers.

Native Windows PowerShell 5.1 and PowerShell 7.6.7 also exercised 16 baseline-versus-patched admission comparisons for valid linked metadata, missing HEAD, broken gitfiles, and non-checkout subdirectories, stopping before dependency installation or builds. A hidden-gitfile fixture setup error was corrected and those four cases rerun; the subsequent PowerShell source change adds recovery guidance only.

Shell syntax, ShellCheck at error severity, TypeScript parsing, and formatting pass. Scoped Oxlint cannot start because the available tooling lacks eslint-plugin-solid; CI supplies lint and broad integration proof. The focused Vitest run took 109 seconds; full test-file timing is unavailable because unrelated tests were excluded.

Independent Codex review of the initial repair and fresh follow-up review of the complete installer owners, regression fixture, and docs are clean through P2.

Recognize native gitfiles while preserving explicit checkout-local HEAD
validation. Share the Bash guard and reject nonempty destinations without
local Git metadata in the sibling shell and PowerShell installers.

Exercise real linked worktrees, broken/missing HEAD metadata, and ancestor-only
destinations across Bash and native PowerShell, retaining metadata and the
other worktree HEAD. Keep release-note context in the PR.
@clawsweeper

clawsweeper Bot commented Oct 15, 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 scripts Repository scripts size: M labels Oct 15, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2509de3794

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/install-policy.sh Resolved
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-15T09:26:45.271102Z bf765a4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 15, 2026
@clawsweeper

clawsweeper Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

The installers recognize Git metadata files, share Bash checkout validation, and reject nonempty destinations without checkout-local metadata.

Example: Install a commit-pinned checkout at /tmp/linked checkout whose .git is a linked-worktree metadata file.

  • Before: The prefix installer rejects the directory as not a Git repository.
  • After: The installer validates its own HEAD and proceeds without replacing the metadata file.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused repair has value, but an actionable installation failure prevents a correctness pass.
Proof confidence 🌊 off-meta tidepool Not applicable: The host identifies this as maintainer-authored, outside the ordinary contributor proof gate; supplied evidence describes real-Git admission harnesses and synthetic builds rather than captured shipped-installer or upgrade runs.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A valid linked Git checkout is refused, while sibling installers can proceed from invalid checkout boundaries.
Reason: The maintainer-authored direction restores a valid Git layout and preserves checkout safety without adding options.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this PR open: the checkout validation repair is useful, but branch-selected linked-worktree installs still fail when another worktree holds main.

Priority: P2
Reviewed head: 2509de3794d1148aefbaa8c7038805848ff1c171

Before merge

  • Handle reserved branches in newly admitted linked checkouts (P2) - With a clean linked checkout on feature, an origin remote, and main checked out in the primary worktree, the new gitfile admission succeeds but --version main reaches checkout_git_openclaw_ref and runs git checkout main at scripts/install-policy.sh:371. Git rejects that operation because main is already used by another worktree, aborting installation before dependency setup; latest has the same failure when it falls back to main. The added fixture selects only a detached full SHA. Complete branch selection safely in the shared owner, preserve the other worktree, and cover this layout. This confirms the existing review discussion.
  • Explain how to recover from a non-checkout destination (P3) - For a nonempty subdirectory such as /tmp/seed/subdirectory, this new rejection says only that the destination is not a Git repository. It gives no next action, although the required correction is to select the checkout root containing .git or a new empty destination. Add that guidance to this message and the corresponding new PowerShell error at scripts/install.ps1:1961, preserving the existing files.

Findings

  • [P2] Handle reserved branches in newly admitted linked checkouts — scripts/install-cli.sh:1149
  • [P3] Explain how to recover from a non-checkout destination — scripts/install.sh:2865

Tests

  • Missing end-to-end proof: The fixtures omit branch-selected installation with main held by another worktree, and the supplied evidence contains no shipped fresh-install or stable-to-head upgrade trace.
Agent review details

How this fits together

The shell and PowerShell installers turn an operator-selected checkout into a built CLI and executable wrapper after validating metadata and selecting source revisions.

flowchart TD
  A[Installer arguments] --> B[Checkout admission]
  B --> C[Git revision selection]
  C --> D[Dependency installation]
  D --> E[Source build]
  E --> F[CLI wrapper]
Loading

Technical review

Best possible solution:

Complete linked-worktree handling in the existing shared revision selector while preserving other worktrees and providing actionable destination errors.

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

Source establishes both the current-main gitfile rejection and the remaining main-branch ownership failure; no target code or tests were executed during this read-only review.

Is this the best way to solve the issue?

Sharing explicit checkout-local validation is appropriate, but admitting gitfiles alone does not complete installation for branch selectors.

Full review comments:

  • [P2] Handle reserved branches in newly admitted linked checkouts — scripts/install-cli.sh:1149
    With a clean linked checkout on feature, an origin remote, and main checked out in the primary worktree, the new gitfile admission succeeds but --version main reaches checkout_git_openclaw_ref and runs git checkout main at scripts/install-policy.sh:371. Git rejects that operation because main is already used by another worktree, aborting installation before dependency setup; latest has the same failure when it falls back to main. The added fixture selects only a detached full SHA. Complete branch selection safely in the shared owner, preserve the other worktree, and cover this layout. This confirms the existing review discussion.
    Confidence: 0.98
  • [P3] Explain how to recover from a non-checkout destination — scripts/install.sh:2865
    For a nonempty subdirectory such as /tmp/seed/subdirectory, this new rejection says only that the destination is not a Git repository. It gives no next action, although the required correction is to select the checkout root containing .git or a new empty destination. Add that guidance to this message and the corresponding new PowerShell error at scripts/install.ps1:1961, preserving the existing files.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Checkout-local commit validation keeps the original intent (8075063: Reject incomplete checkouts without borrowing an enclosing repository's HEAD or deleting recoverable files.)
  • Shared Bash policy ownership keeps the original intent (4874680: Keep common installer policy in one source owner and assemble standalone distribution scripts.)
  • Nonempty destination admission changes intended behavior with a stated reason (076a8cc: Publish fresh clones transactionally while preserving existing destinations; this PR explicitly tightens reuse to checkout roots with their own metadata.)
  • Requested Git revision selection keeps the original intent (d1fdd6e: Honor requested Git versions rather than silently building an arbitrary checkout revision.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • node scripts/run-vitest.mjs test/scripts/install-cli.test.ts test/scripts/install-sh.test.ts test/scripts/install-ps1.test.ts --maxWorkers=1
  • bash -n scripts/install-policy.sh scripts/install-cli.sh scripts/install.sh
  • git diff --check
  • Verify the added branch-ownership case fails before repair and passes afterward with the primary worktree unchanged.

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 04181e4 adds scripts/install-policy.sh:359 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 04181e4d6272; files: scripts/install-policy.sh)
  • ooiuuii: Raw commit 8075063 adds scripts/install.ps1:1472 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 807506381a03; files: scripts/install.ps1)

PR surface

Tests +171, Docs +4, Other 0. Total +175 across 11 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 6 211 40 +171
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 4 27 27 0
Total 11 242 67 +175

Review metrics

Metric Value Why it matters
Production versus test delta Production +27/-27 lines; tests and fixtures +211/-40 lines Production remains net neutral; test growth replaces mocked validation with real Git layouts and native PowerShell admission coverage.

Labels

Label changes:

  • add P2: The failure affects advanced source-install workflows with linked worktrees and has limited blast radius.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: The failure affects advanced source-install workflows with linked worktrees and has limited blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🌊 off-meta tidepool and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 15, 2026, 4:30 AM ET / 08:30 UTC.

Select occupied branches detached without changing the primary worktree.
Keep local-main behavior when Git updates are disabled, share destination
validation, and explain recovery from non-checkout destinations.
@steipete
steipete merged commit 04296fd into main Oct 15, 2026
114 checks passed
@steipete
steipete deleted the codex/fix-installer-linked-worktrees branch October 15, 2026 09:51
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
* fix(install): support linked Git worktree checkouts

Recognize native gitfiles while preserving explicit checkout-local HEAD
validation. Share the Bash guard and reject nonempty destinations without
local Git metadata in the sibling shell and PowerShell installers.

Exercise real linked worktrees, broken/missing HEAD metadata, and ancestor-only
destinations across Bash and native PowerShell, retaining metadata and the
other worktree HEAD. Keep release-note context in the PR.

* fix(install): preserve branches owned by other worktrees

Select occupied branches detached without changing the primary worktree.
Keep local-main behavior when Git updates are disabled, share destination
validation, and explain recovery from non-checkout destinations.
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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M 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.

1 participant