feat(analytics): PR-B -- integration clients + multi-tenant RBAC - #38
Merged
Conversation
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.
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 patternroutes_dashboard.py::_business_sectionalready uses). No billing math duplicated.analytics/tes_client.py-- wraps TES's existing Run Store API (GET /api/runs), reusingroutes_dashboard.py::_workflow_section's own call instead of inventing aworkflow.*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