feat(zap): ZAP wire v1.0 — handshake/seq/retry/FIN session layer + spec + vectors (#85)#129
Open
Pattermesh wants to merge 1 commit into
Open
feat(zap): ZAP wire v1.0 — handshake/seq/retry/FIN session layer + spec + vectors (#85)#129Pattermesh wants to merge 1 commit into
Pattermesh wants to merge 1 commit into
Conversation
Add the connection-level ZAP wire v1.0 session semantics that sit under the existing PaymentOffer/PaymentProof codecs. Pure-Python, no zap_py dependency. Spec (docs/zap-wire-spec-v1.0.md): 26-byte frame header (magic 0x5A50, wire version, frame type, flags, per-direction u32 seq, cumulative u32 ack, u64 request_id, length-prefixed payload); HELLO/WELCOME handshake; capability bitmask = 8 bits version + 24 bits feature flags (baseline 0x0100001F); cumulative ACK; configurable-RTT retry with exponential backoff; request_id idempotency/dedup; graceful FIN with orphaned-sequence handling; RST error codes; full state machine. Code (switchboard/zap_transport.py): SessionFrame encode/decode, capability make/negotiate helpers, and the ZapSession state machine (handshake, in-order + reorder-buffered delivery, cumulative ack, retransmit queue with injectable clock, idempotent dedup, FIN/close + incomplete-gap detection). Tests: 25 new pure-Python tests in tests/test_zap_transport.py plus static byte-for-byte conformance vectors in tests/protocol_vectors/zap_session.v1.json. `python3 -m pytest tests/test_zap_transport.py -q` -> 28 passed, 36 skipped. Does not touch x402_middleware.py, gas_*.py, or lucidly. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| FRAME_RST, | ||
| } | ||
| # Frame types that consume sequence space (spec §5). | ||
| _SEQ_CONSUMING = {FRAME_HELLO, FRAME_WELCOME, FRAME_DATA, FRAME_FIN} |
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.
Implements ZAP wire v1.0 for #85: spec doc, pure-Python session state machine, conformance vectors, 25 TDD tests.
🤖 Generated with Claude Code