#pragma once #include #include #include struct RegistryStats { int total_functions = 0; int total_types = 0; int total_apps = 0; int total_analysis = 0; int total_unit_tests = 0; int total_proposals = 0; int tested_functions = 0; int pure_functions = 0; int impure_functions = 0; }; struct LangCount { std::string lang; int count = 0; }; struct DomainCount { std::string domain; int count = 0; }; struct KindCount { std::string kind; int count = 0; }; struct DateCount { std::string date; // YYYY-MM-DD int count = 0; }; struct FunctionRow { std::string id; std::string name; std::string lang; std::string domain; std::string kind; std::string purity; std::string description; std::string created_at; bool tested = false; }; struct AppRow { std::string id; std::string name; std::string lang; std::string domain; std::string description; std::string framework; std::string repo_url; std::string dir_path; }; struct AnalysisRow { std::string id; std::string name; std::string lang; std::string domain; std::string description; }; struct TypeRow { std::string id; std::string name; std::string lang; std::string domain; std::string algebraic; std::string description; }; struct VaultRow { std::string id; std::string name; std::string path; std::string description; bool symlink = false; }; struct ProjectRow { std::string id; std::string name; std::string description; int apps_count = 0; int analyses_count = 0; int vaults_count = 0; }; // Test unitario asociado a una funcion (1:N — una funcion puede tener varios). struct UnitTestRow { std::string id; std::string function_id; std::string name; std::string lang; std::string file_path; std::string code; std::string created_at; }; // Detalle completo de una funcion (codigo + documentacion). // Cargado on-demand cuando el usuario selecciona una funcion en Explorer. struct FunctionDetail { std::string id; std::string name; std::string lang; std::string domain; std::string kind; std::string purity; std::string version; std::string signature; std::string description; std::string code; std::string documentation; std::string notes; std::string example; std::string params_schema; std::string uses_functions; std::string uses_types; std::string returns; std::string error_type; std::string file_path; std::string created_at; bool tested = false; }; struct ProjectDetail { std::string id; // "" si no hay seleccion; "orphans" para huerfanas std::string name; std::string description; std::vector apps; std::vector analyses; std::vector vaults; }; // All data loaded from registry.db in one shot // Issue 0085: Claude usage telemetry rows from call_monitor.operations.db. struct ClaudeUsageRow { std::string function_id; int calls_total = 0; int calls_7d = 0; int errors_total = 0; double error_rate = 0.0; double mean_duration_ms = 0.0; }; struct ClaudeViolationRow { std::string rule_id; std::string function_id; std::string command_snippet; std::string severity; long long ts = 0; }; struct ClaudeCopiedRow { std::string app_file; std::string app_function; std::string registry_id; std::string kind; double similarity = 1.0; }; // Una invocacion concreta del registro de telemetria. Lo que el agente lanzo, // cuanto tardo, si fallo. Usado por la tabla "Recent Executions" del Monitor. struct RecentExecutionRow { long long id = 0; // calls.id (watermark para WS deltas) long long ts = 0; // epoch seconds std::string function_id; std::string tool_used; // mcp / fn_cli_run / bash / heredoc / ... int duration_ms = 0; bool success = true; std::string error_class; std::string error_snippet; // texto de error si success=false std::string command_snippet; // raw command (truncado/redactado) cuando function_id vacio std::string session_id; }; struct ClaudeUsageData { bool available = false; // true if call_monitor.operations.db is reachable int total_calls = 0; int total_errors = 0; int total_violations = 0; int total_copies = 0; int total_versions = 0; // Calls que Claude lanza via tools registry-aware: MCP del registry // (mcp), `fn run` (fn_cli_run) o heredocs python. Excluye bash plano. int total_mcp = 0; // % de filas en la ventana con function_id != '' — es decir, calls que // golpean una funcion registrada. Indicador clave de adopcion del registry. double registry_pct = 0.0; std::vector top_functions; // top 20 by calls_total std::vector recent_violations; // last 20 std::vector copies; std::vector recent_executions; // last N within window // Filtro de fecha. 0 = All. Otros valores en segundos. int window_secs = 86400; // default 24h // WS live state. true cuando hay conexion WS activa al hub de eventos. bool ws_connected = false; long long last_event_ts = 0; // ultimo ts recibido por WS long long last_seen_call_id = 0; // watermark (max id procesado) }; struct RegistryData { RegistryStats stats; std::vector by_lang; std::vector by_domain; std::vector by_kind; std::vector by_date; // last 30 days std::vector recent_funcs; // last 20 std::vector apps; std::vector analyses; std::vector types; std::vector projects; ClaudeUsageData claude; int orphan_apps = 0; int orphan_analyses = 0; int orphan_vaults = 0; // For chart data (populated by prepare_chart_data) std::vector lang_labels; std::vector lang_values; std::vector domain_labels; std::vector domain_values; std::vector kind_labels; std::vector kind_values; std::vector date_labels; std::vector date_values; void prepare_chart_data(); }; // Load all data from registry.db. Returns true on success. bool load_registry_data(const char* db_path, RegistryData& out);