diff --git a/plugins/memory/honcho/__init__.py b/plugins/memory/honcho/__init__.py index 9246f26b6e..cebc52a5be 100644 --- a/plugins/memory/honcho/__init__.py +++ b/plugins/memory/honcho/__init__.py @@ -1047,8 +1047,7 @@ class HonchoMemoryProvider(MemoryProvider): def _note_dialectic_failure(self, exc: BaseException) -> None: """Widen the empty-streak backoff after a failed dialectic cycle. - Auth failures are exempt: waiting cannot fix a dead token, and backoff - would delay recovery after the user re-authenticates. + Auth failures are exempt because waiting cannot fix a dead token. """ from plugins.memory.honcho.session import HonchoAuthError diff --git a/plugins/memory/honcho/oauth.py b/plugins/memory/honcho/oauth.py index cdd31daf66..02a1be0e55 100644 --- a/plugins/memory/honcho/oauth.py +++ b/plugins/memory/honcho/oauth.py @@ -304,11 +304,9 @@ def _exchange_refresh_token(cred: OAuthCredential, *, now: float) -> OAuthCreden def _exchange_with_retry(cred: OAuthCredential, *, now: float) -> OAuthCredential: - """Exchange the refresh token, retrying once immediately on transient failure. + """Exchange the refresh token, retrying once on transient failure. - The server honors a replayed refresh token only within a short grace - window after rotating it, so the retry must happen now — deferring to the - next memory call lands outside the window and revokes the grant. + The server accepts a replayed token only briefly after rotating it, so the retry cannot wait. """ try: return _exchange_refresh_token(cred, now=now) @@ -440,13 +438,9 @@ def ensure_fresh_token( def force_refresh_token(path: Path, host: str) -> str | None: - """Rotate ``host``'s access token now, ignoring local expiry math. + """Rotate ``host``'s access token now, ignoring local expiry. - Recovery path for a server-side 401 on a token the local clock still - considers valid (clock skew, server-side rotation, revocation). Returns - the new access token, or ``None`` when the host has no OAuth credential, - the grant is dead, or the exchange fails — callers surface the original - auth error in that case. + Recovers a 401 on a token the local clock still thinks is valid. """ now = time.time() key = (str(path), host) diff --git a/plugins/memory/honcho/session.py b/plugins/memory/honcho/session.py index 8e8db7e311..d8463ed6c5 100644 --- a/plugins/memory/honcho/session.py +++ b/plugins/memory/honcho/session.py @@ -26,18 +26,13 @@ _PEER_ID_HASH_ESCALATION_LENGTHS = (_PEER_ID_HASH_LEN, 12, 16, 24, 32, 64) class HonchoAuthError(RuntimeError): - """Auth failure that survived a forced token refresh and one retry. + """Auth failure that survived a forced refresh and one retry. - Raised instead of swallowed so callers can tell a rejected credential - apart from an empty result; cadence backoff must not count it as empty. + Raised, not swallowed, so callers can tell a rejected credential from an empty result. """ -# Text fallback for transports without a status attribute. Conservative on -# purpose: a false positive spends a refresh-token rotation, and a lost -# rotation response can permanently revoke the grant. A missed auth error -# only costs one un-recovered call. "authentication failed" (not bare -# "authentication") so auth-infrastructure outage messages stay transient. +# Matched narrowly: a false positive spends a token rotation, and a lost rotation revokes the grant. _AUTH_ERROR_MARKERS = ( "invalid or expired access token", "authentication failed", @@ -240,10 +235,9 @@ class HonchoSessionManager: return self._auth_failure def _reauth_required(self) -> bool: - """True when the OAuth grant is dead and only a new login can fix it. + """True when the grant is dead and only a new login can fix it. - Reads the config and compares the refresh-token digest, so a re-login - flips this back to False with no network call — recovery is immediate. + Compares the on-disk refresh-token digest, so a new login clears it with no network call. """ try: from plugins.memory.honcho import oauth @@ -257,11 +251,9 @@ class HonchoSessionManager: return False def _force_reauth(self) -> bool: - """Rotate the OAuth token after a server-side 401 and rebind the client. + """Rotate the token after a 401 and rebind the client. - Returns True when a fresh token was obtained and applied. False for - static API keys (no OAuth credential), a dead grant, or a failed - exchange — callers surface the original auth error in that case. + False for a static API key, a dead grant, or a failed exchange. """ try: from plugins.memory.honcho import oauth