well-event-transfer-audit / incremental-well-validation.js
sankalpsthakur's picture
Add complete incremental well validation, exact inputs and retained failures
242f713 verified
Raw History Blame Contribute Delete
7.59 kB
'use strict';
const $ = id => document.getElementById(id);
const number = n => n.toLocaleString('en-US');
const ms = n => n === null ? 'Unavailable' : `${(n / 1e6).toFixed(3)} ms`;
const featureLabels = { raw_features: 'Raw summaries', bin_means: 'Past bin means', bin_fractions: 'Past bin availability', summary: 'Scaled summaries', temporal: 'Scaled temporal input' };
let saved;
function cell(row, value) { const td = document.createElement('td'); td.textContent = value; row.append(td); return td; }
function render() {
const profile = saved.result.profiles.find(p => p.candidate === $('checkpoint').value);
const checked = saved.review.profiles.find(p => p.candidate === profile.candidate);
const row = profile.records[Number($('recording').value)];
if (!row || !checked) throw new Error('Complete selected recording is absent');
$('selection-note').textContent = `${profile.candidate} · ${row.path} · ${number(row.rows)} accepted source rows · ${number(row.grid_rows)} decisions · ${row.state === 'PASSED' ? 'Original conformance checks pass' : 'Original conformance checks FAILED'}`;
$('selection-note').className = row.state === 'PASSED' ? 'pass' : 'fail';
$('score-failures').textContent = number(row.score_comparison.failed_values);
$('score-failures').className = row.score_comparison.failed_values ? 'fail' : '';
$('score-detail').textContent = `${number(row.score_comparison.finite_pairs)} finite pairs; maximum difference ${row.score_comparison.max_finite_abs_difference === null ? 'unavailable' : row.score_comparison.max_finite_abs_difference.toExponential(6)}. Atol 1e-10 / rtol 1e-9.`;
$('alarm-changes').textContent = number(row.alarm_changes);
$('alarm-changes').className = row.alarm_changes ? 'fail' : '';
$('alarm-detail').textContent = profile.frozen_threshold === null ? 'This checkpoint’s original alarm is disabled' : 'Unchanged original threshold and alarm semantics';
$('pipeline-median').textContent = ms(row.pipeline_eligible_grid.median_ns);
$('pipeline-tail').textContent = `P95 ${ms(row.pipeline_eligible_grid.p95_ns)}; maximum ${ms(row.pipeline_eligible_grid.max_ns)}; first eligible call ${ms(row.pipeline_eligible_grid.first_ns)}. All retained.`;
$('missing-now').textContent = `${number(row.supported_with_current_missing)} of ${number(row.supported_rows)} historically eligible decisions have missing current channels; ${number(row.supported_with_fewer_than_three_current_channels)} have fewer than three current channels, and ${number(row.supported_with_fewer_than_two_current_pressure_channels)} fewer than two current pressure channels. Historical eligibility is not physical sensor quality.`;
$('feature-rows').replaceChildren();
for (const [key, detail] of Object.entries(row.feature_comparisons)) {
const tr = document.createElement('tr'); tr.dataset.feature = key;
if (detail.failed_values) tr.className = 'fail';
for (const item of [featureLabels[key] || key, number(detail.values), number(detail.failed_values), number(detail.different_bit_values), detail.max_finite_abs_difference === null ? 'Unavailable' : detail.max_finite_abs_difference.toExponential(6)]) cell(tr, item);
$('feature-rows').append(tr);
}
$('discrete-changes').textContent = 'Discrete changes: ' + Object.entries(row.discrete_changes).map(([key,value]) => `${key}: ${number(value)}`).join('; ') + '.';
const m = profile.common_metric, c = m.counts;
$('alarm-usefulness').textContent = `Complete checkpoint, common eligibility: ${c.covered_episodes}/${c.episodes} episodes covered; ${c.new_known_onset_discoveries_300s} new known-onset discoveries within 300 s; ${c.false_normal_alarm_episodes ?? 0} false normal alarm episodes over ${m.eligible_normal_days.toFixed(6)} eligible normal days. These reused validation outcomes are not fresh field performance.`;
$('group-rows').replaceChildren();
for (const [name, group] of Object.entries(checked.groups)) {
const tr = document.createElement('tr'); tr.dataset.group = name;
tr.classList.toggle('selected', name === row.group);
if (group.feature_failures || group.score_failures || group.alarm_changes) tr.classList.add('fail');
for (const item of [name, number(group.supported_rows), number(group.feature_failures), number(group.score_failures), number(group.alarm_changes), number(group.supported_current_missing)]) cell(tr, item);
$('group-rows').append(tr);
}
}
fetch('incremental-well-validation.json').then(response => {
if (!response.ok) throw new Error(`Saved result response ${response.status}`);
return response.json();
}).then(data => {
if (data.schema !== 'industrial.well.incremental.saved.presentation.v1' || data.result.state !== 'COMPLETE_VALIDATION_REVIEW_NOT_FIELD_ADMISSION' || data.result.profiles.length !== 2 || data.review.state !== 'VERIFIED_SAVED_ARRAY_CONFORMANCE_AND_FAILURES_NOT_FIELD_ADMISSION' || !/^[0-9a-f]{40}$/.test(data.artifact_revision)) throw new Error('Complete reviewed and pinned source required');
saved = data;
for (const profile of data.result.profiles) { const option = document.createElement('option'); option.value = profile.candidate; option.textContent = profile.candidate; $('checkpoint').append(option); }
for (const [index, row] of data.result.profiles[0].records.entries()) { const option = document.createElement('option'); option.value = String(index); option.textContent = row.path; $('recording').append(option); }
$('source-rows').textContent = number(data.result.profiles[0].accepted_rows);
$('timing-rows').textContent = number(data.review.accepted_row_timing_records_verified);
$('execution-state').textContent = data.provider.state;
$('conformance-state').textContent = data.result.conformance_passed ? 'Numerical conformance passes; industrial admission remains false' : 'Numerical conformance FAILED; every failure retained';
$('conformance-state').className = data.result.conformance_passed ? 'detail' : 'detail fail';
$('original-failure').textContent = `Original version 1: ${data.original_error.provider_status}, ${number(data.original_error.actual_cloud_authored_checks_passed)} authored checks passed, null-column decoder failure after ${number(data.original_error.complete_reference_source_rows)} complete reference rows; zero trained rolling predictions. Recovery version 2: ${data.provider.authored_checks} authored checks passed. No third attempt is implied.`;
$('artifact-revision').textContent = data.artifact_revision;
$('output-sha').textContent = data.provider.output_zip_sha256;
const base = `https://huggingface.co/sankalpsthakur/well-production-event-causal/`;
for (const [id,file] of [['report-link','REPORT.md'],['output-link','ORIGINAL-RECOVERY-OUTPUT.zip'],['rebuild-link','REBUILD.md']]) $(id).href = `${base}${id === 'output-link' ? 'resolve' : 'blob'}/${data.artifact_revision}/incremental-well-validation/${file}`;
$('runtime').textContent = `Observed Linux CPU runtime: Torch ${data.result.runtime.torch}, NumPy ${data.result.runtime.numpy}, PyArrow ${data.result.runtime.pyarrow}; two CPU threads. Child elapsed ${data.result.elapsed_seconds.toFixed(3)} s; process-lifetime peak RSS ${number(data.result.peak_rss)} ${data.result.peak_rss_unit}.`;
$('checkpoint').addEventListener('change',render); $('recording').addEventListener('change',render);
render(); $('audit').hidden = false; $('load-state').hidden = true;
}).catch(error => { $('audit').hidden = true; $('load-state').className = 'error'; $('load-state').textContent = `Saved results unavailable: ${error.message}. No inference is performed.`; });