feat(core): add agent-identity extension (ERC-8004) - #91
Conversation
Adds an opt-in `agent-identity` x402 v2 extension to r402-core behind the `ext-agent-identity` feature flag, binding an optional ERC-8004 agent id to a payment. The id is advertised to clients, validated (length, no whitespace/control chars), and surfaced in verify/settle responses so downstream treasuries and compliance hooks can attribute and gate spend per agent rather than per shared wallet. Chain-agnostic: the id is an opaque string (ERC-8004 registry is EVM-first, the binding is a plain field). Composes with any scheme. Refs qntx#87.
|
Can't merge this.
|
|
Confirmed on all three points — thanks for the direct review. Re-reading the trait contract after your note: Where we landed, matching your split: The right home for enforcement is the facilitator's verify step. The extension point the trait doesn't have today is a pre-result hook that can reject: a verifier trait resolved from the registry inside verify, returning Identity resolution belongs in qntx/erc8004 (per your cross-ref). We'd rather build that as an erc8004-side verifier/consumer of this SDK than wedge it into a wire extension. Plan from here — your call on all of it:
Noted on us for next time: protocol-level contributions here start at the trait/facilitator layer, not payload decoration. — GenTech Labs (production multi-facilitator x402 gateway; v1/v2 facilitator quirks) |
Implements the gap proposed in #87 — happy to adjust design per maintainer direction.
Summary
Adds an opt-in
agent-identityx402 v2 extension tor402-corebehind theext-agent-identityfeature flag, binding an optional ERC-8004 agent id to a payment:info.requiredplus a JSON schema toPaymentRequired.extensionsunder theagent-identitykey.agentId(length bound, no whitespace/control chars) and surfaces it in the response extensions, so downstream treasuries and compliance hooks can attribute and gate spend per agent instead of per shared wallet.eip155:1:0x…,urn:erc8004:agent:42, …). The ERC-8004 registry is EVM-first, but the binding is a plain field, so it composes with any scheme (exact,upto, …).Follows the existing extension patterns: module shape mirrors
payment-identifier,ext-*feature flag wired intoall-extensions/full, README feature-table row, CHANGELOG entry. On the open question in #87, the id rides the extensioninfoobject rather than a separate signed claim — it survives facilitator settlement without extra round-trips, and signing stays scheme-side.Testing
cargo test -p r402-core --features ext-agent-identity --lib→ 95 passed, 0 failed (10 new tests: wire shape, extraction variants, validation rules, hook behavior)cargo clippy -p r402-core --all-features --all-targets→ cleancargo fmt(stable) applied