MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / summary

Method summary

uncommon_route/stats.py:334–490  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

332 return [record_to_recent_dict(r) for r in records[:limit]]
333
334 def summary(self) -> StatsSummary:
335 if not self._records:
336 return StatsSummary(
337 total_requests=0, time_range_s=0.0,
338 by_tier={}, by_decision_tier={}, by_served_quality={}, by_capability_lane={}, by_model={},
339 by_transport={}, by_cache_mode={}, by_cache_family={},
340 by_mode={}, by_method={}, complexity_distribution={},
341 avg_confidence=0.0, avg_savings=0.0, avg_latency_us=0.0,
342 avg_input_reduction_ratio=0.0, avg_cache_hit_ratio=0.0,
343 total_estimated_cost=0.0, total_baseline_cost=0.0, total_actual_cost=0.0,
344 total_savings_absolute=0.0, total_savings_ratio=0.0,
345 total_cache_savings=0.0, total_compaction_savings=0.0,
346 total_usage_input_tokens=0, total_usage_output_tokens=0,
347 total_cache_read_input_tokens=0, total_cache_write_input_tokens=0,
348 total_cache_breakpoints=0,
349 total_input_tokens_before=0, total_input_tokens_after=0,
350 total_artifacts_created=0, total_compacted_messages=0,
351 total_semantic_summaries=0, total_semantic_calls=0,
352 total_semantic_failures=0, total_semantic_quality_fallbacks=0,
353 total_checkpoints_created=0,
354 total_rehydrated_artifacts=0,
355 )
356
357 now = self._now()
358 oldest = min(r.timestamp for r in self._records)
359 n = len(self._records)
360
361 tier_groups: dict[str, list[RouteRecord]] = {}
362 model_groups: dict[str, list[RouteRecord]] = {}
363 transport_groups: dict[str, list[RouteRecord]] = {}
364 cache_mode_groups: dict[str, list[RouteRecord]] = {}
365 cache_family_groups: dict[str, list[RouteRecord]] = {}
366 mode_counts: dict[str, int] = {}
367 decision_tier_counts: dict[str, int] = {}
368 served_quality_counts: dict[str, int] = {}
369 capability_lane_counts: dict[str, int] = {}
370 method_counts: dict[str, int] = {}
371 complexity_dist = {"simple": 0, "medium": 0, "complex": 0}
372
373 for r in self._records:
374 tier = _normalize_tier_label(r.tier)
375 tier_groups.setdefault(tier, []).append(r)
376 model_groups.setdefault(r.model, []).append(r)
377 transport_groups.setdefault(r.transport, []).append(r)
378 cache_mode_groups.setdefault(r.cache_mode, []).append(r)
379 cache_family_groups.setdefault(r.cache_family, []).append(r)
380 mode_counts[r.mode] = mode_counts.get(r.mode, 0) + 1
381 decision_tier = _normalize_tier_label(r.decision_tier or r.tier)
382 decision_tier_counts[decision_tier] = decision_tier_counts.get(decision_tier, 0) + 1
383 if r.served_quality:
384 served_quality_counts[r.served_quality] = served_quality_counts.get(r.served_quality, 0) + 1
385 if r.capability_lane:
386 capability_lane_counts[r.capability_lane] = capability_lane_counts.get(r.capability_lane, 0) + 1
387 method_counts[r.method] = method_counts.get(r.method, 0) + 1
388 c = getattr(r, "complexity", 0.33)
389 if c < 0.33:
390 complexity_dist["simple"] += 1
391 elif c < 0.67:

Calls 10

StatsSummaryClass · 0.85
TierSummaryClass · 0.85
_effective_costFunction · 0.85
ModelSummaryClass · 0.85
_baseline_costFunction · 0.85
_cache_savingsFunction · 0.85
_compaction_savingsFunction · 0.85
_normalize_tier_labelFunction · 0.70
appendMethod · 0.45
getMethod · 0.45