feat(knowledge-flywheel): add Phase 3 Knowledge Flywheel — AI analysis, review queue, analytics
Phase 3 implementation: - AI session analysis service that generates flow proposals from resolved sessions - APScheduler job for batch processing pending analyses (max_instances=1) - Knowledge gap detection (weak options, high escalation signals) - Flow proposals CRUD with team admin review workflow (approve/edit/dismiss/reject) - FlowPilot analytics dashboard with confidence tiers, PSA metrics, knowledge gaps - In-session script generator component - Review queue page with filtering and proposal detail panel Bug fixes from review (12 total): - Fix "Edit & Publish" navigating to non-existent /editor/new route - Hide Approve button for enhancement proposals (require Edit & Publish) - Add max_instances=1 to scheduler to prevent TOCTOU race - Fix eventual_success case() double-counting failed retries - Add tree_structure validation before creating tree from proposal - Simplify script generator rendering condition - Add severity style fallback, toFixed on rates, Link instead of <a href> - Add toast.warning on dismiss failure, fix dedup for domain-less sessions - Cast Decimal to int in knowledge gap evidence dicts Also updates CLAUDE.md with lessons 67-71 and Phase 3 project structure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
72
backend/app/schemas/flowpilot_analytics.py
Normal file
72
backend/app/schemas/flowpilot_analytics.py
Normal file
@@ -0,0 +1,72 @@
|
||||
"""Pydantic schemas for FlowPilot analytics dashboard."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional, Any
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class MTTRDataPoint(BaseModel):
|
||||
date: str
|
||||
mttr_minutes: float
|
||||
session_count: int
|
||||
|
||||
|
||||
class DomainBreakdown(BaseModel):
|
||||
domain: str
|
||||
total: int
|
||||
resolved: int
|
||||
escalated: int
|
||||
resolution_rate: float
|
||||
|
||||
|
||||
class ConfidenceBreakdown(BaseModel):
|
||||
guided_sessions: int
|
||||
guided_resolution_rate: float
|
||||
exploring_sessions: int
|
||||
exploring_resolution_rate: float
|
||||
discovery_sessions: int
|
||||
discovery_resolution_rate: float
|
||||
|
||||
|
||||
class DomainCoverage(BaseModel):
|
||||
domain: str
|
||||
flow_count: int
|
||||
session_count: int
|
||||
guided_rate: float
|
||||
|
||||
|
||||
class KnowledgeCoverage(BaseModel):
|
||||
total_flows: int
|
||||
ai_generated_flows: int
|
||||
total_proposals_pending: int
|
||||
proposals_approved_this_period: int
|
||||
proposals_rejected_this_period: int
|
||||
coverage_by_domain: list[DomainCoverage] = []
|
||||
|
||||
|
||||
class PsaMetrics(BaseModel):
|
||||
ticket_link_rate: float
|
||||
auto_push_success_rate: float
|
||||
auto_push_retry_success_rate: float
|
||||
total_time_entries_logged: int
|
||||
total_hours_logged: float
|
||||
|
||||
|
||||
class FlowPilotDashboard(BaseModel):
|
||||
period: str
|
||||
total_sessions: int
|
||||
resolved_sessions: int
|
||||
escalated_sessions: int
|
||||
abandoned_sessions: int
|
||||
resolution_rate: float
|
||||
avg_steps_to_resolution: float
|
||||
avg_session_duration_minutes: float
|
||||
avg_rating: float | None = None
|
||||
mttr_minutes: float | None = None
|
||||
mttr_trend: list[MTTRDataPoint] = []
|
||||
sessions_by_domain: list[DomainBreakdown] = []
|
||||
confidence_breakdown: ConfidenceBreakdown
|
||||
knowledge_coverage: KnowledgeCoverage
|
||||
psa_metrics: PsaMetrics | None = None
|
||||
Reference in New Issue
Block a user