Skip to content

feat(billing): per-tenant usage metering + usage API + invoice generation (Step 7.9) - #182

Merged
officialCodeWork merged 1 commit into
mainfrom
build/phase-7/step-7.9-billing-metering
Jun 9, 2026
Merged

feat(billing): per-tenant usage metering + usage API + invoice generation (Step 7.9)#182
officialCodeWork merged 1 commit into
mainfrom
build/phase-7/step-7.9-billing-metering

Conversation

@officialCodeWork

Copy link
Copy Markdown
Owner

Step 7.9 — billing & metering. Per-tenant usage accounting that mirrors the 5.6c cost pattern (dataclasses in rag-observability, gateway wraps a Pydantic response → no dist/schemas churn): an observe-only UsageMeter (5 dimensions) fed from record_request_usage independent of quotas, GET /v1/billing/usage, a pure generate_invoice priced from marketplace/pricing.yaml (reconciles with usage ±0.5% by construction), and a BillingProvider Stripe/marketplace seam. cfg.billing (inert by default), ragctl billing, ADR-0051, reference/billing.md. No governed SPI call. Verified: ruff, mypy --strict (330), billing unit + gateway endpoint + ragctl tests, openapi/config drift regenerated. CI red = org Actions billing (unrelated). 🤖 Generated with Claude Code

…tion (Step 7.9)

Per-tenant usage accounting, mirroring the 5.6c cost pattern (dataclasses in
rag-observability, the gateway wraps a Pydantic response — no dist/schemas churn).

- rag_observability.billing: UsageMeter (observe-only per-tenant, per-dimension
  counters: queries/docs_ingested/storage_gb/reranker_calls/llm_tokens),
  UsageSnapshot, pure generate_invoice + PricingModel/load_pricing (priced from
  marketplace/pricing.yaml; reconciles with usage ±0.5% by construction), and a
  BillingProvider Protocol seam (Stripe/marketplace, degrade-open).
- GET /v1/billing/usage (BillingUsageResponse) serves the per-tenant dashboard;
  fed from record_request_usage independent of quotas; inert by default (cfg.billing).
- ragctl billing drives meter→invoice→reconcile.

No governed SPI call (policy-coverage unchanged). Only dist/openapi + dist/rag.schema
regenerate. Verified: ruff, mypy --strict (330), billing unit + gateway endpoint +
ragctl tests, drift gates regenerated. ADR-0051, reference/billing.md.

Deferred: concrete Stripe/marketplace adapters, docs/reranker/storage feed points,
admin usage card.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@officialCodeWork
officialCodeWork force-pushed the build/phase-7/step-7.9-billing-metering branch from 1e44863 to ac33111 Compare June 9, 2026 21:51
@officialCodeWork
officialCodeWork merged commit d12aa50 into main Jun 9, 2026
0 of 9 checks passed
@officialCodeWork
officialCodeWork deleted the build/phase-7/step-7.9-billing-metering branch June 9, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant