Repository navigation
feat(link): an explicit route may name its SSH identity file (link.route/2) - #8714
Conversation
…fers that key alone
…d with a fixed code, from the file's metadata only
…ey, and link.route/2 is declared beside link.route/1
|
Caution Review failedThe pull request is closed.
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. |
|
✅ 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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| 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); |
There was a problem hiding this comment.
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 👍 / 👎.
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 optionalidentityFileto the route and declareslink.route/2.Contract:
explicitRoutemay carryidentityFile, 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 syncfan-out andocx link cleanup. A hermeticssh -Gtest 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 dev28680d5c0before 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 insideexplicitRoute. It is a usage error without the full explicit route, or with a path outside the form.ocx capabilities --contractslistslink.route/2besidelink.route/1, which stays. The dashboard sends no explicit route, so nothing changes there.ocx link routesrefuses 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}inIdentityFileand splits an-ovalue at whitespace or quotes; none of those characters is accepted, and the value always followsIdentityFile=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 answers400 invalid_identity_filewith 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 --jsonshows 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:
failedwith reasonauth;remote_disconnect_failedand keeps the link;ssh_failedand keeps its tombstone.Remedy, in the guide: restore the file with owner-only permissions, or revoke with
--forceand 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 answersoperation_mismatch.Compatibility: a Home or CLI from before
link.route/2parses the route strictly. It refuses alinks.json,tombstones.json, an operation journal reservation or a status row whose route names anidentityFile, which is the trade-offexplicitRouteitself 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, hintidentity_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:
Verification
ssh -Gtest, and the tunnel, status and recover tests fail against dev'sexplicit-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(temporaryHOME/OPENCODEX_HOME): 2376 pass, 29 skip, 1 fail. The failure istests/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.202 committed; another missing key answers409 operation_mismatch; no SSH) failed with400 invalid_identity_filebefore 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.structure-ssot.test.tscases that fail only in this worktree (itsgitfixture spawns exit 127 under the test's restricted PATH, because this Mac resolvesgitthrough a~/.local/binshim, and the doc-map case namesnode_modulespaths this worktree lacks);bun run structure:checkitself passes.bun run typecheck,structure:check,skill:surface:check,privacy:scan: pass. The Spanish docs test: 30/30.ssh -Gran against OpenSSH 10.3p1.NOT RUN: full
bun run test; Windows; a real enrollment against a machine.Checklist