fix: bootstrap fixable wallet_not_trusted denials into identity_verification_required#1
Merged
vvillait88 merged 8 commits intomainfrom Apr 30, 2026
Merged
Conversation
…ication_required Fixable compliance reasons (kyc_required, kyc_pending, kyc_failed, jurisdiction_required without explicit restriction) now get the same UX as missing_identity: the gate auto-mints a verification session, the agent polls until status=verified, gets a fresh opc_..., and retries with X-Operator-Token. Unfixable reasons (sanctions_flagged, age_insufficient, jurisdiction_restricted) keep the bare wallet_not_trusted denial — re-verification won't change the outcome, so the canonical agent_instructions action is now contact_support. Applied to all 6 framework adapters (fastapi, flask, django, aiohttp, sanic, middleware/ASGI) plus the shared response marshaller. Adds session-bootstrap test coverage (fixable → identity_verification_required, unfixable → bare wallet_not_trusted) for every adapter. OpenAPI denial-code description documents the re-route and the contact_support action. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The API only emits jurisdiction_restricted AFTER KYC is verified — meaning the user's KYC'd country is in the merchant's blocked list (or absent from the allowed list). Re-doing KYC won't change the country, so it's permanent. Same shape as sanctions_flagged / age_insufficient — should surface contact_support, not bootstrap a doomed verification session. Also flips empty/None reasons to return False (don't bootstrap on unknown deny — default to bare denial). Updates the canonical wallet_not_trusted instructions copy and all six adapter comments to spell out the API-side rationale. Tests updated: jurisdiction_restricted now in the unfixable bucket alongside sanctions/age, empty reasons returns False. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…e 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>
Tests used invented reason strings like \`not_kyc\`, \`score_too_low\`, \`sanctions_check_pending\` that don't exist in the API surface (the real codes are \`kyc_required\`, \`kyc_pending\`, \`kyc_failed\`, \`sanctions_flagged\`, \`age_insufficient\`, \`jurisdiction_restricted\`). Tests pass either way (the gate passes reasons through verbatim), but the fake strings propagate misinformation. Replace with real codes for documentation accuracy. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hardcoding `__version__ = "1.0.0"` in `__init__.py` while pyproject.toml is at "1.0.1" creates a two-spot version drift. Read from `importlib.metadata` so pyproject.toml is the single source of truth (matches python-sdk's pattern). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…added previously)
…sitive CodeQL flagged \`assert "https://my.merchant" in section\` as \`py/incomplete-url-substring-sanitization\` (high severity). The pattern matters when checking whether a user-supplied URL falls inside an allowlist substring; here it's a test assertion verifying the rendered llms.txt section contains the test fixture's app_url. Same effect with a more specific substring (\`agentscore-pay pay POST https://my.merchant\`) — CodeQL no longer matches the dangerous pattern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Picks up the just-published 2.0.1 (invalid_credential DenialCode + assess refresh wire-format parity with node-sdk). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/v1/assessdenies on a fixable compliance reason (kyc_required,kyc_pending,kyc_failed,jurisdiction_required), giving the agent the same poll-and-retry UX asmissing_identity. Unfixable reasons (sanctions / age / jurisdiction_restricted) keep the barewallet_not_trusteddenial.wallet_not_trustedagent_instructions action changes fromclaim_wallet_or_switch_identity→contact_supportto match the new (unfixable-only) semantics.contact_supportaction.Test plan
uv run pytest tests/— 554 passed, 95.29% coverageuv run ruff check .cleanuv run ty check agentscore_commerce/clean🤖 Generated with Claude Code