Skip to content

feat: tenant-budget Grid-side plumbing for MVP 1b (app/tenant-based routing) #40

Description

@jordigilh

Context

Part of closing the "app/tenant-based routing" third of MVP 1 (multi-cluster routing: model-based, app-based, standard). Model-based and standard routing are covered today (grid-glb-demo, grid-workload-inference, grid-combined-site). Tenant/app-based routing has zero demoable evidence at the Grid (multi-cluster) layer today.

The tenant-identification and cost-metering work is tracked on the ai side:

  • ai#130 — tenant-ID extraction (open, unassigned)
  • ai#104 — per-tenant routing wiring at the single-gateway layer (open, unassigned)
  • ai#191 — budget-enforcement engine, cascading org→team→user→agent limits (open, unassigned)
  • ai#577 / ai-pr-581 — per-request cost-metering / balance-check filter (open PR, assigned to @noyitz)
  • ai#301 — parent epic, "Multi-Tenancy Support"

None of that work extends the budget/tenant concept across cluster boundaries. This issue tracks the Grid-side plumbing needed to make a per-tenant budget cap demoable at the multi-cluster layer.

Scope

  • CRD field for a per-tenant budget on the routing overlay / policy resource
  • Per-tenant-keyed GCounter (today's grid GCounter CRDT is a single global counter — needs to become tenant-keyed)
  • SWIM broadcast wiring so tenant spend state propagates across sites
  • A budget-aware scoring gate that degrades routing (e.g. cheaper backend) as spend approaches the cap, and hard-stops at 100%

Open design question

GCounter is monotonic by construction — it can't natively express a rate-based budget ("$X per hour") without a reset/windowing design. This needs a design call before implementation, not after.

Estimate

Grid-side plumbing alone is well-precedented (~7-8 days) once the design call above is made; the full MVP 1b close (including the ai-side work above) is a 2-3 week cross-repo effort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions