Repository navigation
refactor(runtime): route adapter, split fences, ownership table, combined ratchet - #27218
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to 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 |
|
…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.
ce08af4 to
bb53def
Compare
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.
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 anunverifiableverdict. It is never retried automatically, because the first attempt may already have run.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.shared/host-operation-ownership.ts): it labels every runtime RPC namespace ashost,credential(forge APIs),scope-picked(Jira, Linear, settings: the host comes from an explicit picker),stream(subscriptions) orclient(OS opens). A test fails if a new RPC namespace is added without a label. The adapter refusesclientoperations and unlabeled ones. Later slices fill in per-method forge rows.config/scripts/check-owner-routing-ratchet.mjs, run inpnpm lintand PR CI): it counts renderer calls togetActiveRuntimeTarget(,legacyRouteFromSettings(andsettingsForRuntimeOwner(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;--prunelowers the baseline after a removal.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
callRuntimeRpcand 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.tskeeps 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 asunverifiablewith 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
Notes
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)