Repository navigation
Conversation
ada5013 to
3050f45
Compare
3050f45 to
eefac71
Compare
3a647b5 to
b3408f0
Compare
|
Local CI for b3408f0 (top of the #35195 → #35242 stack): typecheck, changed-code quality, lint, format and both localization checks pass. The relay, runtime-rpc, runtime-environments, shared remote-runtime and renderer relayed suites pass: 116 files, 711 tests, 1 skipped. That includes the real-socket shared-control tests for the relayed transport. |
b3408f0 to
d4a877d
Compare
d4a877d to
def81c4
Compare
…ged hosts A server with relay host wiring advertises runtime.client-relay.v1 to runtime-scope sockets and relays their execution-host calls that name a runtime:<env> target, reusing the phone relay and its delegated devices. Every other runtime-client request keeps ignoring executionHost.
A desktop paired to a server that relays (runtime.client-relay.v1) now shows, read-only below the workspace list, the managed servers that server can relay to and their workspaces. The renderer reads them with mobileRelay.hosts.list/worktrees through the existing runtime call path, only while that server is in contact and advertises the capability for the current pairing. Polling pauses in hidden windows. The rows stay out of the workspace catalog, whose actions the relay would refuse.
A relay:<server>/<pairing>/<runtime:host> environment id now reaches a server's managed host from this computer. Main answers it on the paired server's shared control socket with executionHost set, and only after that socket's own status advertised runtime.client-relay.v1. A reconnect proves it again; an old server is never sent the call. Only read methods pass. status.get is the managed host's own, and its runtime id is never recorded as the paired server's. Subscriptions and opening these workspaces in the sidebar come next.
def81c4 to
38dabe9
Compare
|
Thanks for this series. We run #35195, #35242, #35478 and #35631 together on a headless The next step your notes describe is opening one of those workspaces from the desktop. That means routing activation, subscriptions and If you already have this in progress, say so and we'll review and test yours instead of opening a second one. |
ELI5
#35242 lists the servers that a paired server manages, but you can't open them. This PR adds the part that runs inside the app (main process): a way to read from one of those servers through the server it's paired with, safely. Nothing on screen changes yet. Opening a workspace in the sidebar needs a larger renderer change, which comes in the next PR.
What Changed
Topology: laptop → paired server A (advertises
runtime.client-relay.v1, #35195) → managed server B, which A reaches asruntime:<id on A>.src/shared/relayed-runtime-environment.ts):relay:<A id>/<A pairing revision>/<runtime:B-id-on-A>. The A id and the host are URI-encoded. It is owner-qualified, because two paired servers may each call a different machineruntime:vm-1. It is also revision-qualified, so an id minted before a re-pair of A can never reach the new pairing. To the renderer it is an ordinaryenvironmentId. It is never added toruntimeEnvironments.list(), so settings, pairing and WSL code don't see it.runtimeEnvironments:calland:getStatus(runtime-environment-connectivity-handlers.ts) check for arelay:selector beforeresolveEnvironment, the manual-disconnect check, the WSL move fence and the account steps.runtimeEnvironments:subscriberefuses arelay:selector, so it never resolves it to A (see Deferred).runtime-environment-shared-control-admission.ts): the existing runtime-pinned send (sendRemoteRuntimeSharedControlRequestOnRuntime) is generalized. It now takes an admission predicate over the socket's ownstatus.getand an envelope. It sends only if that status passed, and only while the same socket is current:beforeSendrefuses the send if the socket changed since the status. The runtime-pinned caller passesruntimeId === expectedand behaves as before: it gets null on refusal, failed status or a socket swap, and one timeout per request. An optional per-connection cache keeps an ok status until that socket is replaced and evicts a failed one.getSharedControlConnectionstays private.runtime-environment-relayed-transport.ts) is a separate path. It does not reusecallRuntimeEnvironment, for these reasons:runtime.client-relay.v1", cached per socket generation, so the check runs again after every reconnect, re-pair or restart of A. If the socket is swapped between the check and the send, the call checks once more. A second swap fails asremote_runtime_unavailable("kept changing; nothing was sent"). Without the capability, the call fails closed withremote_runtime_unavailable("update Orca on ") and nothing is sent. An old A would answer the call from its own disk, which reads from the wrong machine. If A's own status fails (e.g.runtime_busy), the caller gets that error code. Nothing is cached, so the next call checks again.timeoutMs(default 15 s) is a single deadline across managed-tunnel repair, the gate probe and the read, over both attempts.executionHost?: runtime:${string}is added toRuntimeOrchestrationEnvelope, andserializeRemoteRuntimeRpcRequestcopies it. That serializer only writes the fields it lists. No existing call site sets the new field.resolveManagedRuntimeEnvironment(which can repair a managed tunnel), and against the caller'sexpectedEnvironmentPairingRevision. If A has been unpaired, the call returnsruntime_environment_changed, not an exception.markEnvironmentUsed,recordRuntimeEnvironmentUsageor the status owner. B's_meta.runtimeIdcan never overwrite A's stored runtimeId, which A's revision guards depend on. Every failure this path returns, including a manually disconnected A, carries_meta.runtimeId: null, never A's id.runtimeId,capabilities). It is never answered with A's status. Features of B's workspaces are then gated on B's protocol and capabilities.RELAYED_RUNTIME_READ_METHODS, data):status.get,files.list/read/readChunk/readDir/readPreview/searchPaths/stat,git.status/diff/history/branchDiff,session.tabs.list,terminal.agentStatus,worktree.show/ps. Each is anexecution-hostroute on A. Anything else returnsforbiddenbefore any socket is touched.expectedEnvironmentRuntimeIdis refused withforbidden("A runtime can't be pinned through a relay"). It does not getruntime_environment_changed, because a refresh-and-retry would be refused the same way. B's runtime can't be proven before the send, and only mutation callers pin it today.getRuntimeEnvironmentRevisionreturns the owner revision arelay:id carries, and only while that is still A's current revision. Calls therefore pin A's pairing through the existingcaptureRuntimeEnvironmentRequestRevision. Main refuses an id minted for an older pairing because the revision is in the id itself. The pin adds the caller's own view of A's pairing on top of that.Why
Issue #29396. The renderer has about 360
kind === 'environment'branches. A virtual environment id resolved in main reaches B through all of them without a newRuntimeClientTargetkind. Fences, caches andruntime:host ids key on the id unchanged.I gave relayed calls their own transport instead of threading
executionHostthroughcallRuntimeEnvironment, for two concrete reasons:shouldUseSharedControlEnvelope(runtime-environment-support-routing.ts:299) passes an envelope on only for non-mutatingorchestration.*methods and drops every other envelope. Afiles.readDirwithexecutionHostwould lose the field and run on A itself. That is the same "field dropped, A runs locally" bug the gate exists to prevent._meta.runtimeId(markEnvironmentUsedFromResponse, the support-routingmarkUsed). That includes the one-shot fallback, the cached request connection and support routing. Through a relay, that id is B's.So the plan's choke points (2) and (3) are covered by not using those branches, not by teaching each one about relays. The shared part, "send only on the socket whose own status admits it", is generalized from the existing runtime-pinned send rather than copied. If the maintainers widen the route table or add a runtime child kind on B, only data changes: the allowlist set here and the method table on A.
Alternatives considered:
resolveOwner,worktree-operation-route,getKnownWorktreeByIdand activation. Activation also seeds a terminal, andterminal.multiplexis refused through the relay. It is well over this PR's budget, so it is the next PR.Mixed versions:
remote_runtime_unavailable, nothing sent to A beyondstatus.getruntime_environment_changed; the old id is deadrelay:idLinked Issue
Part of #29396.
Stacked on #35242 (which is stacked on #35195), so this diff includes their commits until they merge. Review only the last commit,
feat(remote): read a relayed host through the paired server.Visual Proof
N/A: main-process transport plus the renderer's revision pin for
relay:ids. Nothing builds such an id yet, so there is no UI or interaction change.Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
runtime-environment-relayed-transport.test.ts, against a real encrypted shared-control test server standing in for A:executionHostand is answered as B;status.getreturns B's runtimeId;runtime_busy→ the read returnsruntime_busy; the next read checks again and goes through (caching the failure fails it);remote_runtime_unavailable, the read is never sent (removing thebeforeSendsocket check fails it);files.write,terminal.create,git.commitandbrowser.goto→forbiddenwith no connection opened.mobile-desktop-relay.integration.test.ts(feat(remote): relay paired desktop and web clients to a server's managed hosts #35195 harness, real A and B RPC servers over E2EE WebSockets): a laptop profile pairs with A asruntimescope. ThroughgetRelayedRuntimeEnvironmentStatusit gets B's runtimeId, andterminal.agentStatuson B's terminal answers with_meta.runtimeId= B. The laptop's stored A runtimeId is not B's.relayed-runtime-environment-revision.test.ts:callRuntimeRpcon arelay:id reachesruntimeEnvironments.callwith that selector and A's pairing revision.Mutation checks: dropping
executionHostfrom the serializer fails 2 transport tests. Removing the capability gate fails the no-capability and downgrade tests. Removing thebeforeSendsocket check fails the socket-swap test. Caching a failed status fails theruntime_busytest. Marking A used from the relayed reply fails the first test.Commands (Linux):
corepack pnpm tc;corepack pnpm test --maxWorkers=2onsrc/main/ipc/runtime-environments,src/shared/remote-runtime,src/main/runtime/mobile-desktop-relay,src/shared/relayed*, and the rendererrelayed*andruntime-environment-revision*suites (80 files, 507 passed, 1 skipped);node config/scripts/check-changed-code-quality.mjs upstream/main(0 new findings in every pass);oxlintandoxfmt --checkon changed files. No strings changed, so the localization checks don't apply. The fullpnpm check:changedwas not run locally; CI covers it.AI Disclosure
Written with Claude (Anthropic) via an agent harness; reviewed by the author.
Review
execution-hostroutes for aruntimeclient and refuses the rest). This client further limits them to reads. Every call is gated on A's capability for the current socket and pinned to A's pairing. Arelay:id is parsed strictly: three parts, a numeric revision, and a host that parses asruntime:. Malformed ids returninvalid_argumentand never reachresolveEnvironment.resolveManagedRuntimeEnvironment, and the revision is checked again after it. A WSL distro is never used as A. A manually disconnected A is never called.status.getper A socket, cached until that socket changes. A failed status isn't cached. Calls queue per relayed id on the existing runtime call queue, and each call is bounded by one deadline, the caller's timeout.Agent skill upstream boundary
Notes
Deferred to the next PR(s):
relayedRuntimeTarget,readRelayedWorkspaceDirectory): removed from this PR because nothing calls them. They come back with the sidebar change that uses them.resolveOwner/worktree-operation-routeand activation accept. Activation must not seed a terminal. Edit, terminal, browser and git-mutation actions must be hidden. I found no existing read-only workspace flag; editorreadOnlyis per file.runtimeEnvironments:subscriberefusesrelay:ids. That coverssession.tabs.subscribe,files.watch, andcallRuntimeRpcwith asignal(those go through a one-shot subscription; today that's only the file-search clients). Carrying them needsexecutionHoston the subscription request channels (remote-runtime-subscription-transport.ts,-request-channel.ts, shared-control subscribe).runtimeStatusByEnvironmentId, so capability-gated UI reads (e.g. pagedfiles.readDir) fall back to their legacy path.Open questions for maintainers (in addition to the two on #35195):
callRuntimeEnvironmenttake anexecutionHostoption with the identity recording made conditional?deviceScope: 'mobile'). This PR only reads, butsession.tabs.listreturns the mobile projection. Acceptable for view-only, or wait for the runtime child kind?Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)