Skip to content

Commit 096dff7

Browse files
vvillait88claude
andcommitted
docs: clarify compliance_merchant.py example for new bootstrap-fixable architecture
The gate now re-routes fixable reasons (kyc_required/pending/failed) upstream, so by the time wallet_not_trusted reaches the merchant's on_denied, reasons should be unfixable. The is_fixable_denial branch in the example becomes a defensive fallback (only fires if the gate's /v1/sessions mint blipped). Also clarify jurisdiction_restricted is in the unfixable bucket alongside sanctions/age — the API only emits it after KYC is verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent b4140a7 commit 096dff7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

examples/compliance_merchant.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
- AgentScoreGate with full compliance policy (KYC + sanctions + age + jurisdiction)
99
- Custom on_denied composing commerce helpers:
1010
* 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.
1215
* build_contact_support_next_steps for the unfixable branch
1316
* denial_reason_to_body + denial_reason_status for the standard fall-through
1417
(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],
7679
body["agent_instructions"] = VERIFICATION_INSTRUCTIONS
7780
return body, 403
7881

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.
8187
if reason.code == "wallet_not_trusted":
8288
reasons = reason.reasons or []
8389
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.
8493
return {
8594
"error": {"code": "compliance_recoverable", "message": "Re-verify identity and retry."},
8695
"reasons": reasons,

0 commit comments

Comments
 (0)