Skip to content

feat(link): an explicit route may name its SSH identity file (link.route/2) - #8714

Merged
lidge-jun merged 8 commits into
devfrom
feat/link-route-identity-file
Nov 13, 2026
Merged

lidge-jun merged 8 commits into
devfrom
feat/link-route-identity-file

Conversation

@lidge-jun

@lidge-jun lidge-jun commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

An explicit route (link.route/1) names the ProxyCommand, user and port of a Home-initiated link, but not the key: such a link reads no ssh_config (-F none), so ssh authenticates with the Home's agent or a default ~/.ssh/id_* file. A hub that gives each disposable machine its own ed25519 key had no way to name it. This PR adds an optional identityFile to the route and declares link.route/2.

  • Contract: explicitRoute may carry identityFile, an absolute path. When it is present, every ssh command of the link gets three more options after the route's own: -o IdentitiesOnly=yes -o IdentityAgent=none -o IdentityFile=<path>, each as a single argument (explicitRouteSshOptions, src/link/explicit-route.ts). Every ssh builder already takes the link's route, so this reaches probe, confirm-host, plant and apply, the tunnel start and restart, recover (the tombstone keeps the route), a revoke's remote disconnect and purge, platform discovery, observe, sync and update, ocx sync fan-out and ocx link cleanup. A hermetic ssh -G test shows ssh resolves exactly that key, with no agent and identities only, and that a ssh_config adding a key would be read only without -F none.

  • Without it, nothing changes: a test pins the argv of all five builders for a route without identityFile, and the route's enrollment digest, to the values captured on dev 28680d5c0 before any change. A route without the field is the same three-key object, so records, tombstones and journal entries are byte-identical too.

  • CLI: ocx link probe|add --ssh-identity-file <path> sends it inside explicitRoute. It is a usage error without the full explicit route, or with a path outside the form. ocx capabilities --contracts lists link.route/2 beside link.route/1, which stays. The dashboard sends no explicit route, so nothing changes there. ocx link routes refuses edits of an exclusive link, as before.

  • Form (refused, never repaired; identity_file_form): absolute POSIX path, 2-1024 characters, / then letters, digits and . _ + - /, already normal (no empty, . or .. segment, no trailing /). ssh expands ~, % tokens and ${VAR} in IdentityFile and splits an -o value at whitespace or quotes; none of those characters is accepted, and the value always follows IdentityFile= in one argument, so it cannot be read as an option.

  • File check, from metadata only; the key is never opened or read (identityFileRefusal, identityFileProblem). probe and confirm-host check it before their SSH; apply checks it after its operation replay and before its journal entry and any SSH. A failure answers 400 invalid_identity_file with one of these hints:

    • identity_file_missing;
    • identity_file_not_regular: a symlink or any non-regular file;
    • identity_file_permissions: not owned by this user, or any group or other mode bit. ssh ignores its owner's key when others can read it, and the link would fail authentication with nothing pointing at the cause;
    • identity_file_unreadable;
    • identity_file_unsupported_platform: any identity file on a Windows Home (see below).

    The path itself is not a secret: the link keeps it, and ocx link status --json shows it.

  • When the key later disappears or changes: later commands do not re-check it; ssh does. A key ssh cannot use fails public-key authentication like any missing key:

    • the link reads failed with reason auth;
    • a revoke answers remote_disconnect_failed and keeps the link;
    • recover answers ssh_failed and keeps its tombstone.

    Remedy, in the guide: restore the file with owner-only permissions, or revoke with --force and enroll again with another key.

  • Journal: the enrollment digest hashes the whole route, so a repeat of an operation id with another key answers operation_mismatch (test: different keys give different digests; no key gives the old digest). Because apply replays before it checks the file, a lost-answer repeat replays its recorded outcome even after the key was removed or its permissions changed, and a repeat with another, missing key still answers operation_mismatch.

Compatibility: a Home or CLI from before link.route/2 parses the route strictly. It refuses a links.json, tombstones.json, an operation journal reservation or a status row whose route names an identityFile, which is the trade-off explicitRoute itself made one release earlier (structure/remote-link.md, "Explicit route"). Links without it are unaffected.

Windows Home: refused for now. The accepted form is a POSIX path, which Windows resolves against the current drive, and owner and mode bits there say nothing about the file's ACL, so a Windows Home answers every identity file with 400 invalid_identity_file, hint identity_file_unsupported_platform, before looking at the file or running ssh. The platform is a parameter of the check, so this policy is tested on macOS. No Windows run was done.

Docs: guides/remote-link.md en and es (command block and the explicit-route paragraph; identical inline code), structure/remote-link.md "Explicit route", capability text and the generated skill reference. reference/cli does not document the route flags; the guide is where they live.

Commits:

