1import{r as h,j as e,$ as R,p as $,am as V,an as B,i as W,k as H,l as P,m as g,n as J,o as p}from"./utils-CeSPy6h1.js";import{u as q,a as Q,b as X}from"./gate-8qQMZ32P.js";import{u as Y}from"./scores-CU60zuZA.js";import{aa as Z,Q as ee,ad as f,a5 as b,am as A,a1 as se,an as te,ak as ne,a3 as I,U as k,ao as ae,ah as F,ai as U,aj as D,ap as z}from"./app-BxmcKjzL.js";import{E as S}from"./EmptyState-B71v-xGV.js";import{I as ie}from"./InspectorPanel-4G9Akkza.js";import{P as re}from"./PageHeader-BPQ4xKhf.js";import{R as le}from"./RelativeTime-BiXh29AB.js";import{S as y}from"./StatTile-D57vkyCH.js";import{u as oe}from"./useInspectorParam-BzRIMx77.js";import{d as ce}from"./theme-l-9pyaS2.js";import{L as de,R as ue,a as me}from"./LineChart-DXtZVC7b.js";import"./preload-helper-B8tWKQ1F.js";/* empty css */import"./Sparkline-2WFZUwGV.js";/** 2 * @license lucide-react v0.479.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const xe=[["path",{d:"M5 12h14",key:"1ays0h"}]],he=ce("Minus",xe);function fe(l,r){var s;const i=new Map;for(const t of l)for(const n of((s=t.evidence)==null?void 0:s.suites)??[]){const a=n.suite_version_id;let o=i.get(a);o||(o={suiteVersionId:a,evalId:n.eval_id,label:(r==null?void 0:r.get(a))??n.eval_id??a.slice(0,8),blocking:n.blocking,fails:0,inconclusive:0,evaluated:0},i.set(a,o)),o.evaluated+=1,o.blocking=o.blocking||n.blocking,n.verdict==="FAIL"?o.fails+=1:n.verdict==="INCONCLUSIVE"&&(o.inconclusive+=1)}return[...i.values()].sort((t,n)=>Number(n.blocking)-Number(t.blocking)||n.fails-t.fails||n.inconclusive-t.inconclusive||t.label.localeCompare(n.label))}function G(l){return l.template==="max_failures"||l.template==="must_pass_deterministic"?l.threshold-l.estimate:l.lower-l.threshold}function ge(l,r){var s;const i=[];for(const t of l)for(const n of((s=t.evidence)==null?void 0:s.suites)??[]){const a=(r==null?void 0:r.get(n.suite_version_id))??n.eval_id??n.suite_version_id.slice(0,8);for(const o of n.rules??[])i.push({runId:t.runId,createdAt:t.createdAt,suiteVersionId:n.suite_version_id,suiteLabel:a,ruleIndex:o.rule_index,template:o.template,verdict:o.verdict,estimate:o.estimate,lower:o.lower,upper:o.upper,threshold:o.threshold,margin:G(o),n:o.n,reason:o.reason,blocking:n.blocking})}return i}function pe(l,r){var t;const i=[...l].sort((n,a)=>C(n.createdAt)-C(a.createdAt)),s=new Map;for(const n of i)for(const a of((t=n.evidence)==null?void 0:t.suites)??[]){const o=a.suite_version_id;let d=s.get(o);d||(d={suiteVersionId:o,label:(r==null?void 0:r.get(o))??a.eval_id??o.slice(0,8),blocking:a.blocking,points:[]},s.set(o,d)),d.points.push({runId:n.runId,createdAt:n.createdAt,margin:K(a),verdict:a.verdict})}return[...s.values()].sort((n,a)=>Number(a.blocking)-Number(n.blocking)||n.label.localeCompare(a.label))}function K(l){let r=null;for(const i of l.rules??[]){if(i.verdict==="NOT_APPLICABLE")continue;const s=G(i);Number.isFinite(s)&&(r===null||s<r)&&(r=s)}return r}function C(l){const r=new Date(l).getTime();return Number.isNaN(r)?0:r}const ve=.01,je=3;function be(l,r,i={}){const s=i.minRuns??je,t=i.epsilon??ve,n=[...l].filter(d=>d.verdict==="REJECT"&&d.evidence).sort((d,m)=>C(m.createdAt)-C(d.createdAt));if(n.length<s)return[];const a=d=>{var m;return(((m=d.evidence)==null?void 0:m.suites)??[]).filter(x=>x.blocking&&x.verdict==="FAIL")},o=[];for(const d of a(n[0])){let m=0;const x=[];for(const E of n){const N=a(E).find(w=>w.suite_version_id===d.suite_version_id);if(!N)break;m+=1;const j=K(N);j!==null&&x.push(j)}if(m<s||x.length<s)continue;const v=x.slice(0,s).reverse(),_=Math.abs(v[v.length-1]-v[0]);_>t||o.push({suiteVersionId:d.suite_version_id,label:(r==null?void 0:r.get(d.suite_version_id))??d.eval_id??d.suite_version_id.slice(0,8),runs:m,margins:v,drift:_})}return o}const Ne={coverage:"judge coverage below the suite minimum",baseline_coverage:"baseline coverage below the suite minimum",protocol_mismatch:"baseline scored under a different protocol",missing_cells:"score cells never landed",uncalibrated:"judge not calibrated for this suite",judge_drift:"judge drifted since calibration",no_baseline:"no baseline to compare against",no_data:"no scored items",interval_crosses_threshold:"confidence interval straddles the threshold",no_rules:"the ledger entry declares no rules",harness_unhealthy:"the eval harness was unhealthy",reliability:"candidate error rate above the reliability bar"};function _e(l){const r=new Map,i=(s,t)=>{const n=s||"unspecified";let a=r.get(n);a||(a={reason:n,label:Ne[n]??n.replace(/_/g," "),count:0,runIds:[]},r.set(n,a)),a.count+=1,a.runIds.includes(t)||a.runIds.push(t)};for(const s of l){if(s.verdict!=="INCONCLUSIVE")continue;const t=s.evidence;
6if(!t){i("unspecified",s.runId);continue}const n=(t.suites??[]).filter(o=>o.verdict==="INCONCLUSIVE").map(o=>o.reason??"unspecified"),a=n.length>0?n:t.reasons??["unspecified"];for(const o of a)i(o,s.runId)}return[...r.values()].sort((s,t)=>t.count-s.count||s.label.localeCompare(t.label))}function we(l){let r=0,i=0,s=0,t=0;for(const n of l)switch(n.verdict){case"PASS":r+=1;break;case"REJECT":i+=1;break;case"INCONCLUSIVE":s+=1;break;default:t+=1}return{pass:r,reject:i,inconclusive:s,unfinalized:t}}const O=20;function Ge(){var w,L,T;const{pid:l}=Z(),r=q(l),i=Y(l),s=oe("run"),t=h.useMemo(()=>(r.data??[]).filter(c=>c.state==="finalized").sort((c,u)=>new Date(u.finalized_at??u.created_at).getTime()-new Date(c.finalized_at??c.created_at).getTime()).slice(0,O),[r.data]),n=Q(l,t.map(c=>c.id)),a=h.useMemo(()=>t.map((c,u)=>{var M;return{runId:c.id,createdAt:c.finalized_at??c.created_at,verdict:c.verdict,evidence:((M=n[u])==null?void 0:M.evidence)??null}}),[t,n]),o=h.useMemo(()=>{var c;return new Map((((c=i.data)==null?void 0:c.entries)??[]).filter(u=>u.suite_name).map(u=>[u.suite_version_id,u.suite_name]))},[i.data]),d=h.useMemo(()=>we(a),[a]),m=h.useMemo(()=>fe(a,o),[a,o]),x=h.useMemo(()=>be(a,o),[a,o]),v=h.useMemo(()=>pe(a,o).filter(c=>c.points.some(u=>u.margin!==null)),[a,o]),_=h.useMemo(()=>_e(a),[a]),E=h.useMemo(()=>{const c=a[0];return c?ge([c],o):[]},[a,o]),N=(w=r.data)==null?void 0:w.find(c=>c.id===s.value),j=X(l,s.isOpen?s.value??void 0:void 0);return r.isError?e.jsx("div",{className:"p-6",children:e.jsx(ee,{error:r.error,what:"the gate runs",onRetry:r.refetch})}):e.jsxs("div",{className:"flex min-h-0 flex-1",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-6 p-6",children:[e.jsx(re,{title:"Gate",description:`Which suites kill candidates, at what margins, over time. Reading the last ${O} finalized runs.`}),r.isLoading?e.jsx(R,{className:"h-40 w-full"}):t.length===0?e.jsx(S,{title:"No finalized gate run yet",description:"Forensics need at least one run that reached a verdict. A run still collecting cells has nothing to say about margins."}):e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(y,{label:"PASS",value:f(d.pass)}),e.jsx(y,{label:"REJECT",value:f(d.reject)}),e.jsx(y,{label:"INCONCLUSIVE",value:f(d.inconclusive),footnote:"Evidence problems, not quality verdicts."}),e.jsx(y,{label:"Runs in window",value:f(t.length),footnote:(((L=r.data)==null?void 0:L.length)??0)>t.length?`${f((((T=r.data)==null?void 0:T.length)??0)-t.length)} more not finalized`:void 0})]}),x.length>0&&e.jsx("section",{className:"space-y-2",children:x.map(c=>e.jsxs("div",{className:"flex flex-wrap items-start gap-3 rounded-lg border p-3 text-sm",style:se("warning",8,25),children:[e.jsx(he,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0 flex-1 text-foreground",children:[e.jsxs("div",{className:"font-medium",children:["Possible plateau on ",c.label]}),e.jsxs("p",{className:"mt-0.5 text-muted-foreground",children:["The last ",c.runs," rejected candidates all died on this suite, and the margin moved by ",b(c.drift,3)," across them (",c.margins.map(u=>A(u,3)).join(", "),"). More of the same training is unlikely to close it; the approach probably needs to change."]})]})]},c.suiteVersionId))}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Which suites kill candidates"}),e.jsx(ye,{kills:m})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Margins in the latest run"}),a[0]&&e.jsx("button",{type:"button",className:"text-xs underline underline-offset-2",onClick:()=>s.open(a[0].runId),children:"Open run evidence"})]}),e.jsx(ke,{margins:E})]}),v.length>0&&e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Margin over time"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Each panel is one suite's w
6orst rule against its own threshold, oldest first. Zero is the bar; below it the suite is short. Suites are not on a shared scale and are never drawn on one."}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:v.map(c=>e.jsx(Ie,{series:c},c.suiteVersionId))})]}),d.inconclusive>0&&e.jsxs("section",{className:"space-y-2 border-t border-border pt-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-4 w-4 text-status-warning","aria-hidden":"true"}),e.jsx("h3",{className:"text-sm font-medium",children:"Inconclusive runs â evidence problems, not verdicts"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"These runs could not decide. Nothing here says a candidate was bad; it says the measurement did not happen. They are counted apart from REJECT for that reason."}),e.jsx("ul",{className:"divide-y divide-border rounded-lg border border-border",children:_.map(c=>e.jsxs("li",{className:"flex flex-wrap items-center gap-3 p-3 text-sm",children:[e.jsx("span",{className:"flex-1",children:c.label}),e.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:c.reason}),e.jsx($,{variant:"secondary",color:ne.warning,children:f(c.count)}),e.jsx("span",{className:"flex gap-1",children:c.runIds.slice(0,3).map(u=>e.jsx("button",{type:"button",className:"text-xs underline underline-offset-2",onClick:()=>s.open(u),children:u.slice(0,8)},u))})]},c.reason))})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Runs"}),e.jsx("ul",{className:"divide-y divide-border rounded-lg border border-border",children:t.map(c=>e.jsxs("li",{className:"flex flex-wrap items-center gap-3 p-3 text-sm",children:[e.jsx(I,{status:c.verdict||"unknown",domain:"verdict",size:"sm"}),e.jsxs("span",{className:"flex flex-1 items-center gap-1 truncate",children:["candidate ",e.jsx(k,{value:c.candidate_model_version_id})]}),e.jsx(le,{value:c.finalized_at??c.created_at,className:"text-xs text-muted-foreground"}),e.jsx("button",{type:"button",className:"text-xs underline underline-offset-2",onClick:()=>s.toggle(c.id),children:"Evidence"})]},c.id))})]})]})]}),e.jsx(ie,{open:s.isOpen,onClose:s.close,title:N?`Gate run ${N.id.slice(0,8)}`:"Gate run",children:j.isLoading?e.jsx(R,{className:"h-32 w-full"}):j.data?e.jsx(Ce,{evidence:j.data,names:o}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"This run has not finalized, so there is no evidence record yet. That is different from a run that produced none."})})]})}function ye({kills:l}){if(l.length===0)return e.jsx(S,{compact:!0,title:"No suite has failed a candidate in this window"});const r=l.map(s=>({label:s.label,fails:s.fails,inconclusive:s.inconclusive})),i={fails:{label:"Failed",color:"var(--status-error)"},inconclusive:{label:"Inconclusive",color:"var(--status-warning)"}};return e.jsx(V,{config:i,className:"w-full",style:{height:`${Math.max(140,r.length*34+40)}px`},children:e.jsxs(ae,{data:r,layout:"vertical",margin:{left:8,right:16,top:4,bottom:4},children:[e.jsx(F,{horizontal:!1}),e.jsx(U,{type:"number",allowDecimals:!1,fontSize:11,tickLine:!1,axisLine:!1}),e.jsx(D,{type:"category",dataKey:"label",width:150,fontSize:11,tickLine:!1,axisLine:!1}),e.jsx(B,{content:({active:s,payload:t,label:n})=>s&&(t!=null&&t.length)?e.jsxs("div",{className:"rounded-lg border border-border bg-popover p-2 text-sm shadow-overlay",children:[e.jsx("div",{className:"mb-1 font-medium",children:String(n)}),t.map((a,o)=>e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("span",{className:"text-muted-foreground",children:a.dataKey==="fails"?"Failed":"Inconclusive"}),e.jsx("span",{className:"font-mono",children:String(a.value)})]},o))]}):null}),e.jsx(z,{dataKey:"fails",fill:"var(--status-error)",radius:2,isAnimationActive:!1}),e.jsx(z,{dataKey:"inconclusive",fill:"var(--status-warning)",radius:2,isAnimationActive:!1})]})})}function ke({margins:l}){if(l.length===0)return e.jsx(S,{compact:!0,title:"The latest run's evidence has not loaded"});const r=[...l].sort((i,s)=>Number(s.blocking)-Number(i.blocking)||+(i.verdict==="PASS")-+(s.verdict==="PASS")||i.margin-s.margin);return e.jsx("div",{className:"overflow-x-auto rounded-lg border border-border",children:e.jsxs(W,{children:[e.jsx(H,{children:e.jsxs(P,{children:[e.jsx(g,{children:"Suite"}),e.jsx(g,{children:"Rule"}),e.jsx(g,{children:"Verdict"}),e.jsx(g,{className:"text-right",children:"Estimate"}),e.jsx(g,{className:"text-right",children:"Bound"}),e.jsx(g,{className:"text-right",children:"Threshold"}),e.jsx(g,{className:"text-right",children:"Margin"}),e.jsx(g,{className:"text-right",children:"n"})]})}),e.jsx(J,{children:r.map(i=>e.jsxs(P,{children:[e.jsxs(p,{children:[e.jsx("span",{className:"truncate",children:i.suiteLabel}),!i.blocking&&e.jsx("span",{className:"ml-1 text-xs text-muted-foreground",children:"diagnostic"})]}),e.jsxs(p,{className:"text-xs",children:[i.ruleIndex===-1?"target floor":i.template.replace(/_/g," "),i.reason&&e.jsx("div",{className:"text-muted-foreground",children:i.reason.replace(/_/g," ")})]}),e.jsx(p,{children:e.jsx(I,{status:i.verdict,domain:"rule",size:"sm"})}),e.jsx(p,{className:"text-right font-mono",children:b(i.estimate,3)}),e.jsxs(p,{className:"text-right font-mono text-muted-foreground",children:["[",b(i.lower,3),", ",b(i.upper,3),"]"]}),e.jsx(p,{className:"text-right font-mono",children:b(i.threshold,3)}),e.jsx(p,{className:"text-right font-mono",children:A(i.margin,3)}),e.jsx(p,{className:"text-right font-mono",children:f(i.n)})]},`${i.suiteVersionId}-${i.ruleIndex}`))})]})})}function Ie({series:l}){const r=l.points.map((s,t)=>({i:t+1,margin:s.margin,verdict:s.verdict})),i={margin:{label:"Margin",color:"var(--chart-1)"}};return e.jsxs("div",{className:"rounded-lg border border-border bg-card p-3",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:l.label}),l.blocking&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"blocking"})]}),e.jsx(V,{config:i,className:"mt-2 h-32 w-full",children:e.jsxs(de,{data:r,margin:{top:4,right:8,bottom:0,left:0},children:[e.jsx(F,{vertical:!1}
6),e.jsx(U,{dataKey:"i",tick:!1,axisLine:!1,tickLine:!1,height:4}),e.jsx(D,{width:48,fontSize:11,tickLine:!1,axisLine:!1}),e.jsx(ue,{y:0,stroke:"var(--status-warning)",strokeDasharray:"4 3"}),e.jsx(B,{content:({active:s,payload:t})=>{var n,a;return s&&(t!=null&&t.length)?e.jsx("div",{className:"rounded-lg border border-border bg-popover p-2 text-sm shadow-overlay",children:e.jsx("div",{className:"font-mono",children:((n=t[0])==null?void 0:n.value)===null||((a=t[0])==null?void 0:a.value)===void 0?"unknown":A(t[0].value,3)})}):null}}),e.jsx(me,{type:"monotone",dataKey:"margin",stroke:"var(--chart-1)",strokeWidth:2,dot:{r:2},connectNulls:!1,isAnimationActive:!1})]})})]})}function Ce({evidence:l,names:r}){var i;return e.jsxs("div",{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(I,{status:l.verdict,domain:"verdict"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l.engine_version})]}),(((i=l.reasons)==null?void 0:i.length)??0)>0&&e.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:l.reasons.map(s=>e.jsx("li",{children:s.replace(/_/g," ")},s))}),e.jsx("div",{className:"space-y-2",children:l.suites.map(s=>e.jsxs("div",{className:"rounded-md border border-border p-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium",children:r.get(s.suite_version_id)??s.eval_id}),e.jsx(I,{status:s.verdict,domain:"rule",size:"sm"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:s.blocking?"blocking":"diagnostic"})]}),s.reason&&e.jsx("div",{className:"mt-0.5 text-xs text-muted-foreground",children:s.reason.replace(/_/g," ")}),typeof s.deficit=="number"&&e.jsxs("div",{className:"mt-0.5 text-xs",children:["short of the floor by ",b(s.deficit,3)]}),s.sealed_summary&&s.sealed_summary.n>0&&e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["sealed: ",f(s.sealed_summary.n_failed)," failed of"," ",f(s.sealed_summary.n)]})]},s.suite_version_id))}),e.jsxs("div",{className:"space-y-1 border-t border-border pt-3 text-xs",children:[e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Ledger"}),e.jsx(k,{value:l.ledger_version_id})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Protocol"}),e.jsx(k,{value:l.protocol_id})]}),e.jsxs("div",{className:"flex justify-between gap-2",children:[e.jsx("span",{className:"text-muted-foreground",children:"Candidate"}),e.jsx(k,{value:l.candidate_id})]})]})]})}export{Ge as ProjectGateTab,Ge as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.