Skip to content

Issue Reserve/Commit wasm actions for TokenRateLimitPolicy #402

Description

@eguzki

Summary

Wasm-shim mechanics for the reservation flow: issue Reserve at the request phase, capture the reservation_id, and issue Commit at the response/stream-end phase (or immediately on the error path). Marked "TBD" in RFC 0021 — this issue covers the implementation design and build.

Design: RFC 0021, reference-level section "Expected work by component" (wasm-shim).

Depends on: Kuadrant/limitador#506 (Reserve/Commit RPCs).

Acceptance Criteria

  • ServiceType gains RateLimitReserve / RateLimitCommit, additive to the existing enum (RateLimit | RateLimitCheck | RateLimitReport | Auth | Tracing | Dynamic); existing variants/handling in DynamicService/DynamicTask untouched
  • reservation.amount / reservation.ttl evaluated via message_builder CEL on the Reserve action, same mechanism as hits_addend today
  • reservation_id returned by Reserve captured via an on_replyStore action into ReqRespCtx.stored_values, read back later in the same KuadrantFilter instance (no host export needed)
  • On the error path (model call failure, timeout, non-2xx from model server): issue Commit immediately, typically with actual_amount: 0, instead of relying solely on TTL expiry (see RFC's Security considerations)
  • Unit/integration tests covering: happy path (Reserve → Commit with actual usage), over-limit rejection at Reserve, and the error-path immediate-Commit behavior

Notes for reviewers

PR description should include: how to review (suggested order: ServiceType additions → CEL evaluation → stored_values plumbing → error-path Commit), and manual verification (local Envoy + wasm-shim, drive a request through a TokenRateLimitPolicy-protected route, observe Reserve/Commit calls e.g. via Limitador logs).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    • Status
      Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions