The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): cover unsigned OAuth latch vs needsOauthLogin-only retry
HexLab9819e56b446b9d
diff --git a/apps/desktop/electron/backend-health.test.ts b/apps/desktop/electron/backend-health.test.tsindex a23ba5a73be..71ff6924e79 100644--- a/apps/desktop/electron/backend-health.test.ts+++ b/apps/desktop/electron/backend-health.test.ts@@ -11,6 +11,7 @@ import {isReauthRequiredError,isServerSideHttpError,makeNousCloudBackendDownError,+ makeUnsignedOauthError,waitForHermesReady} from './backend-health'@@ -219,6 +220,20 @@ test('a credentialed 401 fails fast for reauth instead of reporting a dead sessiassert.deepEqual(calls, [['probe', 'https://gateway.example/api/health']])})+test('unsigned OAuth is a terminal reauth failure; needsOauthLogin alone is not', () => {+ // The unsigned-in throw must set isReauthRequired so startHermes latches.+ // needsOauthLogin alone (ticket 401/403) stays a Sign-in hint, not a latch —+ // a lapsed AT cookie can still rotate from a live RT on the next mint.+ const unsigned = makeUnsignedOauthError() as any++ assert.equal(unsigned.needsOauthLogin, true)+ assert.equal(unsigned.isReauthRequired, true)+ assert.equal(isReauthRequiredError(unsigned), true)+ assert.match(unsigned.message, /not signed in/i)+ assert.equal(isReauthRequiredError({ needsOauthLogin: true }), false)+ assert.equal(isReauthRequiredError(new Error('Could not reach the remote Hermes gateway')), false)+})+test('a credentialed 403 is also a terminal reauth failure', async () => {await assert.rejects(waitForHermesReady('https://gateway.example', {diff --git a/apps/desktop/electron/backend-start-failure.test.ts b/apps/desktop/electron/backend-start-failure.test.tsindex f612171f469..d92a2058bb5 100644--- a/apps/desktop/electron/backend-start-failure.test.ts+++ b/apps/desktop/electron/backend-start-failure.test.ts@@ -2,6 +2,7 @@ import assert from 'node:assert/strict'import { test } from 'vitest'+import { isReauthRequiredError, makeUnsignedOauthError } from './backend-health'import {isHostKeyChangedBootFailure,isRetryableRemoteBootFailure,@@ -69,6 +70,19 @@ test('a CONFIRMED reauth rejection is never auto-retried (missing capability, noassert.equal(isRetryableRemoteBootFailure({ attemptedRemote: true, isReauth: true }), false)})+test('unsigned OAuth latches and is never auto-retried; needsOauthLogin alone still retries', () => {+ // Production composition in startHermes: isReauth = isReauthRequiredError(error).+ const unsigned = isReauthRequiredError(makeUnsignedOauthError())+ const ticketHint = isReauthRequiredError({ needsOauthLogin: true })++ assert.equal(unsigned, true)+ assert.equal(shouldLatchRemoteReauthFailure({ attemptedRemote: true, isReauth: unsigned }), true)+ assert.equal(isRetryableRemoteBootFailure({ attemptedRemote: true, isReauth: unsigned }), false)+ assert.equal(ticketHint, false)+ assert.equal(shouldLatchRemoteReauthFailure({ attemptedRemote: true, isReauth: ticketHint }), false)+ assert.equal(isRetryableRemoteBootFailure({ attemptedRemote: true, isReauth: ticketHint }), true)+})+test('local failures are never auto-retried by the remote self-heal loop', () => {assert.equal(isRetryableRemoteBootFailure({ attemptedRemote: false, isReauth: false }), false)assert.equal(isRetryableRemoteBootFailure({ attemptedRemote: false, isReauth: true }), false)