fix(miner): check out baseBranch on the fresh-clone path so the first attempt succeeds (#9682) - #9904
Conversation
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-29 21:04:48 UTC
Review summary Nits — 2 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
… attempt succeeds (JSONbored#9682) `ensureRepoClonedUnlocked`'s docstring promises both branches land on the base branch, but the fresh-clone branch returned right after `git clone`. A plain clone creates only origin's default-HEAD local branch, so the consumer's `git worktree add -b <attempt> <path> <baseBranch>` cannot rev-parse a bare non-default `<baseBranch>` -- the first attempt against any repo whose base isn't the origin default fails with `invalid reference` (blocked_worktree_preparation_failed), and only the second attempt (the fetch+reset path, which DWIM-creates the local branch) works. - repo-clone.ts: after a successful clone, run `git checkout <baseBranch>` and return the identical `{ ok:false, error: stderr || "git_checkout_failed" }` shape the existing-clone branch uses. No fetch/reset is added -- a fresh clone is already at origin's tip. The isUnsafeGitArgValue guard still runs first. - attempt-worktree.ts: the clone/checkout-failure return now forwards `repoPath` (ensureRepoCloned always sets it), so a clone/checkout failure and a worktree-add failure surface the same {ok:false, repoPath, error} shape -- an unknown base branch now fails at the checkout step, so callers keep getting repoPath on that path. Tests: three named repo-clone regression cases (checkout after clone on the first-use path; a failing checkout returns git_checkout_failed / stderr; the fresh path emits exactly clone+checkout, no fetch/reset); the per-repo concurrency test's pinned git-op sequence is updated for the new checkout (its non-overlapping guarantee is unchanged); the attempt-worktree unknown-base-branch test now asserts the {ok:false, repoPath, error} shape from the checkout step. All new assertions fail against the current code. Closes JSONbored#9682 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9904 +/- ##
===========================================
- Coverage 91.76% 79.35% -12.42%
===========================================
Files 921 283 -638
Lines 113203 58734 -54469
Branches 27253 8665 -18588
===========================================
- Hits 103884 46606 -57278
- Misses 8034 11843 +3809
+ Partials 1285 285 -1000
Flags with carried forward coverage won't be shown. Click here to find out more.
|
What
ensureRepoClonedUnlocked's docstring promises both branches land on the base branch, but the fresh-clone branch returned right aftergit clone. A plain clone creates only origin's default-HEAD local branch, so the consumer'sgit worktree add -b <attempt> <path> <baseBranch>(worktree-plan.ts:80-84) can't rev-parse a bare non-default<baseBranch>. The first attempt against any repo whose base isn't the origin default fails withfatal: invalid reference: <baseBranch>(surfacing asblocked_worktree_preparation_failed), and only the second attempt — the fetch+reset path that DWIM-creates the local tracking branch — works. Reachable in production (attempt-cli.ts:578passes the PR's real base;attempt-worktree.tsdefaults to"main", failing the first attempt against anymaster-default repo).How
repo-clone.ts: after a successfulgit clone, rungit checkout <baseBranch>and return the identical{ ok: false, repoPath, error: stderr || "git_checkout_failed" }shape the existing-clone branch already uses. Nofetch/resetis added — a fresh clone is already at origin's tip. TheisUnsafeGitArgValue(baseBranch)guard still runs first.attempt-worktree.ts: the clone/checkout-failure return now forwardsrepoPath(whichensureRepoClonedalways sets on failure), so a clone/checkout failure and a worktree-add failure surface the same{ ok: false, repoPath, error }shape. An unknown base branch now fails at the checkout step, and callers keep gettingrepoPathon that path.Tests
git_checkout_failed/ stderr; the fresh path emits exactlyclonethencheckout, nofetch/reset).attempt-worktreeunknown-base-branch test now asserts the{ ok: false, repoPath, error }shape produced at the checkout step.All new assertions fail against the current code.
Closes #9682