'use strict'; const names = { 'tspulse_endwindow':'TSPulse · causal end-window','signal_logistic_C0.1':'Signal logistic · C 0.1','signal_logistic_C1.0':'Signal logistic · C 1','signal_logistic_C10.0':'Signal logistic · C 10', 'missingness_logistic_C0.1':'Missingness logistic · C 0.1','missingness_logistic_C1.0':'Missingness logistic · C 1','missingness_logistic_C10.0':'Missingness logistic · C 10', extra_trees_depth8:'Extra trees · depth 8',extra_trees_depthNone:'Extra trees · full depth',causal_tcn_seed7:'Causal TCN · seed 7',causal_tcn_seed29:'Causal TCN · seed 29', 'normal_residual_max':'Normal residual · maximum','normal_residual_cusum_k0.5':'Normal CUSUM · k 0.5','normal_residual_cusum_k1.0':'Normal CUSUM · k 1','normal_isolation_forest':'Normal isolation forest' }; let data; const el=id=>document.getElementById(id),text=(id,value)=>{el(id).textContent=value;}; const fmt=(value,digits=3)=>value===null||!Number.isFinite(value)?'No eligible exposure':value.toFixed(digits); const pct=value=>value===null||!Number.isFinite(value)?'No eligible exposure':(100*value).toFixed(2)+'%'; const ratio=(a,b)=>b>0?a/b:null; // The frozen arithmetic omits zero Counter entries. Missing keys are zero, // while a zero exposure denominator remains unavailable. const count=(x,key)=>x[key]??0; function row(values,attrs={}){const tr=document.createElement('tr');for(const [key,value] of Object.entries(attrs))tr.setAttribute(key,value);for(const value of values){const td=document.createElement('td');td.textContent=value;tr.append(td);}return tr;} function metric(parent,label,value,bad=false){const box=document.createElement('div');box.className='metric';const head=document.createElement('div');head.className='metric-head';const left=document.createElement('span'),right=document.createElement('span');left.textContent=label;right.textContent=pct(value);head.append(left,right);const track=document.createElement('div');track.className='track';const fill=document.createElement('div');fill.className='fill'+(bad?' bad':'');fill.style.width=(value===null?0:Math.min(100,Math.max(0,100*value)))+'%';track.append(fill);box.append(head,track);parent.append(box);} function renderEpisodes(){const candidate=el('candidate').value,cohort=el('cohort').value,group=el('group-filter').value;const all=data.candidates[candidate].cohorts[cohort].episodes;const rows=all.filter(x=>group==='all'||x.group===group);el('episodes').replaceChildren();for(const x of rows)el('episodes').append(row([x.path,String(x.event),String(x.eligible_decisions),x.covered?'Yes':'No',x.carried_in?'Yes':'No',x.first_covered_delay_seconds===null?'No coverage':x.first_covered_delay_seconds+' s',x.new_known_onset_discovery_300s?'Yes':'No'],{'data-recording':x.path,'data-start':String(x.start)}));text('episode-count',rows.length+' of '+all.length+' labelled episodes');} function render(){ const n=el('candidate').value,k=el('cohort').value,c=data.candidates[n],m=c.cohorts[k],x=m.counts,b=c.bootstrap[k]; text('candidate-meta',names[n]+(n===data.primary?' · validation-selected primary':'')+' · '+c.metadata.numeric_scalars.toLocaleString()+' recorded numeric scalars · '+(c.disabled?'ALARM DISABLED':'Frozen threshold '+c.threshold)+' · '+n); text('cohort-note',k==='common'?'Common eligibility is the intersection of all fifteen methods: '+data.common_decisions.toLocaleString()+' / '+data.full_decisions.toLocaleString()+' grid decisions. All episodes remain in the headline denominator.':'Native eligibility uses this method’s usable inputs and finite scores. Selection and threshold are unchanged; all episodes remain in the headline denominator.'); text('coverage',x.covered_episodes+' / '+x.episodes);text('coverage-detail',x.supported_episodes+' input-supported episodes · '+x.carried_in_covered_episodes+' covered with a carried-in alarm'); text('onset',x.new_known_onset_discoveries_300s+' / '+x.known_onset_episodes);text('onset-detail',x.supported_known_onsets_300s+' input-supported known onsets; alarm must begin after labelled onset'); text('false-rate',fmt(m.false_alarms_per_eligible_normal_day));text('false-detail',x.false_normal_alarm_episodes+' false alarm episodes / '+fmt(m.eligible_normal_days)+' eligible normal days'); text('occupation',pct(m.normal_alarm_occupation));text('occupation-detail',pct(m.normal_alarm_occupation_all_grid)+' of all labelled normal grid time'); el('eligibility-bars').replaceChildren();metric(el('eligibility-bars'),'Normal input eligibility',m.normal_input_eligibility);metric(el('eligibility-bars'),'Positive input eligibility',m.positive_input_eligibility);metric(el('eligibility-bars'),'Normal time in alarm',m.normal_alarm_occupation,true); text('exposure-note',x.unknown_grid_seconds.toLocaleString()+' unknown-label grid seconds; '+x.eligible_unknown_grid_seconds.toLocaleString()+' eligible. '+x.warmup_grid_seconds.toLocaleString()+' warmup grid seconds. Exposure uses recorded timestamps and capped decision durations.'); text('reload-result',c.reload.state+' · original saved-checkpoint tolerance'); text('reload-detail',(c.reload.probes?c.reload.probes+' saved eligible probes':c.reload.complete_validation_decisions+' complete validation decisions')+'; '+c.reload.failed_values+' failed score values. Maximum absolute score difference '+c.reload.max_abs_difference+'. atol '+c.reload.tolerance.atol+', rtol '+c.reload.tolerance.rtol+'.'+(c.reload.channel_failed_values!==undefined?' Channel failures: '+c.reload.channel_failed_values+'.':'')); const rev=data.model_content_revision,base='https://huggingface.co/'+data.model_repo+'/blob/'+(rev||'main')+'/foundation-validation/'; const artifact=c.metadata.kind==='tspulse'?'ORIGINAL-OUTPUT.zip':'outputs/'+c.metadata.artifact; el('checkpoint-link').href=base+artifact;el('checkpoint-link').textContent=c.metadata.kind==='tspulse'?'Inspect pinned pretrained checkpoint in the original archive':'Inspect unchanged saved checkpoint'; el('all-models').replaceChildren();for(const [name,v] of Object.entries(data.candidates)){const z=v.cohorts[k],q=z.counts;el('all-models').append(row([names[name]+(name===data.primary?' · primary':''),q.covered_episodes+' / '+q.episodes,q.new_known_onset_discoveries_300s+' / '+q.known_onset_episodes,fmt(z.false_alarms_per_eligible_normal_day),pct(z.normal_alarm_occupation),v.disabled?'Disabled':'Enabled',v.reload.state],{'data-candidate':name,'class':name===n?'selected':''}));} text('all-caption',k==='common'?'Common support; fixed validation-selected alarms':'Native support; same fixed validation-selected alarms'); el('groups').replaceChildren();for(const [group,g] of Object.entries(m.groups)){const rate=ratio(count(g,'false_normal_alarm_episodes')*86400,count(g,'eligible_normal_grid_seconds')),occupation=ratio(count(g,'normal_alarm_seconds'),count(g,'eligible_normal_grid_seconds'));el('groups').append(row([group,count(g,'covered_episodes')+' / '+count(g,'episodes'),count(g,'new_known_onset_discoveries_300s')+' / '+count(g,'known_onset_episodes'),String(count(g,'carried_in_covered_episodes')),fmt(rate),pct(occupation),pct(ratio(count(g,'eligible_normal_grid_seconds'),count(g,'normal_grid_seconds')))],{'data-group':group,'class':occupation!==null&&occupation>.01?'warn':''}));} text('group-caption',names[n]+' · '+k+' support'); el('uncertainty').replaceChildren();for(const [key,label,percent] of [['all_episode_alarm_coverage','Episode coverage',true],['new_known_onset_discovery_within_300s','New onset ≤300s',true],['false_alarms_per_eligible_normal_day','False alarms/day',false],['normal_alarm_occupation','Normal time in alarm',true],['normal_input_eligibility','Normal eligibility',true]]){const r=b[key],p=document.createElement('p');p.className='small';p.dataset.metric=key;p.textContent=label+': '+(r.interval_95===null?'Undefined interval':r.interval_95.map(v=>percent?pct(v):fmt(v)).join(' – '))+' · '+r.defined_replicates+' defined / '+r.undefined_replicates+' undefined of '+r.replicates+' replicates';el('uncertainty').append(p);} renderEpisodes(); } async function load(){try{ const response=await fetch('foundation-validation.json',{cache:'no-store'});if(!response.ok)throw new Error('Saved result file returned HTTP '+response.status);data=await response.json(); if(data.schema!=='industrial.well.foundation.validation.presentation.v1'||Object.keys(data.candidates).length!==15||data.reserved_predictions_opened!==false||data.fresh_confirmation!==false||data.field_qualified!==false)throw new Error('Unexpected result identity or admission state'); for(const [name,c] of Object.entries(data.candidates)){const option=document.createElement('option');option.value=name;option.textContent=names[name]+(name===data.primary?' · primary':'');el('candidate').append(option);} el('candidate').value=data.primary; for(const group of ['all',...Object.keys(data.candidates[data.primary].cohorts.common.groups)]){const option=document.createElement('option');option.value=group;option.textContent=group==='all'?'All eight filename groups':group;el('group-filter').append(option);} const base='https://huggingface.co/'+data.model_repo+'/blob/'+(data.model_content_revision||'main')+'/foundation-validation/';for(const [id,path] of Object.entries({'report-link':'foundation_review/REPORT.md','archive-link':'ORIGINAL-OUTPUT.zip','rebuild-link':'REBUILD.md','protocol-link':'foundation_study/PROTOCOL.json','diagnostic-link':'tcn_replay_diagnostic/REPORT.md'})){el(id).href=base+path;} text('archive-digest',data.original_output_sha256);text('selection-digest',data.selection_sha256);text('content-revision',data.model_content_revision||'Local preview · publication pending'); el('candidate').addEventListener('change',render);el('cohort').addEventListener('change',render);el('group-filter').addEventListener('change',renderEpisodes);render();el('load-state').hidden=true;el('audit').hidden=false; }catch(error){el('load-state').className='error';text('load-state','Result audit could not load. '+error.message);}} load();