feat(a2a): formalize agent-to-agent payment protocol spec + fix tests#25
Open
kite-builds wants to merge 1 commit intokcolbchain:mainfrom
Open
feat(a2a): formalize agent-to-agent payment protocol spec + fix tests#25kite-builds wants to merge 1 commit intokcolbchain:mainfrom
kite-builds wants to merge 1 commit intokcolbchain:mainfrom
Conversation
Closes kcolbchain#2 ("Add agent-to-agent payment protocol"). Changes: 1. docs/agent-payment-protocol.md — RFC-style v1.0 spec covering: - Message format (every PaymentRequest field with type + required-ness) - Canonical wire encoding (sort_keys + tight separators) - Content-hash semantics (excludes created_at, status) - State machine + lifecycle diagrams (happy path + refund path) - Multi-chain considerations (EIP-155 chain_id, CAIP-2 future work) 2. src/payment_protocol.py: PaymentRequest.content_hash() now excludes created_at and status so two requests representing the same payment intent hash identically. Previously the hash drifted with wall-clock time, which contradicted the dataclass docstring's "content-based hash for integrity check" promise. 3. src/payment_protocol.py: parse_wei("N wei") now returns N. The unit dict had a lowercase "wei" key while .upper() was applied to the incoming unit, so "wei" silently fell through to the ETH default and returned N * 10**18. Both tested. 4. tests/test_payment_protocol.py: fix syntax error (`def/events`) that prevented the entire file from being collected, and add the missing MockEvents stub the test infrastructure expected. Test status: 50/50 passing in tests/ excluding test_nonce_manager.py (which has a pre-existing missing-dep issue unrelated to this PR).
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
Closes #2.
Three concrete things, all grounded in the actual code:
1. New RFC-style spec at
docs/agent-payment-protocol.mdFormalizes what was implicit in
src/payment_protocol.py:PaymentRequestfield with type, required-ness, and meaningsort_keys=True+ tight separators) so the JSON is byte-deterministiccontent_hashsemantics — excludescreated_atandstatusso two requests for the same payment intent hash identicallychain_id; future: CAIP-2 for non-EVM)2. Fix
content_hashdeterminism insrc/payment_protocol.pyPreviously the hash included
created_at(Unix epoch fromtime.time()), so twoPaymentRequestobjects with identical payment data but different instantiation times produced different hashes. That contradicted the docstring's "content-based hash for integrity check" promise.New behavior:
content_hashexcludescreated_atandstatus. For replay protection, agents should userequest_id(UUID) — that's what it's there for.3. Fix
parse_wei("N wei")insrc/payment_protocol.pyparse_wei("1000000000000000000 wei")was returning10^36, not10^18. Fix: uppercase the dictionary keys.4. Make
tests/test_payment_protocol.pycollectibleThe file had
def/events(self):(literal/in a method name) on line 56, which made the whole file aSyntaxErrorand preventedpytestfrom collecting any of the 10 tests in it. Fixed and added the missingMockEventsstub the file referenced.Test results
test_nonce_manager.pyhas a pre-existing missing-dep issue (sortedcontainersnot in any requirements file) that's outside this PR's scope.What this PR does NOT cover
Issue #2 mentions "multi-chain support" as a goal. v1.0 of the spec explicitly captures EIP-155
chain_idand flags CAIP-2 chain identifiers as future work in §7 / §9. Implementing actual non-EVM settlement (Solana, Stellar) is a separate larger PR — happy to follow up if you want a v1.1 design proposal.