mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
Two callers refreshing one Codex token raced: the loser heard refresh_token_reused, read it as a dead grant and parked the connection before the winner wrote its rotated tokens, leaving fresh tokens beside an expired status. Refreshes now share one flight per process and queue on the per-credential advisory lock across processes, re-read the row inside it, use a token a peer already rotated, write the rotated tokens compare-and-set on the spent one together with connected, and re-read after a refusal before parking. refresh_token_reused no longer counts as a dead grant, and neither does a bare 403 without an OAuth error code: an edge challenge answers a valid grant so, and it keeps the ledger's timed cooldown instead of parking until the next sign-in.