Merge commit '8cd63706e245f1450b5c5b31afb28f7fd75e1d2a' into brennanb2025/claude-sdk-ready-mainsync

This commit is contained in:
Merge Sim
2026-09-03 15:28:56 -07:00
2 changed files with 16 additions and 0 deletions
@@ -70,6 +70,20 @@ describe('structuredClaudeMatchesActiveManagedAccount', () => {
).toBe(false)
})
/** Absent is not empty. An empty array is a real answer — the user has no managed accounts, so
* nothing claims an identity and the ambient path is legitimate. Settings with no accounts field
* are settings we failed to parse, which is the same epistemic state as unreadable. */
it('separates an empty account list from an absent one', () => {
expect(
structuredClaudeMatchesActiveManagedAccount(settings({ claudeManagedAccounts: [] }))
).toBe(true)
expect(
structuredClaudeMatchesActiveManagedAccount({
activeClaudeManagedAccountId: null
} as unknown as ClaudeManagedAccountGateSettings)
).toBe(false)
})
it('fails closed when the settings cannot be read at all', () => {
expect(structuredClaudeMatchesActiveManagedAccount(null)).toBe(false)
expect(structuredClaudeMatchesActiveManagedAccount(undefined)).toBe(false)
@@ -27,6 +27,8 @@ export function structuredClaudeMatchesActiveManagedAccount(
settings: ClaudeManagedAccountGateSettings | null | undefined
): boolean {
const accounts = settings?.claudeManagedAccounts
// Absent is not empty: an empty list is a real "no managed accounts" answer, but a missing field
// is settings we failed to parse, which is the same unknown as unreadable. Do not merge these.
if (!settings || !Array.isArray(accounts)) {
return false
}