Skip to content

feat(buyer-agent-registry): add caching + rate-limiting + audit emission to PgBuyerAgentRegistry #380

Description

@bokelley

Context

PgBuyerAgentRegistry (and the v3 ref seller's TenantScopedBuyerAgentRegistry which delegates to it) hits the database on every dispatch with:

  • no in-process cache
  • no rate limit
  • no audit emission on resolve outcomes

Production sellers will eat unnecessary DB load, and the lookup endpoint becomes a credential-stuffing oracle for an attacker who can probe it.

Refs:

  • src/adcp/decisioning/pg/buyer_agent_registry.py
  • examples/v3_reference_seller/src/buyer_registry.py

Acceptance Criteria

  • In-process TTL cache (default 60s, configurable) keyed on the lookup tuple
  • Per-tenant (or per-source-IP) rate limit on the resolve path, configurable
  • Audit event emitted on every resolve outcome (hit / miss / rate-limited / error) via the existing audit hook
  • Metrics hooks (counter for hits/misses/rate-limits, latency histogram)
  • Cache invalidation on registry mutations (sync / delete)
  • Unit tests cover cache hit/miss/expiry, rate-limit triggering, audit emission

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions