Skip to content

fix(projects): refuse to file a folder under a project its own GitHub remote contradicts - #30717

Merged
nwparker merged 4 commits into
mainfrom
nwparker/fix-30663-import-identity
Oct 19, 2026
Merged

nwparker merged 4 commits into
mainfrom
nwparker/fix-30663-import-identity

Conversation

@nwparker

@nwparker nwparker commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​248 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​248
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​72

ELI5

When you told Orca "this folder belongs to project A", Orca believed you, even when the folder's own Git remote plainly said it was repository B. It then rewrote the folder's record to claim it came from A. Now Orca checks the folder's remote first. If the remote names a different GitHub repository, Orca refuses and explains how to fix it.

What Changed

Before: setting up an existing folder under a project (the "set project location" flow, orca project setup-existing-folder, or the same call on a paired Orca server) wrote the project's GitHub owner and repo into the folder's upstream field whenever the folder didn't already resolve to that project. A folder cloned from acme/repo-b and set up under acme/repo-a was filed under repo-a, with a made-up upstream: acme/repo-a. Its workspaces then showed nested under the wrong project in the sidebar. The only way to undo it was editing the profile database by hand (#30663).

After: before writing that upstream, both setup paths (the desktop handler and the runtime/orca serve controller) compare it with the GitHub repository the folder's own primary remote names. That remote is the upstream remote if there is one, otherwise origin. If the owner/repo differ, the setup fails with: its Git remote "origin" points at acme/repo-b, not acme/repo-a, plus how to fix it: pick the right project, add an upstream remote for a fork, or update the URL after a rename. A folder this setup just created is rolled back, as on other refusals.

Mechanism:

  • assertImportedFolderRemoteMatchesProject (new, src/shared/imported-folder-project-identity.ts) is called right before the stamp in both places.
  • For a folder Orca already tracked, the stored remote can be stale or not probed yet. So readCurrentGitRemoteIdentity re-runs git remote -v first, keeping the stored answer only when Git can't be reached.
  • The comparison checks owner and repo only, ignoring case. Hosts are left out, because an SSH alias such as github-work or a GHES HTTPS port can name the same server.

Still allowed, unchanged:

  • folders with no remote
  • folders whose remote is not on GitHub (GitLab, internal mirrors)
  • forks whose upstream remote or GitHub parent names the project

Why

The stamp exists so a folder whose remote can't place it (no remote, a non-GitHub remote) can join a project. It was never meant to overrule a remote that names another GitHub repository. I considered three alternatives:

  • Deriving the project from the remote and ignoring the caller's choice. This would silently put the folder somewhere the user didn't ask for.
  • Stripping the stamp only when the remote disagrees. Same problem.
  • Adding a confirm/force field. This is a wire change that older paired servers wouldn't understand.

A clear refusal at the single place the stamp is written fixes both callers and needs no wire change.

Known tradeoff: two cases that used to link silently are now refused with an actionable message:

  • a clone of a renamed GitHub repo that still uses the old URL
  • a fork that has only an origin remote, on a machine where gh can't report its parent

Remaining limits, accepted: the check is skipped when Git can't be read at all (it keeps the existing best-effort behaviour of the remote probe), and it only looks at the primary remote.

Linked Issue

Fixes #30663

Visual Proof

N/A: there is no new UI. The existing setup flows show the new error text when a setup is refused.

Testing

  • src/main/runtime/orca-runtime-tests/project-setup-folder-remote-identity.spec.ts (runtime / orca serve path, real git init + remotes):

    • refuses repo-b under repo-a (fails on main)
    • links a fork via its upstream remote
    • links a GitLab-remote folder
    • links an SSH-alias remote
    • judges an already-registered folder by its current remotes, not a stale stored one (fails without the re-probe)
  • src/main/ipc/repos-local-add-and-project-setup.test.ts (desktop path):

    • refuses a new folder whose remote conflicts (fails on main)
    • refuses an already-registered folder whose stored remote was still pending (fails without the re-probe)
  • Ran pnpm test on src/main/runtime/orca-runtime.test.ts, src/main/ipc/repos*, the project-host-setup tests and the repo-git-remote tests single-worker. Two repository-project-operations tests fail on macOS only because of /var vs /private/var temp paths; that predates this change and passes on Linux CI.

  • pnpm tc, pnpm run check:code-quality:changed, and the static-analysis job steps from pr.yml (lint, anti-slop, code-quality plugins, type-aware, ratchets, generated catalogs, typecheck:ci) all pass locally.

  • Verified live vs only in tests: verified only in tests. The runtime test drives the real setupProjectExistingFolder against real Git repositories on disk. No real paired server was used.

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

  • Codex (gpt-6.1-sol, high) round 1:
    • SSH alias hosts were treated as a mismatch: fixed, owner/repo only.
    • Stale stored identity on already-registered folders: fixed, re-probe.
    • Rounds 2 and 3: clean.
  • Opus review round 1:
    • pending/stale identity: fixed
    • GHES port mismatch: fixed
    • renamed repos and origin-only forks without gh: accepted tradeoff, actionable message
    • fork test did not reach the check: covered by the new already-registered test
  • Opus review round 2:
    • IPC re-probe untested: fixed
    • skipped when Git is unreachable, and a non-GitHub upstream hiding origin: dismissed as narrow; refusing on an unreachable Git would block setups whenever Git is slow

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH: SSH-host setups were already refused on this path; the probe runs where the folder lives (the desktop for local folders, the server for orca serve).
  • Mixed versions: no RPC or wire change. An older server keeps its old behaviour; a new server refuses with an error string that older clients already display.
  • Folder workspaces: kind: folder is never probed or refused.
  • GitLab: non-GitHub remotes are never refused.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…ub remote contradicts

