M5: per-wallet quota and wallet heuristic gate#11
Merged
Conversation
Initialize paid-scope buckets on session, expose quota consume/status endpoints, and apply lower limits for new wallets.
Use an ephemeral wallet per test so heuristic and quota state are not polluted by parallel runs against account #0.
Coverage reportThresholds: 80% line · 78% region (condition) ✅ Coverage meets the required threshold. Summary |
ExposeMode routes wallet APIs separately from RS-only POST /quota/consume, with DEPLOYMENT.md, ADR 0003, and architecture/sequence diagrams.
Clarify that internal quota consume must forward the user Authorization header; fix sequenceDiagram labels (no semicolons) and add mermaid-github cursor rule.
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
heuristic:seen:{wallet}) — new wallets get lower paid-scope limitsquota:{wallet}:{scope}:{window})GET /v1/auth/quota(public),POST /v1/auth/quota/consume(internal only)[quota]—window_secs,paid_scopes,limits.new_wallet/limits.establishedAPP_SERVER__EXPOSE=all|public|internal— split wallet vs RS routes in one binarydocs/DEPLOYMENT.md, ADR 0003, architecture + sequence diagrams inARCHITECTURE.mdPaid scopes (default):
ai:invoke,mint:request. On-chain heuristics deferred; established tier applies from the second session onward.Public vs internal (GCP)
exposetrust-relay-publicpublicGET /quotatrust-relay-internalinternalPOST /quota/consume,/healthzQuota consume auth (phase 0): RS forwards the user
Authorization: BearerJWT — trust-relay does not identify the RS yet. Network isolation on internal ingress is the guardrail untiltrust-auth(M3b).Test plan
cargo testcargo clippy -- -D warningscargo fmt --checktests/expose.rs— public/internal route surfacestests/quota_redis.rs