Skip to content

fix: route hook files through their stored repository owner - #23184

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-09-25-hook-execution-owner
Sep 26, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-09-25-hook-execution-owner

Conversation

@nwparker

@nwparker nwparker commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​251
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​148 $\color{#cf222e}{\Huge{\mathbf{−}}}$​46 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​102

ELI5

Reading or saving repository hooks now uses the computer that owns that repository, even when an older connection field is missing or stale.

What Changed

Hook adapters previously selected local versus SSH files from legacy connectionId. A repository whose stored executionHostId named its SSH owner could therefore reach a local path or a stale SSH target. Desktop and runtime hook reads, checks, script inspection and issue-command writes now reuse the existing hosted-review resolver for rows in this process's own Store. The hosted-review export remains available.

Controlled route matrix, nine operations per row Before: wrong local/stale-target routes After
Canonical SSH owner only 9 0
Canonical SSH owner plus stale legacy target 9 0
Explicit local owner plus stale legacy target 9 0
Own-store runtime stamp plus nested connection 9 0

This is a correctness fix, not a measured performance improvement. Missing SSH providers never gain a local fallback.

Why

The stored repository's authoritative host already determines hosted-review execution. Generalizing that resolver avoids a second routing policy and supports legacy rows. It is deliberately limited to rows registered in this process; generic routing still rejects runtime hosts this process does not execute.

Linked Issue

Fixes #23181

Visual Proof

N/A — internal filesystem dispatch changes; no rendered layout or control changed. Deterministic tests observe actual hydrated ownership and exact mocked target/path/content. No live SSH or rendered-flow claim.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated

ORCA_BACKGROUND_LAUNCH=1 pnpm exec vitest run --config config/vitest.config.ts src/main/ipc/hooks/worktree-hook-execution-host.test.ts: 68 pass, versus original 37 failures / 31 controls. Independently replayed; eleven extra mismatch/ambiguity, missing-provider, encoded-target deletion and folder-skip controls also pass. Author related coverage totals 102 distinct tests across four suites. Node typecheck, scoped lint/format, changed-code quality across 185 files and reliability-manifest validation pass.

Actual hydration and desktop owner resolution run with mocked filesystem, Git, provider and inspection boundaries. Tests ran on macOS; no real file write, SSH/WSL provider, native application or mixed-version/mobile deployment ran. Full lint/build and broader platform checks remain to CI.

AI Disclosure

Review

Independent review approved all eight frozen source/test files with no finding. Merge risk: low to moderate — host routing affects writes, so the tests assert exact ownership and no local fallback; payloads and existing errors remain unchanged.

Experimental gate workspace-hooks.execution-host-ownership records the invariant that hook operations use the authoritative stored repository host. Its oracle covers canonical/legacy identities, unavailable providers and folder skips. CI soak, native Linux/Windows and physical SSH/WSL/runtime evidence remain gaps. Routing assertions identify the wrong provider, path or local boundary on failure.

Agent skill upstream boundary

  • Not applicable; no upstream skill content copied.

Notes

Negative user-facing trade-offs: none identified. A disconnected canonical SSH write is refused on desktop instead of touching the same path locally. The existing runtime issue-command convention still returns {ok:true} when its provider is absent without writing; this PR does not claim to fix that preexisting response limitation.

Folder skips and legacy connection-only rows are retained. Own-store runtime stamps address files registered here; they do not authorize arbitrary remote rows to run locally. No RPC field, result shape, stream opcode, Git command, path joiner or provider API changed. Local/daemon PTY identity, data and liveness are unaffected. No new cache, poll, broad scan or subprocess fanout.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, before/after, mechanism and alternatives)
  • Visual proof is N/A with reason
  • Self-reviewed and independently reviewed for correctness, security and performance
  • Cross-platform, SSH/remote and path/shortcut impact considered
  • Full lint, typecheck, test and build pass — scoped local checks above; CI covers broader checks

@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 5 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4b7b0cce-3c8a-4660-a786-4b7106a72b95

📥 Commits

Reviewing files that changed from the base of the PR and between 8b7a2a5 and 0e174de.

📒 Files selected for processing (9)
  • config/reliability-gates.jsonc
  • src/main/ipc/hooks/register-worktree-hook-check-handler.ts
  • src/main/ipc/hooks/register-worktree-hook-file-handlers.ts
  • src/main/ipc/hooks/register-worktree-hook-inspection-handler.ts
  • src/main/ipc/hooks/worktree-hook-execution-host.test.ts
  • src/main/repo-execution-host.ts
  • src/main/runtime/runtime-repository-hooks-commands.ts
  • src/main/runtime/runtime-repository-issue-command.ts
  • src/main/source-control/hosted-review-execution-host.ts

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 — hook filesystem dispatch now resolves the repository's authoritative execution owner instead of branching on legacy connectionId, fixing #23181.

  • Shared stored-owner resolver — src/main/repo-execution-host.ts adds getStoredRepoExecutionHostId / getStoredRepoSshConnectionId. The former is the hosted-review helper moved verbatim out of hosted-review-execution-host.ts, which now re-exports it under the old getRepoHostedReviewExecutionHostId name, so its existing callers keep identical behavior.
  • Desktop hook adapters rerouted — register-worktree-hook-{check,file,inspection}-handler.ts use getStoredRepoSshConnectionId(repo) in place of repo.connectionId, so an ssh:-only row no longer reads/writes the remote path locally and a stale legacy target no longer wins.
  • Runtime commands rerouted — runtime-repository-hooks-commands.ts and runtime-repository-issue-command.ts adopt the same resolver for runtime:/local own-store rows.
  • New reliability gate — workspace-hooks.execution-host-ownership (experimental) records the invariant, its oracle, and known gaps.
  • Test coverage — new worktree-hook-execution-host.test.ts drives real handler registration through resolveRepoForExecutionHost across nine operations × seven owner shapes, plus no-local-fallback and folder-skip controls.

I confirmed the test can actually fail: reverting register-worktree-hook-check-handler.ts to repo.connectionId produces the four expected failures (canonical SSH, canonical-over-stale, explicit-local-over-stale, runtime-stamp-with-nested). The related suites (worktree-hook-execution-host, runtime-repository-issue-command, hosted-review-execution-host-routing) pass, and pnpm run check:code-quality:changed is clean.

The runtime:/local → local-I/O collapse is the same contract the hosted-review resolver already carries, and it is grounded in runtime-repository-registration-controller.ts:64: an own-store runtime row is validated and read in-process, and the controller refuses to adopt a runtime: stamp onto a row that already has a connectionId. Missing SSH providers still never gain a local fallback.

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

@nwparker
nwparker merged commit 96c6889 into main Sep 26, 2026
41 checks passed
nwparker added a commit that referenced this pull request Sep 27, 2026
…rows (#23300)

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.
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.

Hook file operations can use the wrong stored repository host

1 participant