Repository navigation
fix(projects): refuse to file a folder under a project its own GitHub remote contradicts - #30717
Conversation
…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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to
|
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'supstreamfield whenever the folder didn't already resolve to that project. A folder cloned fromacme/repo-band set up underacme/repo-awas filed under repo-a, with a made-upupstream: 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 servecontroller) compare it with the GitHub repository the folder's own primary remote names. That remote is theupstreamremote if there is one, otherwiseorigin. 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 anupstreamremote 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.readCurrentGitRemoteIdentityre-runsgit remote -vfirst, keeping the stored answer only when Git can't be reached.github-workor a GHES HTTPS port can name the same server.Still allowed, unchanged:
upstreamremote or GitHub parent names the projectWhy
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:
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:
originremote, on a machine whereghcan't report its parentRemaining 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 servepath, realgit init+ remotes):upstreamremotesrc/main/ipc/repos-local-add-and-project-setup.test.ts(desktop path):Ran
pnpm testonsrc/main/runtime/orca-runtime.test.ts,src/main/ipc/repos*, the project-host-setup tests and the repo-git-remote tests single-worker. Tworepository-project-operationstests fail on macOS only because of/varvs/private/vartemp paths; that predates this change and passes on Linux CI.pnpm tc,pnpm run check:code-quality:changed, and the static-analysis job steps frompr.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
setupProjectExistingFolderagainst 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
origin-only forks withoutgh: accepted tradeoff, actionable messageupstreamhidingorigin: dismissed as narrow; refusing on an unreachable Git would block setups whenever Git is slowAgent skill upstream boundary
Notes
orca serve).kind: folderis never probed or refused.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)