Skip to content

feat(link): let a Remote Link carry an explicit, exclusive SSH route - #8615

Merged
lidge-jun merged 3 commits into
devfrom
feat/link-explicit-route
Nov 13, 2026
Merged

lidge-jun merged 3 commits into
devfrom
feat/link-explicit-route

Conversation

@lidge-jun

Copy link
Copy Markdown
Owner

Summary

A hub that provisions a disposable machine validates one SSH path to it (a relay ProxyCommand, a user and a port) and needs the Remote Link to keep using exactly that path. Today the Home takes ProxyCommand, User and Port for a link's alias from ~/.ssh/config, so an edit there after enrollment silently moves every later command and tunnel to another path, and ocx link routes add can add a second route to the same machine.

This change lets a Home-initiated link record explicitRoute {proxyCommand, user, port} and exclusive: true:

  • Every SSH builder in src/link/ssh-argv.ts now takes a required route (ExplicitRoute | null), so the type checker makes every call site decide. A link with an explicit route passes -o ProxyCommand=… -o ProxyUseFdpass=no -o User=… -o Port=… on the command line, which OpenSSH reads before any ssh_config value, for enrollment (probe, confirm-host, apply with plant, connect, restart and the residual purge), revoke (disconnect and purge), platform discovery, observe, sync and update, ocx sync fan-out, ocx link cleanup and every tunnel start. A builder refuses an explicit route with any destination other than the alias.
  • exclusive means the link has exactly one route, its alias. The store refuses a route list beside it and an explicit route without it. POST /api/link/{id}/routes on an exclusive link answers 409 link_exclusive before any probe, and again under the commit's mutation lock if the link turned exclusive while the new route was being probed. ocx link routes goes through that route.
  • The probe, confirm-host and apply bodies accept optional explicitRoute and exclusive. The probe binds them to the pending host; confirm-host and apply must name the same values (absent means none) or answer 409 route_mismatch, so a probe another caller made with another route cannot be confirmed or applied by mistake.
  • ocx link probe and ocx link add gain --proxy-command, --ssh-user, --ssh-port (all three together) and --exclusive.
  • GET /api/link/status rows of exclusive links carry exclusive and explicitRoute; ocx link status and ocx link routes accept them. That document stays limited to the admin token and dashboard sessions (it is not in the Child-readable relay list).

Accepted form (refused, never repaired, at the store, the builder, the management body and the CLI)

ssh runs ProxyCommand as exec <command> through the user's shell, so only this form passes:

  • proxyCommand: 1 to 1024 ASCII characters; 1 to 32 words separated by exactly one space. The first word is an absolute POSIX path (/ then letters, digits, ., _, +, -, /), so neither PATH nor an exec flag decides what runs. Every later word uses only letters, digits and . _ / : @ + , = - and does not start with = (zsh expands a leading =). Refused: quotes, backslash, $, backquote, ; & | < > ( ) { } [ ] * ? ! # ~, % (ssh expands %h, %p, %r, %n from values ssh_config controls), tab, newline, NUL and non-ASCII.
  • user: a letter or _, then up to 31 letters, digits, ., _ or -.
  • port: an integer from 1 to 65535.

The path form is POSIX only, so a Windows Home cannot use an explicit route yet.

What this does not change: ssh_config stays trusted operator configuration for every other option (identity files, for example), and OpenSSH still evaluates it, so a Match exec block there still runs as it does today. The explicit route fixes where ssh connects and as whom; it does not make ssh_config inert.

What stays unchanged by default

No link has explicitRoute or exclusive until a caller passes the new flags or body keys, and nothing in this repository does. With route: null every builder emits exactly the argv it emitted before (asserted against a literal argv). Status rows, route documents and request bodies are unchanged for every link without the fields; the dashboard parser ignores the new keys. Child-initiated links (src/client/) and messaging (src/messaging/) always pass null. Known trade-off, the same as routes, childKind and remotePlatform: a Home downgraded below this release rejects a links.json holding the new fields.

Verification

