Repository navigation
perf(orchestration): route federated reads over shared control - #13814
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughFederated read requests now carry orchestration envelopes through RPC serialization and shared-control connections. Transport routing uses shared control for eligible non-mutation orchestration requests and preserves one-shot fallback behavior when shared control is unavailable. Federation mutations continue to use one-shot transport. Tests verify routing and metadata preservation. An opt-in benchmark compares one-shot and shared-control latency and checks shared-connection cleanup. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 91a5ec67-a996-43e5-b391-645b0d58fb64
📒 Files selected for processing (9)
src/main/ipc/runtime-environment-federated-read-routing.test.tssrc/main/ipc/runtime-environment-federated-read-transport.bench.test.tssrc/main/ipc/runtime-environment-request-connections.tssrc/main/ipc/runtime-environment-transport-routing.tssrc/shared/remote-runtime-client.tssrc/shared/remote-runtime-memory-limits.tssrc/shared/remote-runtime-shared-control-connection.test.tssrc/shared/remote-runtime-shared-control-connection.tssrc/shared/remote-runtime-shared-control-requests.ts
| const shared = new RemoteRuntimeSharedControlConnection(pairing, { | ||
| environmentId: environment.id | ||
| }) | ||
| const sharedControl = await measureRequests(() => | ||
| shared.request('orchestration.federationPull', params, 15_000, { | ||
| orchestrationContractVersion: 1 | ||
| }) | ||
| ) | ||
| const diagnostics = shared.getDiagnostics() | ||
| shared.close() | ||
|
|
||
| expect(diagnostics).toMatchObject({ state: 'ready', pendingRequestCount: 0 }) | ||
| process.stdout.write(`${JSON.stringify({ oneShot, sharedControl }, null, 2)}\n`) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Close the shared connection in a finally block.
If measureRequests() rejects or an assertion fails, Line 56 does not run. The retained WebSocket can remain open and prevent the benchmark process from exiting.
Proposed fix
const shared = new RemoteRuntimeSharedControlConnection(pairing, {
environmentId: environment.id
})
- const sharedControl = await measureRequests(() =>
- shared.request('orchestration.federationPull', params, 15_000, {
- orchestrationContractVersion: 1
- })
- )
- const diagnostics = shared.getDiagnostics()
- shared.close()
-
- expect(diagnostics).toMatchObject({ state: 'ready', pendingRequestCount: 0 })
- process.stdout.write(`${JSON.stringify({ oneShot, sharedControl }, null, 2)}\n`)
+ try {
+ const sharedControl = await measureRequests(() =>
+ shared.request('orchestration.federationPull', params, 15_000, {
+ orchestrationContractVersion: 1
+ })
+ )
+ const diagnostics = shared.getDiagnostics()
+
+ expect(diagnostics).toMatchObject({ state: 'ready', pendingRequestCount: 0 })
+ process.stdout.write(`${JSON.stringify({ oneShot, sharedControl }, null, 2)}\n`)
+ } finally {
+ shared.close()
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const shared = new RemoteRuntimeSharedControlConnection(pairing, { | |
| environmentId: environment.id | |
| }) | |
| const sharedControl = await measureRequests(() => | |
| shared.request('orchestration.federationPull', params, 15_000, { | |
| orchestrationContractVersion: 1 | |
| }) | |
| ) | |
| const diagnostics = shared.getDiagnostics() | |
| shared.close() | |
| expect(diagnostics).toMatchObject({ state: 'ready', pendingRequestCount: 0 }) | |
| process.stdout.write(`${JSON.stringify({ oneShot, sharedControl }, null, 2)}\n`) | |
| const shared = new RemoteRuntimeSharedControlConnection(pairing, { | |
| environmentId: environment.id | |
| }) | |
| try { | |
| const sharedControl = await measureRequests(() => | |
| shared.request('orchestration.federationPull', params, 15_000, { | |
| orchestrationContractVersion: 1 | |
| }) | |
| ) | |
| const diagnostics = shared.getDiagnostics() | |
| expect(diagnostics).toMatchObject({ state: 'ready', pendingRequestCount: 0 }) | |
| process.stdout.write(`${JSON.stringify({ oneShot, sharedControl }, null, 2)}\n`) | |
| } finally { | |
| shared.close() | |
| } |
21ce3ce to
ebe09e5
Compare
ebe09e5 to
5e18b1d
Compare
…yai#13814) (cherry picked from commit 09c8597)
Summary
orchestration.*RPCs over the retained shared-control mux when the remote advertises supportLinear: STA-3880
Measured impact
Physical
windows 2remote, 30 sequentialorchestration.federationPullcalls per transport from the rebased PR tip:Shared control reduced median latency by 86.6% (7.5x faster) and reused one retained connection instead of opening a fresh authenticated connection for every read.
Screenshots
No visual change.
Testing
pnpm lintpnpm typecheckpnpm test— full suite not run; 165 focused tests passed during implementation and the 31 direct routing/wire tests passed again after rebasingpnpm build— no build-system or packaging changeswindows 2AI Review Report
A performance audit and three correctness review rounds checked transport selection, mutation classification, mixed-version fallback, envelope integrity, reconnect behavior, and regression-test determinism. Reviews flagged formatting/max-lines issues and an unsafe envelope spread; the implementation was split to satisfy the ratchet and now serializes an explicit authority-field whitelist. Both fresh final-round reviewers returned clean.
Cross-platform compatibility was explicitly checked for macOS, Linux, Windows, SSH, and folder workspaces. The change does not touch shortcuts, labels, paths, shell behavior, UI, or platform-specific Electron behavior. The live validation used a physical Windows remote.
Security Audit
The affected boundary carries orchestration authorization metadata over an authenticated encrypted channel. Only the five existing authority fields are serialized; runtime keys cannot overwrite request ID, device token, method, or params. Mutations remain on the existing one-shot path, old hosts require no wire change and fall back safely, and the PR adds no command execution, filesystem input, secrets, dependencies, or new RPC opcodes.
Notes