Skip to content

fix(projects): enrich git remote identity for runtime-addressed repo rows - #23300

Merged
nwparker merged 1 commit into
mainfrom
nwparker/fix-runtime-identity-enrich
Sep 27, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/fix-runtime-identity-enrich

Conversation

@nwparker

@nwparker nwparker commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​94 $\color{#cf222e}{\Huge{\mathbf{−}}}$​31 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​63
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​4

ELI5

Orca figures out which GitHub/GitLab project a folder belongs to by quietly running git remote -v in the background, then uses that answer to group the same project across your different machines and to fetch its avatar.

For projects you added through a remote Orca machine or the web/mobile client, Orca stopped asking that question entirely. It had mistakenly decided those folders lived on somebody else's computer, when in fact they were sitting right there on the machine doing the asking. So those projects sat forever in a "still figuring it out" state: they never grouped together with the same project on your other machines, and a wrong project picture never fixed itself.

This teaches it that those folders are local, so the question gets asked again.

What Changed

Before: add a project through a remote runtime host or a paired web/mobile client. The project's remote identity never resolves. It stays pending indefinitely, gets a machine-local fallback key so it never groups with the same project on another host, and an automatic project avatar that has gone stale never repairs.

After: the same project resolves its identity on the next background sweep, groups across hosts, and repairs its avatar.

Two mechanisms were wrong, and both had to change for the row to enrich:

  1. Which machine gets asked. Rows carry a stamp saying which host they belong to. A runtime:<name> stamp is how a paired client addresses a project that is registered in the very process reading it — the files are local. The sweep was instead treating that stamp as proof the files were on another machine and skipping the row. It now reuses the existing helper that already encodes the correct reading, so there is one answer to "which host holds this row's files" rather than two that disagree.

  2. Which row gets written. The sweep passed the host it probed (local) as the identifier for the row it wanted to update. The store matches that argument against the row's own stamp, so for one of these rows it matched nothing and the result was silently discarded. It now addresses the row by its stamp.

Rows that name a nested SSH target on top of a runtime: stamp are still skipped: that target belongs to the remote machine's own connection list, not this one's, and the same path here would be an unrelated checkout. There is no host this process can honestly ask.

Why

This is a regression, not a long-standing gap. #22421 added a genuinely useful avatar repair, and while tightening it to avoid writing another machine's metadata it reclassified these rows as belonging to another machine. One day later #23184 wrote down the opposite (and correct) reading of the same stamp in src/main/repo-execution-host.ts, so the two shipped in the same release contradicting each other.

The alternative was a second host classifier local to the sweep. Rejected: a duplicate classifier is how the two readings diverged in the first place. Reusing #23184's helper means there is now a single place that decides this, so the next change to the rule cannot desynchronise them again.

The narrower alternative — treating every runtime: row as unreachable and instead fixing the symptom downstream in the consumers that read a pending identity — was rejected because the identity genuinely is knowable here, and leaving it unknown keeps every downstream gate permissive.

Worth a maintainer's confirmation: #22421's intent was that a runtime: row is peer-owned. I could not find any code path that puts another machine's repo row into the store this sweep reads, and a runtime host has no notion of its own environment id to compare against, so every runtime: stamp that reaches this store arrived from a client addressing this host. If that assumption is ever meant to change, this is the decision to revisit.

Linked Issue

Fixes #

Visual Proof

N/A — no UI was changed. The user-visible effect is a background field settling, which surfaces indirectly as cross-host project grouping and avatar repair; there is no new or altered pixel to capture.

Testing

Automated, in the two test files #22421 created, both of which fail before this change and pass after:

  • src/main/repo-git-remote-identity-enrichment.test.ts — "probes a self-addressed runtime row here and writes it back under its own stamp". Before: probeGitRemoteIdentity is never called (0 calls). After: called with local, and the write is addressed runtime:env-a.
  • src/main/repo-git-remote-avatar-refresh.test.ts — "repairs a same-id runtime-addressed row under its own stamp", covering the avatar repair and per-row write addressing when a runtime row and a local row collide on id and path.

Each half of the fix was confirmed necessary on its own: with only the host-classification change applied, the probe runs but the write is still addressed local and the second assertion fails.

The store behaviour that makes the second half necessary was verified against the real Store, not the test fake: updateRepo(id, updates, 'local') on a row stamped runtime:env-1 returns null (the write is dropped), while the same call under runtime:env-1 succeeds.

Still-skip coverage is unchanged and still green — the pre-existing runtime:peer + connectionId: nested cases in both files pass untouched, across missing, matching, and differing stored identities.

One pre-existing test was corrected rather than added to: repo-git-remote-avatar-refresh.test.ts parameterised "a foreign row must not be repaired locally" over ssh:build and runtime:peer. The ssh:build case is right and is kept verbatim; the bare runtime:peer case asserted the behaviour this PR fixes, so it is replaced by the corrected expectation with a comment explaining why the two hosts differ.

  • pnpm test on all five affected suites: 173 passed
  • pnpm tc:node: clean
  • pnpm run check:code-quality:changed: 0 new findings

Platforms: this is host-classification logic with no platform branches and no new process spawning, so there is nothing platform-specific to exercise; verified on macOS.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

Notes

  • Performance / git scan safety: no new scan shape. The probe is still a single bounded git remote -v per repo row (5s local, 20s over SSH), and runtime rows join the existing candidate set under the same retry TTLs, the 6h resolved-refresh window, the 5m startup delay, and the MAX_IDENTITY_REFRESHES_PER_SWEEP = 4 cap. No ref enumeration, no --all walk, no per-ref ls-tree.
  • Remote SSH: SSH rows are unaffected — every SSH shape resolves to exactly the host it did before, including a row carrying only executionHostId: ssh:<target>. The one skip that remains is specifically to avoid dialling a peer's nested target from this client.
  • Provider neutrality: nothing GitHub-specific is added. The identity probe and getProjectProviderIdentity are provider-agnostic; the avatar branch this row now reaches was already scoped to icons that are source: 'github', and that scope is untouched, so GitLab and other providers gain the identity fix without inheriting a GitHub-only assumption.
  • Backwards compatibility: no wire, RPC, or persisted-shape change. A row whose identity is already resolved keeps it; the write guard still refuses to let a failure or a no-remote answer clear a resolved identity.
  • Security: narrows nothing and widens no trust boundary — a runtime: row that names a nested SSH target is still never dialled from this client.
  • Mobile: the mobile sidebar reads through the same runtime repo.list sweep, so it picks the fix up with no mobile-side change.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

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)

