@actuarial-ts/core 0.4.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -215
- package/dist/casualtyDiagnostics.d.ts +19 -49
- package/dist/casualtyDiagnostics.d.ts.map +1 -1
- package/dist/casualtyDiagnostics.js +84 -114
- package/dist/casualtyDiagnostics.js.map +1 -1
- package/dist/diagnosticAggregation.d.ts +29 -0
- package/dist/diagnosticAggregation.d.ts.map +1 -0
- package/dist/diagnosticAggregation.js +50 -0
- package/dist/diagnosticAggregation.js.map +1 -0
- package/dist/diagnosticDefinitions.d.ts +286 -0
- package/dist/diagnosticDefinitions.d.ts.map +1 -0
- package/dist/diagnosticDefinitions.js +1026 -0
- package/dist/diagnosticDefinitions.js.map +1 -0
- package/dist/diagnosticDerivations.d.ts +12 -0
- package/dist/diagnosticDerivations.d.ts.map +1 -0
- package/dist/diagnosticDerivations.js +80 -0
- package/dist/diagnosticDerivations.js.map +1 -0
- package/dist/diagnosticExposure.d.ts +51 -0
- package/dist/diagnosticExposure.d.ts.map +1 -0
- package/dist/diagnosticExposure.js +65 -0
- package/dist/diagnosticExposure.js.map +1 -0
- package/dist/diagnosticExpressions.d.ts +56 -0
- package/dist/diagnosticExpressions.d.ts.map +1 -0
- package/dist/diagnosticExpressions.js +104 -0
- package/dist/diagnosticExpressions.js.map +1 -0
- package/dist/diagnosticFormulas.d.ts +195 -0
- package/dist/diagnosticFormulas.d.ts.map +1 -0
- package/dist/diagnosticFormulas.js +85 -0
- package/dist/diagnosticFormulas.js.map +1 -0
- package/dist/diagnosticIdentity.d.ts +237 -0
- package/dist/diagnosticIdentity.d.ts.map +1 -0
- package/dist/diagnosticIdentity.js +454 -0
- package/dist/diagnosticIdentity.js.map +1 -0
- package/dist/diagnosticPeriods.d.ts +16 -0
- package/dist/diagnosticPeriods.d.ts.map +1 -0
- package/dist/diagnosticPeriods.js +98 -0
- package/dist/diagnosticPeriods.js.map +1 -0
- package/dist/diagnosticPreparation.d.ts +98 -0
- package/dist/diagnosticPreparation.d.ts.map +1 -0
- package/dist/diagnosticPreparation.js +169 -0
- package/dist/diagnosticPreparation.js.map +1 -0
- package/dist/diagnosticReview.d.ts +44 -0
- package/dist/diagnosticReview.d.ts.map +1 -0
- package/dist/diagnosticReview.js +84 -0
- package/dist/diagnosticReview.js.map +1 -0
- package/dist/diagnosticRules.d.ts +32 -0
- package/dist/diagnosticRules.d.ts.map +1 -0
- package/dist/diagnosticRules.js +32 -0
- package/dist/diagnosticRules.js.map +1 -0
- package/dist/diagnosticRunner.d.ts +85 -0
- package/dist/diagnosticRunner.d.ts.map +1 -0
- package/dist/diagnosticRunner.js +117 -0
- package/dist/diagnosticRunner.js.map +1 -0
- package/dist/index.d.ts +24 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +17 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +114 -0
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/package.json +2 -2
- package/src/casualtyDiagnostics.ts +79 -187
- package/src/diagnosticAggregation.ts +79 -0
- package/src/diagnosticDefinitions.ts +1375 -0
- package/src/diagnosticDerivations.ts +89 -0
- package/src/diagnosticExposure.ts +91 -0
- package/src/diagnosticExpressions.ts +173 -0
- package/src/diagnosticFormulas.ts +150 -0
- package/src/diagnosticIdentity.ts +767 -0
- package/src/diagnosticPeriods.ts +117 -0
- package/src/diagnosticPreparation.ts +233 -0
- package/src/diagnosticReview.ts +91 -0
- package/src/diagnosticRules.ts +69 -0
- package/src/diagnosticRunner.ts +110 -0
- package/src/index.ts +156 -1
- package/src/types.ts +161 -0
- package/src/version.ts +2 -0
- package/dist/metricDiagnostics.d.ts +0 -212
- package/dist/metricDiagnostics.d.ts.map +0 -1
- package/dist/metricDiagnostics.js +0 -627
- package/dist/metricDiagnostics.js.map +0 -1
- package/src/metricDiagnostics.ts +0 -876
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type CompiledDiagnosticDefinition, type DiagnosticDeepReadonly, type DiagnosticSourceLocation, type DiagnosticsFilter, type JsonValue } from "./diagnosticDefinitions.js";
|
|
2
|
+
import { type DiagnosticMeasureContribution, type DiagnosticStructuralBlocker } from "./diagnosticAggregation.js";
|
|
3
|
+
import { type DiagnosticAuditedNumericValue, type DiagnosticExposureObservation, type ReconciledDiagnosticExposure } from "./diagnosticExposure.js";
|
|
4
|
+
import type { DiagnosticMeasureStats } from "./diagnosticDefinitions.js";
|
|
5
|
+
import type { DiagnosticMetricFinding } from "./diagnosticFormulas.js";
|
|
6
|
+
export interface DiagnosticLossRecordBase {
|
|
7
|
+
readonly recordId: string;
|
|
8
|
+
readonly sourceGroup: string;
|
|
9
|
+
readonly origin: string;
|
|
10
|
+
readonly valuation: string;
|
|
11
|
+
readonly complete: boolean;
|
|
12
|
+
readonly source?: DiagnosticSourceLocation;
|
|
13
|
+
readonly measures: Readonly<Record<string, number | null>>;
|
|
14
|
+
}
|
|
15
|
+
export interface DiagnosticClaimObservation extends DiagnosticLossRecordBase {
|
|
16
|
+
readonly rowType: "claim";
|
|
17
|
+
readonly claimId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DiagnosticLossSnapshot extends DiagnosticLossRecordBase {
|
|
20
|
+
readonly rowType: "aggregate";
|
|
21
|
+
}
|
|
22
|
+
export type DiagnosticLossInput = DiagnosticClaimObservation | DiagnosticLossSnapshot;
|
|
23
|
+
export interface DiagnosticCompletePeriodCutoff {
|
|
24
|
+
readonly sourceGroup: string;
|
|
25
|
+
readonly originThrough: string | null;
|
|
26
|
+
readonly valuationThrough: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface DiagnosticExpectedCell {
|
|
29
|
+
readonly sourceGroup: string;
|
|
30
|
+
readonly origin: string;
|
|
31
|
+
readonly valuation: string;
|
|
32
|
+
readonly source?: DiagnosticSourceLocation;
|
|
33
|
+
}
|
|
34
|
+
export interface PrepareDiagnosticDataInput {
|
|
35
|
+
readonly definition: CompiledDiagnosticDefinition;
|
|
36
|
+
readonly losses: readonly DiagnosticLossInput[];
|
|
37
|
+
readonly exposures: readonly DiagnosticExposureObservation[];
|
|
38
|
+
readonly filter?: DiagnosticsFilter;
|
|
39
|
+
readonly completePeriodCutoffs?: readonly DiagnosticCompletePeriodCutoff[];
|
|
40
|
+
readonly expectedCells?: readonly DiagnosticExpectedCell[];
|
|
41
|
+
}
|
|
42
|
+
export type DiagnosticInputDisposition = "invalid" | "complete-period-cutoff" | "filter" | "retained";
|
|
43
|
+
export type DiagnosticInputAuditRecord = {
|
|
44
|
+
readonly kind: "loss";
|
|
45
|
+
readonly disposition: DiagnosticInputDisposition;
|
|
46
|
+
readonly record: DiagnosticDeepReadonly<DiagnosticLossInput>;
|
|
47
|
+
} | {
|
|
48
|
+
readonly kind: "exposure";
|
|
49
|
+
readonly disposition: DiagnosticInputDisposition;
|
|
50
|
+
readonly record: DiagnosticDeepReadonly<DiagnosticExposureObservation>;
|
|
51
|
+
} | {
|
|
52
|
+
readonly kind: "expected-cell";
|
|
53
|
+
readonly disposition: Exclude<DiagnosticInputDisposition, "invalid">;
|
|
54
|
+
readonly record: DiagnosticDeepReadonly<DiagnosticExpectedCell>;
|
|
55
|
+
};
|
|
56
|
+
export interface PreparedDiagnosticSourceCell {
|
|
57
|
+
readonly sourceGroup: string;
|
|
58
|
+
readonly origin: string;
|
|
59
|
+
readonly valuation: string;
|
|
60
|
+
readonly developmentAge: number;
|
|
61
|
+
readonly ageUnit: string;
|
|
62
|
+
readonly lossRecordIds: readonly string[];
|
|
63
|
+
readonly contributions: Readonly<Record<string, readonly DiagnosticMeasureContribution[]>>;
|
|
64
|
+
readonly components: Readonly<Record<string, DiagnosticMeasureStats>>;
|
|
65
|
+
readonly structuralBlockers: Readonly<Record<string, readonly DiagnosticStructuralBlocker[]>>;
|
|
66
|
+
readonly findings: readonly DiagnosticMetricFinding[];
|
|
67
|
+
}
|
|
68
|
+
declare const preparedDiagnosticDataBrand: unique symbol;
|
|
69
|
+
export interface PreparedDiagnosticData {
|
|
70
|
+
readonly [preparedDiagnosticDataBrand]: true;
|
|
71
|
+
readonly definition: CompiledDiagnosticDefinition;
|
|
72
|
+
readonly preparationFingerprint: string;
|
|
73
|
+
readonly filter: DiagnosticDeepReadonly<DiagnosticsFilter> | null;
|
|
74
|
+
readonly completePeriodCutoffs: readonly DiagnosticCompletePeriodCutoff[];
|
|
75
|
+
readonly inputAudit: readonly DiagnosticInputAuditRecord[];
|
|
76
|
+
readonly cells: readonly PreparedDiagnosticSourceCell[];
|
|
77
|
+
readonly exposures: readonly ReconciledDiagnosticExposure[];
|
|
78
|
+
readonly expectedCellsProvided: boolean;
|
|
79
|
+
readonly expectedCells: readonly DiagnosticExpectedCell[];
|
|
80
|
+
readonly findings: readonly DiagnosticMetricFinding[];
|
|
81
|
+
}
|
|
82
|
+
export interface NormalizedDiagnosticPreparationIdentity {
|
|
83
|
+
readonly definitionIntegrity: string;
|
|
84
|
+
readonly filter: DiagnosticDeepReadonly<DiagnosticsFilter> | null;
|
|
85
|
+
readonly completePeriodCutoffs: readonly DiagnosticCompletePeriodCutoff[];
|
|
86
|
+
readonly inputAudit: readonly DiagnosticInputAuditRecord[];
|
|
87
|
+
readonly cells: readonly PreparedDiagnosticSourceCell[];
|
|
88
|
+
readonly exposures: readonly ReconciledDiagnosticExposure[];
|
|
89
|
+
readonly expectedCellsProvided: boolean;
|
|
90
|
+
readonly expectedCells: readonly DiagnosticExpectedCell[];
|
|
91
|
+
readonly findings: readonly DiagnosticMetricFinding[];
|
|
92
|
+
}
|
|
93
|
+
export declare function prepareDiagnosticData(input: PrepareDiagnosticDataInput): PreparedDiagnosticData;
|
|
94
|
+
export declare function assertPreparedDiagnosticData(value: unknown): asserts value is PreparedDiagnosticData;
|
|
95
|
+
export declare function getPreparedDiagnosticDataIdentity(value: PreparedDiagnosticData): DiagnosticDeepReadonly<NormalizedDiagnosticPreparationIdentity>;
|
|
96
|
+
export declare function verifyPreparedDiagnosticDataIntegrity(value: PreparedDiagnosticData): void;
|
|
97
|
+
export type { JsonValue, DiagnosticAuditedNumericValue };
|
|
98
|
+
//# sourceMappingURL=diagnosticPreparation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticPreparation.d.ts","sourceRoot":"","sources":["../src/diagnosticPreparation.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAkE,KAAK,6BAA6B,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AAGlL,OAAO,EAAgC,KAAK,6BAA6B,EAAE,KAAK,6BAA6B,EAAE,KAAK,4BAA4B,EAAyB,MAAM,yBAAyB,CAAC;AACzM,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAGvE,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAC3C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC5D;AACD,MAAM,WAAW,0BAA2B,SAAQ,wBAAwB;IAA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CAyF/F;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,sBAAsB,CAEpG;AACD,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,sBAAsB,GAAG,sBAAsB,CAAC,uCAAuC,CAAC,CAAuE;AACxN,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,sBAAsB,GAAG,IAAI,CAIzF;AAED,YAAY,EAAE,SAAS,EAAE,6BAA6B,EAAE,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { canonicalJson, fnv1a64 } from "./canonical.js";
|
|
2
|
+
import { assertCompiledDiagnosticDefinition, getCompiledDiagnosticDefinitionInternals, } from "./diagnosticDefinitions.js";
|
|
3
|
+
import { auditedDiagnosticContribution, finalizeDiagnosticContributions } from "./diagnosticAggregation.js";
|
|
4
|
+
import { deriveDiagnosticClaimMeasures } from "./diagnosticDerivations.js";
|
|
5
|
+
import { diagnosticDevelopmentAge, normalizeDiagnosticPeriod } from "./diagnosticPeriods.js";
|
|
6
|
+
import { reconcileDiagnosticExposures } from "./diagnosticExposure.js";
|
|
7
|
+
import { DiagnosticValidationError } from "./types.js";
|
|
8
|
+
const authentic = new WeakSet();
|
|
9
|
+
const identities = new WeakMap();
|
|
10
|
+
function deepFreeze(value, seen = new WeakSet()) {
|
|
11
|
+
if (value === null || typeof value !== "object" || seen.has(value))
|
|
12
|
+
return value;
|
|
13
|
+
seen.add(value);
|
|
14
|
+
for (const child of Object.values(value))
|
|
15
|
+
deepFreeze(child, seen);
|
|
16
|
+
return Object.freeze(value);
|
|
17
|
+
}
|
|
18
|
+
function codeUnit(left, right) { return left < right ? -1 : left > right ? 1 : 0; }
|
|
19
|
+
function own(record, key) { return Object.prototype.hasOwnProperty.call(record, key) ? record[key] : undefined; }
|
|
20
|
+
function normalizeFilter(filter) {
|
|
21
|
+
if (filter === undefined)
|
|
22
|
+
return null;
|
|
23
|
+
const set = (values) => values === undefined ? undefined : [...new Set(values)].sort(codeUnit);
|
|
24
|
+
return {
|
|
25
|
+
...(filter.sourceGroups === undefined ? {} : { sourceGroups: set(filter.sourceGroups) }),
|
|
26
|
+
...(filter.outputGroups === undefined ? {} : { outputGroups: set(filter.outputGroups) }),
|
|
27
|
+
...(filter.origins === undefined ? {} : { origins: set(filter.origins) }),
|
|
28
|
+
...(filter.originFrom === undefined ? {} : { originFrom: filter.originFrom }),
|
|
29
|
+
...(filter.originThrough === undefined ? {} : { originThrough: filter.originThrough }),
|
|
30
|
+
...(filter.valuations === undefined ? {} : { valuations: set(filter.valuations) }),
|
|
31
|
+
...(filter.valuationFrom === undefined ? {} : { valuationFrom: filter.valuationFrom }),
|
|
32
|
+
...(filter.valuationThrough === undefined ? {} : { valuationThrough: filter.valuationThrough }),
|
|
33
|
+
...(filter.minDevelopmentAge === undefined ? {} : { minDevelopmentAge: filter.minDevelopmentAge }),
|
|
34
|
+
...(filter.maxDevelopmentAge === undefined ? {} : { maxDevelopmentAge: filter.maxDevelopmentAge }),
|
|
35
|
+
...(filter.instanceIds === undefined ? {} : { instanceIds: set(filter.instanceIds) }),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function selected(filter, group, origin, valuation, age) {
|
|
39
|
+
return (filter?.sourceGroups === undefined || filter.sourceGroups.includes(group)) &&
|
|
40
|
+
(filter?.origins === undefined || filter.origins.includes(origin)) &&
|
|
41
|
+
(filter?.valuations === undefined || filter.valuations.includes(valuation)) &&
|
|
42
|
+
(filter?.originFrom === undefined || origin >= filter.originFrom) &&
|
|
43
|
+
(filter?.originThrough === undefined || origin <= filter.originThrough) &&
|
|
44
|
+
(filter?.valuationFrom === undefined || valuation >= filter.valuationFrom) &&
|
|
45
|
+
(filter?.valuationThrough === undefined || valuation <= filter.valuationThrough) &&
|
|
46
|
+
(filter?.minDevelopmentAge === undefined || age >= filter.minDevelopmentAge) &&
|
|
47
|
+
(filter?.maxDevelopmentAge === undefined || age <= filter.maxDevelopmentAge);
|
|
48
|
+
}
|
|
49
|
+
export function prepareDiagnosticData(input) {
|
|
50
|
+
assertCompiledDiagnosticDefinition(input.definition);
|
|
51
|
+
const definition = input.definition;
|
|
52
|
+
const internals = getCompiledDiagnosticDefinitionInternals(definition);
|
|
53
|
+
const issues = [];
|
|
54
|
+
const filter = normalizeFilter(input.filter);
|
|
55
|
+
for (const bound of [filter?.minDevelopmentAge, filter?.maxDevelopmentAge])
|
|
56
|
+
if (bound !== undefined && (!Number.isSafeInteger(bound) || bound < 0))
|
|
57
|
+
issues.push({ domain: "configuration", code: "invalid-configuration", path: "$.filter", message: "Development-age bounds must be nonnegative safe integers" });
|
|
58
|
+
if (filter?.minDevelopmentAge !== undefined && filter.maxDevelopmentAge !== undefined && filter.minDevelopmentAge > filter.maxDevelopmentAge)
|
|
59
|
+
issues.push({ domain: "configuration", code: "invalid-configuration", path: "$.filter", message: "Minimum development age exceeds maximum" });
|
|
60
|
+
input.losses.forEach((row, index) => {
|
|
61
|
+
if (row.rowType !== definition.definition.lossRowGrain)
|
|
62
|
+
issues.push({ domain: "input", code: "invalid-input-relationship", path: `$.losses[${index}].rowType`, message: "Loss row type does not match definition grain" });
|
|
63
|
+
});
|
|
64
|
+
input.exposures.forEach((row, index) => {
|
|
65
|
+
const measure = internals.measuresById.get(row.measureId);
|
|
66
|
+
if (measure?.exposureTiming === "valuation-specific" && row.valuation === undefined)
|
|
67
|
+
issues.push({ domain: "input", code: "missing-required", path: `$.exposures[${index}].valuation`, message: "Valuation-specific exposure requires valuation" });
|
|
68
|
+
});
|
|
69
|
+
if (issues.length > 0)
|
|
70
|
+
throw new DiagnosticValidationError(issues);
|
|
71
|
+
const normalizedLosses = [];
|
|
72
|
+
const audit = [];
|
|
73
|
+
for (const row of input.losses) {
|
|
74
|
+
let disposition = "retained";
|
|
75
|
+
try {
|
|
76
|
+
const period = diagnosticDevelopmentAge(definition, row.origin, row.valuation);
|
|
77
|
+
const normalized = { ...row, origin: period.origin.label, valuation: period.valuation.label };
|
|
78
|
+
if (!selected(filter, row.sourceGroup, normalized.origin, normalized.valuation, period.developmentAge))
|
|
79
|
+
disposition = "filter";
|
|
80
|
+
if (disposition === "retained")
|
|
81
|
+
normalizedLosses.push(normalized);
|
|
82
|
+
audit.push({ kind: "loss", disposition, record: normalized });
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
audit.push({ kind: "loss", disposition: "invalid", record: row });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const derivedLosses = definition.definition.lossRowGrain === "claim"
|
|
89
|
+
? deriveDiagnosticClaimMeasures(normalizedLosses, definition)
|
|
90
|
+
: normalizedLosses;
|
|
91
|
+
const cells = new Map();
|
|
92
|
+
for (const row of derivedLosses) {
|
|
93
|
+
const key = `${row.sourceGroup}\u0000${row.origin}\u0000${row.valuation}`;
|
|
94
|
+
const list = cells.get(key) ?? [];
|
|
95
|
+
list.push(row);
|
|
96
|
+
cells.set(key, list);
|
|
97
|
+
}
|
|
98
|
+
const normalizedExposureInputs = [];
|
|
99
|
+
for (const row of input.exposures) {
|
|
100
|
+
try {
|
|
101
|
+
const origin = normalizeDiagnosticPeriod(definition, "origin", row.origin).label;
|
|
102
|
+
const valuation = row.valuation === undefined ? undefined : normalizeDiagnosticPeriod(definition, "valuation", row.valuation).label;
|
|
103
|
+
const normalized = { ...row, origin, ...(valuation === undefined ? {} : { valuation }) };
|
|
104
|
+
const timing = internals.measuresById.get(row.measureId)?.exposureTiming;
|
|
105
|
+
const age = valuation === undefined ? 0 : diagnosticDevelopmentAge(definition, origin, valuation).developmentAge;
|
|
106
|
+
const keep = timing === "origin-static"
|
|
107
|
+
? (filter?.sourceGroups === undefined || filter.sourceGroups.includes(row.sourceGroup)) && (filter?.origins === undefined || filter.origins.includes(origin))
|
|
108
|
+
: selected(filter, row.sourceGroup, origin, valuation ?? "", age);
|
|
109
|
+
audit.push({ kind: "exposure", disposition: keep ? "retained" : "filter", record: normalized });
|
|
110
|
+
if (keep)
|
|
111
|
+
normalizedExposureInputs.push(normalized);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
audit.push({ kind: "exposure", disposition: "invalid", record: row });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const timingByMeasure = Object.fromEntries(definition.definition.measures.filter((measure) => measure.kind === "exposure").map((measure) => [measure.id, measure.exposureTiming]));
|
|
118
|
+
const exposures = reconcileDiagnosticExposures(normalizedExposureInputs, timingByMeasure);
|
|
119
|
+
const preparedCells = [];
|
|
120
|
+
for (const [key, rows] of cells) {
|
|
121
|
+
const [sourceGroup, origin, valuation] = key.split("\u0000");
|
|
122
|
+
const period = diagnosticDevelopmentAge(definition, origin, valuation);
|
|
123
|
+
const contributions = Object.create(null);
|
|
124
|
+
const blockers = Object.create(null);
|
|
125
|
+
for (const measure of definition.definition.measures) {
|
|
126
|
+
contributions[measure.id] = [];
|
|
127
|
+
blockers[measure.id] = [];
|
|
128
|
+
}
|
|
129
|
+
for (const row of rows) {
|
|
130
|
+
for (const measure of definition.definition.measures.filter((item) => item.source !== "exposure")) {
|
|
131
|
+
contributions[measure.id].push(auditedDiagnosticContribution(row.recordId, own(row.measures, measure.id), measure.missing, row.source ? [row.source] : []));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
for (const exposure of exposures) {
|
|
135
|
+
if (exposure.status !== "valid" || exposure.sourceGroup !== sourceGroup || exposure.origin !== origin || (exposure.valuation !== undefined && exposure.valuation !== valuation))
|
|
136
|
+
continue;
|
|
137
|
+
contributions[exposure.measureId].push(auditedDiagnosticContribution(exposure.key, exposure.value, "unknown", exposure.sources, exposure.deduplicated));
|
|
138
|
+
}
|
|
139
|
+
for (const measure of definition.definition.measures.filter((item) => item.source === "exposure")) {
|
|
140
|
+
if (contributions[measure.id].length === 0)
|
|
141
|
+
blockers[measure.id].push({ code: "loss-without-exposure", message: "Loss cell has no applicable exposure observation", sourceIds: rows.map((row) => row.recordId).sort(codeUnit), sources: [] });
|
|
142
|
+
}
|
|
143
|
+
const components = Object.fromEntries(definition.definition.measures.map((measure) => [measure.id, finalizeDiagnosticContributions(contributions[measure.id], measure.missing, blockers[measure.id])]));
|
|
144
|
+
preparedCells.push(deepFreeze({ sourceGroup, origin, valuation, developmentAge: period.developmentAge, ageUnit: period.ageUnit, lossRecordIds: rows.map((row) => row.recordId).sort(codeUnit), contributions, components, structuralBlockers: blockers, findings: [] }));
|
|
145
|
+
}
|
|
146
|
+
preparedCells.sort((a, b) => codeUnit(a.sourceGroup, b.sourceGroup) || codeUnit(a.origin, b.origin) || codeUnit(a.valuation, b.valuation));
|
|
147
|
+
const expectedCells = (input.expectedCells ?? []).map((item) => ({ ...item }));
|
|
148
|
+
for (const item of expectedCells)
|
|
149
|
+
audit.push({ kind: "expected-cell", disposition: "retained", record: item });
|
|
150
|
+
const identity = deepFreeze({ definitionIntegrity: definition.definitionIntegrity, filter, completePeriodCutoffs: [...(input.completePeriodCutoffs ?? [])], inputAudit: audit, cells: preparedCells, exposures, expectedCellsProvided: input.expectedCells !== undefined, expectedCells, findings: [] });
|
|
151
|
+
const preparationFingerprint = `fnv1a64-jcs-v1:${fnv1a64(canonicalJson({ identityVersion: 1, kind: "diagnostic-preparation", preparation: identity }))}`;
|
|
152
|
+
const preparedBase = { definition, preparationFingerprint, filter, completePeriodCutoffs: input.completePeriodCutoffs ?? [], inputAudit: audit, cells: preparedCells, exposures, expectedCellsProvided: input.expectedCells !== undefined, expectedCells, findings: [] };
|
|
153
|
+
const prepared = deepFreeze(preparedBase);
|
|
154
|
+
authentic.add(prepared);
|
|
155
|
+
identities.set(prepared, identity);
|
|
156
|
+
return prepared;
|
|
157
|
+
}
|
|
158
|
+
export function assertPreparedDiagnosticData(value) {
|
|
159
|
+
if (value === null || typeof value !== "object" || !authentic.has(value))
|
|
160
|
+
throw new DiagnosticValidationError([{ domain: "input", code: "invalid-input-relationship", path: "$.prepared", message: "Value is not authentic prepared diagnostic data" }]);
|
|
161
|
+
}
|
|
162
|
+
export function getPreparedDiagnosticDataIdentity(value) { assertPreparedDiagnosticData(value); return identities.get(value); }
|
|
163
|
+
export function verifyPreparedDiagnosticDataIntegrity(value) {
|
|
164
|
+
const identity = getPreparedDiagnosticDataIdentity(value);
|
|
165
|
+
const tag = `fnv1a64-jcs-v1:${fnv1a64(canonicalJson({ identityVersion: 1, kind: "diagnostic-preparation", preparation: identity }))}`;
|
|
166
|
+
if (tag !== value.preparationFingerprint)
|
|
167
|
+
throw new DiagnosticValidationError([{ domain: "input", code: "invalid-input-relationship", path: "$.prepared.preparationFingerprint", message: "Prepared diagnostic data integrity does not match its content" }]);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=diagnosticPreparation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticPreparation.js","sourceRoot":"","sources":["../src/diagnosticPreparation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EACL,kCAAkC,EAClC,wCAAwC,GAMzC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,6BAA6B,EAAE,+BAA+B,EAAwE,MAAM,4BAA4B,CAAC;AAClL,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AAC7F,OAAO,EAAE,4BAA4B,EAAoI,MAAM,yBAAyB,CAAC;AAGzM,OAAO,EAAE,yBAAyB,EAAkC,MAAM,YAAY,CAAC;AAwEvF,MAAM,SAAS,GAAG,IAAI,OAAO,EAAU,CAAC;AACxC,MAAM,UAAU,GAAG,IAAI,OAAO,EAA2E,CAAC;AAE1G,SAAS,UAAU,CAAI,KAAQ,EAAE,OAAO,IAAI,OAAO,EAAU;IAC3D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC;QA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AAyB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,4BAA4B,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,iDAAiD,EAAE,CAAC,CAAC,CAAC;AAC3P,CAAC;AACD,MAAM,UAAU,iCAAiC,CAAC,KAA6B,IAAqE,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,UAAU,CAAC,GAAG,CAAC,KAAK,CAAE,CAAA,CAAC,CAAC;AACxN,MAAM,UAAU,qCAAqC,CAAC,KAA6B;IACjF,MAAM,QAAQ,GAAG,iCAAiC,CAAC,KAAK,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,kBAAkB,OAAO,CAAC,aAAa,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC;IACtI,IAAI,GAAG,KAAK,KAAK,CAAC,sBAAsB;QAAE,MAAM,IAAI,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,4BAA4B,EAAE,IAAI,EAAE,mCAAmC,EAAE,OAAO,EAAE,+DAA+D,EAAE,CAAC,CAAC,CAAC;AAChQ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type DiagnosticReviewRule, type DiagnosticSourceLocation } from "./diagnosticDefinitions.js";
|
|
2
|
+
import { type PreparedDiagnosticData } from "./diagnosticPreparation.js";
|
|
3
|
+
import { type DiagnosticRuleNotEvaluatedReason } from "./diagnosticRules.js";
|
|
4
|
+
export interface DiagnosticReviewCoordinate {
|
|
5
|
+
readonly sourceGroup: string;
|
|
6
|
+
readonly origin: string;
|
|
7
|
+
readonly valuation: string;
|
|
8
|
+
readonly developmentAge: number;
|
|
9
|
+
readonly ageUnit: string;
|
|
10
|
+
}
|
|
11
|
+
export type DiagnosticReviewEvaluationScope = {
|
|
12
|
+
readonly kind: "cell";
|
|
13
|
+
readonly coordinate: DiagnosticReviewCoordinate;
|
|
14
|
+
readonly sources: readonly DiagnosticSourceLocation[];
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: "valuation-pair";
|
|
17
|
+
readonly previous: DiagnosticReviewCoordinate;
|
|
18
|
+
readonly current: DiagnosticReviewCoordinate;
|
|
19
|
+
readonly sources: readonly DiagnosticSourceLocation[];
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: "control-total";
|
|
22
|
+
readonly selectedCellCount: number;
|
|
23
|
+
readonly selectedContributionCount: number;
|
|
24
|
+
readonly sources: readonly DiagnosticSourceLocation[];
|
|
25
|
+
};
|
|
26
|
+
export interface DiagnosticReviewRuleEvaluation {
|
|
27
|
+
readonly ruleId: string;
|
|
28
|
+
readonly kind: DiagnosticReviewRule["kind"];
|
|
29
|
+
readonly status: "pass" | "triggered" | "not-evaluated";
|
|
30
|
+
readonly severity: "warning" | "fail";
|
|
31
|
+
readonly triggerReason: "predicate" | "missing-input" | null;
|
|
32
|
+
readonly left: number | null;
|
|
33
|
+
readonly right: number | null;
|
|
34
|
+
readonly relation: "less" | "equal" | "greater" | null;
|
|
35
|
+
readonly notEvaluatedReasons: readonly DiagnosticRuleNotEvaluatedReason[];
|
|
36
|
+
readonly expressionOverflows: readonly {
|
|
37
|
+
readonly expressionPath: string;
|
|
38
|
+
readonly sources: readonly DiagnosticSourceLocation[];
|
|
39
|
+
}[];
|
|
40
|
+
readonly reviewScope: DiagnosticReviewEvaluationScope;
|
|
41
|
+
}
|
|
42
|
+
/** Evaluates definition-owned semantic review rules over authenticated prepared cells. */
|
|
43
|
+
export declare function evaluateDiagnosticReviewRules(prepared: PreparedDiagnosticData): readonly DiagnosticReviewRuleEvaluation[];
|
|
44
|
+
//# sourceMappingURL=diagnosticReview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticReview.d.ts","sourceRoot":"","sources":["../src/diagnosticReview.ts"],"names":[],"mappings":"AAAA,O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WAAW,GAAG,eAAe,CAAC;IACxD,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,MAAM,CAAC;IACtC,QAAQ,CAAC,aAAa,EAAE,WAAW,GAAG,eAAe,GAAG,IAAI,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC;IACvD,QAAQ,CAAC,mBAAmB,EAAE,SAAS,gCAAgC,EAAE,CAAC;IAC1E,QAAQ,CAAC,mBAAmB,EAAE,SAAS;QAAE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,wBAAwB,EAAE,CAAA;KAAE,EAAE,CAAC;IACpI,QAAQ,CAAC,WAAW,EAAE,+BAA+B,CAAC;CACvD;AAwBD,0FAA0F;AAC1F,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,sBAAsB,GAAG,SAAS,8BAA8B,EAAE,CA2CzH"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { getCompiledDiagnosticDefinitionInternals } from "./diagnosticDefinitions.js";
|
|
2
|
+
import { evaluateDiagnosticMeasureExpression } from "./diagnosticFormulas.js";
|
|
3
|
+
import { assertPreparedDiagnosticData } from "./diagnosticPreparation.js";
|
|
4
|
+
import { classifyDiagnosticComparison, diagnosticPredicateMatches } from "./diagnosticRules.js";
|
|
5
|
+
function states(prepared, components) {
|
|
6
|
+
const internals = getCompiledDiagnosticDefinitionInternals(prepared.definition);
|
|
7
|
+
return Object.fromEntries(Object.entries(components).map(([id, stats]) => {
|
|
8
|
+
const measure = internals.measuresById.get(id);
|
|
9
|
+
const readiness = [];
|
|
10
|
+
if (stats.missing)
|
|
11
|
+
readiness.push(stats.imputedZero ? "imputed" : "missing");
|
|
12
|
+
if (stats.nonFinite)
|
|
13
|
+
readiness.push("non-finite");
|
|
14
|
+
if (stats.structural)
|
|
15
|
+
readiness.push("structural-ambiguity");
|
|
16
|
+
if (stats.sum === null && !stats.nonFinite && !stats.structural)
|
|
17
|
+
readiness.push("aggregation-overflow");
|
|
18
|
+
return [id, { quantity: { kind: measure.kind, unit: measure.unit, value: stats.value }, stats, readiness }];
|
|
19
|
+
}));
|
|
20
|
+
}
|
|
21
|
+
function coordinate(cell) { return { sourceGroup: cell.sourceGroup, origin: cell.origin, valuation: cell.valuation, developmentAge: cell.developmentAge, ageUnit: cell.ageUnit }; }
|
|
22
|
+
function evaluation(rule, scope, left, right, asserted, reasons = []) {
|
|
23
|
+
if (left === null || right === null || reasons.length)
|
|
24
|
+
return { ruleId: rule.id, kind: rule.kind, status: rule.missingInput === "finding" ? "triggered" : "not-evaluated", severity: rule.severity, triggerReason: rule.missingInput === "finding" ? "missing-input" : null, left, right, relation: null, notEvaluatedReasons: reasons.length ? reasons : ["missing"], expressionOverflows: [], reviewScope: scope };
|
|
25
|
+
const compared = classifyDiagnosticComparison(left, right, rule.tolerance);
|
|
26
|
+
if (compared.status === "not-evaluated")
|
|
27
|
+
return { ruleId: rule.id, kind: rule.kind, status: "not-evaluated", severity: rule.severity, triggerReason: null, left, right, relation: null, notEvaluatedReasons: [compared.reason], expressionOverflows: [], reviewScope: scope };
|
|
28
|
+
return { ruleId: rule.id, kind: rule.kind, status: asserted ? "pass" : "triggered", severity: rule.severity, triggerReason: asserted ? null : "predicate", left, right, relation: compared.relation, notEvaluatedReasons: [], expressionOverflows: [], reviewScope: scope };
|
|
29
|
+
}
|
|
30
|
+
/** Evaluates definition-owned semantic review rules over authenticated prepared cells. */
|
|
31
|
+
export function evaluateDiagnosticReviewRules(prepared) {
|
|
32
|
+
assertPreparedDiagnosticData(prepared);
|
|
33
|
+
const results = [];
|
|
34
|
+
for (const rule of prepared.definition.definition.reviewRules) {
|
|
35
|
+
if (rule.kind === "control-total") {
|
|
36
|
+
const values = prepared.cells.map((cell) => evaluateDiagnosticMeasureExpression(rule.expression, states(prepared, cell.components), "$.reviewRules.control-total").value);
|
|
37
|
+
const left = values.some((value) => value === null) ? null : values.reduce((sum, value) => sum + value, 0);
|
|
38
|
+
const scope = { kind: "control-total", selectedCellCount: prepared.cells.length, selectedContributionCount: prepared.cells.reduce((sum, cell) => sum + Object.values(cell.contributions).reduce((n, items) => n + items.length, 0), 0), sources: [] };
|
|
39
|
+
const classified = classifyDiagnosticComparison(left, rule.expected, rule.tolerance);
|
|
40
|
+
results.push(evaluation(rule, scope, left, rule.expected, classified.status === "evaluated" && classified.relation === "equal"));
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (rule.kind === "monotonic") {
|
|
44
|
+
const groups = new Map();
|
|
45
|
+
for (const cell of prepared.cells) {
|
|
46
|
+
const key = `${cell.sourceGroup}\0${cell.origin}`;
|
|
47
|
+
groups.set(key, [...(groups.get(key) ?? []), cell]);
|
|
48
|
+
}
|
|
49
|
+
for (const cells of groups.values()) {
|
|
50
|
+
const sorted = [...cells].sort((a, b) => a.developmentAge - b.developmentAge);
|
|
51
|
+
for (let index = 1; index < sorted.length; index++) {
|
|
52
|
+
const previous = sorted[index - 1], current = sorted[index];
|
|
53
|
+
const left = evaluateDiagnosticMeasureExpression(rule.expression, states(prepared, previous.components), "$.reviewRules.monotonic").value;
|
|
54
|
+
const right = evaluateDiagnosticMeasureExpression(rule.expression, states(prepared, current.components), "$.reviewRules.monotonic").value;
|
|
55
|
+
results.push(evaluation(rule, { kind: "valuation-pair", previous: coordinate(previous), current: coordinate(current), sources: [] }, left, right, rule.direction === "nondecreasing" ? left !== null && right !== null && left <= right : left !== null && right !== null && left >= right));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
for (const cell of prepared.cells) {
|
|
61
|
+
const state = states(prepared, cell.components);
|
|
62
|
+
const scope = { kind: "cell", coordinate: coordinate(cell), sources: [] };
|
|
63
|
+
if (rule.kind === "compare") {
|
|
64
|
+
const operand = (item) => item.op === "constant" ? item.value : evaluateDiagnosticMeasureExpression(item, state, "$.reviewRules.compare").value;
|
|
65
|
+
const left = operand(rule.when.left), right = operand(rule.when.right);
|
|
66
|
+
const classified = classifyDiagnosticComparison(left, right, rule.tolerance);
|
|
67
|
+
results.push(evaluation(rule, scope, left, right, classified.status === "evaluated" && !diagnosticPredicateMatches(rule.when.operator, classified.relation)));
|
|
68
|
+
}
|
|
69
|
+
else if (rule.kind === "reconcile") {
|
|
70
|
+
const left = evaluateDiagnosticMeasureExpression(rule.actual, state, "$.reviewRules.reconcile.actual").value;
|
|
71
|
+
const right = rule.expected.op === "constant" ? rule.expected.value : evaluateDiagnosticMeasureExpression(rule.expected, state, "$.reviewRules.reconcile.expected").value;
|
|
72
|
+
const classified = classifyDiagnosticComparison(left, right, rule.tolerance);
|
|
73
|
+
results.push(evaluation(rule, scope, left, right, classified.status === "evaluated" && classified.relation === "equal"));
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const left = evaluateDiagnosticMeasureExpression(rule.narrower, state, "$.reviewRules.layer.narrower").value;
|
|
77
|
+
const right = evaluateDiagnosticMeasureExpression(rule.broader, state, "$.reviewRules.layer.broader").value;
|
|
78
|
+
results.push(evaluation(rule, scope, left, right, left !== null && right !== null && left <= right));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Object.freeze(results.map((item) => Object.freeze(item)));
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=diagnosticReview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticReview.js","sourceRoot":"","sources":["../src/diagnosticReview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAA4D,MAAM,4BAA4B,CAAC;AAChJ,OAAO,EAAE,mCAAmC,EAAmC,MAAM,yBAAyB,CAAC;AAC/G,OAAO,EAAE,4BAA4B,EA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QAAQ,CAAC,EAAE,KAAG,UAAU,CAAA,CAAC,CAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAA,CAAC,CAAA,mCAAmC,CAAC,IAAI,CAAC,QAAQ,EAAC,KAAK,EAAC,kCAAkC,CAAC,CAAC,KAAK,CAAC;gBAChK,MAAM,UAAU,GAAC,4BAA4B,CAAC,IAAI,EAAC,KAAK,EAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAAA,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,KAAK,EAAC,UAAU,CAAC,MAAM,KAAG,WAAW,IAAE,UAAU,CAAC,QAAQ,KAAG,OAAO,CAAC,CAAC,CAAC;YAC1L,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,GAAC,mCAAmC,CAAC,IAAI,CAAC,QAAQ,EAAC,KAAK,EAAC,8BAA8B,CAAC,CAAC,KAAK,CAAC;gBAAA,MAAM,KAAK,GAAC,mCAAmC,CAAC,IAAI,CAAC,OAAO,EAAC,KAAK,EAAC,6BAA6B,CAAC,CAAC,KAAK,CAAC;gBACjN,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,KAAK,EAAC,IAAI,KAAG,IAAI,IAAE,KAAK,KAAG,IAAI,IAAE,IAAI,IAAE,KAAK,CAAC,CAAC,CAAC;YACzF,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DiagnosticComparisonPredicate, DiagnosticSourceLocation } from "./diagnosticDefinitions.js";
|
|
2
|
+
export type DiagnosticComparisonClassification = {
|
|
3
|
+
readonly status: "evaluated";
|
|
4
|
+
readonly relation: "less" | "equal" | "greater";
|
|
5
|
+
} | {
|
|
6
|
+
readonly status: "not-evaluated";
|
|
7
|
+
readonly reason: "missing" | "non-finite" | "tolerance-overflow";
|
|
8
|
+
};
|
|
9
|
+
export type DiagnosticRuleNotEvaluatedReason = "missing" | "imputed" | "non-finite" | "structural-ambiguity" | "aggregation-overflow" | "expression-overflow" | "tolerance-overflow";
|
|
10
|
+
export interface DiagnosticExpressionOverflow {
|
|
11
|
+
readonly expressionPath: string;
|
|
12
|
+
readonly sources: readonly DiagnosticSourceLocation[];
|
|
13
|
+
}
|
|
14
|
+
export interface DiagnosticRuleEvaluation {
|
|
15
|
+
readonly ruleId: string;
|
|
16
|
+
readonly status: "pass" | "triggered" | "not-evaluated";
|
|
17
|
+
readonly severity: "warning" | "fail";
|
|
18
|
+
readonly left: number | null;
|
|
19
|
+
readonly right: number | null;
|
|
20
|
+
readonly relation: "less" | "equal" | "greater" | null;
|
|
21
|
+
readonly notEvaluatedReasons: readonly DiagnosticRuleNotEvaluatedReason[];
|
|
22
|
+
readonly expressionOverflows: readonly DiagnosticExpressionOverflow[];
|
|
23
|
+
readonly code: string | null;
|
|
24
|
+
readonly message: string | null;
|
|
25
|
+
}
|
|
26
|
+
/** Pure, overflow-safe three-way comparison shared by metric and review rules. */
|
|
27
|
+
export declare function classifyDiagnosticComparison(left: number | null, right: number | null, tolerance?: {
|
|
28
|
+
readonly absolute?: number;
|
|
29
|
+
readonly relative?: number;
|
|
30
|
+
}): DiagnosticComparisonClassification;
|
|
31
|
+
export declare function diagnosticPredicateMatches(predicate: DiagnosticComparisonPredicate["operator"], relation: "less" | "equal" | "greater"): boolean;
|
|
32
|
+
//# sourceMappingURL=diagnosticRules.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticRules.d.ts","sourceRoot":"","sources":["../src/diagnosticRules.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,6BAA6B,EAAE,wBAAwB,EAAE,M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,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,SAAS,GAAE;IAAE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GACzE,kCAAkC,CAkBpC;AAED,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,6BAA6B,CAAC,UAAU,CAAC,EACpD,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,GACrC,OAAO,CAOT"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Pure, overflow-safe three-way comparison shared by metric and review rules. */
|
|
2
|
+
export function classifyDiagnosticComparison(left, right, tolerance = {}) {
|
|
3
|
+
if (left === null || right === null)
|
|
4
|
+
return { status: "not-evaluated", reason: "missing" };
|
|
5
|
+
if (!Number.isFinite(left) || !Number.isFinite(right))
|
|
6
|
+
return { status: "not-evaluated", reason: "non-finite" };
|
|
7
|
+
const absolute = tolerance.absolute ?? 0;
|
|
8
|
+
const relative = tolerance.relative ?? 0;
|
|
9
|
+
const scale = Math.max(1, Math.abs(left), Math.abs(right));
|
|
10
|
+
const relativeTolerance = relative * scale;
|
|
11
|
+
const totalTolerance = absolute + relativeTolerance;
|
|
12
|
+
if (!Number.isFinite(absolute) || absolute < 0 || !Number.isFinite(relative) || relative < 0 ||
|
|
13
|
+
!Number.isFinite(relativeTolerance) || !Number.isFinite(totalTolerance)) {
|
|
14
|
+
return { status: "not-evaluated", reason: "tolerance-overflow" };
|
|
15
|
+
}
|
|
16
|
+
if (left === right)
|
|
17
|
+
return { status: "evaluated", relation: "equal" };
|
|
18
|
+
const distance = left > right ? left - right : right - left;
|
|
19
|
+
if (Number.isFinite(distance) && distance <= totalTolerance) {
|
|
20
|
+
return { status: "evaluated", relation: "equal" };
|
|
21
|
+
}
|
|
22
|
+
return { status: "evaluated", relation: left < right ? "less" : "greater" };
|
|
23
|
+
}
|
|
24
|
+
export function diagnosticPredicateMatches(predicate, relation) {
|
|
25
|
+
return predicate === "lt" ? relation === "less"
|
|
26
|
+
: predicate === "lte" ? relation !== "greater"
|
|
27
|
+
: predicate === "eq" ? relation === "equal"
|
|
28
|
+
: predicate === "neq" ? relation !== "equal"
|
|
29
|
+
: predicate === "gte" ? relation !== "less"
|
|
30
|
+
: relation === "greater";
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=diagnosticRules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticRules.js","sourceRoot":"","sources":["../src/diagnosticRules.ts"],"names":[],"mappings":"AAiCA,kFAAkF;AAClF,MAAM,UAAU,4BAA4B,CAC1C,IAAmB,EACnB,KAAoB,EACpB,YAAwE,EAAE;IAE1E,IAAI,IAAI,KAAK,IAAI,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC3F,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IAChH,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,IAAI,CAAC,CAAC;IACzC,MAAM,QAAQ,GAAG,SAAS,CAAC,QAAQ,IAAI,CAAC,CAAC;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,MAAM,iBAAiB,GAAG,QAAQ,GAAG,KAAK,CAAC;IAC3C,MAAM,cAAc,GAAG,QAAQ,GAAG,iBAAiB,CAAC;IACpD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,IA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,CAAC,CAAC,QAAQ,KAAK,MAAM;wBACzC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { DiagnosticDeepReadonly, DiagnosticMetricPresentation, JsonValue } from "./diagnosticDefinitions.js";
|
|
2
|
+
import { type DiagnosticMetricFinding, type DiagnosticQuantity } from "./diagnosticFormulas.js";
|
|
3
|
+
import { type DiagnosticRuleEvaluation } from "./diagnosticRules.js";
|
|
4
|
+
import { type PreparedDiagnosticData } from "./diagnosticPreparation.js";
|
|
5
|
+
import type { DiagnosticMeasureStats } from "./diagnosticDefinitions.js";
|
|
6
|
+
export interface RunMetricDiagnosticsInput {
|
|
7
|
+
readonly prepared: PreparedDiagnosticData;
|
|
8
|
+
readonly groupMap?: Readonly<Record<string, string>>;
|
|
9
|
+
readonly groupDimensions?: Readonly<Record<string, JsonValue>>;
|
|
10
|
+
}
|
|
11
|
+
export interface DiagnosticMetricEvaluation {
|
|
12
|
+
readonly instanceId: string;
|
|
13
|
+
readonly instanceVersion: string;
|
|
14
|
+
readonly formulaId: string;
|
|
15
|
+
readonly formulaVersion: string;
|
|
16
|
+
readonly semanticReferences: {
|
|
17
|
+
readonly amountBasisIds: readonly string[];
|
|
18
|
+
readonly countPopulationIds: readonly string[];
|
|
19
|
+
readonly exposureBasisIds: readonly string[];
|
|
20
|
+
};
|
|
21
|
+
readonly formulaFingerprint: string;
|
|
22
|
+
readonly calculationFingerprint: string;
|
|
23
|
+
readonly definitionIntegrity: string;
|
|
24
|
+
readonly calculation: {
|
|
25
|
+
readonly numerator: DiagnosticQuantity;
|
|
26
|
+
readonly denominator: DiagnosticQuantity;
|
|
27
|
+
readonly value: number | null;
|
|
28
|
+
};
|
|
29
|
+
readonly presentation: DiagnosticMetricPresentation & {
|
|
30
|
+
readonly value: number | null;
|
|
31
|
+
};
|
|
32
|
+
readonly components: Readonly<Record<string, DiagnosticMeasureStats>>;
|
|
33
|
+
readonly rules: readonly DiagnosticRuleEvaluation[];
|
|
34
|
+
readonly findings: readonly DiagnosticMetricFinding[];
|
|
35
|
+
}
|
|
36
|
+
export interface DiagnosticEmergencePoint {
|
|
37
|
+
readonly group: string;
|
|
38
|
+
readonly sourceGroups: readonly string[];
|
|
39
|
+
readonly dimensions?: JsonValue;
|
|
40
|
+
readonly origin: string;
|
|
41
|
+
readonly valuation: string;
|
|
42
|
+
readonly developmentAge: number;
|
|
43
|
+
readonly ageUnit: string;
|
|
44
|
+
readonly components: Readonly<Record<string, DiagnosticMeasureStats>>;
|
|
45
|
+
readonly metrics: Readonly<Record<string, DiagnosticMetricEvaluation>>;
|
|
46
|
+
readonly findings: readonly DiagnosticMetricFinding[];
|
|
47
|
+
}
|
|
48
|
+
export interface DiagnosticMetricTriangleCell {
|
|
49
|
+
readonly origin: string;
|
|
50
|
+
readonly valuation: string;
|
|
51
|
+
readonly developmentAge: number;
|
|
52
|
+
readonly ageUnit: string;
|
|
53
|
+
readonly evaluation: DiagnosticMetricEvaluation;
|
|
54
|
+
}
|
|
55
|
+
export interface DiagnosticMetricTriangle {
|
|
56
|
+
readonly group: string;
|
|
57
|
+
readonly instanceId: string;
|
|
58
|
+
readonly origins: readonly string[];
|
|
59
|
+
readonly developmentAges: readonly number[];
|
|
60
|
+
readonly ageUnit: string;
|
|
61
|
+
readonly calculationValues: readonly (readonly (number | null)[])[];
|
|
62
|
+
readonly presentationValues: readonly (readonly (number | null)[])[];
|
|
63
|
+
readonly cells: readonly (readonly (DiagnosticMetricTriangleCell | null)[])[];
|
|
64
|
+
}
|
|
65
|
+
export interface MetricDiagnosticsResult {
|
|
66
|
+
readonly definitionIntegrity: string;
|
|
67
|
+
readonly preparationFingerprint: string;
|
|
68
|
+
readonly ageUnit: string;
|
|
69
|
+
readonly emergence: readonly DiagnosticEmergencePoint[];
|
|
70
|
+
readonly triangles: readonly DiagnosticMetricTriangle[];
|
|
71
|
+
readonly latestDiagonal: readonly DiagnosticEmergencePoint[];
|
|
72
|
+
readonly findings: readonly DiagnosticMetricFinding[];
|
|
73
|
+
}
|
|
74
|
+
export interface CommonMaturityResult {
|
|
75
|
+
readonly developmentAge: number | null;
|
|
76
|
+
readonly ageUnit: string;
|
|
77
|
+
readonly points: readonly DiagnosticDeepReadonly<DiagnosticEmergencePoint>[];
|
|
78
|
+
}
|
|
79
|
+
export type NormalizedDiagnosticResultIdentity = DiagnosticDeepReadonly<MetricDiagnosticsResult>;
|
|
80
|
+
export declare function validateDiagnosticGroupingConfiguration(input: RunMetricDiagnosticsInput): void;
|
|
81
|
+
export declare function runMetricDiagnostics(input: RunMetricDiagnosticsInput): DiagnosticDeepReadonly<MetricDiagnosticsResult>;
|
|
82
|
+
export declare function sameMaturity(result: DiagnosticDeepReadonly<MetricDiagnosticsResult>, developmentAge: number, outputGroups?: readonly string[]): readonly DiagnosticDeepReadonly<DiagnosticEmergencePoint>[];
|
|
83
|
+
export declare function commonMaturity(result: DiagnosticDeepReadonly<MetricDiagnosticsResult>, outputGroups: readonly string[]): DiagnosticDeepReadonly<CommonMaturityResult>;
|
|
84
|
+
export declare function getMetricDiagnosticsResultIdentity(result: DiagnosticDeepReadonly<MetricDiagnosticsResult>): NormalizedDiagnosticResultIdentity;
|
|
85
|
+
//# sourceMappingURL=diagnosticRunner.d.ts.map
|