Gobernanza: execution, models (training, run monitor, checks, lineage, bundles, interpretability), EEG studies

Share one execution selection across training and analysis. Use the first
configured scheduler for a remote default and let the API validate typed
addresses. Suspend health polling when the document is hidden. Poll each
run serially, retry status reads on transient errors, and compute ETA from
completed items and elapsed seconds.

Reuse the Conectar Formly types with nullable fields and inlined references.
Omit the optional cohort when its name is blank, and offer the declared
input sets in a datalist with filename validation before upload. Identify
the versions created by a training run from its version log lines, then
check each exact version before promotion. Use native dialogs for checks,
lineage, bulk confirmation and preview. Recheck promotion eligibility before
submitting changes, and list results per version.

Verify bundle hashes using SubtleCrypto before upload. Use blob downloads
for bundles and reports. Read age centiles from the curve endpoint and keep
the count-rate reference line from the report. Join study metrics by code
and regional values by feature, skipping absent ages and values. Use one
Plotly trace per association pair and scale the forest plot height by row
count.

Preflight the TEA pipeline before staging EDFs, then start the pipeline once
for the batch. Refresh studies, their overlays and summary on completed
runs. Page through analyze history to compare its end times against the
latest tea_eeg result. The branch base lacks export/pdf.ts, so the preview
uses the specified TODO and omits the PDF action.

Added Vitest coverage for execution and run polling, ETA and cancellation,
training schema, version actions, bundle digest verification, study overlays
and the association forest. Ruff check, Ruff format --check, Prettier,
strict Angular and TypeScript diagnostics for Gobernanza and git diff --check
passed. npm ci, ng build and vitest run are assigned to the test machines.
This commit is contained in:
2026-11-30 13:53:24 -06:00
parent 5d03f333f7
commit e2d1c9f277
17 changed files with 2202 additions and 265 deletions
+82 -4
View File
@@ -1,4 +1,4 @@
import { interpretabilityFigures } from './figures';
import { interpretabilityFigures, studyPoints } from './figures';
describe('governance figures', () => {
it('draws a survival report as curves with bands and the model points', () => {
@@ -9,7 +9,7 @@ describe('governance figures', () => {
],
predicted: { name: 'Modelo', months: [6], survival: [0.92], low: [0.85], high: [0.97] },
});
expect(found.figure.data.length).toBe(3); // band, curve, model points
expect(found.figure.data.length).toBe(3);
expect((found.figure.data[2] as any).error_y.array[0]).toBeCloseTo(0.05);
});
@@ -32,7 +32,7 @@ describe('governance figures', () => {
});
expect(found.length).toBe(2);
expect(found[1].title).toContain('fallecidos = 308');
expect(found[1].figure.data.length).toBe(5); // band, KM, Weibull, fractional, points
expect(found[1].figure.data.length).toBe(5);
expect((found[1].figure.data[4] as any).x).toEqual([6, 12, 18]);
});
@@ -55,7 +55,7 @@ describe('governance figures', () => {
],
},
});
expect(found.figure.data.length).toBe(5); // band, KM, Weibull, fractional, points
expect(found.figure.data.length).toBe(5);
});
it('draws an age curve with its centile band', () => {
@@ -71,6 +71,84 @@ describe('governance figures', () => {
expect(found.figure.data.length).toBe(2);
});
it('overlays the matching analysed metric at each study age on the API centiles', () => {
const points = studyPoints(
[
{
id: 'one',
valid: true,
level: null,
age_months: 21,
checks: [],
regions: [],
metrics: [{ code: 'posterior_rhythm', value: 7, z: null, outside: null, model: null }],
},
{
id: 'two',
valid: true,
level: null,
age_months: null,
checks: [],
regions: [],
metrics: [{ code: 'posterior_rhythm', value: 9, z: null, outside: null, model: null }],
},
],
'eeg-posterior-rhythm',
'value',
);
const [found] = interpretabilityFigures(
{
kind: 'age_curves',
curves: { value: { kind: 'curves' } },
},
{
points,
centiles: [
{ age_months: 16, p5: 4, median: 6, p95: 8 },
{ age_months: 36, p5: 5, median: 7, p95: 9 },
],
},
);
expect(found.figure.data[1]).toMatchObject({ x: [16, 36], y: [6, 7] });
expect(found.figure.data[2]).toMatchObject({ mode: 'markers', x: [21], y: [7] });
});
it('plots one row per association pair on the log odds-ratio axis', () => {
const [found] = interpretabilityFigures({
kind: 'forest',
rows: [
{
biomarker: 'Spindles',
zone: 'F',
outcome_code: 'A1',
odds_ratio: 2,
ci_low: 1.5,
ci_high: 3,
q: 0.04,
},
{
biomarker: 'Spindles',
zone: 'O',
outcome_code: 'A1',
odds_ratio: 0.5,
ci_low: 0.25,
ci_high: 1,
q: 0.1,
},
],
});
expect(found.figure.layout?.xaxis?.type).toBe('log');
expect(found.figure.data).toHaveLength(2);
expect(found.figure.data[0]).toMatchObject({
x: [2],
y: ['Spindles · F · A1'],
error_x: { array: [1], arrayminus: [0.5] },
hovertemplate: expect.stringContaining('q: 0.04'),
});
});
it('draws nothing for a report it does not know', () => {
expect(interpretabilityFigures({ kind: 'other' })).toEqual([]);
});