Fix #85: alert via ntfy when Claude CLI authentication fails#88
Open
ClaydeCode wants to merge 1 commit into
Open
Fix #85: alert via ntfy when Claude CLI authentication fails#88ClaydeCode wants to merge 1 commit into
ClaydeCode wants to merge 1 commit into
Conversation
Distinguish Claude authentication failures from usage/rate limits in the availability pre-check so an expired/replaced credentials situation no longer silently skips work every cycle. - claude.py: add ClaudeStatus enum; rename backend is_available() -> check_availability() returning AVAILABLE / USAGE_LIMIT / AUTH_FAILED; add module-level check_claude_availability() (is_claude_available() kept as a bool wrapper). - orchestrator.py: on AUTH_FAILED send a one-shot high-priority ntfy alert and skip; on USAGE_LIMIT keep existing silent skip. The latch is cleared once Claude is reachable again so a future failure re-alerts. - state.py: persist the notified latch in a top-level claude_auth_failure_notified flag (get/set helpers) so the alert fires once per failure streak rather than every cycle. - Update README + CLAUDE.md; add tests. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
When Claude CLI credentials expire or are replaced, the availability pre-check returned
Falsefor both auth failures and usage limits, so Clayde silently skipped all work every cycle with no notification. This PR distinguishes the two failure modes and alerts the operator on auth failure.What changed
claude.py— added aClaudeStatusenum (AVAILABLE/USAGE_LIMIT/AUTH_FAILED). The backend pre-check methodis_available()is renamed tocheck_availability()and now returns aClaudeStatus. A new module-levelcheck_claude_availability()exposes this;is_claude_available()is kept as a thin bool wrapper for callers that don't need the distinction.orchestrator.py—main()now branches on the status:AUTH_FAILED→ send a high-priority (Priority: 5, 🚨) ntfy alert titled "Clayde: Claude CLI auth failed" via the existing ntfy infra, then skip the cycle.USAGE_LIMIT→ existing behaviour (silent skip, retried next tick).AVAILABLE→ clear the alert latch so a future failure re-alerts.state.py— the alert fires once per failure streak, tracked by a top-levelclaude_auth_failure_notifiedflag instate.json(get_claude_auth_notified()/set_claude_auth_notified()). It re-arms when Claude becomes reachable again.All 353 tests pass.
Closes #85
Recommended reading order
src/clayde/claude.py— theClaudeStatusenum and the renamedcheck_availability()backends (the core distinction).src/clayde/state.py— the once-per-streak latch helpers.src/clayde/orchestrator.py—_notify_claude_auth_failure()and the newmain()branching that ties it together.tests/test_claude.py,tests/test_orchestrator.py,tests/test_state.py— coverage for each piece.README.md,CLAUDE.md— docs.🤖 Generated with Claude Code