Skip to content

feat(browser): route paired browser sockets through runtime - #14470

Closed
Jinwoo-H wants to merge 1 commit into
sta-4150-client-hosted-remote-browserfrom
sta-4150-paired-browser-tunnel
Closed

Jinwoo-H wants to merge 1 commit into
sta-4150-client-hosted-remote-browserfrom
sta-4150-paired-browser-tunnel

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​803 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​803
Prod 22 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1317 $\color{#cf222e}{\Huge{\mathbf{−}}}$​105 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1212

ELI5

The browser window will eventually live on the desktop that is displaying it, while its network requests still leave from the runtime that owns the workspace. This stage proves that network path: a desktop-side loopback SOCKS route carries bounded TCP frames over a dedicated authenticated paired-runtime connection, and the runtime opens the real destination socket without resolving names on the desktop.

Nothing selects this route in production yet. The RPC method is test-injected only and the client-host/tunnel capabilities remain unadvertised, so existing clients and server-hosted browser placement are unchanged.

What Changed

  • Added the source-side tunnel multiplexer and Duplex bridge with bounded per-stream writes, destination receive credit, generation fencing, ordered half-close/close handling, and stream retirement.
  • Added a dedicated raw-binary router that keeps tunnel frames and terminal multiplex frames connection-exclusive.
  • Added a paired-runtime route that owns the authenticated E2EE subscription and loopback SOCKS listener, preserves execution-host DNS, disables compression, and fails closed on attach/transport/queue errors.
  • Added the native execution-host tunnel RPC behind an explicit test-only method injection. It verifies runtime-scoped pairing, paired-device identity, authority runtime ID, generation, and the optional client capability.
  • Made subscription binary enqueue return actual admission and added bounded queue overrides.
  • Added deterministic unit and real paired-runtime integration coverage plus a reliability gate.

Why

STA-4150 needs client-hosted Electron pages to render and accept input locally without giving them the desktop's DNS, localhost, or private-network identity. The tunnel is the first executable cross-boundary route for that architecture. Keeping registration and capability advertisement off prevents this transport from becoming a hidden arbitrary-TCP feature before browser-host leases, server-owned route generations, aggregate accounting, proxy trust, and Electron isolation exist.

This is stacked on #14440, which contains the inert framing, destination-flow, capability, and SOCKS contracts.

Linked Issue

Part of STA-4150.

Visual Proof

N/A — this stage has no registered production method, Electron webview, or visible interaction change.

Testing

  • 25/25 shared protocol, destination flow, and SOCKS tests.

  • 19/19 source flow, route lifecycle, raw/terminal routing, RPC authorization, and real paired-runtime SOCKS-to-HTTP tests.

  • 17/17 authenticated remote-runtime subscription tests.

  • 5/5 terminal cross-version wire tests.

  • pnpm run typecheck

  • pnpm run check:code-quality:changed

  • pnpm run check:reliability-gates

  • pnpm run check:max-lines-ratchet

  • git diff --check

  • Rebased and rerun on origin/main at 9e5ee5ef8e on macOS.

  • Automated tests added/updated

  • Electron rendered validation — not applicable until a later stage registers a host and webview

Review

Please treat these as activation blockers, not follow-ups that can be deferred after registration:

  • live browser-host lease, authority epoch, exact execution-host revision, and server-owned route generation;
  • bounded pending-open/open-rate admission, aggregate 8 MiB route / 32 MiB browser-host / process accounting, and fair scheduling;
  • approved same-host SOCKS no-auth trust boundary or stronger isolation/authentication;
  • reconnect with generation replacement and tunnel recycling before stream-ID exhaustion;
  • E2EE v2/relay-compatible capability negotiation;
  • SSH2, system SSH, exact-distro WSL, browserless, Linux, and physical Windows adapters/evidence;
  • Electron partition proxy policy before every request, plus HTTP(S), DNS, WebSocket, worker, redirect, speculative-request, UDP/QUIC/DoH denial, and desktop no-fallback proof.

Existing server/offscreen placement, old callers that omit placement, terminal framing, mobile surfaces, SSH, WSL, folder workspaces, and git worktrees are not activated or semantically changed by this stage.

Checklist

  • This PR is a focused second layer in the STA-4150 stack
  • I explained what changed and why
  • Visual proof is N/A because there is no UI activation
  • Fresh correctness and security/performance reviews completed
  • Cross-platform, SSH/remote, mobile, and mixed-version impact considered
  • Focused local tests and static/reliability gates pass; full matrix delegated to PR CI

@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 0cd3404 to 4efd597 Compare August 14, 2026 07:02
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 4efd597 to 2050b69 Compare August 14, 2026 07:27
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 2050b69 to 3b00b5a Compare August 14, 2026 07:51
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch 2 times, most recently from 3d41869 to 9ff17fc Compare August 14, 2026 09:14
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 9ff17fc to 6987a05 Compare August 14, 2026 10:18
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 6987a05 to 713f8b6 Compare August 14, 2026 20:02
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 713f8b6 to 2e19bd3 Compare August 14, 2026 20:14
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 2e19bd3 to 68223e3 Compare August 14, 2026 21:00
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch 2 times, most recently from 122379c to 80ac724 Compare August 15, 2026 00:44
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch 2 times, most recently from c6c0a77 to 74cc344 Compare August 15, 2026 02:57
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 74cc344 to 54751ef Compare August 15, 2026 03:24
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 54751ef to 2953a2f Compare August 15, 2026 08:53
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 2953a2f to 76a439f Compare August 15, 2026 10:24
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 76a439f to 4665de4 Compare August 15, 2026 11:34
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-paired-browser-tunnel branch from 4665de4 to 6096764 Compare August 15, 2026 12:30
@OrcaWin

OrcaWin commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Closing because this paired-browser transport stage is implemented on main (1a723194c32), with subsequent authorization and recovery improvements.

I read the complete production patch, body and available discussion and compared its regression intent. Main retains the bounded source multiplexer/Duplex bridge, generation and stream limits, ordered half-close/close, remote-DNS SOCKS targets, and credit granted only after the browser-facing socket write settles. Memory claims now also cover pending and unsettled application bytes. Retired-stream late packets are deliberately ignored so they cannot terminate healthy sibling streams; never-reserved stream identities still fail closed.

The dedicated raw binary router still excludes terminal framing on the same connection and is wired through the extracted runtime dispatcher. Authenticated E2EE subscriptions still disable compression, bind the optional capabilities, enforce the 1 MiB soft / 7 MiB queued / 2048-frame limits, and return actual enqueue admission. Current per-turn drain and aggregate socket-memory admission strengthen that boundary. Late acquisition, pre-ready close, readiness deadline, cleanup failures and runtime termination remain covered; bounded independent transport recovery now preserves the listener while replacing tunnel generations.

The original test-only registration and self-asserted identity/generation are superseded by live browser-host leases, exact runtime authority, server-minted generations and production activation. This is closure of the implemented transport stage, not a claim that every activation-blocker platform or Electron containment matrix was rerun.

Validation: seven focused current suites passed all 62 tests, including real paired-runtime SOCKS-to-HTTP transport, source/client memory accounting, raw/terminal isolation, route lifecycle, subscription requests and outbound admission. The preceding tunnel RPC suite passed 13 tests. Relevant HEAD..origin/main transport contracts are unchanged. No new live Electron or physical-platform run was performed.

@OrcaWin OrcaWin closed this Oct 26, 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.

2 participants