…rows

A repo row stamped `executionHostId: runtime:<env>` is how a paired client
addresses a project registered in *this* process, so its files are local
(`runtime-repository-registration-controller.ts`, and the helper #23184 added in
`repo-execution-host.ts`). #22421 reclassified those rows as peer-owned and
dropped them from the identity sweep, so `gitRemoteIdentity` never settled on
remote-runtime and paired-web setups: the project stayed pending, fell back to a
host-local `repo:<id>` that never grouped across hosts, and a stale automatic
avatar never repaired.

Reuse `getStoredRepoExecutionHostId` instead of a second host classifier, and
keep skipping only a `runtime:` row that also names a nested SSH target — that
target lives in the peer's dispatch table and the same path here is a different
checkout. The store matches a write against the row's own stamp, so address
`updateRepo` by that stamp rather than the probe host, which is `local` for these
rows and would match no row at all.
@coderabbitai

coderabbitai Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 4d34a9bf-d678-4066-8b61-9a29d099877b

📥 Commits

Reviewing files that changed from the base of the PR and between 3eb1ade and 445aabc.

📒 Files selected for processing (3)
  • src/main/repo-git-remote-avatar-refresh.test.ts
  • src/main/repo-git-remote-identity-enrichment.test.ts
  • src/main/repo-git-remote-identity-enrichment.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

Walkthrough

Repo identity enrichment now selects probe hosts from stored execution-host stamps and scopes identity writes to the repo row’s stamp. Tests cover nested SSH-target and self-addressed runtime rows. Avatar-refresh tests cover collisions between local rows and SSH- or runtime-stamped rows.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 445aa

The change appears ready to merge after normal checks. No outstanding issue is established for probing runtime-stamped repositories or updating the correct repository row.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 445aa

The change narrows probing of nested remote targets and directs updates to the intended project record. No new exploitable security issue was established, though changes to a project’s host configuration during a probe remain worth guarding against.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — Probe output can affect a tracked row’s repository identity and automatic avatar; host-stamped persistence limits an update from selecting a same-ID row stamped for another host.

Trust Boundaries and Controls

  • observed — The host-selection guard rejects nested SSH connections on locally held runtime rows, while the write path separately validates row identity and supplies its stamp to persistence. The changed test-file ranges do not expose a new caller across that boundary.

Resilience and Maintainability Implications

  • observed — A connectionId-only change while a runtime-row probe is in flight leaves its location key and stale-row comparison unchanged, permitting the old local result to be written. The base version had the same comparison and locally probed bare runtime rows, so an introduced security impact is not established.

Hardening Proposals

  • proposed — Revalidate the live row’s nested connection before accepting a probe result, or retire an in-flight probe when that connection changes, to prevent stale identity or avatar repair after ownership changes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: fixing Git remote identity enrichment for runtime-addressed repository rows.
Description check ✅ Passed The description is detailed and aligned with the template. It explains the user impact, mechanism, rationale, testing, compatibility, security, and checklist status. The Linked Issue section remains a…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Runtime-addressed rows probe locally again. getRepoProbeHostId now derives the probe host from getStoredRepoExecutionHostId instead of getRepoExecutionHostId + getSshTargetIdForExecutionHost, so a bare runtime: row (a paired client addressing this process) is probed on local, while a runtime: row naming a nested SSH target is still skipped via getRepoSshConnectionId.
  • Writes are addressed to the row's own stamp. writeIdentity passes getRepoExecutionHostId(snapshot) to store.updateRepo rather than the probe host, which is what the store matches a write against (repo-update-operations.ts:80-83).
  • Tests mirror the real store and split the two host cases. The enrichment fake store now matches updateRepo's hostId against the row's stamp; the avatar suite separates the ssh:build and bare-runtime: cases and adds a runtime/local collision at the same id and path.

I checked every case of getRepoProbeHostId — local, local + connectionId, ssh:, bare runtime:, runtime: + nested target, a legacy connectionId-only row, and a malformed executionHostId — and only the bare-runtime: case changes behavior, as intended. The write host differs from the probe host only for runtime rows (which previously never wrote), so local and SSH rows are unaffected. Both added tests fail without their respective half of the fix, and pnpm test on the two suites passes locally (56 passed).

The assumption the author flags for confirmation is corroborated elsewhere in the tree: RequestedHostId treats a caller's runtime: id as naming this machine and normalizes new rows to local (with a comment that legacy rows keep their client-minted stamp), and host-repo-catalog-snapshot.ts:58 refuses to serve a remote host catalog for a runtime: request. The one route that copies an arbitrary executionHostId across (profile transfer, createTargetRepo) is same-machine only.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 268f0e9 into main Sep 27, 2026
41 checks passed
@nwparker
nwparker deleted the nwparker/fix-runtime-identity-enrich branch September 27, 2026 07:31
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.

1 participant