Resolve ssh.<forge> remotes to their web/API host #343
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/ssh-host-api-host"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #342.
parse_remotereturned the git transport host as the API host. On a Fjord forge the git SSH endpoint is a separatessh.<forge>name while the web and API live at the parent<forge>, so a repo cloned overssh.<forge>resolved tossh.<forge>and every API or web request hit a host that does not serve them.For SSH transports only (an
ssh://URL, or the scp formgit@ssh.<forge>:owner/name), a leadingssh.label now resolves to its parent when the config establishes that relationship. Anhttps://ssh.example/...remote is a real web host and keeps its name, and a baresshhost with no dot is left alone.authorityalready drops the port for SSH transports, so the resolved host is portless.Scope change since the first version (read before merging). The first version stripped
ssh.from every SSH remote. Review showed that can send an independent forge's clone to the wrong host. Nowssh.<host>maps to<host>only when<host>is a configured Fjord Account instance URL (the destinationroute()already matches). Nothing else maps:ssh.<host>remote no longer auto-map. They keep the name the remote has. An explicit--hostor-Rstill works as before.ssh.<name>keeps its own name, even beside a Fjord instance at<name>.<host>also has a PAT host entry, the pairing is ambiguous (route()prefers the PAT entry over the gateway), so the remote keeps its name.web_urland--hostare not treated as evidence of the ssh relationship.Tests: parse-level cases for
ssh://and scp remotes (known and unknown parent, web port, configuredssh.host, httpsssh.host, baressh), and a discovery test that runsdiscover()over a real temporary git repository andhosts.tomlfor the Fjord Account, PAT-only,web_url, nothing-configured,--host, other-instance, stale-PAT andssh.<name>cases. The Fjord-instance case fails when the instance URLs are dropped from the known set.Automated Codex review (read-only) of head
2545cb257f.src/git/remote.rs:144. Invariant: Repository inference must preserve the actual forge identity unless there is evidence that the SSH endpoint maps to a different web host. Both SSH URL and scp remotes unconditionally removessh.for every Forgejo or Gitea server, althoughfjsupports independent self-hosted forges. For a forge serving both SSH and web traffic atssh.example.com,git@ssh.example.com:owner/repo.gitnow selectsexample.com. Commands can fail authentication or act on a same-named repository on that other host;--host ssh.example.comalso fails remote discovery. This regression belongs in this PR because the new mapping causes it. Restrict the mapping to known Fjord destinations or an explicit configured mapping, and preserve the original host when the relationship is unknown. Test both SSH forms and preferred-host discovery for an independent forge.BLOCKING: 1
Reviewed head
2545cb257fat 2026-11-29T21:45:02Z by codex exec (read-only sandbox).Automated Codex review (read-only) of head
e0b5441e58.Medium src/config/hosts.rs: Invariant: a resolved clone host must route to the configuration and credentials that established it.
forge_destinationstreats a PAT host’sweb_urlas evidence for strippingssh., butmetadata::routedoes not match PATweb_urlvalues. For a supported PAT configuration whose stored key differs from its web URL, a clone atgit@ssh.forge.example:o/r.gitnow resolves toforge.example, then routes to a default, unconfigured host instead of the PAT entry. Repository commands can fail authentication or use the wrong configuration. This is newly reachable through both discovery and pinned-remote parsing in this PR. Route PAT web URLs to their owning configuration with ambiguity checks, and test through the command routing boundary.Medium src/git/remote.rs: Invariant: inferred repository identity must not change merely because an unrelated forge is configured. Knowing that
exampleis a forge does not establish thatssh.exampleis its SSH endpoint. A user with a configuredexampleforge who clones a separate forge hosted atssh.examplewill have commands directed toexample; a matching owner and repository slug can cause mutations on the wrong repository. The same inference applies to discovery and pinned remotes. Require an authoritative SSH-to-web mapping, or restrict the transform to an established Fjord relationship, and test the distinct-forge case when only the parent is configured.Low src/git/remote.rs: Invariant: a configuration read failure must not be treated as an empty configuration. If the second
Hosts::loadfails after a command has loaded its configuration, discovery silently keeps the SSH hostname and can route differently from the command’s existing snapshot. This is an edge case involving a concurrent configuration change or read failure. Pass the already loaded configuration into discovery and propagate read errors at entry points that lack a snapshot.BLOCKING: 2
Reviewed head
e0b5441e58at 2026-11-30T20:06:21Z by codex exec (read-only sandbox).Follow-up, not in this PR:
KnownForges::configured()readshosts.tomlagain insidediscoverandpinned_remote, whileresolve_repoalready holds a loadedHostssnapshot. If the file changes between the two reads (another terminal switching the selected instance), inference and routing could disagree, and a read failure silently falls back to "nothing configured", which keeps the ssh name. The fix is to pass the loadedHostsinto both discovery paths and propagate read errors where no snapshot exists. Gerri and self-review both raised it as a Low.Automated Codex review (read-only) of head
22e75c213f.No actionable findings found.
BLOCKING: 0
Reviewed head
22e75c213fat 2026-11-30T20:33:52Z by codex exec (read-only sandbox).