@actuarial-ts/core 0.6.0 → 0.7.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 +12 -3
- package/dist/canonical.d.ts +11 -0
- package/dist/canonical.d.ts.map +1 -1
- package/dist/canonical.js +136 -26
- package/dist/canonical.js.map +1 -1
- package/dist/capping.d.ts.map +1 -1
- package/dist/capping.js +39 -6
- package/dist/capping.js.map +1 -1
- package/dist/diagnosticAggregation.d.ts +3 -0
- package/dist/diagnosticAggregation.d.ts.map +1 -1
- package/dist/diagnosticAggregation.js +30 -7
- package/dist/diagnosticAggregation.js.map +1 -1
- package/dist/diagnosticDefinitions.d.ts +3 -0
- package/dist/diagnosticDefinitions.d.ts.map +1 -1
- package/dist/diagnosticDefinitions.js +844 -182
- package/dist/diagnosticDefinitions.js.map +1 -1
- package/dist/diagnosticDerivations.d.ts +23 -0
- package/dist/diagnosticDerivations.d.ts.map +1 -1
- package/dist/diagnosticDerivations.js +187 -43
- package/dist/diagnosticDerivations.js.map +1 -1
- package/dist/diagnosticEvidenceIntern.d.ts +16 -0
- package/dist/diagnosticEvidenceIntern.d.ts.map +1 -0
- package/dist/diagnosticEvidenceIntern.js +139 -0
- package/dist/diagnosticEvidenceIntern.js.map +1 -0
- package/dist/diagnosticExposure.d.ts +2 -2
- package/dist/diagnosticExposure.d.ts.map +1 -1
- package/dist/diagnosticExposure.js +319 -21
- package/dist/diagnosticExposure.js.map +1 -1
- package/dist/diagnosticExpressions.d.ts +1 -1
- package/dist/diagnosticExpressions.d.ts.map +1 -1
- package/dist/diagnosticExpressions.js +35 -15
- package/dist/diagnosticExpressions.js.map +1 -1
- package/dist/diagnosticFormulas.d.ts +3 -0
- package/dist/diagnosticFormulas.d.ts.map +1 -1
- package/dist/diagnosticFormulas.js +160 -26
- package/dist/diagnosticFormulas.js.map +1 -1
- package/dist/diagnosticIdentity.d.ts +15 -1
- package/dist/diagnosticIdentity.d.ts.map +1 -1
- package/dist/diagnosticIdentity.js +321 -51
- package/dist/diagnosticIdentity.js.map +1 -1
- package/dist/diagnosticIdentityStream.d.ts +56 -0
- package/dist/diagnosticIdentityStream.d.ts.map +1 -0
- package/dist/diagnosticIdentityStream.js +472 -0
- package/dist/diagnosticIdentityStream.js.map +1 -0
- package/dist/diagnosticOrdering.d.ts +8 -0
- package/dist/diagnosticOrdering.d.ts.map +1 -0
- package/dist/diagnosticOrdering.js +73 -0
- package/dist/diagnosticOrdering.js.map +1 -0
- package/dist/diagnosticPeriodAxis.d.ts +9 -0
- package/dist/diagnosticPeriodAxis.d.ts.map +1 -0
- package/dist/diagnosticPeriodAxis.js +69 -0
- package/dist/diagnosticPeriodAxis.js.map +1 -0
- package/dist/diagnosticPeriods.d.ts +2 -3
- package/dist/diagnosticPeriods.d.ts.map +1 -1
- package/dist/diagnosticPeriods.js +20 -68
- package/dist/diagnosticPeriods.js.map +1 -1
- package/dist/diagnosticPreparation.d.ts +75 -14
- package/dist/diagnosticPreparation.d.ts.map +1 -1
- package/dist/diagnosticPreparation.js +1606 -112
- package/dist/diagnosticPreparation.js.map +1 -1
- package/dist/diagnosticReview.d.ts +40 -15
- package/dist/diagnosticReview.d.ts.map +1 -1
- package/dist/diagnosticReview.js +600 -42
- package/dist/diagnosticReview.js.map +1 -1
- package/dist/diagnosticReviewSources.d.ts +18 -0
- package/dist/diagnosticReviewSources.d.ts.map +1 -0
- package/dist/diagnosticReviewSources.js +76 -0
- package/dist/diagnosticReviewSources.js.map +1 -0
- package/dist/diagnosticReviewStore.d.ts +88 -0
- package/dist/diagnosticReviewStore.d.ts.map +1 -0
- package/dist/diagnosticReviewStore.js +455 -0
- package/dist/diagnosticReviewStore.js.map +1 -0
- package/dist/diagnosticRunner.d.ts +27 -2
- package/dist/diagnosticRunner.d.ts.map +1 -1
- package/dist/diagnosticRunner.js +764 -70
- package/dist/diagnosticRunner.js.map +1 -1
- package/dist/diagnosticRuntime.d.ts +26 -0
- package/dist/diagnosticRuntime.d.ts.map +1 -0
- package/dist/diagnosticRuntime.js +243 -0
- package/dist/diagnosticRuntime.js.map +1 -0
- package/dist/diagnosticSourceOrdering.d.ts +6 -0
- package/dist/diagnosticSourceOrdering.d.ts.map +1 -0
- package/dist/diagnosticSourceOrdering.js +38 -0
- package/dist/diagnosticSourceOrdering.js.map +1 -0
- package/dist/fnvAccumulator.d.ts +6 -0
- package/dist/fnvAccumulator.d.ts.map +1 -0
- package/dist/fnvAccumulator.js +21 -0
- package/dist/fnvAccumulator.js.map +1 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -4
- package/dist/index.js.map +1 -1
- package/dist/mack.d.ts +4 -0
- package/dist/mack.d.ts.map +1 -1
- package/dist/mack.js +32 -4
- package/dist/mack.js.map +1 -1
- package/dist/triangle.d.ts.map +1 -1
- package/dist/triangle.js +59 -9
- package/dist/triangle.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +22 -8
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +3 -2
- package/src/canonical.ts +144 -26
- package/src/capping.ts +109 -18
- package/src/diagnosticAggregation.ts +69 -20
- package/src/diagnosticDefinitions.ts +2675 -426
- package/src/diagnosticDerivations.ts +281 -49
- package/src/diagnosticEvidenceIntern.ts +151 -0
- package/src/diagnosticExposure.ts +550 -50
- package/src/diagnosticExpressions.ts +99 -17
- package/src/diagnosticFormulas.ts +239 -39
- package/src/diagnosticIdentity.ts +700 -191
- package/src/diagnosticIdentityStream.ts +553 -0
- package/src/diagnosticOrdering.ts +106 -0
- package/src/diagnosticPeriodAxis.ts +92 -0
- package/src/diagnosticPeriods.ts +67 -82
- package/src/diagnosticPreparation.ts +2558 -132
- package/src/diagnosticReview.ts +1072 -58
- package/src/diagnosticReviewSources.ts +85 -0
- package/src/diagnosticReviewStore.ts +692 -0
- package/src/diagnosticRunner.ts +1273 -72
- package/src/diagnosticRuntime.ts +264 -0
- package/src/diagnosticSourceOrdering.ts +50 -0
- package/src/fnvAccumulator.ts +20 -0
- package/src/index.ts +69 -4
- package/src/mack.ts +72 -9
- package/src/triangle.ts +103 -13
- package/src/types.ts +55 -20
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnosticDerivations.js","sourceRoot":"","sources":["../src/diagnosticDerivations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,wCAAwC,GAEzC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"diagnosticDerivations.js","sourceRoot":"","sources":["../src/diagnosticDerivations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kCAAkC,EAClC,wCAAwC,GAEzC,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACL,yBAAyB,GAE1B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,wBAAwB,CAAC;AAgChC,SAAS,aAAa,CACpB,KAAa;IAEb,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;QACxB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,GAAG,CAAC;YACT,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,mBAAmB,CAAC;AAC5B,CAAC;AAED,SAAS,mBAAmB,CAC1B,MAAsE;IAEtE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC,KAAK,CAAC;AAChD,CAAC;AAED,SAAS,QAAQ,CAAC,MAAyB;IAIzC,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,KAAK,MAAM,KAAK,IAAI,MAAM,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GAAG,GAAG;gBACN,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;aAClC,CAA2C;YAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAC/B,mBAAmB,EAAE,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC;SACxD,CAAC,CAAC;IACL,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,6BAA6B,CAG3C,IAAqB,EACrB,UAAwC;IAExC,kCAAkC,CAAC,UAAU,CAAC,CAAC;IAC/C,OAAO,MAAM,CAAC,MAAM,CAClB,sCAAsC,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,GAAG,CAC1D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CACnB,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Private, invocation-scoped sharing of small, newly owned evidence nodes.
|
|
3
|
+
* This is not a validation boundary: callers must finish normalizing/cloning
|
|
4
|
+
* every child first, and must never submit caller-owned objects or SDK brands.
|
|
5
|
+
*/
|
|
6
|
+
export interface DiagnosticEvidenceInternOptions {
|
|
7
|
+
readonly maxEntries?: number;
|
|
8
|
+
readonly maxSignatureCharacters?: number;
|
|
9
|
+
readonly maxCandidateProperties?: number;
|
|
10
|
+
}
|
|
11
|
+
type EvidenceMode = "plain" | "source" | "free";
|
|
12
|
+
export declare function createDiagnosticEvidenceInterner(options?: DiagnosticEvidenceInternOptions): {
|
|
13
|
+
internOwned<T extends object>(candidate: T, mode: EvidenceMode): T;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=diagnosticEvidenceIntern.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticEvidenceIntern.d.ts","sourceRoot":"","sources":["../src/diagnosticEvidenceIntern.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;CAC1C;AAED,KAAK,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AA8BhD,wBAAgB,gCAAgC,CAC9C,OAAO,GAAE,+BAAoC,GAC5C;IACD,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,CAAC,CAAC;CACpE,CAyGA"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const DEFAULT_MAX_ENTRIES = 100_000;
|
|
2
|
+
const DEFAULT_MAX_SIGNATURE_CHARACTERS = 16 * 1024 * 1024;
|
|
3
|
+
// Wide result envelopes are usually unique; focus the budget on their small
|
|
4
|
+
// repeated coordinates, sources, scopes, states, and short child lists.
|
|
5
|
+
const DEFAULT_MAX_CANDIDATE_PROPERTIES = 10;
|
|
6
|
+
const MAX_CANDIDATE_STRING_CHARACTERS = 4096;
|
|
7
|
+
function sameOwnedNode(left, right) {
|
|
8
|
+
if (Object.getPrototypeOf(left) !== Object.getPrototypeOf(right))
|
|
9
|
+
return false;
|
|
10
|
+
const leftKeys = Reflect.ownKeys(left);
|
|
11
|
+
const rightKeys = Reflect.ownKeys(right);
|
|
12
|
+
if (leftKeys.length !== rightKeys.length)
|
|
13
|
+
return false;
|
|
14
|
+
return leftKeys.every((key, index) => {
|
|
15
|
+
if (key !== rightKeys[index])
|
|
16
|
+
return false;
|
|
17
|
+
const a = Object.getOwnPropertyDescriptor(left, key);
|
|
18
|
+
const b = Object.getOwnPropertyDescriptor(right, key);
|
|
19
|
+
return ("value" in a &&
|
|
20
|
+
"value" in b &&
|
|
21
|
+
a.enumerable === b.enumerable &&
|
|
22
|
+
a.configurable === b.configurable &&
|
|
23
|
+
a.writable === b.writable &&
|
|
24
|
+
Object.is(a.value, b.value));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export function createDiagnosticEvidenceInterner(options = {}) {
|
|
28
|
+
const maxEntries = options.maxEntries ?? DEFAULT_MAX_ENTRIES;
|
|
29
|
+
const maxSignatureCharacters = options.maxSignatureCharacters ?? DEFAULT_MAX_SIGNATURE_CHARACTERS;
|
|
30
|
+
const maxCandidateProperties = options.maxCandidateProperties ?? DEFAULT_MAX_CANDIDATE_PROPERTIES;
|
|
31
|
+
const pool = new Map();
|
|
32
|
+
const childIds = new WeakMap();
|
|
33
|
+
let nextChildId = 1;
|
|
34
|
+
let signatureCharacters = 0;
|
|
35
|
+
return {
|
|
36
|
+
internOwned(candidate, mode) {
|
|
37
|
+
if (!Object.isFrozen(candidate))
|
|
38
|
+
return candidate;
|
|
39
|
+
const prototype = Object.getPrototypeOf(candidate);
|
|
40
|
+
const array = Array.isArray(candidate);
|
|
41
|
+
if (array
|
|
42
|
+
? prototype !== Array.prototype
|
|
43
|
+
: prototype !== null && prototype !== Object.prototype)
|
|
44
|
+
return candidate;
|
|
45
|
+
if (array && candidate.length >= maxCandidateProperties)
|
|
46
|
+
return candidate;
|
|
47
|
+
const keys = Reflect.ownKeys(candidate);
|
|
48
|
+
if (keys.length > maxCandidateProperties)
|
|
49
|
+
return candidate;
|
|
50
|
+
const signatureParts = [
|
|
51
|
+
mode,
|
|
52
|
+
array ? "array" : prototype === null ? "null" : "object",
|
|
53
|
+
];
|
|
54
|
+
// A declined candidate must not grow persistent bookkeeping. Stage at
|
|
55
|
+
// most this small candidate's children, including repeated references,
|
|
56
|
+
// and commit their IDs only if the candidate enters the bounded pool.
|
|
57
|
+
let pendingChildIds;
|
|
58
|
+
let stringCharacters = 0;
|
|
59
|
+
for (const key of keys) {
|
|
60
|
+
// Diagnostic JSON does not contain symbols. Declining unexpected
|
|
61
|
+
// shapes is harmless and never invokes an accessor or caller method.
|
|
62
|
+
if (typeof key !== "string")
|
|
63
|
+
return candidate;
|
|
64
|
+
const descriptor = Object.getOwnPropertyDescriptor(candidate, key);
|
|
65
|
+
if (!("value" in descriptor))
|
|
66
|
+
return candidate;
|
|
67
|
+
const value = descriptor.value;
|
|
68
|
+
let tokenType;
|
|
69
|
+
let tokenValue;
|
|
70
|
+
if (value === null) {
|
|
71
|
+
tokenType = "null";
|
|
72
|
+
tokenValue = null;
|
|
73
|
+
}
|
|
74
|
+
else if (typeof value === "object") {
|
|
75
|
+
if (!Object.isFrozen(value))
|
|
76
|
+
return candidate;
|
|
77
|
+
tokenType = "object";
|
|
78
|
+
const existingId = childIds.get(value);
|
|
79
|
+
if (existingId !== undefined)
|
|
80
|
+
tokenValue = existingId;
|
|
81
|
+
else {
|
|
82
|
+
pendingChildIds ??= new Map();
|
|
83
|
+
let pendingId = pendingChildIds.get(value);
|
|
84
|
+
if (pendingId === undefined) {
|
|
85
|
+
pendingId = nextChildId + pendingChildIds.size;
|
|
86
|
+
pendingChildIds.set(value, pendingId);
|
|
87
|
+
}
|
|
88
|
+
tokenValue = pendingId;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else if (typeof value === "number") {
|
|
92
|
+
if (!Number.isFinite(value))
|
|
93
|
+
return candidate;
|
|
94
|
+
tokenType = "number";
|
|
95
|
+
tokenValue = Object.is(value, -0) ? "-0" : value;
|
|
96
|
+
}
|
|
97
|
+
else if (typeof value === "string" ||
|
|
98
|
+
typeof value === "boolean" ||
|
|
99
|
+
value === undefined) {
|
|
100
|
+
tokenType = typeof value;
|
|
101
|
+
tokenValue = value;
|
|
102
|
+
if (typeof value === "string")
|
|
103
|
+
stringCharacters += value.length;
|
|
104
|
+
}
|
|
105
|
+
else
|
|
106
|
+
return candidate;
|
|
107
|
+
stringCharacters += key.length;
|
|
108
|
+
if (stringCharacters > MAX_CANDIDATE_STRING_CHARACTERS)
|
|
109
|
+
return candidate;
|
|
110
|
+
// Frozen data properties are necessarily non-configurable and
|
|
111
|
+
// non-writable. Keep the varying enumerability bit (including array
|
|
112
|
+
// length) and a fixed four-slot typed tuple, without temporary nested
|
|
113
|
+
// arrays. The independent equality check still verifies every flag.
|
|
114
|
+
signatureParts.push(key, descriptor.enumerable, tokenType, tokenValue);
|
|
115
|
+
}
|
|
116
|
+
const signature = JSON.stringify(signatureParts);
|
|
117
|
+
// An unseen child cannot occur in an existing entry: every admitted
|
|
118
|
+
// entry committed all its child IDs. No equality hit is skipped here.
|
|
119
|
+
const existing = pendingChildIds ? undefined : pool.get(signature);
|
|
120
|
+
// Signatures encode exact children and descriptor/order information;
|
|
121
|
+
// independently check equality before sharing rather than treating a
|
|
122
|
+
// fingerprint as proof of equality.
|
|
123
|
+
if (existing !== undefined && sameOwnedNode(existing, candidate))
|
|
124
|
+
return existing;
|
|
125
|
+
if (pool.size < maxEntries &&
|
|
126
|
+
signatureCharacters + signature.length <= maxSignatureCharacters) {
|
|
127
|
+
if (pendingChildIds) {
|
|
128
|
+
for (const [child, id] of pendingChildIds)
|
|
129
|
+
childIds.set(child, id);
|
|
130
|
+
nextChildId += pendingChildIds.size;
|
|
131
|
+
}
|
|
132
|
+
pool.set(signature, candidate);
|
|
133
|
+
signatureCharacters += signature.length;
|
|
134
|
+
}
|
|
135
|
+
return candidate;
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=diagnosticEvidenceIntern.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnosticEvidenceIntern.js","sourceRoot":"","sources":["../src/diagnosticEvidenceIntern.ts"],"names":[],"mappings":"AAaA,MAAM,mBAAmB,GAAG,OAAO,CAAC;AACpC,MAAM,gCAAgC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAC1D,4EAA4E;AAC5E,wEAAwE;AACxE,MAAM,gCAAgC,GAAG,EAAE,CAAC;AAC5C,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAE7C,S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,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,eAAe;wBAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;oBACnE,WAAW,IAAI,eAAe,CAAC,IAAI,CAAC;gBACtC,CAAC;gBACD,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBAC/B,mBAAmB,IAAI,SAAS,CAAC,MAAM,CAAC;YAC1C,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DiagnosticSourceLocation } from "./diagnosticDefinitions.js";
|
|
1
|
+
import type { DiagnosticPeriodAxis, DiagnosticSourceLocation } from "./diagnosticDefinitions.js";
|
|
2
2
|
export interface DiagnosticExposureObservation {
|
|
3
3
|
readonly key: string;
|
|
4
4
|
readonly sourceGroup: string;
|
|
@@ -47,5 +47,5 @@ export type ReconciledDiagnosticExposure = {
|
|
|
47
47
|
readonly observations: readonly DiagnosticExposureAuditObservation[];
|
|
48
48
|
};
|
|
49
49
|
export declare function auditDiagnosticNumber(value: number | null): DiagnosticAuditedNumericValue;
|
|
50
|
-
export declare function reconcileDiagnosticExposures(observations: readonly DiagnosticExposureObservation[], timingByMeasure: Readonly<Record<string, "origin-static" | "valuation-specific"
|
|
50
|
+
export declare function reconcileDiagnosticExposures(observations: readonly DiagnosticExposureObservation[], timingByMeasure: Readonly<Record<string, "origin-static" | "valuation-specific">>, periodAxis?: DiagnosticPeriodAxis): readonly ReconciledDiagnosticExposure[];
|
|
51
51
|
//# sourceMappingURL=diagnosticExposure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnosticExposure.d.ts","sourceRoot":"","sources":["../src/diagnosticExposure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"diagnosticExposure.d.ts","sourceRoot":"","sources":["../src/diagnosticExposure.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|
3
|
+
import { compareDiagnosticSourceLocations } from "./diagnosticSourceOrdering.js";
|
|
4
|
+
import { compareDiagnosticIdentityValues } from "./diagnosticOrdering.js";
|
|
5
|
+
import { normalizeDiagnosticPeriodWithAxis } from "./diagnosticPeriodAxis.js";
|
|
6
|
+
import { validateDiagnosticPeriodAxisInput } from "./diagnosticDefinitions.js";
|
|
7
|
+
import { DiagnosticValidationError, } from "./types.js";
|
|
8
|
+
import { diagnosticJsonPreflight, diagnosticRecord, hasDiagnosticOwn, isDiagnosticPlainRecord, isDiagnosticToken, snapshotDiagnosticJson, MAX_DIAGNOSTIC_JSON_DEPTH, } from "./diagnosticRuntime.js";
|
|
9
|
+
// Bound the collection separately from each untrusted record. The generic
|
|
10
|
+
// million-node JSON cap otherwise rejects legitimate files at ~71k–100k rows,
|
|
11
|
+
// depending only on how much source provenance each observation carries.
|
|
12
|
+
const MAX_EXPOSURE_OBSERVATIONS = 250_000;
|
|
13
|
+
// JSON enumeration skips hidden properties, but the strict exposure schema
|
|
14
|
+
// reads recognized own fields. Refuse hidden accessors before those reads.
|
|
15
|
+
function hiddenExposureAccessorIssues(value, path) {
|
|
16
|
+
if (!isDiagnosticPlainRecord(value))
|
|
17
|
+
return [];
|
|
18
|
+
const issues = [];
|
|
19
|
+
for (const key of Object.getOwnPropertyNames(value)) {
|
|
20
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
21
|
+
if (!descriptor.enumerable && !("value" in descriptor))
|
|
22
|
+
issues.push({
|
|
23
|
+
domain: "input",
|
|
24
|
+
code: "invalid-json-value",
|
|
25
|
+
path: propertyPath(path, key),
|
|
26
|
+
message: "JSON objects may contain only data properties",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return issues;
|
|
30
|
+
}
|
|
31
|
+
function exposureCollectionPreflight(value) {
|
|
32
|
+
if (!Array.isArray(value))
|
|
33
|
+
return diagnosticJsonPreflight(value, "input");
|
|
34
|
+
if (Object.getPrototypeOf(value) !== Array.prototype)
|
|
35
|
+
return [
|
|
36
|
+
{
|
|
37
|
+
domain: "input",
|
|
38
|
+
code: "invalid-json-value",
|
|
39
|
+
path: "$",
|
|
40
|
+
message: "Value must use a plain object or array prototype",
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
if (value.length > MAX_EXPOSURE_OBSERVATIONS)
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
domain: "input",
|
|
47
|
+
code: "expression-limit",
|
|
48
|
+
path: "$",
|
|
49
|
+
message: `Exposure observation count exceeds ${MAX_EXPOSURE_OBSERVATIONS}`,
|
|
50
|
+
},
|
|
51
|
+
];
|
|
52
|
+
const issues = [];
|
|
53
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
54
|
+
if (key === "length")
|
|
55
|
+
continue;
|
|
56
|
+
const index = typeof key === "string" ? Number(key) : Number.NaN;
|
|
57
|
+
if (Number.isInteger(index) &&
|
|
58
|
+
index >= 0 &&
|
|
59
|
+
index < value.length &&
|
|
60
|
+
String(index) === key)
|
|
61
|
+
continue;
|
|
62
|
+
issues.push({
|
|
63
|
+
domain: "input",
|
|
64
|
+
code: "invalid-json-value",
|
|
65
|
+
path: typeof key === "symbol" ? "$" : propertyPath("$", key),
|
|
66
|
+
message: "JSON arrays may contain only indexed data properties",
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
for (let index = 0; index < value.length; index++) {
|
|
70
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, String(index));
|
|
71
|
+
if (!descriptor || !("value" in descriptor)) {
|
|
72
|
+
issues.push({
|
|
73
|
+
domain: "input",
|
|
74
|
+
code: "invalid-json-value",
|
|
75
|
+
path: `$[${index}]`,
|
|
76
|
+
message: "JSON arrays may contain only indexed data properties",
|
|
77
|
+
});
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
issues.push(...hiddenExposureAccessorIssues(descriptor.value, `$[${index}]`));
|
|
81
|
+
if (isDiagnosticPlainRecord(descriptor.value)) {
|
|
82
|
+
const source = Object.getOwnPropertyDescriptor(descriptor.value, "source");
|
|
83
|
+
if (source && "value" in source)
|
|
84
|
+
issues.push(...hiddenExposureAccessorIssues(source.value, `$[${index}].source`));
|
|
85
|
+
}
|
|
86
|
+
// The outer collection used to occupy depth 1: keep the exact depth
|
|
87
|
+
// contract, and retain the default million-node guard for each record.
|
|
88
|
+
for (const issue of diagnosticJsonPreflight(descriptor.value, "input", {
|
|
89
|
+
maxDepth: MAX_DIAGNOSTIC_JSON_DEPTH - 1,
|
|
90
|
+
}))
|
|
91
|
+
issues.push({ ...issue, path: `$[${index}]${issue.path.slice(1)}` });
|
|
92
|
+
}
|
|
93
|
+
return issues;
|
|
94
|
+
}
|
|
95
|
+
/** Only for new SDK-owned objects whose leaves have already been validated. */
|
|
96
|
+
function freezeExposureRecord(value) {
|
|
97
|
+
return Object.freeze(Object.assign(diagnosticRecord(), value));
|
|
98
|
+
}
|
|
1
99
|
export function auditDiagnosticNumber(value) {
|
|
100
|
+
if (value !== null && typeof value !== "number")
|
|
101
|
+
throw new DiagnosticValidationError([
|
|
102
|
+
{
|
|
103
|
+
domain: "input",
|
|
104
|
+
code: "invalid-type",
|
|
105
|
+
path: "$",
|
|
106
|
+
message: "Numeric input must be a number or null",
|
|
107
|
+
},
|
|
108
|
+
]);
|
|
2
109
|
if (value === null)
|
|
3
|
-
return { status: "missing", value: null };
|
|
110
|
+
return Object.freeze({ status: "missing", value: null });
|
|
4
111
|
if (!Number.isFinite(value))
|
|
5
|
-
return
|
|
6
|
-
|
|
112
|
+
return Object.freeze({
|
|
113
|
+
status: "non-finite",
|
|
114
|
+
value: null,
|
|
115
|
+
nonFiniteKind: Number.isNaN(value)
|
|
116
|
+
? "nan"
|
|
117
|
+
: value > 0
|
|
118
|
+
? "positive-infinity"
|
|
119
|
+
: "negative-infinity",
|
|
120
|
+
});
|
|
121
|
+
return Object.freeze({
|
|
122
|
+
status: "observed",
|
|
123
|
+
value: Object.is(value, -0) ? 0 : value,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function propertyPath(path, key) {
|
|
127
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key)
|
|
128
|
+
? `${path}.${key}`
|
|
129
|
+
: `${path}[${JSON.stringify(key)}]`;
|
|
130
|
+
}
|
|
131
|
+
function validateExposureArguments(observations, timingByMeasure, periodAxis) {
|
|
132
|
+
// Nonfinite exposure amounts are supported audited inputs. They are the
|
|
133
|
+
// only non-JSON numbers permitted here; metadata still must be finite.
|
|
134
|
+
const issues = [
|
|
135
|
+
...exposureCollectionPreflight(observations)
|
|
136
|
+
.filter((issue) => !(issue.code === "invalid-json-value" &&
|
|
137
|
+
issue.message === "JSON numeric value must be finite" &&
|
|
138
|
+
/^\$\[\d+\]\.value$/.test(issue.path)))
|
|
139
|
+
.map((issue) => ({
|
|
140
|
+
...issue,
|
|
141
|
+
path: `$.observations${issue.path.slice(1)}`,
|
|
142
|
+
})),
|
|
143
|
+
...diagnosticJsonPreflight(timingByMeasure, "configuration").map((issue) => ({
|
|
144
|
+
...issue,
|
|
145
|
+
path: `$.timingByMeasure${issue.path.slice(1)}`,
|
|
146
|
+
})),
|
|
147
|
+
...(periodAxis === undefined
|
|
148
|
+
? []
|
|
149
|
+
: validateDiagnosticPeriodAxisInput(periodAxis)),
|
|
150
|
+
];
|
|
151
|
+
if (issues.length > 0)
|
|
152
|
+
throw new DiagnosticValidationError(issues);
|
|
153
|
+
const issue = (domain, code, path, message) => issues.push({ domain, code, path, message });
|
|
154
|
+
const token = (value, path, domain = "input") => {
|
|
155
|
+
if (!isDiagnosticToken(value))
|
|
156
|
+
issue(domain, typeof value === "string" ? "invalid-string" : "invalid-type", path, "Expected a nonempty token with valid Unicode and no U+0000");
|
|
157
|
+
};
|
|
158
|
+
const exactKeys = (value, allowed, path) => {
|
|
159
|
+
for (const key of Object.keys(value))
|
|
160
|
+
if (!allowed.includes(key))
|
|
161
|
+
issue("input", "unknown-key", propertyPath(path, key), `Unknown key ${key}`);
|
|
162
|
+
};
|
|
163
|
+
if (!Array.isArray(observations))
|
|
164
|
+
issue("input", "invalid-type", "$.observations", "Exposure observations must be an array");
|
|
165
|
+
if (!isDiagnosticPlainRecord(timingByMeasure))
|
|
166
|
+
issue("configuration", "invalid-type", "$.timingByMeasure", "Exposure timings must be a plain record");
|
|
167
|
+
if (issues.length > 0)
|
|
168
|
+
throw new DiagnosticValidationError(issues);
|
|
169
|
+
const timings = timingByMeasure;
|
|
170
|
+
for (const [measureId, timing] of Object.entries(timings)) {
|
|
171
|
+
const path = propertyPath("$.timingByMeasure", measureId);
|
|
172
|
+
token(measureId, path, "configuration");
|
|
173
|
+
if (timing !== "origin-static" && timing !== "valuation-specific")
|
|
174
|
+
issue("configuration", "invalid-type", path, "Exposure timing must be origin-static or valuation-specific");
|
|
175
|
+
}
|
|
176
|
+
for (const [index, observation] of observations.entries()) {
|
|
177
|
+
const path = `$.observations[${index}]`;
|
|
178
|
+
if (!isDiagnosticPlainRecord(observation)) {
|
|
179
|
+
issue("input", "invalid-type", path, "Exposure observation must be an object");
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
exactKeys(observation, [
|
|
183
|
+
"key",
|
|
184
|
+
"sourceGroup",
|
|
185
|
+
"origin",
|
|
186
|
+
"valuation",
|
|
187
|
+
"measureId",
|
|
188
|
+
"value",
|
|
189
|
+
"complete",
|
|
190
|
+
"source",
|
|
191
|
+
], path);
|
|
192
|
+
for (const key of ["key", "sourceGroup", "origin", "measureId"])
|
|
193
|
+
token(observation[key], `${path}.${key}`);
|
|
194
|
+
if (hasDiagnosticOwn(observation, "valuation"))
|
|
195
|
+
token(observation.valuation, `${path}.valuation`);
|
|
196
|
+
if (typeof observation.complete !== "boolean")
|
|
197
|
+
issue("input", "invalid-type", `${path}.complete`, "Exposure completeness must be boolean");
|
|
198
|
+
if (observation.value !== null && typeof observation.value !== "number")
|
|
199
|
+
issue("input", "invalid-type", `${path}.value`, "Exposure value must be a number or null");
|
|
200
|
+
if (isDiagnosticToken(observation.measureId)) {
|
|
201
|
+
if (!hasDiagnosticOwn(timings, observation.measureId))
|
|
202
|
+
issue("configuration", "unknown-reference", `${path}.measureId`, "Exposure measure has no declared timing");
|
|
203
|
+
else if (timings[observation.measureId] === "valuation-specific" &&
|
|
204
|
+
!hasDiagnosticOwn(observation, "valuation"))
|
|
205
|
+
issue("input", "missing-required", `${path}.valuation`, "Valuation-specific exposure requires a valuation");
|
|
206
|
+
}
|
|
207
|
+
if (hasDiagnosticOwn(observation, "source")) {
|
|
208
|
+
const source = observation.source;
|
|
209
|
+
if (!isDiagnosticPlainRecord(source))
|
|
210
|
+
issue("input", "invalid-type", `${path}.source`, "Source location must be an object");
|
|
211
|
+
else {
|
|
212
|
+
exactKeys(source, [
|
|
213
|
+
"artifactId",
|
|
214
|
+
"sourceFile",
|
|
215
|
+
"sourceSheet",
|
|
216
|
+
"sourceRow",
|
|
217
|
+
"sourceCell",
|
|
218
|
+
], `${path}.source`);
|
|
219
|
+
token(source.artifactId, `${path}.source.artifactId`);
|
|
220
|
+
for (const key of ["sourceFile", "sourceSheet", "sourceCell"])
|
|
221
|
+
if (hasDiagnosticOwn(source, key))
|
|
222
|
+
token(source[key], `${path}.source.${key}`);
|
|
223
|
+
if (hasDiagnosticOwn(source, "sourceRow") &&
|
|
224
|
+
(typeof source.sourceRow !== "number" ||
|
|
225
|
+
!Number.isSafeInteger(source.sourceRow) ||
|
|
226
|
+
source.sourceRow < 0))
|
|
227
|
+
issue("input", "invalid-number", `${path}.source.sourceRow`, "Source row must be a nonnegative safe integer");
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (periodAxis !== undefined)
|
|
231
|
+
for (const side of ["origin", "valuation"]) {
|
|
232
|
+
if (isDiagnosticToken(observation[side]) &&
|
|
233
|
+
normalizeDiagnosticPeriodWithAxis(periodAxis, side, observation[side]) === null)
|
|
234
|
+
issue("input", "invalid-period", `${path}.${side}`, `Unknown ${side} period ${JSON.stringify(observation[side])}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (issues.length > 0)
|
|
238
|
+
throw new DiagnosticValidationError(issues);
|
|
7
239
|
}
|
|
8
240
|
function equalAudit(left, right) {
|
|
9
|
-
return left.sourceGroup === right.sourceGroup &&
|
|
10
|
-
|
|
241
|
+
return (left.sourceGroup === right.sourceGroup &&
|
|
242
|
+
left.origin === right.origin &&
|
|
243
|
+
left.complete === right.complete &&
|
|
244
|
+
JSON.stringify(left.value) === JSON.stringify(right.value));
|
|
11
245
|
}
|
|
12
|
-
export function reconcileDiagnosticExposures(observations, timingByMeasure) {
|
|
246
|
+
export function reconcileDiagnosticExposures(observations, timingByMeasure, periodAxis) {
|
|
247
|
+
validateExposureArguments(observations, timingByMeasure, periodAxis);
|
|
248
|
+
const periodValue = (role, label) => label === undefined || periodAxis === undefined
|
|
249
|
+
? label
|
|
250
|
+
: (normalizeDiagnosticPeriodWithAxis(periodAxis, role, label)
|
|
251
|
+
?.coordinate ?? label);
|
|
252
|
+
const observationOrder = (left, right) => compareDiagnosticIdentityValues([
|
|
253
|
+
left.sourceGroup,
|
|
254
|
+
periodValue("origin", left.origin),
|
|
255
|
+
periodValue("valuation", left.valuation),
|
|
256
|
+
left.value.status,
|
|
257
|
+
left.value.status === "non-finite"
|
|
258
|
+
? left.value.nonFiniteKind
|
|
259
|
+
: left.value.value,
|
|
260
|
+
left.complete,
|
|
261
|
+
], [
|
|
262
|
+
right.sourceGroup,
|
|
263
|
+
periodValue("origin", right.origin),
|
|
264
|
+
periodValue("valuation", right.valuation),
|
|
265
|
+
right.value.status,
|
|
266
|
+
right.value.status === "non-finite"
|
|
267
|
+
? right.value.nonFiniteKind
|
|
268
|
+
: right.value.value,
|
|
269
|
+
right.complete,
|
|
270
|
+
]) ||
|
|
271
|
+
(left.source === undefined || right.source === undefined
|
|
272
|
+
? compareDiagnosticIdentityValues(left.source, right.source)
|
|
273
|
+
: compareDiagnosticSourceLocations(left.source, right.source));
|
|
13
274
|
const cohorts = new Map();
|
|
14
275
|
for (const observation of observations) {
|
|
15
|
-
const timing = timingByMeasure
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
276
|
+
const timing = hasDiagnosticOwn(timingByMeasure, observation.measureId)
|
|
277
|
+
? timingByMeasure[observation.measureId]
|
|
278
|
+
: undefined;
|
|
279
|
+
const identity = canonicalJson(timing === "valuation-specific"
|
|
280
|
+
? [
|
|
281
|
+
observation.measureId,
|
|
282
|
+
observation.key,
|
|
283
|
+
observation.valuation ?? null,
|
|
284
|
+
]
|
|
285
|
+
: [observation.measureId, observation.key]);
|
|
19
286
|
const cohort = cohorts.get(identity) ?? [];
|
|
20
287
|
cohort.push(observation);
|
|
21
288
|
cohorts.set(identity, cohort);
|
|
22
289
|
}
|
|
23
|
-
return Object.freeze([...cohorts.values()]
|
|
290
|
+
return Object.freeze([...cohorts.values()]
|
|
291
|
+
.map((cohort) => {
|
|
24
292
|
const first = cohort[0];
|
|
25
|
-
const timing = timingByMeasure
|
|
26
|
-
|
|
293
|
+
const timing = hasDiagnosticOwn(timingByMeasure, first.measureId)
|
|
294
|
+
? timingByMeasure[first.measureId]
|
|
295
|
+
: undefined;
|
|
296
|
+
const audited = cohort
|
|
297
|
+
.map((item) => snapshotDiagnosticJson({
|
|
27
298
|
sourceGroup: item.sourceGroup,
|
|
28
299
|
origin: item.origin,
|
|
29
|
-
...(item.valuation === undefined
|
|
300
|
+
...(item.valuation === undefined
|
|
301
|
+
? {}
|
|
302
|
+
: { valuation: item.valuation }),
|
|
30
303
|
value: auditDiagnosticNumber(item.value),
|
|
31
304
|
complete: item.complete,
|
|
32
|
-
...(item.source === undefined
|
|
33
|
-
|
|
305
|
+
...(item.source === undefined
|
|
306
|
+
? {}
|
|
307
|
+
: { source: Object.freeze({ ...item.source }) }),
|
|
308
|
+
}))
|
|
309
|
+
.sort(observationOrder);
|
|
34
310
|
const issues = [];
|
|
35
311
|
if (audited.some((item) => item.value.status === "missing"))
|
|
36
312
|
issues.push("missing");
|
|
@@ -44,22 +320,44 @@ export function reconcileDiagnosticExposures(observations, timingByMeasure) {
|
|
|
44
320
|
issues.push("conflict");
|
|
45
321
|
const validStaticCopies = timing === "origin-static" && issues.length === 0;
|
|
46
322
|
if (issues.length > 0)
|
|
47
|
-
return
|
|
323
|
+
return freezeExposureRecord({
|
|
324
|
+
measureId: first.measureId,
|
|
325
|
+
key: first.key,
|
|
326
|
+
status: "invalid",
|
|
327
|
+
issues: Object.freeze(issues),
|
|
328
|
+
value: null,
|
|
329
|
+
observations: Object.freeze(audited),
|
|
330
|
+
});
|
|
48
331
|
const value = audited[0].value;
|
|
49
332
|
if (value.status !== "observed")
|
|
50
333
|
throw new Error("unreachable invalid exposure state");
|
|
51
|
-
const sources = audited.
|
|
52
|
-
return
|
|
334
|
+
const sources = normalizeDiagnosticSourceLocations(audited.map((item) => item.source)).map((source) => snapshotDiagnosticJson(source));
|
|
335
|
+
return freezeExposureRecord({
|
|
53
336
|
measureId: first.measureId,
|
|
54
337
|
key: first.key,
|
|
55
338
|
status: "valid",
|
|
56
339
|
sourceGroup: first.sourceGroup,
|
|
57
340
|
origin: first.origin,
|
|
58
|
-
...(timing === "valuation-specific"
|
|
341
|
+
...(timing === "valuation-specific"
|
|
342
|
+
? { valuation: first.valuation }
|
|
343
|
+
: {}),
|
|
59
344
|
value: value.value,
|
|
60
345
|
deduplicated: validStaticCopies ? audited.length - 1 : 0,
|
|
61
346
|
sources: Object.freeze(sources),
|
|
62
347
|
});
|
|
63
|
-
})
|
|
348
|
+
})
|
|
349
|
+
.sort((left, right) => {
|
|
350
|
+
return (compareDiagnosticIdentityValues([
|
|
351
|
+
left.measureId,
|
|
352
|
+
left.key,
|
|
353
|
+
left.status,
|
|
354
|
+
left.status === "invalid" ? left.issues : undefined,
|
|
355
|
+
], [
|
|
356
|
+
right.measureId,
|
|
357
|
+
right.key,
|
|
358
|
+
right.status,
|
|
359
|
+
right.status === "invalid" ? right.issues : undefined,
|
|
360
|
+
]) || compareDiagnosticIdentityValues(left, right));
|
|
361
|
+
}));
|
|
64
362
|
}
|
|
65
363
|
//# sourceMappingURL=diagnosticExposure.js.map
|