1fba43069 feat(link): an explicit route may name its identity file; ssh then offers that key alone
0b0ee6526 feat(link): a route request names a usable identity file or is refused with a fixed code, from the file's metadata only
6926db7bb feat(cli): ocx link probe|add --ssh-identity-file sends the route's key, and link.route/2 is declared beside link.route/1
97e610bec test(link): the tunnel, link status and recover use the keyed route's identity file
2b508d57d docs(link): the guides and structure describe --ssh-identity-file and link.route/2
6d5c6e1e1 fix(link): a repeat of a journalled enrollment replays before its identity file is checked
f699fd25d fix(link): a Windows Home refuses an explicit route's identity file
2a331c13d docs(link): when the Home checks an identity file, replay first, and the Windows refusal

Verification

  • Test-first: the identity-file form, option and argv tests, the ssh -G test, and the tunnel, status and recover tests fail against dev's explicit-route.ts (I swapped the old file in and ran them). The management API file-check refusals and the CLI flag test failed before their commits.
  • bun test tests/cli/cli-link*.test.ts tests/cli/cli-capabilities*.test.ts tests/server/link-*.test.ts tests/clients/link-*.test.ts tests/ci-workflows/docs-spanish-localization.test.ts tests/ci-workflows/skill-ocx.test.ts (temporary HOME/OPENCODEX_HOME): 2376 pass, 29 skip, 1 fail. The failure is tests/clients/link-full-install-census.test.ts "an ocx-child alone…", environment only: this machine has the desktop app at /Applications/OpenCodex.app/Contents/MacOS/ocx, one of the census's fixed candidates, so the census reports a full install. This PR does not touch that code.
  • Review fixes, test-first: the replay test (a journalled apply, the key removed, the same operation id replays 202 committed; another missing key answers 409 operation_mismatch; no SSH) failed with 400 invalid_identity_file before 6d5c6e1, and the Windows test failed (null) before f699fd2. A new journalled apply whose key widened to 0644 after confirm-host is refused before its journal file exists and before any SSH.
  • After the fixes: the explicit-route, recover, operations-journal, operations-routes, skill and Spanish docs suites: 343 pass, 0 fail, plus the 3 structure-ssot.test.ts cases that fail only in this worktree (its git fixture spawns exit 127 under the test's restricted PATH, because this Mac resolves git through a ~/.local/bin shim, and the doc-map case names node_modules paths this worktree lacks); bun run structure:check itself passes.
  • bun run typecheck, structure:check, skill:surface:check, privacy:scan: pass. The Spanish docs test: 30/30.
  • ssh -G ran against OpenSSH 10.3p1.

NOT RUN: full bun run test; Windows; a real enrollment against a machine.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

@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 github-actions Bot added the enhancement New feature or request label Nov 13, 2026
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

…ntity file is checked

splitRouteRequest checked the identity file on every probe, confirm-host and
apply, so a lost-answer repeat of ocx link add --operation-id answered
invalid_identity_file once the key had been removed or its permissions had
changed, and a repeat with another, missing key never reached the digest
comparison that answers operation_mismatch. The request now checks only the
route's form; probe and confirm-host check the file before their SSH, and apply
checks it after the replay and before the journal entry and any SSH.
The accepted identityFile form is a POSIX path, which Windows resolves against
the current drive, and identityFileProblem skipped the owner and mode checks
there, so a Windows Home accepted a key without any private-file check. It now
refuses every identity file before looking at it (400 invalid_identity_file,
hint identity_file_unsupported_platform). The platform is a parameter so the
policy is tested on any Home.
…the Windows refusal

structure/remote-link.md, both guides and the link probe|add capability text now say that probe and confirm-host check the file before SSH, apply after its operation replay and before its journal entry, and that a Windows Home refuses the flag (identity_file_unsupported_platform). The skill surface is regenerated.
@lidge-jun
lidge-jun marked this pull request as ready for review November 13, 2026 21:50
@lidge-jun
lidge-jun requested a review from Ingwannu as a code owner November 13, 2026 21:50
@lidge-jun
lidge-jun merged commit 86be880 into dev Nov 13, 2026
31 of 32 checks passed
@lidge-jun
lidge-jun deleted the feat/link-route-identity-file branch November 13, 2026 21:50
@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-13T21:52:45.135193Z 2a331c1 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a331c13d1

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +214 to +216
const key = keyFile();
const keyed = { explicitRoute: { ...ROUTE, identityFile: key }, exclusive: true };
expect((await h.call("POST", "probe", { alias: ALIAS, includeVersion: true, ...keyed })).status).toBe(200);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate POSIX identity-file enrollment tests on the host platform

On Windows, keyFile() returns a Windows-native temporary path, which checkExplicitRoute rejects as identity_file_form; consequently this unconditional success assertion receives 400 instead of 200. The other new keyed-enrollment tests likewise assume POSIX paths and permission semantics, despite the implementation intentionally refusing identity files on Windows. The platform-windows job in .github/workflows/ci.yml runs the batch wrapper with BUN_TEST_FILE_SCOPE: all, so these cases break that cross-platform lane. Skip the POSIX-only enrollment cases on Windows and retain a separate assertion for the supported Windows refusal.

Useful? React with 👍 / 👎.

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