Spaces:
Running
Running
| import{o as e}from"./chunk-CMxvf4Kt.js";import{t}from"./react-DrNXigiH.js";import{C as n}from"./index-Caa1r77e.js";var r=e(t(),1),i=n(),a=[`checkout`,`auth`,`inventory`,`payments`,`notifications`,`search`,`cdn`,`postgres`,`redis`,`kafka`];function o(){let e=Date.now();return[{id:`ci-1`,timestamp:e-3e5,title:`Checkout latency spike — 5x above p99 baseline`,severity:`critical`,status:`root-caused`,rootCause:`PostgreSQL connection pool exhaustion caused by leaked connections in payments service`,affectedServices:[`checkout`,`payments`,`postgres`],causalChain:[{id:`cn-1`,service:`postgres`,metric:`pg.connections.active`,value:95,baseline:40,deviation:137.5,isRootCause:!0,confidence:.94,depth:0,children:[`cn-2`]},{id:`cn-2`,service:`payments`,metric:`http.request.duration_p99`,value:2400,baseline:150,deviation:1500,isRootCause:!1,confidence:.88,depth:1,children:[`cn-3`]},{id:`cn-3`,service:`checkout`,metric:`http.request.duration_p99`,value:3200,baseline:200,deviation:1500,isRootCause:!1,confidence:.91,depth:2,children:[]}],mttrMs:18e4,counterfactuals:[`If pg.connections.max increased to 200, predicted latency impact: -85%`,`If payments service connection pooling fixed, predicted p99: ~180ms`,`If read replicas active, predicted checkout impact: negligible`]},{id:`ci-2`,timestamp:e-18e5,title:`Auth service error rate surge — 12% of requests failing`,severity:`high`,status:`resolved`,rootCause:`Redis primary node memory pressure causing eviction of session tokens`,affectedServices:[`auth`,`redis`,`checkout`,`search`],causalChain:[{id:`cn-4`,service:`redis`,metric:`redis.memory.used_percent`,value:98,baseline:65,deviation:50.8,isRootCause:!0,confidence:.91,depth:0,children:[`cn-5`]},{id:`cn-5`,service:`auth`,metric:`http.error_rate`,value:12.3,baseline:.1,deviation:12200,isRootCause:!1,confidence:.87,depth:1,children:[`cn-6`,`cn-7`]},{id:`cn-6`,service:`checkout`,metric:`http.error_rate`,value:8.1,baseline:.05,deviation:16100,isRootCause:!1,confidence:.83,depth:2,children:[]},{id:`cn-7`,service:`search`,metric:`http.error_rate`,value:3.2,baseline:.1,deviation:3100,isRootCause:!1,confidence:.79,depth:2,children:[]}],mttrMs:42e4,counterfactuals:[`If redis.maxmemory increased 2x, predicted memory: 49% (safe)`,`If session TTL reduced from 24h to 4h, predicted eviction rate: 0%`,`If auth fallback to DB-backed sessions, predicted error rate: 0.3%`]},{id:`ci-3`,timestamp:e-72e5,title:`Kafka consumer lag causing stale inventory data`,severity:`medium`,status:`resolved`,rootCause:`Consumer group rebalance storm due to aggressive session timeout (10s)`,affectedServices:[`kafka`,`inventory`,`search`],causalChain:[{id:`cn-8`,service:`kafka`,metric:`kafka.consumer.rebalance_rate`,value:14,baseline:.1,deviation:13900,isRootCause:!0,confidence:.89,depth:0,children:[`cn-9`]},{id:`cn-9`,service:`inventory`,metric:`kafka.consumer.lag`,value:45e3,baseline:200,deviation:22400,isRootCause:!1,confidence:.86,depth:1,children:[`cn-10`]},{id:`cn-10`,service:`search`,metric:`search.stale_results_ratio`,value:8.5,baseline:.1,deviation:8400,isRootCause:!1,confidence:.82,depth:2,children:[]}],mttrMs:3e5,counterfactuals:[`If session.timeout.ms increased to 45s, predicted rebalance rate: 0.2/min`,`If consumer instances scaled from 4 to 8, predicted lag: < 500`,`If partition count increased, predicted throughput: +150%`]}]}function s({severity:e}){let t={critical:`bg-red-500`,high:`bg-orange-500`,medium:`bg-yellow-500`,low:`bg-green-500`};return(0,i.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t[e]||t.low} ${e===`critical`?`animate-pulse`:``}`})}function c({status:e}){return(0,i.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-mono rounded border uppercase ${{investigating:`bg-blue-500/10 text-blue-400 border-blue-500/20`,"root-caused":`bg-purple-500/10 text-purple-400 border-purple-500/20`,remediating:`bg-orange-500/10 text-orange-400 border-orange-500/20`,resolved:`bg-green-500/10 text-green-400 border-green-500/20`}[e]||``}`,children:e})}function l(){let[e,t]=(0,r.useState)([]),[n,l]=(0,r.useState)(null);(0,r.useEffect)(()=>{let e=o();t(e),l(e[0])},[]);let u=e.length?Math.round(e.reduce((e,t)=>e+t.mttrMs,0)/e.length/6e4):0;return(0,i.jsxs)(`div`,{className:`space-y-6 max-w-[1400px] mx-auto`,children:[(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`p`,{className:`text-xs font-mono uppercase tracking-[0.2em] text-[#f5f5f5]/40 mb-1`,children:`A11OY · INTELLIGENCE · CAUSAL RCA`}),(0,i.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-[#f5f5f5]`,children:`Causal Root-Cause Analysis`}),(0,i.jsx)(`p`,{className:`text-sm text-[#f5f5f5]/50 mt-1 max-w-3xl`,children:`Structural causal models for incident diagnosis — inspired by Causely's causal reasoning platform. Encodes service dependency graphs as directed acyclic graphs (DAGs) to trace anomaly propagation and identify true root causes, not just symptoms. Counterfactual "what-if" analysis for remediation planning.`})]}),(0,i.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{label:`Active Incidents`,value:e.filter(e=>e.status!==`resolved`).length,color:`#ef4444`},{label:`Avg MTTR`,value:`${u}m`,color:`#06b6d4`},{label:`Auto-Diagnosed`,value:`${e.length}/${e.length}`,color:`#4ade80`},{label:`Services Modeled`,value:a.length,color:`#c9b787`}].map(e=>(0,i.jsxs)(`div`,{className:`bg-[#0a0a0f] border border-white/[0.06] rounded-lg p-3 space-y-1`,children:[(0,i.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-widest text-white/30`,children:e.label}),(0,i.jsx)(`p`,{className:`text-xl font-mono font-bold`,style:{color:e.color},children:e.value})]},e.label))}),(0,i.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,i.jsxs)(`div`,{className:`bg-[#0a0a0f] border border-white/[0.06] rounded-lg overflow-hidden`,children:[(0,i.jsx)(`div`,{className:`p-4 border-b border-white/[0.06]`,children:(0,i.jsx)(`h2`,{className:`text-sm font-mono font-semibold uppercase tracking-wider text-white/70`,children:`Incidents`})}),(0,i.jsx)(`div`,{className:`divide-y divide-white/[0.03] max-h-[500px] overflow-y-auto`,children:e.map(e=>(0,i.jsxs)(`button`,{type:`button`,className:`w-full text-left px-4 py-3 cursor-pointer transition-colors ${n?.id===e.id?`bg-white/[0.04]`:`hover:bg-white/[0.02]`}`,onClick:()=>l(e),children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,i.jsx)(s,{severity:e.severity}),(0,i.jsx)(c,{status:e.status})]}),(0,i.jsx)(`p`,{className:`text-xs font-bold text-white/80`,children:e.title}),(0,i.jsxs)(`p`,{className:`text-[10px] text-white/30 mt-0.5`,children:[new Date(e.timestamp).toLocaleTimeString(),` · `,e.affectedServices.length,` services`]})]},e.id))})]}),n&&(0,i.jsxs)(`div`,{className:`lg:col-span-2 space-y-4`,children:[(0,i.jsxs)(`div`,{className:`bg-[#0a0a0f] border border-white/[0.06] rounded-lg p-5`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-3 mb-3`,children:[(0,i.jsx)(s,{severity:n.severity}),(0,i.jsx)(`h2`,{className:`text-sm font-mono font-semibold text-white/80`,children:n.title}),(0,i.jsx)(c,{status:n.status})]}),(0,i.jsxs)(`div`,{className:`p-3 rounded bg-red-500/5 border border-red-500/10 mb-4`,children:[(0,i.jsx)(`p`,{className:`text-[10px] font-mono uppercase tracking-wider text-red-400/60 mb-1`,children:`ROOT CAUSE`}),(0,i.jsx)(`p`,{className:`text-xs text-white/70`,children:n.rootCause})]}),(0,i.jsx)(`h3`,{className:`text-xs font-mono uppercase tracking-wider text-white/50 mb-3`,children:`Causal Chain (DAG)`}),(0,i.jsx)(`div`,{className:`space-y-2`,children:n.causalChain.map((e,t)=>(0,i.jsxs)(`div`,{className:`flex items-start gap-3`,style:{paddingLeft:e.depth*24},children:[e.depth>0&&(0,i.jsx)(`div`,{className:`flex items-center gap-1 text-white/15 flex-shrink-0`,children:(0,i.jsx)(`span`,{className:`text-[10px] font-mono`,children:`└→`})}),(0,i.jsxs)(`div`,{className:`flex-1 p-3 rounded border ${e.isRootCause?`bg-red-500/5 border-red-500/20`:`bg-white/[0.02] border-white/[0.04]`}`,children:[(0,i.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,i.jsx)(`span`,{className:`text-xs font-mono font-bold text-[#c9b787]`,children:e.service}),e.isRootCause&&(0,i.jsx)(`span`,{className:`text-[9px] font-mono px-1 py-0.5 rounded bg-red-500/10 text-red-400 border border-red-500/20`,children:`ROOT CAUSE`})]}),(0,i.jsxs)(`span`,{className:`text-[10px] font-mono text-white/30`,children:[(e.confidence*100).toFixed(0),`% confidence`]})]}),(0,i.jsxs)(`p`,{className:`text-[10px] font-mono text-white/50 mt-1`,children:[e.metric,`: `,(0,i.jsx)(`span`,{className:`text-white/70`,children:e.value}),(0,i.jsxs)(`span`,{className:`text-white/25`,children:[` (baseline: `,e.baseline,`, +`,e.deviation.toFixed(0),`%)`]})]})]})]},e.id))})]}),(0,i.jsxs)(`div`,{className:`bg-[#0a0a0f] border border-white/[0.06] rounded-lg p-5`,children:[(0,i.jsx)(`h3`,{className:`text-xs font-mono uppercase tracking-wider text-white/50 mb-3`,children:`Counterfactual Analysis`}),(0,i.jsx)(`p`,{className:`text-[10px] font-mono text-white/30 mb-3`,children:`What-if scenarios generated by causal structural model`}),(0,i.jsx)(`div`,{className:`space-y-2`,children:n.counterfactuals.map((e,t)=>(0,i.jsxs)(`div`,{className:`flex items-start gap-2 p-2 rounded bg-white/[0.02] border border-white/[0.04]`,children:[(0,i.jsx)(`span`,{className:`text-[10px] font-mono text-purple-400 flex-shrink-0 mt-0.5`,children:`↳`}),(0,i.jsx)(`p`,{className:`text-[11px] text-white/50`,children:e})]},t))})]})]})]})]})}export{l as CausalRCA}; |