|
8 | 8 | - AgentScoreGate with full compliance policy (KYC + sanctions + age + jurisdiction) |
9 | 9 | - Custom on_denied composing commerce helpers: |
10 | 10 | * verification_agent_instructions for the canonical poll-and-retry instructions |
11 | | - * is_fixable_denial to branch fixable (KYC re-do) vs unfixable (sanctions/age) |
| 11 | + * is_fixable_denial defensive fallback for fixable (KYC re-do) vs unfixable |
| 12 | + (sanctions / age / jurisdiction_restricted) compliance fails. Gate normally |
| 13 | + re-routes fixable reasons to identity_verification_required upstream — this |
| 14 | + branch only fires if the /v1/sessions mint blipped. |
12 | 15 | * build_contact_support_next_steps for the unfixable branch |
13 | 16 | * denial_reason_to_body + denial_reason_status for the standard fall-through |
14 | 17 | (token_expired, invalid_credential, api_error get the right status + body for free) |
@@ -76,11 +79,17 @@ def _on_denied(_request: Request, reason: DenialReason) -> tuple[dict[str, Any], |
76 | 79 | body["agent_instructions"] = VERIFICATION_INSTRUCTIONS |
77 | 80 | return body, 403 |
78 | 81 |
|
79 | | - # wallet_not_trusted = compliance fail. Branch on fixable vs not — fixable (KYC pending/failed/ |
80 | | - # required, jurisdiction) gets a fresh session; unfixable (sanctions, age) gets contact-support. |
| 82 | + # wallet_not_trusted = UNFIXABLE compliance fail (sanctions / age / jurisdiction_restricted). |
| 83 | + # The gate auto-routes fixable reasons (kyc_required / kyc_pending / kyc_failed) to |
| 84 | + # identity_verification_required upstream — by the time on_denied sees wallet_not_trusted, |
| 85 | + # the reasons should be unfixable. The is_fixable_denial branch below is a defensive |
| 86 | + # fallback in case the gate's /v1/sessions mint blipped and fell back to bare denial. |
81 | 87 | if reason.code == "wallet_not_trusted": |
82 | 88 | reasons = reason.reasons or [] |
83 | 89 | if is_fixable_denial(reasons): |
| 90 | + # Defensive: gate normally bootstraps these into identity_verification_required. |
| 91 | + # If we hit this branch, the gate's /v1/sessions mint failed — surface verify_url |
| 92 | + # so the agent can recover via the manual session flow. |
84 | 93 | return { |
85 | 94 | "error": {"code": "compliance_recoverable", "message": "Re-verify identity and retry."}, |
86 | 95 | "reasons": reasons, |
|
0 commit comments