Skip to content

perf(orchestration): route federated reads over shared control - #13814

Merged
Jinwoo-H merged 1 commit into
mainfrom
jinwoo/sta-3880-shared-control-federated-reads
Aug 11, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
jinwoo/sta-3880-shared-control-federated-reads

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route read-only enveloped orchestration.* RPCs over the retained shared-control mux when the remote advertises support
  • keep orchestration mutations on the isolated one-shot transport and preserve one-shot fallback for older hosts
  • explicitly serialize the five orchestration authority fields on both transports
  • add deterministic routing/wire regression coverage and an opt-in live remote benchmark

Linear: STA-3880

Measured impact

Physical windows 2 remote, 30 sequential orchestration.federationPull calls per transport from the rebased PR tip:

Transport Median p95
One-shot WebSocket + E2EE handshake 786.96 ms 875.46 ms
Shared-control mux 105.14 ms 127.60 ms

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 lint
  • pnpm typecheck
  • pnpm test — full suite not run; 165 focused tests passed during implementation and the 31 direct routing/wire tests passed again after rebasing
  • pnpm build — no build-system or packaging changes
  • Added high-quality tests covering read routing, mutation isolation, unsupported-host fallback, and authority-envelope integrity
  • Live opt-in benchmark passed against windows 2

AI 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

  • one shared-control socket is retained per active environment
  • the first capability probe and connection warm-up still pay handshake cost
  • the benchmark covers sequential small responses, not large-payload or long-duration heap/reconnect stress

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 37b54e19-4f62-47db-8845-fea43ff8debb

📥 Commits

Reviewing files that changed from the base of the PR and between 21ce3ce and 5e18b1d.

📒 Files selected for processing (3)
  • src/main/ipc/runtime-environment-federated-read-transport.bench.test.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/main/ipc/runtime-environment-federated-read-transport.bench.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts

📝 Walkthrough

Walkthrough

Federated 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)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes routing federated orchestration reads over shared control.
Description check ✅ Passed The description includes all template sections, change details, test status, review findings, security audit, and follow-up notes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between a0a654c and 21ce3ce.

📒 Files selected for processing (9)
  • src/main/ipc/runtime-environment-federated-read-routing.test.ts
  • src/main/ipc/runtime-environment-federated-read-transport.bench.test.ts
  • src/main/ipc/runtime-environment-request-connections.ts
  • src/main/ipc/runtime-environment-transport-routing.ts
  • src/shared/remote-runtime-client.ts
  • src/shared/remote-runtime-memory-limits.ts
  • src/shared/remote-runtime-shared-control-connection.test.ts
  • src/shared/remote-runtime-shared-control-connection.ts
  • src/shared/remote-runtime-shared-control-requests.ts

Comment on lines +47 to +59
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`)

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.

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

Suggested change
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()
}

@Jinwoo-H
Jinwoo-H force-pushed the jinwoo/sta-3880-shared-control-federated-reads branch from 21ce3ce to ebe09e5 Compare August 11, 2026 22:39
@Jinwoo-H
Jinwoo-H force-pushed the jinwoo/sta-3880-shared-control-federated-reads branch from ebe09e5 to 5e18b1d Compare August 11, 2026 22:46
@Jinwoo-H
Jinwoo-H merged commit 09c8597 into main Aug 11, 2026
44 checks passed
@Jinwoo-H
Jinwoo-H deleted the jinwoo/sta-3880-shared-control-federated-reads branch August 11, 2026 23:17
zpyoung pushed a commit to zpyoung/orca that referenced this pull request Aug 14, 2026
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