Skip to content

Keep start from following redirected Git destinations - #1604

Merged
mergify[bot] merged 3 commits into
mainfrom
lean178/1539-1540-guard-start-paths-v2
Nov 26, 2026
Merged

mergify[bot] merged 3 commits into
mainfrom
lean178/1539-1540-guard-start-paths-v2

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Keep start from following redirected Git destinations

Context and goal

  • Goal: Starting a task leaves unrelated local branches and external files intact.
  • Problem: Git could follow a symbolic remote-tracking ref, and the exclude writer could follow a link outside the repository's Git directory.
  • Context: Start fetches the advertised commit without a destination, then updates the tracking ref directly. It verifies the exclude destination before creating a checkout.

Closes #1539
Closes #1540

Acceptance

  • A symbolic tracking ref leaves its target branch intact. A file or directory link outside the Git directory prevents checkout creation and leaves the target unchanged.

Base

main @ 9c42f8a
Base: 9c42f8a

Notes

This draft supersedes #1591 and includes the missing-base diagnostic fix.

Validation

Recorded for 24e942737303

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 24e9427, approve

eowca and others added 3 commits November 26, 2026 08:05
Architecture-Review: unchanged; Start still fetches the configured base and creates the task checkout. It now binds both preparation writes to their intended Git destinations.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; start still fetches the configured base before creating the checkout.
Co-Authored-By: Codex <noreply@openai.com>
Architecture-Review: unchanged; the new shared Git directory arguments retain the same destination guard.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

loopzero primary review by claude on 24e942737303c91f2afa31e3bc9efbe5e01a4fe7, 53.0s: approve (0 critical, 0 important, 3 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/worktree.py
base, _, ref = advertised.partition("\t")
if ref != remote_ref:
raise GitError(("git", *lookup), f"origin did not report a unique {remote_ref}")
_git(repo_root, "fetch", "--quiet", "--no-tags", "--no-write-fetch-head", "--refmap=", "origin", base)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Fetching the ls-remote SHA can fail if origin moves between the two calls

Start now looks up the tip with ls-remote, then makes a second connection to fetch that SHA. If refs/heads/<base> moves between the two calls, the old SHA is no longer an advertised tip. A protocol-v0 server without uploadpack.allowReachableSHA1InWant (or allowAnySHA1InWant) then rejects the want ('not our ref'), and start fails with a raw fetch error. Protocol-v2 servers such as GitHub accept it, so this is an uncommon transient failure, not a correctness bug. Smallest fix: if the SHA fetch fails, redo the lookup and fetch once more, or say in the error that the base moved and start can be retried.

Comment thread src/loopzero/worktree.py
advertised = _git(repo_root, *lookup)
base, _, ref = advertised.partition("\t")
if ref != remote_ref:
raise GitError(("git", *lookup), f"origin did not report a unique {remote_ref}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Missing-base message says 'unique' when origin has no such branch

When the base branch does not exist on origin, ls-remote succeeds with empty output, and the user sees origin did not report a unique refs/heads/<base>. The common case is that the branch is missing, not that it is ambiguous, so 'unique' is misleading. Smallest fix: when advertised is empty, report something like origin has no branch <base>; check [repo] base_branch, and keep the 'unique' wording only when several lines match.

Comment thread tests/test_worktree.py
repo = checkout
invoke = worktree._git
invoke, local_head = worktree._git, worktree.head(repo)
def interleave(path, *args, **kwargs):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: The interleaving fetch in the test is now dead weight

interleave fetches another branch after start's fetch. Its job was to overwrite FETCH_HEAD and prove start did not read it. Start now passes --no-write-fetch-head and uses the SHA from ls-remote, so this hook no longer exercises a real race. Either remove it, or make it push a new commit to origin's main between ls-remote and fetch. The second option would show that start branches from the commit it looked up and would cover the race in the first finding.

@eowca
eowca marked this pull request as ready for review November 26, 2026 07:35
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as a8fc35c at 07:40 UTC

4 min in the queue, 3 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 07:36 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1647
  • ✅ Merged 07:40 · a8fc35c · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit a8fc35c into main Nov 26, 2026
24 checks passed
@eowca
eowca deleted the lean178/1539-1540-guard-start-paths-v2 branch November 26, 2026 07:41
@mergify mergify Bot removed the queued label Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep start from rewriting an external Git exclude symlink target Keep start fetch from force-updating a local branch through a symbolic tracking ref

1 participant