0.5.0: sell against an allowance the caller counted - #8
Merged
Merged
Conversation
@profullstack/throttle meters every route on a site, not just the paths a
crawler list matches, and then wants the same 402 the gateway already knows
how to write. Two seams were missing for that.
`sell(request, { usage, quota })` now takes the allowance to quote. It used
to read `o.freeQuota` unconditionally whenever a usage was passed, so a
gateway that had no allowance of its own -- which is every gateway whose
counting lives in the throttle -- threw on that path. The gateway's own
quota is still the default, so nothing that worked before changes.
`passFrom` and `verifyPass` are exposed because a pass has to be honoured by
everything that could refuse a request, not only by `handle`. The throttle
has to skip whoever already paid, and recomputing the signing-secret
fallback (`secret || coinpay.apiKey`) on its side is the kind of duplicated
rule that drifts and starts charging paying crawlers twice.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YDGCxTmEPs3ecwjjLJDQXh
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.
@profullstack/throttlemeters every route on a site, not just the paths a crawler list matches, and then wants the same 402 the gateway already knows how to write. Two seams were missing for that.sell(request, { usage, quota })now takes the allowance to quote. It used to reado.freeQuotaunconditionally whenever a usage was passed, so a gateway with no allowance of its own — which is every gateway whose counting lives in the throttle — threw on that path. The gateway's own quota is still the default, so nothing that worked before changes.passFromandverifyPassare exposed because a pass has to be honoured by everything that could refuse a request, not only byhandle. The throttle has to skip whoever already paid, and recomputing the signing-secret fallback (secret || coinpay.apiKey) on its side is the kind of duplicated rule that drifts and starts charging paying crawlers twice.Additive: 82/82 tests pass, six of them new.
🤖 Generated with Claude Code