Tests that failed first, and why (each run against unmodified origin/dev sources):

  • tests/clients/link-explicit-route.test.ts "an ssh_config edit after enrollment … does not change the route of any command an exclusive link runs": a hostile ssh_config for the alias (ProxyCommand with %h/%p, ProxyJump, User, Port, HostName, ProxyUseFdpass, a Match block) and ssh -G on the argv the supervisor builds for the tunnel and on the exec, probe and Windows-probe argv. Before: proxycommand /usr/bin/evil-relay %h %p, user intruder, port 2222, proxyusefdpass yes, because nothing passed the route. After: the route's values; ProxyJump absent.
  • tests/server/link-route-edit-exclusive.test.ts "adding a direct route to an exclusive link … is refused before any probe": before, the add answered 200 and stored the route; now 409 link_exclusive, no SSH, store unchanged. Same file: remove and order refused; a link that turns exclusive during the new route's probe is refused at commit.
  • tests/server/link-enrollment-explicit-route.test.ts: every SSH argv of probe, confirm and apply carries the route and the record keeps it; revoke's disconnect carries it; confirm or apply with another route, or none, answers 409 route_mismatch; refused forms answer 400 before any SSH. (8 of 9 failed before; the ninth, exclusive: false → 400, already passed because origin/dev refuses unknown body keys.)
  • tests/clients/link-explicit-route-paths.test.ts: platform discovery (both variants), runtime inspection, purge, observe and the pinned sync carry the record's route.
  • tests/cli/cli-link-explicit-route.test.ts: the CLI sends the route with all three requests; bad combinations and forms are usage errors before any request; without the flags the bodies are unchanged.
  • tests/clients/link-explicit-route.test.ts also covers the accepted and refused forms (each refusal reason), the store rules, every builder with and without a route, and the status projection plus ocx link status validation.

Commands (Bun 1.4.4, TMPDIR=/tmp):

  • bun run typecheck → exit 0
  • bun run privacy:scan → exit 0
  • bun run structure:check → exit 0
  • bun run skill:surface:check → exit 0
  • bun scripts/test.ts --parallel=2 over tests/clients/link-, tests/clients/client-link-, tests/server/link-, tests/cli/cli-link, tests/cli/sync-, tests/cli/link-, tests/codex-integration/messaging-remote*, the layout, structure, file-size ratchet, skill-ocx and CLI capability tests, and tests/clients/link-boundary.test.ts → exit 1: 2279 pass, 27 skip, 3 fail across 143 files (run on a12b7a9). The 3 failures are the Rust-toolchain cases listed under NOT RUN and fail identically on origin/dev. The last commit (0c47081) changes only two fixture strings in tests/clients/link-explicit-route.test.ts; that file rerun alone: 73 pass, 0 fail. typecheck, privacy:scan and structure:check rerun on 0c47081: exit 0 each.

NOT RUN: the full bun run test suite (this machine is limited to focused files); tests/clients/link-ocx-child-e2e.test.ts (2 cases) and the Rust conformance runner in tests/clients/link-ocx-child-conformance.test.ts, which need a Rust toolchain this machine does not have (rustup has no default toolchain; they fail identically on origin/dev); the opt-in real OpenSSH fixture (OCX_OPENSSH_ROUTE_FIXTURE=1); Windows and macOS. A Windows Home cannot use an explicit route (POSIX path form).

Review: an independent read-only review of e85a975..a12b7a9 (injection, call-site completeness, ssh_config precedence, exclusivity, inertness, enrollment binding) reported no P0-P2 findings. Its only note was the Match exec limitation stated above. It could not run tests in its own checkout (no installed dependencies), so the test evidence is the runs listed here. It did not see 0c47081 (fixture strings only).

Docs: structure/remote-link.md gains "Explicit route"; the English Remote Link guide documents the flags; the generated skill surface is regenerated from the capability registry.

Checklist

  • Targets dev
  • Behaviour change in src/ has focused regression tests in the matching domain folders, registered in the test layout maps
  • Owned structure doc updated in the same change
  • Inert by default (see above)
  • No GUI change

Implemented by Claude Opus 5.5 (anthropic/claude-opus-5-5) in GOAT through the Codex harness; in-lane review by GPT-6.1 Terra (xhigh). Received as a git bundle from the VM that built it and pushed by the coordinator.

A Home-initiated link may now record explicitRoute {proxyCommand, user, port}
and exclusive. Every SSH builder takes a required route, so each caller decides;
the route reaches ssh on the command line for enrollment, revoke, purge, every
exec and every tunnel start, where ssh_config cannot change it. An exclusive
link refuses route edits. No link has either field until a caller passes the
new flags.
The inspection dependency now takes the link's explicit route after the alias;
the mock records it so a routed inspection would show up.
The privacy scan reads tracked files and flags user@domain text; the fixtures
keep their @ words without a domain.
@lidge-jun lidge-jun added the enhancement New feature or request label Nov 13, 2026
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 01:44
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 01:44
@lidge-jun
lidge-jun merged commit b1b6dca into dev Nov 13, 2026
35 of 36 checks passed
@lidge-jun
lidge-jun deleted the feat/link-explicit-route branch November 13, 2026 01:44
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T01:47:09.575044Z 0c47081 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

lidge-jun added a commit that referenced this pull request Nov 13, 2026
The tombstone of a force-revoked ephemeral link keeps the link's explicit route and exclusive flag
(an explicit route requires exclusive, as on the record), and recover passes that route's
ProxyCommand, user and port on the ssh command line; a link without one still uses its alias. The
operation-recovery slot's target carries the explicit route for O1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant