Skip to content

refactor(runtime): route adapter, split fences, ownership table, combined ratchet - #27218

Merged
OrcaWin merged 3 commits into
mainfrom
OrcaWin/d4-d4-f3
Oct 10, 2026
Merged

OrcaWin merged 3 commits into
mainfrom
OrcaWin/d4-d4-f3

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​324 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​324
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​520 $\color{#cf222e}{\Huge{\mathbf{−}}}$​29 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​491

ELI5

When Orca talks to another machine on your behalf, it should send the request to the machine that owns the thing you are working on, and it should notice if that machine changed in the middle of the request. This PR adds the shared building blocks for that, plus a counter that stops new code from going back to "send it wherever the focused server is".

What Changed

Users see no change except in one rare case (below). This is groundwork that later PRs build on.

  • Route adapter (runtime/host-route-call.ts): callHostRoute(route, method, params) calls a method on the host a route names (the route says which Orca endpoint to reach and where on it the work runs). It records who it is talking to before the call (pairing, runtime connection, and the route's own SSH target) and checks again when the reply arrives. If that changed, the reply is not applied and the call fails with an unverifiable verdict. It is never retried automatically, because the first attempt may already have run.
  • Split fences (store/host-catalog-fencing.ts): a new identity fence (who answered) is used for writes. The existing catalog fence is now that identity fence plus the data generations (catalog fetch generation, SSH-state generation), and it still guards snapshot reads. So a write is no longer marked uncertain just because the server refreshed its project list, or another SSH target on that server reconnected. A re-pair that is proven to be the same machine keeps the identity.
  • Ownership table (shared/host-operation-ownership.ts): it labels every runtime RPC namespace as host, credential (forge APIs), scope-picked (Jira, Linear, settings: the host comes from an explicit picker), stream (subscriptions) or client (OS opens). A test fails if a new RPC namespace is added without a label. The adapter refuses client operations and unlabeled ones. Later slices fill in per-method forge rows.
  • Combined ratchet (config/scripts/check-owner-routing-ratchet.mjs, run in pnpm lint and PR CI): it counts renderer calls to getActiveRuntimeTarget(, legacyRouteFromSettings( and settingsForRuntimeOwner( together, per file, so renaming one into another does not lower the count. The count today is 228. Calls with a space before the parenthesis and uses of the helper as a value are counted too, and importing or re-exporting a helper under another name fails the check, because the alias would hide its calls from the count. Counts may only go down; --prune lowers the baseline after a removal.
  • One exemplar: saving review notes on a folder workspace owned by a paired server now goes through callHostRoute. It reaches the same server as before. The write is checked only against that server's own identity, because the folder's record lives on the server even when the folder names an SSH target, so an SSH target reconnecting does not affect it. Behavior change: if that server's runtime is replaced while the save is in flight, the note is rolled back and an error is logged, instead of being shown as saved when nobody knows whether it landed. That is the same handling a timed-out save already gets today.

Why

The design asks for one adapter that later slices move their own call sites onto directly, so no call site is migrated twice. This PR therefore moves only one exemplar. The fences are split because a single fence that includes catalog generations makes a write mark its own successful reply as uncertain: the write's own change event triggers a catalog refetch, which bumps the generation. Counting the three focus-routing helpers together closes the loophole of renaming a call to lower the count. The adapter wraps the existing callRuntimeRpc and the existing generation counters, so it adds no new transport and no wire change.

Not done here (deliberately): no IPC twin is removed, and worktree-operation-generation.ts keeps its own snapshot. Its later slice can adopt the identity fence.

Linked Issue

None. This is groundwork in the owner-routing stack (D4-F3), and it closes no issue on its own.

Visual Proof

N/A. There is no UI change. The only behavior change is the rollback described above, which happens only when a server is replaced mid-save.

Testing

  • I manually tested these changes locally

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

  • host-catalog-fencing.test.ts: the identity fence holds through catalog and SSH-state churn that the data fence rejects. It moves on a reconnect, on a re-pair to a different machine and on removal, but holds across a re-pair proven to be the same machine. It tracks only the nested SSH target the route names, and a directly dialed SSH target by its local generation.

  • host-route-call.test.ts: it passes the captured pairing revision, reports a reply from a replaced runtime as unverifiable with no retry, and refuses client and unlabeled methods.

  • host-operation-ownership.test.ts: every method in the generated RPC catalog has a label.

  • folder-workspace-diff-comments.test.ts: covers the new rollback, and the existing local/runtime routing tests pass unchanged.

  • check-owner-routing-ratchet.test.mjs, plus the 30 existing catalog-fence test files.

  • pnpm tc, oxlint, check:code-quality:changed.

Review

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: nested (server → SSH target) and directly dialed SSH routes are each fenced on their own target's connection generation.
  • Mixed versions: no RPC or IPC change.
  • Folder workspaces: the exemplar is the folder-workspace path.
  • Platforms: no platform-specific code.

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)

@coderabbitai

coderabbitai Bot commented Oct 10, 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: 15d72c3a-bf72-4fe8-9c70-ee77e47af715

📥 Commits

Reviewing files that changed from the base of the PR and between ce08af4730c43f3fdb975fac7eaf18519e5d088a and bb53def.


📒 Files selected for processing (1)
  • config/scripts/pr-preflight-gates.test.mjs

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



📝 Walkthrough

Walkthrough

The changes add runtime RPC ownership classification and host identity checks for routed calls. Folder-workspace diff-comment updates use the fenced route when a runtime environment ID is available. A new checker tracks selected renderer focus-routing uses against a per-file baseline. Lint and static-analysis preflight run the checker.


Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to bb53d

The host-routed note save rejects replies made stale by a host change, and a later catalog refresh can recover a note the server may already have saved. No actionable regression was established, so no merge-blocking risk remains.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 11 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 identifies the main changes: the runtime route adapter, split fences, ownership table, and combined ratchet. It is concise and relevant to the changeset.
Description check Passed The description is detailed and covers the required ELI5, changes, rationale, testing, visual proof, notes, and checklist sections. The linked issue is listed as unavailable, and the full lint, typech…
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


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

m4air added 3 commits October 10, 2026 03:31
…ined ratchet

Adds callHostRoute, which calls a host-owned method on the host a HostRoute
names and reports a reply whose host identity moved mid-call as unverifiable
instead of applying it. Host fences are split: an identity fence (pairing,
runtime connection generation, the route's own SSH target) for mutations, and
the catalog data fence built on top of it for snapshot reads, so unrelated
catalog or SSH-state churn no longer moves a mutation's fence.

HOST_OPERATION_OWNERSHIP classifies every runtime RPC namespace. A new
ratchet counts getActiveRuntimeTarget( + legacyRouteFromSettings( +
settingsForRuntimeOwner( together per renderer file (227). One exemplar, the
folder workspace review-note write, moves onto the adapter.
…ed ratchet helpers

The folder catalog row lives on the paired server, so its write is fenced on
that server's identity, not on the SSH target the folder names. The ratchet
now counts spaced calls and value uses, and refuses an aliased import or
re-export that would hide calls from the count.
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