Add verified PAT account profiles and explicit default selection (#157 step 2a) #308

Merged
stephen merged 3 commits from fj-157-account-profiles into main 2026-11-10 17:34:40 +00:00
Owner

Step 2a of #157: named, verified PAT account profiles stored next to the existing host entries, plus explicit default selection. Fjord gateway sessions, OIDC refresh/locking, instances and cookies are step 2b, a separate change; #157 stays open until both land.

Each host can now carry named account descriptors (keyed by the exact configured host and the canonical login) and a default pointer under accounts.<host> in hosts.toml; host URL, API mount and proxy settings stay host-level. fj auth login --account <name> verifies the login with /user, stages a fresh credential under a host/account/pat/generation key, reads it back, and only then atomically publishes the descriptor, so a failed stage, read-back or rename leaves the old metadata and credential untouched. Updating a profile adds a new immutable generation instead of overwriting the live one. A named login without a new token migrates the matching legacy credential after verification, and never switches a different default; fj auth switch <host> --account <name> re-verifies the stored credential and fences the verified host snapshot before moving the pointer. With --account, an eligible environment PAT is used first, otherwise exactly that profile; a missing profile or credential never falls back to another account or host. Legacy host fields and credential keys are retained for at least a release, with no cleanup code.

The review rounds also closed: named login reads --with-token stdin exclusively so another host's FJ_TOKEN can never reach the new host; the maintenance commands (token, refresh, session, setup-git, logout) refuse profiled hosts through the same host resolver the handlers use, and setup-git on a profiled host is rejected with a migration note because the old helper cannot pick an account; all file-backed token writes share one lock; legacy saves reload under the publication lock and apply only their own change; and account names stay out of --debug keychain diagnostics.

Status shows configured counts and a redacted default state. Tests (22 unit, workflow, recovery, overlapping-writer, debug-stderr and sole-host cases) run offline against the 0600 file store with dummy credentials; OS keychain integration and CI coverage are still to be confirmed.

Step 2a of #157: named, verified PAT account profiles stored next to the existing host entries, plus explicit default selection. Fjord gateway sessions, OIDC refresh/locking, instances and cookies are step 2b, a separate change; #157 stays open until both land. Each host can now carry named account descriptors (keyed by the exact configured host and the canonical login) and a default pointer under `accounts.<host>` in `hosts.toml`; host URL, API mount and proxy settings stay host-level. `fj auth login --account <name>` verifies the login with `/user`, stages a fresh credential under a host/account/pat/generation key, reads it back, and only then atomically publishes the descriptor, so a failed stage, read-back or rename leaves the old metadata and credential untouched. Updating a profile adds a new immutable generation instead of overwriting the live one. A named login without a new token migrates the matching legacy credential after verification, and never switches a different default; `fj auth switch <host> --account <name>` re-verifies the stored credential and fences the verified host snapshot before moving the pointer. With `--account`, an eligible environment PAT is used first, otherwise exactly that profile; a missing profile or credential never falls back to another account or host. Legacy host fields and credential keys are retained for at least a release, with no cleanup code. The review rounds also closed: named login reads `--with-token` stdin exclusively so another host's `FJ_TOKEN` can never reach the new host; the maintenance commands (token, refresh, session, setup-git, logout) refuse profiled hosts through the same host resolver the handlers use, and setup-git on a profiled host is rejected with a migration note because the old helper cannot pick an account; all file-backed token writes share one lock; legacy saves reload under the publication lock and apply only their own change; and account names stay out of `--debug` keychain diagnostics. Status shows configured counts and a redacted default state. Tests (22 unit, workflow, recovery, overlapping-writer, debug-stderr and sole-host cases) run offline against the 0600 file store with dummy credentials; OS keychain integration and CI coverage are still to be confirmed.
gerri approved these changes 2026-11-10 17:16:52 +00:00
gerri left a comment

Automated Codex review (read-only) of head 8d1ccf0930.

No real findings against the diff or ~/fleet-week/STANDARDS.md. Profile selection, credential maintenance guards, and publication paths preserve the stated invariants.

cargo fmt --all -- --check passed. Builds and tests were not run.

BLOCKING: 0

Reviewed head 8d1ccf0930 at 2026-11-10T17:16:52Z by codex exec (read-only sandbox).

Automated Codex review (read-only) of head 8d1ccf0930510520258ab52cc958f304fb0d01f4. No real findings against the diff or `~/fleet-week/STANDARDS.md`. Profile selection, credential maintenance guards, and publication paths preserve the stated invariants. `cargo fmt --all -- --check` passed. Builds and tests were not run. BLOCKING: 0 --- Reviewed head 8d1ccf0930510520258ab52cc958f304fb0d01f4 at 2026-11-10T17:16:52Z by codex exec (read-only sandbox).
Sign in to join this conversation.
No description provided.