Skip to content

feat(analytics): PR-B -- integration clients + multi-tenant RBAC - #38

Merged
man4ish merged 1 commit into
mainfrom
feature/analytics-b-clients-rbac
Aug 12, 2026
Merged

feat(analytics): PR-B -- integration clients + multi-tenant RBAC#38
man4ish merged 1 commit into
mainfrom
feature/analytics-b-clients-rbac

Conversation

@man4ish

@man4ish man4ish commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Second of four sub-PRs implementing Usage Analytics v1 (see PR #37 for PR-A / the pipeline foundation this depends on). Pure library layer, no router yet.

  • analytics/permissions.py -- require_analytics_scope, entirely JWT-claim-based (org_id/org_role/team_id/team_role/permissions), no new remote authorization call per request. Full platform_admin/org_admin/team_admin/regular-user test matrix.
  • analytics/prometheus.py -- real Prometheus HTTP API client. No Prometheus server is deployed anywhere in this workspace (confirmed by grep) -- degrades to {"available": False} on every real call today, fully implemented/tested for when one exists.
  • analytics/billing_client.py -- wraps omnibioai-billing's existing usage/subscription/usage-limits endpoints (same pattern routes_dashboard.py::_business_section already uses). No billing math duplicated.
  • analytics/tes_client.py -- wraps TES's existing Run Store API (GET /api/runs), reusing routes_dashboard.py::_workflow_section's own call instead of inventing a workflow.* event producer.

Test plan

  • python -m pytest: 1077 passed, 99.83% coverage (gate: 98%). All 4 new modules individually 100% covered.

🤖 Generated with Claude Code

Second of four sub-PRs for Usage Analytics v1. Pure library layer, no
router yet -- everything here is independently unit-testable and used
by PR-C.

- analytics/permissions.py: require_analytics_scope, a FastAPI
  dependency enforcing platform_admin/org_admin/team_admin/regular-user
  access entirely from the already-verified JWT claims (org_id,
  org_role, team_id, team_role, permissions) -- same trust model
  core/auth.py::require_permission already uses, no new remote
  authorization call per request. A caller-supplied org_id/team_id is
  always validated against the token's own claims, never trusted as-is.
- analytics/prometheus.py: a real Prometheus HTTP API client (instant/
  range query, histogram_quantile P50/P95/P99 builder). No Prometheus
  server is deployed anywhere in this workspace today (confirmed by
  grepping every repo) -- this degrades to {"available": False} on
  every real call right now, by design, and is fully implemented/tested
  for the day one exists.
- analytics/billing_client.py: thin wrapper over omnibioai-billing's
  existing usage/subscription/usage-limits endpoints, same
  forwarded-Authorization pattern as routes_dashboard.py's own
  _business_section. No billing math duplicated.
- analytics/tes_client.py: thin wrapper over TES's existing Run Store
  API (GET /api/runs), reusing routes_dashboard.py::_workflow_section's
  own call rather than inventing a workflow.* event producer.

100% coverage on all 4 new modules; full existing suite (1077 tests)
green at 99.83% overall, above the 98% gate.
@man4ish
man4ish merged commit 6a80c4f into main Aug 12, 2026
@man4ish
man4ish deleted the feature/analytics-b-clients-rbac branch August 12, 2026 03:41
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