Skip to content

feat(browser): establish client-hosted tunnel contracts - #14440

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

Jinwoo-H wants to merge 1 commit into
mainfrom
sta-4150-client-hosted-remote-browser

Conversation

@Jinwoo-H

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

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​790 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​790
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1124 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1124

Summary

  • reserve browser.clientHost.v1 and network.browserTunnel.v1 without advertising either capability
  • define a strict versioned TCP tunnel codec and bounded destination-session state machine
  • add a main-owned loopback SOCKS5 CONNECT endpoint with remote-DNS preservation and injected fail-closed routing
  • record the remaining activation criteria in an experimental reliability gate

Architecture decision

ELI5: the browser window will eventually live on the desktop client, but every network socket must still exit from the selected execution host. The runtime remains the owner of page identity, placement, generations, and agent/CLI routing. Existing pages and old clients stay on the server-hosted engine; live pages never silently migrate engines.

This draft is an intentionally inert Stage 1 foundation. The new capabilities are excluded from RUNTIME_CAPABILITIES, so there is no RPC, binary subscription, webview, Electron partition, placement change, or mixed-version behavior change yet.

Scope boundary

This does not duplicate or modify STA-4231 / #14402, which is Stage 0 server-hosted compatibility hardening. It also does not base on #10046: that draft overlaps future placement UI/defaults but does not provide execution-host networking, so desktop-local routing would break remote localhost and private DNS semantics.

Deterministic evidence

Red evidence was recorded before each production primitive existed: the protocol, session, and SOCKS tests failed with missing-module errors on the source checkout, then passed after implementation.

Post-rebase validation on origin/main:

  • pnpm exec vitest run --config config/vitest.config.ts src/shared/browser-network-capabilities.test.ts src/shared/browser-network-tunnel-protocol.test.ts src/main/browser/browser-network-tunnel-session.test.ts src/main/browser/remote-browser-socks-server.test.ts — 4 files, 25 tests passed
  • pnpm run typecheck — passed
  • pnpm run check:code-quality:changed — passed with zero new findings
  • pnpm run check:reliability-gates — passed
  • pnpm run check:max-lines-ratchet — passed with no new bypasses
  • git diff --check — passed

An exploratory full repository run completed 51,718 passing tests with six unrelated environment/resource failures. Isolated reruns passed the filesystem/process tests; the relay test passed after removing Orca-terminal-injected Git guard variables; the two deleted-CWD PTY tests passed with a 120-second timeout.

Compatibility and activation blockers

No exchanged field, opcode, capability, or publication semantic is active, so old desktop/mobile clients, current servers, SSH/WSL, folder workspaces, git worktrees, headed/headless hosts, and browserless hosts retain current behavior.

Before capability advertisement, later stages must add:

  • one dedicated authenticated paired-runtime binary route with both skew directions
  • aggregate 8 MiB route / 32 MiB browser-host / process accounting, WebSocket drain awareness, and fair scheduling
  • an approved same-host process/user trust boundary for Chromium-compatible SOCKS no-auth, or stronger process isolation
  • native, SSH2, system-SSH, exact-distro WSL, and browserless/headless adapters
  • an exact Electron session partition configured before requests with loopback bypass disabled
  • Linux, physical Windows, UDP/DoH, DNS, HTTP(S), WebSocket, worker, speculative-request, revocation, and no-desktop-fallback proof

Linear: https://linear.app/stably/issue/STA-4150/refactor-remote-browser-to-client-hosted-electron-webviews

@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-client-hosted-remote-browser branch 2 times, most recently from 87df81c to 9f2b17d Compare August 14, 2026 06:54
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-client-hosted-remote-browser branch 7 times, most recently from e63dcde to dacb536 Compare August 14, 2026 20:02
@Jinwoo-H
Jinwoo-H force-pushed the sta-4150-client-hosted-remote-browser branch 11 times, most recently from 716e0dd to ffe4492 Compare August 15, 2026 12:30
@OrcaWin

OrcaWin commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Closing because the tunnel foundation is already implemented on main (1a723194c32).

I read the complete production patch, body and available discussion and compared the regression intent. The strict versioned tunnel codec is byte-identical, including frame identity/size/opcode checks, bounded UTF-8 DNS targets, control payload validation and exact window-credit encoding. Destination session generation fencing, stream-ID nonreuse, receive credit after write settlement, bounded pending data/chunks, ordered EOF/close and fail-closed transport admission all remain.

Main has since extracted open admission, heartbeat and stream lifecycle and added pending-open/open-rate limits, aggregate retained-byte accounting and exact release of pending writes. One old behavior is deliberately superseded: late traffic for an already retired stream is ignored so concurrent streams survive, while never-reserved or reused stream identities still fence the tunnel. Current regressions cover that distinction.

The main-owned loopback SOCKS5 CONNECT listener still preserves domain names until the execution-host connector, normalizes listener wildcards at that boundary, rejects other commands, bounds handshake/pipelined data, destroys late upstreams and closes deterministically. Its pending-input buffering and upstream backpressure have since been strengthened. Both capability names now live in the browser capability module; the old unadvertised-stage assertion has been superseded by the activated implementation.

Validation: 5 focused current suites, 36 tests passed (wire protocol, destination session, stream-scoped failure, aggregate memory and SOCKS). Relevant files are unchanged in HEAD..origin/main. No live Electron or physical platform/network containment matrix was rerun; this closure concerns this foundation stage.

@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