Registry Mirror
Skip to content

Conversation

@saphid

@saphid saphid commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Problem

isLocalSshDeviceHost in apps/server/src/device/localSshDeviceHost.ts fails to recognize SSH device hosts whose resolved ssh -G hostname is an expanded, zero-padded, or uppercase IPv6 loopback or local interface address (for example 0:0:0:0:0:0:0:1, ::0001, FD7A:115C:A1E0::1, or fd7a:115c:a1e0:0:0:0:0:1). Although unmapIPv4 already canonicalizes IPv6 via new URL(\http://[${address}]`).hostname, it discards the canonical value for non-::ffff:addresses and compares the raw string against"::1"andos.networkInterfaces(), so self-targeting SSH hosts are kept as remote hosts in WS_METHODS.serverUpdateSettings (apps/server/src/ws.ts) and DeviceService.reconcile (apps/server/src/device/DeviceService.ts), and probed over SSH instead of returning localHost.summary`.

Deterministic repro on origin/main (93f2c5190dfaf92733697f0ab375e2aa57b84c58):
Run from apps/server against real /usr/bin/ssh -G (OpenSSH 9.6p1) with LocalDeviceHostAddresses = new Set(["fd7a:115c:a1e0::1"]):

cd apps/server && node --input-type=module -e '
import * as NodeServices from "@effect/platform-node/NodeServices";
import * as Effect from "effect/Effect";
import { isLocalSshDeviceHost, LocalDeviceHostAddresses, remoteSshDeviceHosts } from "./src/device/localSshDeviceHost.ts";

for (const target of ["::1", "[0:0:0:0:0:0:0:1]", "[::0001]", "FD7A:115C:A1E0::1", "[fd7a:115c:a1e0:0:0:0:0:1]", "2001:DB8::1"]) {
  const host = { kind: "ssh", id: target, label: target, target };
  const local = await Effect.runPromise(isLocalSshDeviceHost(host).pipe(Effect.provideService(LocalDeviceHostAddresses, new Set(["fd7a:115c:a1e0::1"])), Effect.provide(NodeServices.layer)));
  const kept = (await Effect.runPromise(remoteSshDeviceHosts([host]).pipe(Effect.provideService(LocalDeviceHostAddresses, new Set(["fd7a:115c:a1e0::1"])), Effect.provide(NodeServices.layer)))).length;
  console.log(`${target} -> local:${local}, keptRemote:${kept}`);
}
'
  • Observed on origin/main: [0:0:0:0:0:0:0:1], [::0001], FD7A:115C:A1E0::1, and [fd7a:115c:a1e0:0:0:0:0:1] all return local:false, keptRemote:1.
  • Expected: All four return local:true, keptRemote:0, while the remote control 2001:DB8::1 remains local:false, keptRemote:1.

Change

Renamed unmapIPv4 to normalizeIpAddress in apps/server/src/device/localSshDeviceHost.ts and returned canonical.slice(1, -1) (the RFC 5952 lowercase compressed IPv6 form from the WHATWG URL parser) for non-IPv4-mapped IPv6 addresses instead of the raw string, and normalized LocalDeviceHostAddresses with the same helper before membership checks. Extended apps/server/src/device/localSshDeviceHost.test.ts with expanded/padded loopback, uppercase/expanded local IPv6, and remote IPv6 control cases. Server-only change covering all callers (WS_METHODS.serverUpdateSettings, DeviceService.reconcile, and DeviceService host probing); no client, contract, or i18n surfaces are affected.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • Base (93f2c5190dfaf92733697f0ab375e2aa57b84c58) -> Head (6dcc806e19f363e600bdb0917901f32fedde7d66):
    • vp test run apps/server/src/device/localSshDeviceHost.test.ts: failed on base (1 failed | 2 passed, AssertionError: expected false to be true), passed on head (3 passed (3)).
    • Direct Node execution of isLocalSshDeviceHost and remoteSshDeviceHosts via real /usr/bin/ssh -G: all four non-canonical local IPv6 inputs flipped from local:false, keptRemote:1 on base to local:true, keptRemote:0 on head; remote control 2001:DB8::1 stayed local:false, keptRemote:1.
    • Full transcript: https://gist.github.com/saphid/2cabcf024f9e94c5fd9d70a9f0db38b1
  • vp run check:changed exited 0 (format, lint, knip, graphql (apps/server), typecheck (3 packages), and test (2 files, 5 passed)).
  • Not shown: End-to-end Settings UI save flow and live SSH device hub probing were not run because this fix is confined to localSshDeviceHost.ts address normalization and the isolated environment has no remote SSH device hub configured.

Authored by Gemini 4 Neon (Antigravity); reviewed by GPT-6.2 Sol (Codex).

Not shown

  • packages/contracts/src/device.ts:17 — The draft repro uses IPv6 target strings as host IDs, which the settings schema would reject. Use fixed valid IDs such as host-0 and add a server.updateSettings response assertion for scenario-ready evidence.
  • apps/server/src/device/localSshDeviceHost.ts:72 — The linked transcript shows the regression test and real OpenSSH behavior, but not the reported vp run check:changed run. Attach its output with HEAD 6dcc806e19f363e600bdb0917901f32fedde7d66 recorded, or note that the run was reported but not independently verified.
  • apps/server/src/device/localSshDeviceHost.ts:37 — Label 93f2c519 as the candidate base, not current origin/main; the remote main tip was b429a6bc, where the reviewer independently reproduced the same bug.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Dec 2, 2026
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The SSH host locality check now canonicalizes IPv6 addresses and unwraps IPv4-mapped IPv6 addresses before comparing resolved host addresses with local interface addresses. Tests add alternate local IPv6 forms and a remote IPv6 destination.

Changes: SSH host address check

Layer / File(s) Summary
Normalize addresses and verify host locality
apps/server/src/device/localSshDeviceHost.ts, apps/server/src/device/localSshDeviceHost.test.ts
The address helper canonicalizes IPv6 and unwraps IPv4-mapped IPv6. The locality check normalizes resolved host and local interface addresses. Tests include alternate local IPv6 forms and a remote IPv6 destination.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 0182f

This change makes SSH hosts written as non-canonical IPv6 addresses be recognized as local, and it adds tests for that case. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: canonicalizing IPv6 addresses so that SSH device hosts are correctly detected as local. It follows the conventional commit format and matches the summary of changes in…
Description check Passed The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each section gives specific content. The Problem section explains the bug and gives a rep…
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.
Full details: Title check

Explanation

The title names the main change: canonicalizing IPv6 addresses so that SSH device hosts are correctly detected as local. It follows the conventional commit format and matches the summary of changes in localSshDeviceHost.ts and its test file. It is a single sentence and does not use vague terms.

Full details: Description check

Explanation

The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each section gives specific content. The Problem section explains the bug and gives a reproduction. The Change section describes the rename, the normalization, and the new tests. The Scope section explains why no issue is linked. The Verification section lists focused test runs, direct Node execution results, and a transcript link. It states what was not checked. The reviewer notes in the Not shown list point to gaps, such as the missing check:changed output and base-label wording. These gaps do not make the description largely incomplete. The description also does not follow the template's note on the agent model and harness exactly, but it does name the model and harness at the end.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6e74bde and 0182fed.

Files selected for processing: 2

  • apps/server/src/device/localSshDeviceHost.test.ts
  • apps/server/src/device/localSshDeviceHost.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Dec 2, 2026
@macroscopeapp

macroscopeapp Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 0182fed

Macroscope's review found this PR approvable — This change consistently normalizes IPv6 addresses when identifying SSH hosts that refer to the local machine. Existing port and proxy safeguards remain intact, keeping the change limited to equivalent address representations.

You can add or adjust custom eligibility rules. Learn more.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Dec 2, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review December 2, 2026 22:38

Dismissing prior approval to re-evaluate 0182fed

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Dec 2, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

scenarios:prove from current origin/main, running the real base/head web app and server in isolated worktrees and fresh scenario data; deterministic e2e browser, 1280×800, light theme, Linux, OpenSSH 9.6p1. Synthetic project seeded through t3.project; real SSH CLI and real local IPv6 interface; no mocks.

On fresh state on each commit, create a synthetic project and open Settings → Devices. Temporary real OpenSSH aliases use port 22 and no proxy: lower/upper spellings of the machine's own Tailscale IPv6 interface, expanded loopback 0:0:0:0:0:0:0:1, and remote 2001:DB8::1. For lower, expanded, remote, then upper: Add source → Machine over SSH; fill name and alias; Test connection; capture the completed result (expand errors); Save host; capture Device sources and read the isolated settings.json. Restore SSH config afterward.

Scenario: Uppercase local IPv6 SSH sources use the local device summary

Proven: the scenario fails on base 8fc71a2eec and passes on head 0182fedb8f.

Base 8fc71a2eec Head 0182fedb8f
Result ❌ failed
ASSERTION_FAILED: expected {"lower":{"local":true,"retained":false,"persisted":false},"expanded":{"local":true,"retained":false,"persisted":false},"remote":{"local":false,"retained":true,"persisted":true},"upper":{"local":false,"retained":true,"persisted":true}} to equal {"lower":{"local":true,"retained":false,"persisted":false},"expanded":{"local":true,"retained":false,"persisted":false},"remote":{"local":false,"retained":true,"persisted":true},"upper":{"local":true,"retained":false,"persisted":false}}
✅ passed
lower ipv6 connection check Base 8fc71a2eec: lower ipv6 connection check Head 0182fedb8f: lower ipv6 connection check
lower ipv6 saved sources Base 8fc71a2eec: lower ipv6 saved sources Head 0182fedb8f: lower ipv6 saved sources
expanded ipv6 connection check Base 8fc71a2eec: expanded ipv6 connection check Head 0182fedb8f: expanded ipv6 connection check
expanded ipv6 saved sources Base 8fc71a2eec: expanded ipv6 saved sources Head 0182fedb8f: expanded ipv6 saved sources
remote ipv6 connection check Base 8fc71a2eec: remote ipv6 connection check Head 0182fedb8f: remote ipv6 connection check
remote ipv6 saved sources Base 8fc71a2eec: remote ipv6 saved sources Head 0182fedb8f: remote ipv6 saved sources
upper ipv6 connection check Base 8fc71a2eec: upper ipv6 connection check Head 0182fedb8f: upper ipv6 connection check
upper ipv6 saved sources Base 8fc71a2eec: upper ipv6 saved sources Head 0182fedb8f: upper ipv6 saved sources
failure Base 8fc71a2eec: failure

| Recordings | Before interaction | After interaction |

Scenario driver

Base attempts SSH to the uppercase self alias and retains it in Device sources and settings.json. Head uses the local summary and excludes it from both. Lowercase and expanded loopback are local on both; the remote control remains remote on both.

Not shown:

  • Expanded loopback works on both commits because OpenSSH 9.6 canonicalizes it before T3 compares addresses; this run proves the uppercase-interface defect, not a new expanded-address difference. Zero-padded interface spellings were not separately exercised.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Dec 2, 2026
@juliusmarminge
juliusmarminge merged commit 773616a into pingdotgg:main Dec 2, 2026
47 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants