Lock PAT profile replacement and fence pasted-token refresh (CLS-1267) #316
Loading…
Reference in a new issue
No description provided.
Delete branch "stephen/cls-1267-replacement-lock"
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?
CLS-1267 item 2 (the lock and the refresh fence). Old-generation cleanup is a separate PR.
profile_sessionimport, clear and logout take a per-account lock and check the profile generation. PAT login and pasted-token refresh published throughprofiles::storewithout it, so a replacement could interleave with a stale destructive operation.profiles::storenow takes the same lock (fjord_scope::lock, keyed by host and account) around staging and publishing.auth refresh --tokencaptured the profile it verified but published without checking it was unchanged. It now goes throughstore_fenced, which re-checks the generation before staging, inside the lock, and again inside the publish edit. A logout or replacement in between wins, and the refresh fails with "profile changed; retry" with nothing written. Plainauth loginreplacement keeps last-writer-wins.Tests (config dir and keychain isolated in a child process): a stale
profile_session::logoutafter a replacement is refused and leaves the new secret readable; a fenced store publishes when unchanged and, when stale, is refused with the token file unchanged; a replacement blocks while another holder has the account lock (confirmed to fail with the lock line removed).Not here: a failed cleanup still loses the staged key's identity (deletion errors are ignored), which self-review flagged as Low. That belongs with the old-generation cleanup PR, where a retired-generation list needs a hosts.toml schema field; I am asking the lead before adding that. Touches only
src/config/profiles.rs,src/cli/profile_maintenance.rsand tests, and fj-cl confirmed it is not editing those.Automated Codex review (read-only) of head
0508b4a78a.No high or medium findings.
BLOCKING: 0
Reviewed head
0508b4a78aat 2026-11-11T16:39:29Z by codex exec (read-only sandbox).