fix: gate CLI background usage fetch on confirmed-absent OAuth creds - #1
Merged
Conversation
Add directCredentialIsMissingOverride TaskLocal for deterministic testing and thread an oauthCredentialsConfirmedAbsent check into ClaudeCLIBackgroundAvailability.allowsBackgroundAutoUsageFetch so the CLI background fallback only proceeds when direct OAuth credentials are confirmed absent. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqBGFKF9M8etkRpgz2bk2Z
allowsBackgroundAutoUsageFetch's deadlock-breaker only checked isEstablished(), which drops a marker as soon as it's revoked by a failed foreground fetch. That let the OAuth-absence probe re-permit a background CLI usage attempt on every tick after a failure, defeating the existing revocation/backoff guarantee. Check isRevoked() before falling through to oauthCredentialsConfirmedAbsent so a revoked marker stays denied until the next foreground success. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqBGFKF9M8etkRpgz2bk2Z
allowsBackgroundAutoUsageFetch's deadlock-breaker could still fire for a profile ClaudeAccountProfile.identifiedSessionScope can't identify (missing/malformed/unreadable account config), since isEstablished and the round-1 isRevoked check both silently return false when captureMarker is nil. That let a background CLI fetch launch with no stable account binding, and a failed attempt could never be recorded as a revocation (revoke() needs a marker), so nothing would bound repeated launches. Require a non-nil marker before consulting oauthCredentialsConfirmedAbsent, matching the fail-closed contract identifiedSessionScope already documents for background work. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HqBGFKF9M8etkRpgz2bk2Z
Owner
Author
🔍 Local review (cycle 3/3, final) — round a4f67011-f2ea-4bdb-a3c3-1b6e0d0f6b5aReviewed locally (
No FIX or UNVERIFIED findings this round. Cycle complete. |
Owner
Author
📋 Review summary — all cycles
Totals: 2 FIX (both resolved), 6 SKIP, 1 HALLUCINATION, 1 IRRELEVANT, 0 UNVERIFIED. Review complete after 3 cycles — no FIX or UNVERIFIED findings remain. Per the review-only-on-merge policy, merging is a manual step for the PR author. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
directCredentialIsMissingOverrideTaskLocal toClaudeOAuthFetchStrategyfor deterministic test overridesoauthCredentialsConfirmedAbsentcheck intoClaudeCLIBackgroundAvailability.allowsBackgroundAutoUsageFetchso the CLI background fallback only fires when direct OAuth credentials are confirmed absentTest plan
swift test🤖 Generated with Claude Code