Skip to content

feat: x402 carrier adapter and challenge type mapping #419

Merged
jithinraj merged 5 commits intomainfrom
feat/x402-carrier-adoption
Feb 23, 2026
Merged

feat: x402 carrier adapter and challenge type mapping #419
jithinraj merged 5 commits intomainfrom
feat/x402-carrier-adoption

Conversation

@jithinraj
Copy link
Member

Summary

  • Adds Evidence Carrier Contract (DD-124) adapter for @peac/adapter-x402
  • Carrier extraction from PEAC-Receipt HTTP header (offer/settlement responses)
  • toPeacCarrier() using shared computeReceiptRef() from @peac/schema (correction item 4)
  • ChallengeType taxonomy for cross-protocol normalization (payment for x402)

Changes

New files

  • src/carrier.ts: fromOfferResponse, fromSettlementResponse, async variants, X402CarrierAdapter
  • src/challenge.ts: ChallengeType, mapX402ToChallengeType
  • tests/carrier.test.ts: 22 tests

Modified files

  • src/map.ts: added toPeacCarrier() function
  • src/index.ts: re-exports carrier + challenge modules

Design decisions

  • DD-124: PeacEvidenceCarrier type placement
  • DD-127: x402 embed 64 KB / headers 8 KB
  • DD-129: Async extraction with receipt_ref consistency
  • Correction item 4: shared computeReceiptRef() (not local SHA-256)

Test plan

  • x402 carrier tests pass (22 new tests)
  • All existing x402 tests unchanged (95 total)
  • Full gate: build (77/77), lint, typecheck, test (174 files / 4268 tests)
  • guard.sh, check-planning-leak.sh pass

Stacked on

Ship PeacEvidenceCarrier types (Layer 0, zero runtime) and Zod schemas
with shared computeReceiptRef() helper (Layer 1). Includes carrier
conformance fixtures (5 valid, 3 invalid) and verifyReceiptRefConsistency()
for DD-129 async extraction enforcement.

- kernel: PeacEvidenceCarrier, CarrierAdapter<T,U>, CarrierMeta types
- kernel: PEAC_RECEIPT_HEADER canonical constant (DD-127)
- schema: ReceiptRefSchema, CompactJwsSchema, PeacEvidenceCarrierSchema
- schema: computeReceiptRef() with WebCrypto runtime guard
- schema: validateCarrierConstraints() transport-aware validation
- schema: verifyReceiptRefConsistency() for tamper detection
- schema: CARRIER_TRANSPORT_LIMITS per-transport size constants
- conformance: 8 carrier fixtures in specs/conformance/fixtures/carrier/
- conformance: carrier category registered in manifest and tracking
Add Evidence Carrier Contract adapter for @peac/adapter-x402:

Carrier adapter (src/carrier.ts):
- fromOfferResponse: extract carrier from HTTP 402 PEAC-Receipt header
- fromSettlementResponse: extract carrier from HTTP 200 headers
- Async variants with computeReceiptRef (DD-129)
- X402CarrierAdapter: implements CarrierAdapter<X402ResponseLike>
- Case-insensitive header lookup per RFC 9110

Challenge type mapping (src/challenge.ts):
- ChallengeType taxonomy for cross-protocol normalization
- mapX402ToChallengeType: always returns 'payment' for x402

Mapping update (src/map.ts):
- toPeacCarrier: converts receipt JWS to PeacEvidenceCarrier using
  shared computeReceiptRef from @peac/schema (correction item 4)
… mode

- Update module comment to state header-only in v0.11.1
- Use x402_headers (8 KB) limit for all constraint validation since
  the transport surface is PEAC-Receipt header
- Throw on attach when receipt_jws absent (no silent reference drop)
- Remove embed/reference branching from defaultX402Meta
- Add reference mode rejection test, update constraint test limits
@jithinraj jithinraj changed the base branch from feat/evidence-carrier-types to main February 23, 2026 18:29
@jithinraj jithinraj changed the title feat: x402 carrier adapter and challenge type mapping (DD-124) feat: x402 carrier adapter and challenge type mapping Feb 23, 2026
@jithinraj jithinraj merged commit ad02b97 into main Feb 23, 2026
7 checks passed
@jithinraj jithinraj deleted the feat/x402-carrier-adoption branch February 24, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant