PageSourceSearch

https://ultimateswarm.ai/assets/js/MLGraduationPanel-C8ShSEa6.js

js ultimateswarm.ai collected 2026-10-05 13:12:38 UTC 7,404 bytes, 1 lines download raw bytes

1import{r as s,j as e}from"./vendor-react-WbYzT9B1.js";import{J as a,L as I,M as C}from"./AuthenticatedTerminal-Dx1xTefe.js";import{q as S}from"./index-gQh_1vMV.js";import{A as M,R as G,a as k}from"./vendor-icons-DL8ftop_.js";import"./vendor-shared-DDxGyXze.js";import"./vendor-supabase-bqjDK5Eu.js";import"./schemas-DGe_Id1b.js";import"./vendor-ai-CRM-FDtT.js";import"./vendor-xstate-DTXGpalr.js";import"./vendor-sentry-QE7Hifj1.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};i.SENTRY_RELEASE={id:"b19af26d6b3b2e41c3d08e2ef62b63e2331ea50d"};var l=new i.Error().stack;l&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[l]="785dbf94-683b-474b-91f3-b583603228c8",i._sentryDebugIdIdentifier="sentry-dbid-785dbf94-683b-474b-91f3-b583603228c8")}catch{}})();const H=({onStateChange:i})=>{const[l,b]=s.useState(null),[f,D]=s.useState(!0),[m,N]=s.useState(!1),[x,d]=s.useState(null),[P,R]=s.useState(null),p=s.useRef(0),w=s.useRef(!1),v=s.useRef(-1),y=s.useRef(!1),E=s.useCallback(async()=>{if(y.current)return;const t=++p.current,n=a.getGeneration();v.current=n,D(!0),d(null);const o=await a.syncFromServer(S,I);!w.current||t!==p.current||n!==a.getGeneration()||(v.current=n,b(o.ok?o.snapshot:null),R(o.ok?null:`Server graduation evidence unavailable: ${o.reason}`),D(!1))},[]);s.useEffect(()=>{const t=p;w.current=!0,E();const n=setInterval(()=>{E()},6e4),o=setInterval(()=>{v.current!==a.getGeneration()&&(y.current=!1,b(null),d(null),N(!1),v.current=a.getGeneration(),E())},250);return()=>{w.current=!1,t.current++,clearInterval(n),clearInterval(o)}},[E]);const T=async()=>{if(y.current)return;if(!x||!l&&x!=="DEMOTED"||v.current!==a.getGeneration()){d(null),b(null),R("Model or account changed; refresh server evidence before continuing.");return}const t=++p.current,n=a.getGeneration(),o=x;y.current=!0,N(!0);const h=await a.graduateViaServer(S,I,o);!w.current||t!==p.current||n!==a.getGeneration()||(y.current=!1,N(!1),d(null),b(h.ok?h.snapshot:null),R(h.ok?null:`Transition rejected or unconfirmed: ${h.reason}`),h.ok&&i?.(h.snapshot.state))},c=a.getState(),A=c==="DEMOTED"&&l?.state!=="DEMOTED",j=A?null:c==="SHADOW"||c==="DEMOTED"?"PAPER":c==="PAPER"?"LIVE":null,u=l?.evaluation,g=C,r=u?.metrics,L=[{label:"Total Trades",value:r?.totalTrades,threshold:g.minTrades,unit:"trades"},{label:"Direction Accuracy",value:r?.directionAccuracy==null?null:r.directionAccuracy*100,threshold:g.minDirectionAccuracy*100,unit:"%"},{label:"Sharpe Ratio",value:r?.sharpeRatio,threshold:g.minSharpeRatio,unit:""},{label:"Max Drawdown",value:r?.maxDrawdown==null?null:r.maxDrawdown*100,threshold:g.maxDrawdown*100,unit:"%",inverse:!0},{label:"Timing Error",value:r?.avgTimingError,threshold:g.maxTimingErrorSeconds,unit:"sec",inverse:!0},{label:"Days in State",value:r?.daysInCurrentState,threshold:g.minDaysInState,unit:"days"}];return e.jsxs("section",{className:"space-y-6","aria-label":"ML Model Graduation",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-white flex items-center gap-2",children:[e.jsx(M,{size:24}),"ML Model Graduation"]}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["Current State:"," ",e.jsx("strong",{children:l?c:`Unconfirmed — ${c} safety state`})]}),A&&e.jsx("p",{role:"status",className:"text-yellow-200",children:"Model locally disabled; server demotion unconfirmed."}),e.jsxs("p",{className:"text-gray-400 text-sm",children:["Artifact: ",l?.artifact_version??"Unavailable"]})]}),e.jsxs("button",{type:"button",onClick:()=>{E()},disabled:f||m,className:"px-3 py-2 rounded bg-gray-700 text-white disabled:opacity-50",children:[e.jsx(G,{size:16,className:f?"animate-spin inline mr-2":"inline mr-2"}),"Refresh"]})]}),f&&e.jsx("p",{role:"status",className:"text-gray-400",children:"Loading server graduation evidence..."}),P&&e.jsxs("div",{role:"alert",className:"p-4 border border-red-600 rounded-lg text-red-200",children:[e.jsx(k,{size:20,className:"inline mr-2"}),P]}),e.jsx("p",{className:"text-gray-300 text-sm",children:"PAPER admits observation of a genuine artifact; it does not certify LIVE readiness. LIVE graduation requires trusted prospective model-specific PAPER evidence. Browser prediction history never authorizes graduation."}),e.jsx("h3",{className:"text-white font-semibold",children:"LIVE evidence requirements"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:L.map(t=>{const n=t.value!=null&&(t.inverse?t.value<=t.threshold:t.value>=t.threshold);return e.jsxs("div",{className:`p-4 rounded-lg border ${n?"bg-green-900/20 border-green-600":"bg-gray-800 border-gray-700"}`,children:[e.jsx("h4",{className:"font-medium text-white",children:t.label}),e.jsx("p",{className:"text-2xl font-bold text-white",children:t.value==null?"Unavailable":`${t.value.toFixed(2)} ${t.unit}`}),e.jsxs("p",{className:"text-xs text-gray-400",children:["Target: ",t.inverse?"≤":"≥"," ",t.threshold.toFixed(2)," ",t.unit]})]},t.label)})}),e.jsxs("div",{className:"flex gap-6 text-gray-300 text-sm",children:[e.jsxs("p",{children:["Win Rate:"," ",r?.winRate==null?"Unavailable":`${(r.winRate*100).toFixed(1)}%`]}),e.jsxs("p",{children:["Profit Factor:"," ",r?.profitFactor==null?"Unavailable":r.profitFactor.toFixed(2)]}),e.jsxs("p",{children:["Evaluated At:"," ",u?new Date(u.evaluatedAt).toLocaleTimeString():"Unavailable"]})]}),u&&j&&e.jsxs("div",{className:"p-4 rounded-lg border border-gray-700 space-y-3",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:j==="PAPER"?"PAPER observation admission":"LIVE graduation"}),u.eligible?e.jsxs("p",{className:"text-green-300",children:["Server permits requesting"," ",j==="PAPER"?"PAPER observation admission":"LIVE graduation","; the request is revalidated on the server."]}):e.jsx("ul",{className:"list-disc list-inside text-yellow-200",children:u.failedCriteria.map((t,n)=>e.jsx("li",{children:t},n))}),e.jsx("button",{type:"button",disabled:!u.eligible||f||m,onClick:()=>d(j),className:"px-4 py-2 rounded bg-green-700 text-white disabled:opacity-50",children:j==="PAPER"?"Admit to PAPER observation":"Graduate to LIVE"})]}),(c==="LIVE"||A)&&e.jsx("button",{type:"button",disabled:f||m,onClick:()=>d("DEMOTED"),className:"px-4 py-2 rounded bg-red-700 text-white",children:"Demote model"}),x&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"graduation-confirmation",className:"fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-4",children:e.jsxs("div",{className:"bg-gray-900 rounded-xl max-w-md p-6 border border-gray-700 space-y-4",children:[e.jsxs("h3",{id:"graduation-confirmation",className:"text-xl font-bold text-white",children:["Confirm"," ",x==="PAPER"?"PAPER observation admission":x==="LIVE"?"LIVE graduation":"demotion"]}),e.jsx("p",{className:"text-gray-300",children:"This requests a server-authorized model state change, not activation of trading or execution permissions."}),e.jsx("button",{type:"button",disabled:m,onClick:()=>d(null),className:"px-4 py-2 bg-gray-700 text-white rounded mr-3",children:"Cancel"}),e.jsx("button",{type:"button",disabled:m,onClick:()=>{T()},className:"px-4 py-2 bg-purple-700 text-white rounded",children:m?"Processing...":"Confirm"})]})})]})};export{H as MLGraduationPanel};

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.