Repository navigation
Conversation
When a worktree's PR came from a fork, Orca reused any existing remote
whose URL matched and ran the same narrowing it uses for remotes it
minted itself: the wide `+refs/heads/*:refs/remotes/<name>/*` was
deleted, `tagOpt` forced to --no-tags, and only the PR branch's narrow
refspec left behind. For a remote the user added by hand that broke
tracking for every other branch they push (`@{u}`, ahead/behind, plain
fetch) and, through the missing tracking ref, Orca's own PR detection.
The reuse and adoption paths now check the `remote.<name>.orca-created`
marker: remotes Orca minted keep the narrowing behavior unchanged, and
remotes it did not create get the branch's narrow refspec appended
add-only — nothing dropped, nothing rewritten, tagOpt untouched, and
the wide refspec survives re-runs. The migration sweep for pre-marker
`pr-*` remotes is intentionally untouched.
Fixes stablyai#25703
Generated-by: GLM-5.3-Flash (ZCode)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughReused fork remotes now use Orca provenance to select their refspec update path. Orca-created remotes retain narrow branch tracking. Other remotes receive the requested branch refspec without replacing existing refspecs or changing Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The changed reuse paths preserve user-managed remote configuration while adding branch tracking. No issue identified here needs resolution before merge. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change protects user-managed remotes from destructive configuration updates. One legacy compatibility risk remains: older application-created remotes can retain fork-wide tracking, allowing later fetches to import more branches than intended into the shared repository. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation [
🧰 Additional context used📚 Code guidelines (1)Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the complete diff at 8d9d25e (7 files, single commit). The reuse paths that previously narrowed the fetch refspec of any URL-matching remote now gate that rewrite on Orca provenance.
ensureRemoteAlsoTracksBranch— new add-only twin infork-remote-refspec.ts; appends the branch's narrow refspec only when absent, leaving the user's wide default, other branches' entries, andtagOptintact.prepareWorktreePushTargetWithExecreuse path — readsremote.<name>.orca-createdand dispatches to the narrow rewrite for Orca-minted remotes, add-only for user-created ones.adoptExistingForkRemoteForBranch— the same provenance gate on the deferred materialize path.remoteHasOrcaProvenance— exported from the cleanup module and reused rather than reimplemented.- Tests — unit cases for the add-only helper, red-before reuse cases (wide default preserved, the issue's workaround survives a second branch, a minted remote still narrows), and an adoption-path case asserting no
--unset-all/tagOptagainst a user remote.
I traced every caller of ensureRemoteTracksBranchNarrowly; the only remaining non-marker-gated rewrite of a reused remote is the refspec migration sweep, which the PR deliberately leaves untouched and documents. The added logic is correct and the behavior matches the issue's stated expectation (only add its per-branch line without removing the user's existing refspecs). Verified locally: 61/61 across the three touched suites, oxlint clean on all seven files.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

ELI5
When a worktree's PR lives on a fork, Orca borrows whatever existing remote points at that fork — including one you added by hand — and rewrites its fetch configuration down to just the PR's branch. Every other branch you push to that fork then loses its upstream:
@{u}fails, ahead/behind counts vanish, plaingit fetchstops updating them, and Orca can no longer find those branches' PRs. Now Orca only rewrites remotes it created itself; for yours, it quietly adds the one line it needs and leaves everything else exactly as you configured it.What Changed
prepareWorktreePushTargetWithExec(reuse path) andadoptExistingForkRemoteForBranch(deferred materialization path) now check the existingremote.<name>.orca-createdmarker before touching a remote's refspec:ensureRemoteTracksBranchNarrowly, unchanged behavior;ensureRemoteAlsoTracksBranch, which appends this branch's narrow refspec only if absent — nothing dropped, nothing rewritten,tagOptuntouched.remoteHasOrcaProvenanceis exported from the cleanup module and reused rather than reimplemented.pr-*remotes is intentionally untouched (those predate the marker and rely on the sweep to get narrowed).--unset-allever runs against a user remote.Why
The narrowing exists to keep Orca-minted
pr-*remotes single-branch (#17887 already stamps an ownership marker for exactly this distinction) — the reuse path just never consulted it. Deleting user refspecs was never necessary for Orca's own goal: the per-branch line only needs to exist, and--addachieves that without destroying anything. That also fixes the issue's workaround trap, where re-adding the wide refspec only lasted until the next fork-PR worktree on another branch stripped it again. Provenance-gating stays at the call sites so the refspec module remains plumbing with no knowledge of who created what.Linked Issue
Fixes #25703
Visual Proof
N/A — no UI change; the before/after is in
git config --get-all remote.<name>.fetchoutput, pinned by the tests described above.Testing
Commands actually run locally (macOS): the three new red-before cases failed for the bug itself (user remote's wide refspec and other branch lines deleted;
--unset-allcalled against a user remote); after the fix 61/61 across the three touched suites and 248/248 across the 24-file push-target/refspec/materialization/migration/cleanup/relay matrix;pnpm tcreports only the pre-existingstructured-agent-session-stop-note-opened-turn.test.tsTS2353 failure that also reproduces on cleanupstream/main(see the notes on #24689/#25245);oxlint/oxfmt --checkclean on all seven touched files. The exact Google Drive / two-machine scenario from the report was not reproduced locally; the git-level behavior is pinned at the config-mutation boundary.AI Disclosure
Investigation scoping and coding by GLM-5.3-Flash (ZCode agent); orchestrated, reviewed and committed by a main agent with the same model, human overseeing.
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Git commands used are baseline-safe (
config --get/--add). Provider-neutral: the marker check gates on Orca provenance, not on GitHub-specific state. Known scope edges, stated honestly: a pre-marker Orcapr-*remote reused on the adoption path now gets add-only treatment (its wide refspec cleanup waits for the migration sweep), and a user remote manually namedpr-*would still be narrowed by the sweep's prefix heuristic — both pre-existing behaviors this PR deliberately does not change.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)