fix: bootstrap fixable wallet_not_trusted denials into identity_verification_required#1
Merged
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. Implementation lives in core.ts (the shared evaluate() factory used by all 5 framework adapters): extracted tryMintSessionDenial helper, wired it into both the cache-hit deny branch and the fresh-fetch deny branch when reasons are fixable. New session-bootstrap test coverage (fixable → identity_verification_ required, unfixable → bare wallet_not_trusted). _response.ts canonical agent_instructions for wallet_not_trusted updated to contact_support copy. OpenAPI denial-code description documents the re-route + 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/undefined reasons to return false (don't bootstrap on unknown deny — default to bare denial). Updates the canonical wallet_not_trusted instructions copy and core.ts 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 onDenied, reasons should be unfixable. The isFixableDenial 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. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
\`sanctions_check_pending\` isn't a real API code. The real codes are kyc_required, kyc_pending, kyc_failed, sanctions_flagged, age_insufficient, jurisdiction_restricted. Test passes either way (gate passes reasons through verbatim), but the fake string propagates misinformation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Node 18 EOL'd April 2025; pay already declares >=20. Match the canonical floor across the publishable npm packages. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…added previously)
Picks up the just-published 2.1.0 (optional Subject.address + credential_prefix, optional CredentialListResponse.account_verification, invalid_credential DenialCode, engines.node >=20). Tests + lint + typecheck pass with the new version. 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.src/core.ts(the sharedevaluate()factory used by all 5 framework adapters): extractedtryMintSessionDenialhelper, wired into both cache-hit and fresh-fetch deny branches when reasons are fixable. New session-bootstrap tests intests/hono.test.ts.contact_supportaction.Test plan
bun run test --exclude '**/integration.test.ts'— 539 passedbun run lintcleanbun run typecheckclean🤖 Generated with Claude Code