Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /dislovelhl_enhanced-agent-bus /api /routes /stats.py
| """ | |
| ACGS-2 Stats Endpoint | |
| Constitutional Hash: 608508a9bd224290 | |
| GET /v1/stats — returns real aggregated validation statistics. | |
| Requires API key authentication. | |
| """ | |
| from fastapi import APIRouter, Depends, Request | |
| from pydantic import BaseModel | |
| try: | |
| from enhanced_agent_bus._compat.constants import CONSTITUTIONAL_HASH | |
| except ImportError: | |
| CONSTITUTIONAL_HASH = "standalone" | |
| from ..api_key_auth import require_api_key | |
| from ..rate_limiting import limiter | |
| from ..runtime_guards import require_sandbox_endpoint | |
| from ..validation_store import ( | |
| RecentValidationRecord, | |
| ValidationStats, | |
| get_validation_store, | |
| ) | |
| router = APIRouter(prefix="/v1", tags=["stats"]) | |
| class StatsResponse(BaseModel): | |
| """Aggregated validation statistics.""" | |
| total_validations: int | |
| compliance_rate: float | |
| avg_latency_ms: float | |
| unique_agents: int | |
| constitutional_hash: str | |
| recent_validations: list[RecentValidationRecord] | |
| async def get_stats( | |
| request: Request, | |
| _api_key: str = Depends(require_api_key), | |
| ) -> StatsResponse: | |
| """Return sandbox-only validation statistics from the in-memory store.""" | |
| require_sandbox_endpoint( | |
| "Public stats endpoint", | |
| "it reports non-authoritative in-memory validation history", | |
| ) | |
| stats: ValidationStats = get_validation_store().get_stats() | |
| return StatsResponse(constitutional_hash=CONSTITUTIONAL_HASH, **stats) | |
Xet Storage Details
- Size:
- 1.49 kB
- Xet hash:
- f6024b697ab8dd9d5e186915254544d62d259775494ca702c0839ebd300fa795
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.