Setting an existing folder up for a project stamped the project's identity
as the folder's upstream even when the folder's own remote named another
GitHub repository, so the folder was silently relabelled into the wrong
project (fabricated upstream, wrong projectId on its setup and workspaces).

Fixes #30663
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f31230c7-721b-4d47-a2a8-f09bf344d6a0
📥 Commits

Reviewing files that changed from the base of the PR and between 25e53f4 and af91f87.

📒 Files selected for processing: 8
  • src/main/ipc/repos-local-add-and-project-setup.test.ts
  • src/main/ipc/repos/project-host-setup-handlers.ts
  • src/main/repo-git-remote-identity.ts
  • src/main/runtime/orca-runtime-tests/project-setup-folder-remote-identity.spec.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/runtime-project-host-setup-controller.ts
  • src/shared/imported-folder-project-identity.ts
  • src/shared/project-host-setup-projection.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

📝 Walkthrough

Runtime and IPC folder setup now validate a folder’s GitHub owner and repository against the selected project before linking. Existing repositories use their current Git remote identity; newly registered repositories use their stored identity. Project identity projection can fall back to the primary remote. Tests cover mismatched remotes, matching upstream remotes, non-GitHub remotes, and SSH aliases.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to af91f

Setup now refuses to link an imported folder to a project whose GitHub repository differs from the folder's own remote. No concrete merge-blocking risk was identified in the supplied changes.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Linked Issues check Warning Issue [#30663] requires the imported repository to use its own GitHub remote identity, independently of the calling workspace, and requires upstream to remain unset unless GitHub reports a parent. T… Change both setup paths so a GitHub remote that identifies another repository determines the imported project's identity instead of causing setup to fail. Do not write a fabricated upstream; set it only when GitHub reports a parent. Add t…
Docstring Coverage Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: refusing to assign a folder to a project when its GitHub remote contradicts the selected project.
Description check Passed The description is complete and focused. It covers the user impact, implementation, rationale, linked issue, testing, known tradeoffs, compatibility considerations, and checklist status. It also expla…
Out of Scope Changes check Passed The changed production and test files stay focused on project setup and remote identity. Re-probing registered folders, checking both desktop and runtime paths, rolling back new registrations, and tes…
Full details: Description check

Explanation

The description is complete and focused. It covers the user impact, implementation, rationale, linked issue, testing, known tradeoffs, compatibility considerations, and checklist status. It also explains why the PR refuses conflicting setups instead of deriving or overriding the project.

Full details: Out of Scope Changes check

Explanation

The changed production and test files stay focused on project setup and remote identity. Re-probing registered folders, checking both desktop and runtime paths, rolling back new registrations, and testing GitHub, non-GitHub, fork, and SSH-alias cases support the remote-identity setup behavior. No unrelated change is demonstrated.

Full details: Linked Issues check

Explanation

Issue [#30663] requires the imported repository to use its own GitHub remote identity, independently of the calling workspace, and requires upstream to remain unset unless GitHub reports a parent. The reviewed code instead calls assertImportedFolderRemoteMatchesProject and rejects a folder whose origin names another repository. When the remote matches or cannot place the folder, alignRepoWithRequestedProject and linkRepo still write the selected project's identity into upstream. The added tests verify this refusal behavior, not the issue's required auto-import and upstream behavior.

Resolution

Change both setup paths so a GitHub remote that identifies another repository determines the imported project's identity instead of causing setup to fail. Do not write a fabricated upstream; set it only when GitHub reports a parent. Add tests for the direct paired-server scenario and the resulting project, setup, repository identity, and upstream state.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[Bug]: Repo auto-imported by orca terminal create --worktree path:… inherits the project identity of the calling workspace

1 participant