feat: add detect_rail_from_headers helper - #24
Merged
Conversation
Returns "mpp" when Authorization: Payment is present, "x402" when payment-signature/x-payment is present, None otherwise. Case-insensitive header lookup per RFC 7230 §3.2; auth scheme matched per RFC 7235. In practice a client constructs a request with exactly one protocol's headers; if somehow both arrive (client bug or misconfigured proxy), MPP wins by checking it first. Documented as a tiebreaker, not a feature. Tests lock 14 cross-language fixtures with the @agent-score/commerce sibling. Parametrized so multiple drifts surface independently. 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
\"mpp\"whenAuthorization: Paymentis present,\"x402\"whenpayment-signature/x-paymentis present,Noneotherwise.agentscore_commerce.payment.detect_rail_from_headers.Tests
@agent-score/commerce'sdetectRailFromHeaders.pytest.mark.parametrizeso multiple drifts surface independently.Test plan
uv run pytest tests/test_dispatch.py— 16 tests passuv run pytest— full suite 945 pass / 3 skip, coverage 95.05%uv run ruff check,uv run ruff format --check,uv run ty check— green🤖 Generated with Claude Code