Skip to content

Commit de9784e

Browse files
vvillait88claude
andcommitted
fix: add invalid_credential to DenialCode union
The commerce gate emits `invalid_credential` on 401 (separate from token_expired — permanent state, no auto-session). Tests already exercise this code path but the DenialCode literal was missing it; type checkers would flag any branch on this value as unreachable. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d284bdc commit de9784e

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

agentscore/types.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -338,23 +338,32 @@ class AssociateWalletResponse(TypedDict):
338338

339339

340340
DenialCode = Literal[
341-
"operator_verification_required",
342-
"compliance_denied",
343-
"compliance_error",
344-
"wallet_not_trusted",
341+
# Gate-emitted codes from commerce middleware (canonical 9-element union)
345342
"missing_identity",
346343
"identity_verification_required",
347-
"payment_required",
348-
"api_error",
349-
"kyc_required",
350-
# Wallet-signer binding — claimed X-Wallet-Address must resolve to the same operator
351-
# as the payment signer; wallet-auth is rejected on rails with no wallet signer.
352-
"wallet_signer_mismatch",
353-
"wallet_auth_requires_wallet_signing",
354344
# Credential is no longer valid (revoked or past its TTL — the two cases share this
355345
# code deliberately so the API doesn't leak which one). The 401 body carries an
356346
# auto-minted session so agents recover without holding an API key.
357347
"token_expired",
348+
# Credential doesn't exist at all (typo, fabricated, never minted). Permanent state;
349+
# no auto-session is issued because the agent may have other valid tokens to try.
350+
"invalid_credential",
351+
# Wallet-signer binding — claimed X-Wallet-Address must resolve to the same operator
352+
# as the payment signer; wallet-auth is rejected on rails with no wallet signer.
353+
"wallet_signer_mismatch",
354+
"wallet_auth_requires_wallet_signing",
355+
"wallet_not_trusted",
356+
"api_error",
357+
"payment_required",
358+
# Merchant-emitted convenience codes (e.g. martin-estate's on_denied wraps gate
359+
# denials into wine-specific business codes). Not emitted by the AgentScore API
360+
# itself but appear in 4xx bodies the SDK may surface back to callers.
361+
"operator_verification_required",
362+
"compliance_denied",
363+
"compliance_error",
364+
# Decision-reason code surfaced in error.code by some merchants — kept for back-compat
365+
# with merchants that flatten policy reasons into the error envelope.
366+
"kyc_required",
358367
]
359368
"""Denial codes returned by the gate in 403/402 error bodies. Lets agents pick the right
360369
remediation without natural-language parsing."""

0 commit comments

Comments
 (0)