Route browser, mute and work context through named profiles (#157 step 2b-ii) #310
Loading…
Reference in a new issue
No description provided.
Delete branch "fj-157-profile-maintenance"
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?
Step 2b-ii of #157: browser shortcuts, mute and inbox filtering and the work and status instance display now read the selected named profile instead of the legacy host. Scoped session cookies, logout and maintenance are step 2b-iii; the work sessions stay deferred. #157 stays open.
Inferred clone destinations are routed against the selected account's own instance only, and a clone that points at a different instance than the selected one is refused before any request or mutation is sent. One authority function (lowercase host, port kept only when it is not the scheme default; http 80 and https 443 collapse to the bare host; SSH transport ports are dropped) is shared by remote parsing, preferred-host discovery, routing, cached public destinations and PAT host keys, so explicit
--hostand inferred entry points agree.Pinned
fj.resolvedslugs now infer the destination from the clone too. If the highest-priority remote exists but cannot be parsed (for example a path-mounted URL), the command fails instead of falling back to the default host; a clone with no remote still falls back, an unparseable lower-priority backup remote is ignored, and--hostand-Rstay the overrides.Existing hosts.toml entries are not migrated. Stored host keys are matched ignoring ASCII case (two keys that differ only by case are refused as ambiguous),
--hostresolves through the same match, and a PAT login for a host that already has an entry under another casing updates that entry in place, so a legacyFORGE.EXAMPLEkey keeps its credentials and no lowercase twin appears.Failure paths
--host, pinned and unpinned, with exactly 36 authenticated requests on the direct mock and zero on the trap.Review state: the pinned backup-remote fix and the first legacy host key fix were not re-reviewed after the third local self-review round. The later changes (authority-only case folding with exact keys first, stored-key use in named PAT login and proxy setup, and the Fjord session in the legacy host fixture) got one more local round. Its one Medium is a known limit, below.
Known limit: a PAT host configured with a mount path (for example
https://forge.example/forgejo) plus a pinnedfj.resolvedslug and a clone remote under that mount now fails with the discovery error ("cannot infer the instance") instead of using the default host. This is the same refusal rule as for any unparseable remote;--hostand-Roverride it. Mount-aware inference is not part of this PR.Size: the PR is 1,308 gross added lines, accepted by the lead. Splitting it now would cost more than it saves.
Offline tests only: profile_consumers, auth_profiles, account_override, legacy_host_key, and the config, client::resolve, cli::auth and git unit tests. Live browser behaviour is unchecked.
Automated Codex review (read-only) of head
b9e6b9a27e.Medium
src/config/metadata.rs:36,src/cli/context.rs:81,127,src/config/muted.rs:121: Invariant: API credentials, browser destinations and mute state must use the same stored host identity (standards 16 and 17). Client resolution now matches host keys case-insensitively, but these consumers retain exact lookups and the supplied spelling. With a supported legacyLOCALHOST:3000entry containingweb_url = "http://localhost:3000",fj --host localhost:3000 issue list -R o/r --webconnects using the stored configuration, then constructs the browser URL from an empty default configuration, opening HTTPS instead. Mute, unmute, muted and inbox filtering likewise use a separate lowercase scope, ignoring existing mutes. Named profiles also lose their metadata on this path; unpinned Fjord discovery can incorrectly filter by the platform host. This belongs in this PR because its new case-insensitive client lookup makes these inconsistent paths reachable. Resolve the stored key once and propagate it through discovery, profile lookup, browser metadata and scope hashing. Extend the legacy-key integration test to cover these consumers.Low (edge case)
src/cli/context.rs:122: Invariant: routing, credentials and browser metadata must describe one configuration snapshot. The independently loaded snapshots can mix accounts or instances during a concurrent switch. This is the unchanged concurrency deferral acknowledged in the PR body, not a blocking regression. Follow up by passing one resolved snapshot through client and metadata construction.BLOCKING: 1
Reviewed head
b9e6b9a27eat 2026-11-11T01:04:16Z by codex exec (read-only sandbox).Automated Codex review (read-only) of head
bb7c6f4ed8.Medium:
src/config/metadata.rs:35,src/cli/context.rs:83,127,src/config/muted.rs:121. Invariant: API routing, browser destinations and mute persistence must use the same resolved host identity (standards 11 and 17). The client now matches stored keys ignoring case, but these consumers still perform exact lookups or retain the original flag spelling. With the explicitly supported legacy keyFORGE.EXAMPLEand a configuredweb_url,fj --host forge.example issue list -R o/r --webauthenticates using the stored entry but builds the browser URL from an empty default configuration, losing its scheme, port or mount path. The same mismatch splits mute/unmute/muted and inbox filtering into different scopes depending on flag casing. For a Fjord gateway, the discovery lookup can also misclassify it as PAT and reject its instance remote. This belongs in this PR because its new case-insensitive client resolution makes these inconsistent paths reachable. Resolve the stored key once and carry it through discovery, metadata lookup, browser construction and mute hashing. Extend the legacy-key integration test beyondapi userto cover these consumers.Low:
src/cli/context.rs:126, edge case. Invariant: routing, credentials and browser metadata should describe one configuration snapshot (standard 7). The separately loaded snapshots can mix accounts or instances during a concurrent switch. This is the unchanged concurrency deferral already identified in the PR body; it remains follow-up work.BLOCKING: 1
Reviewed head
bb7c6f4ed8at 2026-11-11T01:12:08Z by codex exec (read-only sandbox).Automated Codex review (read-only) of head
42b54abd1e.Medium
src/cli/auth_login.rs:1083: Invariant: login and credential lookup must preserve one stored host identity. Lowercasing PAT host keys also affects named login insrc/cli/invocation_profiles.rs, which still uses exact lookup and never callsexisting_key. With a legacyFORGE.EXAMPLEentry, runningfj auth login --host FORGE.EXAMPLE --account alice --with-tokennow createsforge.examplealongside it. Subsequent explicit API, browser and mute commands fail becauseexisting_keyrejects the pair as ambiguous. This breaks the supported legacy-to-profile migration and is introduced by this PR’s normalization change. Resolve the stored key in named PAT login before config, credential and profile lookup or publication. Extendlegacy_host_keyto exercise named login.Low
src/config/metadata.rs:73: Edge case. Invariant: authority normalization must preserve case-sensitive URL paths.existing_keycompares the entire stored key ignoring case, including mount paths supported by PAT login. Withforge.example/Teamconfigured,--host forge.example/teamsilently selects/Team; if both are configured, lookup refuses them as ambiguous. This affects client resolution, browser shortcuts, mute scopes and legacy PAT login. Compare authorities ignoring case while comparing mount paths exactly.Low
src/cli/context.rs:118: Edge case. Invariant: routing, credentials and browser destinations must share one selected-profile snapshot. The separate config loads retain the concurrent-switch risk acknowledged in the PR’s “Concurrency” deferral. No new normal-operation evidence makes that accepted follow-up blocking; resolve all three from one snapshot in that follow-up.BLOCKING: 1
Reviewed head
42b54abd1eat 2026-11-11T01:43:11Z by codex exec (read-only sandbox).Automated Codex review (read-only) of head
fb7bdaf755.Low (edge case),
src/config/metadata.rs:73: Invariant: ambiguous stored authorities must be refused consistently. The exact-key return bypasses ambiguity detection. With legacy entriesforge.exampleandFORGE.EXAMPLE, lowercase discovery silently selects the first entry, while explicit uppercase selects the second, potentially using different credentials or profiles.route()also bypasses the check at lines 96 and 102. This affects client resolution, browser routing, mute scopes, PAT/profile login and proxy setup. Fix by checking all authority-folded matches before accepting an exact key, preserving case-sensitive mount paths, and removing routing shortcuts that bypass that check. Add coverage where one ambiguous key exactly matches the input.Low (edge case),
src/cli/context.rs:119: Invariant: routing, credentials and browser metadata should use one configuration snapshot. The separately loaded snapshots can disagree during a concurrent account or instance switch. This is the unchanged concurrency deferral already documented under the PR’s “Failure paths”; retain it in the referenced follow-up. The eventual fix should carry one resolved selection through routing, client construction and metadata lookup.BLOCKING: 0
Reviewed head
fb7bdaf755at 2026-11-11T01:59:49Z by codex exec (read-only sandbox).