@actuarial-ts/compliance 0.7.1 → 0.8.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 CHANGED
@@ -3,11 +3,15 @@
3
3
  Documentation, judgment, provenance, and reproducibility primitives for actuarial-ts. The package is designed to support compliance work under applicable ASOPs; it neither determines compliance nor replaces the actuary’s review.
4
4
 
5
5
  ```bash
6
- npm install @actuarial-ts/compliance@0.7.1 @actuarial-ts/core@0.7.1 @actuarial-ts/data@0.7.1 @actuarial-ts/interchange@0.7.1
6
+ npm install @actuarial-ts/compliance@0.8.0 @actuarial-ts/core@0.8.0 @actuarial-ts/data@0.8.0 @actuarial-ts/interchange@0.8.0
7
7
  ```
8
8
 
9
9
  Node 20+, ESM.
10
10
 
11
+ SDK 0.8 adds fresh-execution customization provenance and source-bound bounded
12
+ replay receipts. See the [0.8 adoption guide](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/migrations/0.8-reusable-customization.md)
13
+ and [customization reference](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/reference/reusable-customization.md).
14
+
11
15
  ## Diagnostic provenance
12
16
 
13
17
  The example below uses eager provenance. `createDiagnosticRunIdentity` accepts only an owner-authenticated, completed eager data-package run. It does not accept caller-restated formulas, filters, review status, or result identities. Compact runs use the separate workflow below.
@@ -59,7 +63,7 @@ Material host judgments worth recording in the assumption ledger include amount
59
63
 
60
64
  The package also provides estimate metadata, assumption ledgers, ASOP No. 41 draft disclosure generation, ASOP No. 56 model cards, actual-versus-expected roll-forward, and canonical reproducibility bundles.
61
65
 
62
- See the [formula catalog](https://github.com/yerromnitsuj/actng/blob/v0.7.1/docs/reference/diagnostic-formulas.md) and [migration guide](https://github.com/yerromnitsuj/actng/blob/v0.7.1/docs/migrations/0.6-generalized-diagnostics.md).
66
+ See the [formula catalog](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/reference/diagnostic-formulas.md) and [migration guide](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/migrations/0.6-generalized-diagnostics.md).
63
67
 
64
68
  ## Compact provenance and replay streams
65
69
 
@@ -86,7 +90,7 @@ documents afterward can erase the representation's memory benefit.
86
90
  object, not an eager `VerifiedDiagnosticRunProvenance` or a serializable
87
91
  authorization token. It cannot be cast into `createBundle`, the eager verifier,
88
92
  or the current diagnostic agent executor. The stream format is
89
- `diagnostic-replay/1`, separate from interchange wire `1.1.0`; it is not a
93
+ `diagnostic-replay/1`, separate from interchange wire `1.2.0`; it is not a
90
94
  single JSON document or a `BundleDoc`.
91
95
 
92
96
  Replay identities include the producing SDK's engine versions. Preserve those
@@ -96,8 +100,29 @@ in particular, a patch upgrade must not be assumed to verify an older stream.
96
100
  Successful replay establishes internal reproducibility, not source authenticity,
97
101
  a digital signature, correct claim-level capping, or actuarial correctness.
98
102
 
99
- The runnable [compact adoption guide](https://github.com/yerromnitsuj/actng/blob/v0.7.1/docs/migrations/0.7-compact-diagnostics.md)
100
- and complete [replay reference](https://github.com/yerromnitsuj/actng/blob/v0.7.1/docs/reference/diagnostic-replay-stream.md)
103
+ ## Reusable customization replay
104
+
105
+ `writeBoundedAnalysisReplay` writes independently recalculable evidence for
106
+ normalized selected records. `writeBoundedHistoryAnalysisReplay` adds raw
107
+ history validation, revision selection, exact/latest evaluation selection, a
108
+ blocking preparation-review gate, and two host-owned external-state stages.
109
+ The latter supports mergeable sums, ratios, weighted means, and extrema. Exact
110
+ distinct counts and type-7 quantiles use `writeBoundedAnalysisReplay` after the
111
+ host supplies their required global order. `verifyBoundedAnalysisReplay`
112
+ returns a `VerifiedBoundedReplayReceipt`; use
113
+ `assertVerifiedBoundedReplayReceipt` when an authentic in-process receipt is a
114
+ precondition. Verification requires `expectedSourceArtifact`, the authentic
115
+ handle returned by `digestDiagnosticArtifactChunks` for the source bytes.
116
+ Parsed or copied JSON cannot satisfy either authenticity check.
117
+
118
+ All paths require explicit record, partition, memory, input, output, and active
119
+ scenario ceilings. A ceiling applies to the stated SDK record or frame; it is
120
+ not a promise about total process RSS or host storage caches. The host owns the
121
+ adapter, source bytes, output publication, pending-I/O cancellation, and
122
+ temporary-state durability.
123
+
124
+ The runnable [compact adoption guide](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/migrations/0.7-compact-diagnostics.md)
125
+ and complete [replay reference](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/reference/diagnostic-replay-stream.md)
101
126
  document ownership, artifact bytes, paging, framing, resource limits, and
102
127
  assurance boundaries. These repository guides are linked here for npm users;
103
128
  the guide files themselves are not shipped inside the package.
package/dist/bundle.d.ts CHANGED
@@ -54,7 +54,7 @@ export type WrappedBundleDoc = BundleDoc;
54
54
  * test parses the emitted doc with the real interchange parser, which
55
55
  * refuses a wrong-major version — drift fails loudly.
56
56
  */
57
- export declare const WRAPPED_BUNDLE_INTERCHANGE_VERSION = "1.1.0";
57
+ export declare const WRAPPED_BUNDLE_INTERCHANGE_VERSION = "1.2.0";
58
58
  /**
59
59
  * This package's version, stamped into a wrapped bundle's `generator`
60
60
  * envelope field. A sync test asserts it matches package.json so it cannot
@@ -0,0 +1,64 @@
1
+ import { BOUNDED_REPLAY_CONTRACT_VERSION, type AnalysisStatisticDefinition, type CustomizationResourceLimits, type JsonValue } from "@actuarial-ts/core";
2
+ import { type CustomizationExternalRecord } from "@actuarial-ts/data";
3
+ import { type ComputedDiagnosticArtifactDigest } from "./diagnosticArtifactStream.js";
4
+ import type { DiagnosticArtifactDigest } from "./diagnosticRun.js";
5
+ export type BoundedReplayStatistic = Extract<AnalysisStatisticDefinition, {
6
+ readonly kind: "sum" | "ratio" | "weighted-mean" | "minimum" | "maximum" | "distinct-count" | "quantile";
7
+ }>;
8
+ export interface BoundedReplayMeasure {
9
+ readonly id: string;
10
+ readonly unit: string;
11
+ readonly statistic: BoundedReplayStatistic;
12
+ /** Required for exact externally ordered quantiles; counts finite values. */
13
+ readonly orderedPopulationSize?: number;
14
+ }
15
+ export interface BoundedReplayValue {
16
+ readonly measureId: string;
17
+ readonly value: number | null;
18
+ readonly numerator: number | null;
19
+ readonly denominator: number | null;
20
+ }
21
+ export interface BoundedReplayVerification {
22
+ readonly contractVersion: typeof BOUNDED_REPLAY_CONTRACT_VERSION;
23
+ readonly runId: string;
24
+ readonly sourceArtifact: DiagnosticArtifactDigest;
25
+ readonly calculationContext?: JsonValue;
26
+ readonly recordCount: number;
27
+ readonly recordDigest: string;
28
+ readonly calculationIdentity: string;
29
+ readonly values: readonly BoundedReplayValue[];
30
+ }
31
+ declare const verifiedBoundedReplayBrand: unique symbol;
32
+ export type VerifiedBoundedReplayReceipt = BoundedReplayVerification & {
33
+ readonly [verifiedBoundedReplayBrand]: true;
34
+ };
35
+ /** Refuses structurally similar JSON that did not come from independent replay. */
36
+ export declare function assertVerifiedBoundedReplayReceipt(value: unknown): asserts value is VerifiedBoundedReplayReceipt;
37
+ type MeasureRecord = {
38
+ readonly measures: Readonly<Record<string, number | null>>;
39
+ /** Namespaced stable keys used by externally ordered exact distinct counts. */
40
+ readonly entityKeys?: Readonly<Record<string, string | null>>;
41
+ };
42
+ /** Validates and owns an untrusted bounded replay measure list. */
43
+ export declare function parseBoundedReplayMeasures(value: unknown, limits: CustomizationResourceLimits): readonly BoundedReplayMeasure[];
44
+ /** Writes a replay whose retained SDK state is bounded by measures and one record frame. */
45
+ export declare function writeBoundedAnalysisReplay(input: {
46
+ readonly runId: string;
47
+ readonly sourceArtifact: ComputedDiagnosticArtifactDigest;
48
+ readonly measures: readonly BoundedReplayMeasure[];
49
+ /** Optional closed calculation/selection context bound into the receipt identity. */
50
+ readonly calculationContext?: JsonValue;
51
+ readonly records: AsyncIterable<CustomizationExternalRecord<MeasureRecord>> | Iterable<CustomizationExternalRecord<MeasureRecord>>;
52
+ readonly limits: CustomizationResourceLimits;
53
+ readonly signal?: AbortSignal;
54
+ }): AsyncGenerator<Uint8Array>;
55
+ /** Independently recomputes every bounded result and identity while reading one frame at a time. */
56
+ export declare function verifyBoundedAnalysisReplay(input: {
57
+ readonly chunks: AsyncIterable<Uint8Array> | Iterable<Uint8Array>;
58
+ readonly limits: CustomizationResourceLimits;
59
+ /** Authentic handle recomputed from the source bytes being verified. */
60
+ readonly expectedSourceArtifact: ComputedDiagnosticArtifactDigest;
61
+ readonly signal?: AbortSignal;
62
+ }): Promise<VerifiedBoundedReplayReceipt>;
63
+ export {};
64
+ //# sourceMappingURL=customizationBoundedReplay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customizationBoundedReplay.d.ts","sourceRoot":"","sources":["../src/customizationBoundedReplay.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAO/B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,EAChC,KAAK,SAAS,EACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,KAAK,2BAA2B,EACjC,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAC1C,2BAA2B,EAC3B;IAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,OAAO,GAAG,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,gBAAgB,GAAG,UAAU,CAAA;CAAE,CAC7G,CAAC;AAEF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;CACzC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,C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AC,KAAK,EAAE;IACvD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,cAAc,EAAE,gCAAgC,CAAC;IAC1D,QAAQ,CAAC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,CAAC;IACnD,qFAAqF;IACrF,QAAQ,CAAC,kBAAkB,CAAC,EAAE,SAAS,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC,GAAG,QAAQ,CAAC,2BAA2B,CAAC,aAAa,CAAC,CAAC,CAAC;IACnI,QAAQ,CAAC,MAAM,EAAE,2BAA2B,CAAC;IAC7C,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,GAAG,cAAc,CAAC,UAAU,CAAC,CAkE7B;AAuBD,oGAAoG;AACpG,wBAAsB,2BAA2B,CAAC,KAAK,EAAE;IACvD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC;IAClE,QAAQ,CAAC,MAAM,EAAE,2BAA2B,CAAC;IAC7C,wEAAwE;IACxE,QAAQ,CAAC,sBAAsB,EAAE,gCAAgC,CAAC;IAClE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B,GAAG,OAAO,CAAC,4BAA4B,CAAC,CA0ExC"}
@@ -0,0 +1,456 @@
1
+ import { BOUNDED_REPLAY_CONTRACT_VERSION, canonicalJson, diagnosticJsonPreflight, fnv1a64, isDiagnosticPlainRecord, isDiagnosticToken, snapshotDiagnosticJson, } from "@actuarial-ts/core";
2
+ import { parseCustomizationResourceLimits, } from "@actuarial-ts/data";
3
+ import { z } from "zod";
4
+ import { ComplianceError } from "./errors.js";
5
+ import { assertComputedDiagnosticArtifactDigest, } from "./diagnosticArtifactStream.js";
6
+ import { createSha256 } from "./sha256Stream.js";
7
+ const verifiedBoundedReplayReceipts = new WeakSet();
8
+ /** Refuses structurally similar JSON that did not come from independent replay. */
9
+ export function assertVerifiedBoundedReplayReceipt(value) {
10
+ if (value === null ||
11
+ typeof value !== "object" ||
12
+ !verifiedBoundedReplayReceipts.has(value))
13
+ invalid("Value is not an authentic independently verified bounded replay receipt");
14
+ }
15
+ const encoder = new TextEncoder();
16
+ const tokenSchema = z.string().refine(isDiagnosticToken, "Expected a valid token");
17
+ const finiteSchema = z.number().finite();
18
+ const jsonValueSchema = z.lazy(() => z.union([
19
+ z.null(),
20
+ z.boolean(),
21
+ finiteSchema,
22
+ z.string(),
23
+ z.array(jsonValueSchema),
24
+ z.record(jsonValueSchema),
25
+ ]));
26
+ const sourceArtifactSchema = z.object({
27
+ id: tokenSchema,
28
+ scope: z.enum(["input", "preparation"]),
29
+ assurance: z.literal("sdk-computed"),
30
+ algorithm: z.literal("sha256"),
31
+ value: z.string().regex(/^[0-9a-f]{64}$/),
32
+ byteLength: z.number().int().nonnegative().safe(),
33
+ }).strict();
34
+ const statisticSchema = z.discriminatedUnion("kind", [
35
+ z.object({ kind: z.literal("sum"), measureId: tokenSchema }).strict(),
36
+ z.object({
37
+ kind: z.literal("ratio"),
38
+ numeratorMeasureId: tokenSchema,
39
+ denominatorMeasureId: tokenSchema,
40
+ scale: finiteSchema,
41
+ denominatorRule: z.enum(["positive", "nonzero"]),
42
+ }).strict(),
43
+ z.object({ kind: z.literal("weighted-mean"), measureId: tokenSchema, weightMeasureId: tokenSchema }).strict(),
44
+ z.object({ kind: z.literal("minimum"), measureId: tokenSchema }).strict(),
45
+ z.object({ kind: z.literal("maximum"), measureId: tokenSchema }).strict(),
46
+ z.object({ kind: z.literal("distinct-count"), entity: z.enum(["claim", "claimant", "occurrence", "policy", "coverage"]) }).strict(),
47
+ z.object({ kind: z.literal("quantile"), measureId: tokenSchema, probability: finiteSchema.min(0).max(1), method: z.literal("hf-type-7") }).strict(),
48
+ ]);
49
+ const boundedReplayMeasureSchema = z.object({
50
+ id: tokenSchema,
51
+ unit: tokenSchema,
52
+ statistic: statisticSchema,
53
+ orderedPopulationSize: z.number().int().positive().safe().optional(),
54
+ }).strict();
55
+ const replayValueSchema = z.object({
56
+ measureId: tokenSchema,
57
+ value: finiteSchema.nullable(),
58
+ numerator: finiteSchema.nullable(),
59
+ denominator: finiteSchema.nullable(),
60
+ }).strict();
61
+ const headerSchema = z.object({
62
+ type: z.literal("header"),
63
+ contractVersion: z.literal(BOUNDED_REPLAY_CONTRACT_VERSION),
64
+ runId: tokenSchema,
65
+ sourceArtifact: sourceArtifactSchema,
66
+ measures: z.array(boundedReplayMeasureSchema),
67
+ calculationContext: jsonValueSchema.optional(),
68
+ }).strict();
69
+ const measureRecordSchema = z.object({
70
+ measures: z.record(tokenSchema, finiteSchema.nullable()),
71
+ entityKeys: z.record(tokenSchema, z.string().nullable()).optional(),
72
+ }).strict();
73
+ const recordFrameSchema = z.object({
74
+ type: z.literal("record"),
75
+ record: z.object({
76
+ id: tokenSchema,
77
+ partitionKey: z.string(),
78
+ orderKey: z.string(),
79
+ value: measureRecordSchema,
80
+ }).strict(),
81
+ }).strict();
82
+ const trailerSchema = z.object({
83
+ type: z.literal("trailer"),
84
+ recordCount: z.number().int().nonnegative().safe(),
85
+ recordDigest: z.string().regex(/^[0-9a-f]{64}$/),
86
+ calculationIdentity: z.string().regex(/^fnv1a64-jcs-v1:[0-9a-f]{16}$/),
87
+ values: z.array(replayValueSchema),
88
+ }).strict();
89
+ function invalid(message) {
90
+ throw new ComplianceError("BAD_DIAGNOSTIC_RUN", message, "$.boundedReplay");
91
+ }
92
+ function validateLimits(limits) {
93
+ try {
94
+ return parseCustomizationResourceLimits(limits);
95
+ }
96
+ catch (error) {
97
+ invalid(error instanceof Error ? error.message : "Invalid customization resource limits");
98
+ }
99
+ }
100
+ /** Validates and owns an untrusted bounded replay measure list. */
101
+ export function parseBoundedReplayMeasures(value, limits) {
102
+ const parsed = z.array(boundedReplayMeasureSchema).safeParse(value);
103
+ if (!parsed.success)
104
+ invalid(`Bounded replay measures are invalid: ${parsed.error.issues[0]?.message ?? "schema mismatch"}`);
105
+ const measures = parsed.data;
106
+ if (measures.length === 0 || measures.length > limits.maximumOutputValues)
107
+ invalid("Bounded replay measure count is outside maximumOutputValues");
108
+ if (new Set(measures.map((measure) => measure.id)).size !== measures.length)
109
+ invalid("Bounded replay measure IDs must be unique");
110
+ for (const measure of measures) {
111
+ const statistic = measure.statistic;
112
+ if (statistic.kind === "quantile" && (!Number.isSafeInteger(measure.orderedPopulationSize) || measure.orderedPopulationSize < 1))
113
+ invalid("Bounded replay exact quantile requires positive orderedPopulationSize");
114
+ if (statistic.kind !== "quantile" && measure.orderedPopulationSize !== undefined)
115
+ invalid("orderedPopulationSize applies only to bounded exact quantiles");
116
+ }
117
+ const distinctEntities = new Set(measures.flatMap((measure) => measure.statistic.kind === "distinct-count" ? [measure.statistic.entity] : []));
118
+ if (distinctEntities.size > 1)
119
+ invalid("One bounded replay may externally order one distinct entity kind");
120
+ const quantileMeasures = new Set(measures.flatMap((measure) => measure.statistic.kind === "quantile" ? [measure.statistic.measureId] : []));
121
+ if (quantileMeasures.size > 1)
122
+ invalid("One bounded replay may externally order one quantile source measure");
123
+ return snapshotDiagnosticJson(measures);
124
+ }
125
+ function checkedAdd(left, right, description) {
126
+ const result = left + right;
127
+ if (!Number.isFinite(result))
128
+ invalid(`Bounded replay ${description} overflowed the finite number range`);
129
+ return Object.is(result, -0) ? 0 : result;
130
+ }
131
+ function checkedProduct(left, right, description) {
132
+ const result = left * right;
133
+ if (!Number.isFinite(result))
134
+ invalid(`Bounded replay ${description} overflowed the finite number range`);
135
+ return Object.is(result, -0) ? 0 : result;
136
+ }
137
+ function checkedResult(value, description) {
138
+ if (!Number.isFinite(value))
139
+ invalid(`Bounded replay ${description} overflowed the finite number range`);
140
+ return Object.is(value, -0) ? 0 : value;
141
+ }
142
+ function aggregates(measures) {
143
+ return measures.map((definition) => ({ definition, sum: 0, numerator: 0, denominator: 0, pairs: 0, minimum: Number.POSITIVE_INFINITY, maximum: Number.NEGATIVE_INFINITY, lastDistinctKey: null, distinctCount: 0, orderedCount: 0, lastOrderedValue: null, lowerOrderedValue: null, upperOrderedValue: null }));
144
+ }
145
+ function acceptRecord(state, record) {
146
+ for (const aggregate of state) {
147
+ const statistic = aggregate.definition.statistic;
148
+ if (statistic.kind === "sum") {
149
+ const value = record.measures[statistic.measureId];
150
+ if (typeof value === "number" && Number.isFinite(value))
151
+ aggregate.sum = checkedAdd(aggregate.sum, value, "sum");
152
+ }
153
+ else if (statistic.kind === "ratio") {
154
+ const numerator = record.measures[statistic.numeratorMeasureId];
155
+ const denominator = record.measures[statistic.denominatorMeasureId];
156
+ if (typeof numerator === "number" && Number.isFinite(numerator) && typeof denominator === "number" && Number.isFinite(denominator)) {
157
+ aggregate.numerator = checkedAdd(aggregate.numerator, numerator, "ratio numerator");
158
+ aggregate.denominator = checkedAdd(aggregate.denominator, denominator, "ratio denominator");
159
+ aggregate.pairs += 1;
160
+ }
161
+ }
162
+ else if (statistic.kind === "weighted-mean") {
163
+ const value = record.measures[statistic.measureId];
164
+ const weight = record.measures[statistic.weightMeasureId];
165
+ if (typeof value === "number" && Number.isFinite(value) && typeof weight === "number" && Number.isFinite(weight)) {
166
+ if (weight < 0)
167
+ invalid("Bounded weighted mean encountered a negative weight");
168
+ if (weight > 0) {
169
+ aggregate.numerator = checkedAdd(aggregate.numerator, checkedProduct(value, weight, "weighted product"), "weighted numerator");
170
+ aggregate.denominator = checkedAdd(aggregate.denominator, weight, "weight denominator");
171
+ aggregate.pairs += 1;
172
+ }
173
+ }
174
+ }
175
+ else if (statistic.kind === "minimum" || statistic.kind === "maximum") {
176
+ const value = record.measures[statistic.measureId];
177
+ if (typeof value === "number" && Number.isFinite(value)) {
178
+ aggregate.minimum = Math.min(aggregate.minimum, value);
179
+ aggregate.maximum = Math.max(aggregate.maximum, value);
180
+ aggregate.pairs += 1;
181
+ }
182
+ }
183
+ else if (statistic.kind === "distinct-count") {
184
+ const distinctKey = record.entityKeys?.[statistic.entity];
185
+ if (distinctKey === undefined)
186
+ invalid(`Bounded distinct count requires entityKeys.${statistic.entity}`);
187
+ if (distinctKey === null)
188
+ continue;
189
+ if (aggregate.lastDistinctKey !== null && distinctKey < aggregate.lastDistinctKey)
190
+ invalid("Bounded distinct keys are not in external ascending order");
191
+ if (distinctKey !== aggregate.lastDistinctKey) {
192
+ if (aggregate.distinctCount === Number.MAX_SAFE_INTEGER)
193
+ invalid("Bounded distinct count exceeds the safe integer range");
194
+ aggregate.distinctCount += 1;
195
+ }
196
+ aggregate.lastDistinctKey = distinctKey;
197
+ }
198
+ else {
199
+ if (statistic.kind !== "quantile")
200
+ invalid("Unsupported bounded replay statistic");
201
+ const value = record.measures[statistic.measureId];
202
+ if (typeof value !== "number" || !Number.isFinite(value))
203
+ continue;
204
+ if (aggregate.lastOrderedValue !== null && value < aggregate.lastOrderedValue)
205
+ invalid("Bounded quantile values are not in external ascending order");
206
+ const populationSize = aggregate.definition.orderedPopulationSize;
207
+ const h = (populationSize - 1) * statistic.probability;
208
+ const lower = Math.floor(h);
209
+ const upper = Math.ceil(h);
210
+ if (aggregate.orderedCount === lower)
211
+ aggregate.lowerOrderedValue = value;
212
+ if (aggregate.orderedCount === upper)
213
+ aggregate.upperOrderedValue = value;
214
+ if (aggregate.orderedCount === Number.MAX_SAFE_INTEGER)
215
+ invalid("Bounded quantile count exceeds the safe integer range");
216
+ aggregate.orderedCount += 1;
217
+ aggregate.lastOrderedValue = value;
218
+ }
219
+ }
220
+ }
221
+ function values(state) {
222
+ return state.map((aggregate) => {
223
+ const statistic = aggregate.definition.statistic;
224
+ if (statistic.kind === "sum")
225
+ return { measureId: aggregate.definition.id, value: Object.is(aggregate.sum, -0) ? 0 : aggregate.sum, numerator: null, denominator: null };
226
+ if (statistic.kind === "weighted-mean")
227
+ return { measureId: aggregate.definition.id, value: aggregate.denominator > 0 ? checkedResult(aggregate.numerator / aggregate.denominator, "weighted mean") : null, numerator: aggregate.pairs > 0 ? aggregate.numerator : null, denominator: aggregate.pairs > 0 ? aggregate.denominator : null };
228
+ if (statistic.kind === "minimum" || statistic.kind === "maximum") {
229
+ const selected = statistic.kind === "minimum" ? aggregate.minimum : aggregate.maximum;
230
+ return { measureId: aggregate.definition.id, value: aggregate.pairs === 0 ? null : Object.is(selected, -0) ? 0 : selected, numerator: null, denominator: null };
231
+ }
232
+ if (statistic.kind === "distinct-count")
233
+ return { measureId: aggregate.definition.id, value: aggregate.distinctCount, numerator: null, denominator: null };
234
+ if (statistic.kind === "quantile") {
235
+ if (aggregate.orderedCount !== aggregate.definition.orderedPopulationSize)
236
+ invalid(`Bounded quantile received ${aggregate.orderedCount} finite values but orderedPopulationSize is ${aggregate.definition.orderedPopulationSize}`);
237
+ const h = (aggregate.orderedCount - 1) * statistic.probability;
238
+ const fraction = h - Math.floor(h);
239
+ const lower = aggregate.lowerOrderedValue;
240
+ const upper = aggregate.upperOrderedValue;
241
+ const interpolated = fraction === 0
242
+ ? lower
243
+ : checkedAdd(checkedProduct(lower, 1 - fraction, "quantile interpolation"), checkedProduct(upper, fraction, "quantile interpolation"), "quantile interpolation");
244
+ return { measureId: aggregate.definition.id, value: interpolated, numerator: null, denominator: null };
245
+ }
246
+ if (statistic.kind !== "ratio")
247
+ invalid("Unsupported bounded replay statistic");
248
+ const allowed = statistic.denominatorRule === "positive" ? aggregate.denominator > 0 : aggregate.denominator !== 0;
249
+ return {
250
+ measureId: aggregate.definition.id,
251
+ value: aggregate.pairs > 0 && allowed ? checkedResult(checkedResult(aggregate.numerator / aggregate.denominator, "ratio") * statistic.scale, "scaled ratio") : null,
252
+ numerator: aggregate.pairs > 0 ? aggregate.numerator : null,
253
+ denominator: aggregate.pairs > 0 ? aggregate.denominator : null,
254
+ };
255
+ });
256
+ }
257
+ function line(value, maximumBytes, limitName = "maximumInMemoryBytes") {
258
+ const bytes = encoder.encode(`${JSON.stringify(value)}\n`);
259
+ if (bytes.byteLength > maximumBytes)
260
+ invalid(`Bounded replay frame exceeds ${limitName}`);
261
+ return bytes;
262
+ }
263
+ function throwIfCancelled(signal) {
264
+ if (signal?.aborted)
265
+ throw new ComplianceError("BAD_DIAGNOSTIC_RUN", "Bounded replay was cancelled", "$.boundedReplay");
266
+ }
267
+ /** Writes a replay whose retained SDK state is bounded by measures and one record frame. */
268
+ export async function* writeBoundedAnalysisReplay(input) {
269
+ const limits = validateLimits(input.limits);
270
+ const runId = input.runId;
271
+ const sourceArtifactHandle = input.sourceArtifact;
272
+ const records = input.records;
273
+ const signal = input.signal;
274
+ const suppliedContext = input.calculationContext;
275
+ if (!isDiagnosticToken(runId))
276
+ invalid("Bounded replay runId is invalid");
277
+ assertComputedDiagnosticArtifactDigest(sourceArtifactHandle);
278
+ const sourceArtifact = snapshotDiagnosticJson(sourceArtifactHandle);
279
+ const measures = parseBoundedReplayMeasures(input.measures, limits);
280
+ if (suppliedContext !== undefined) {
281
+ const issues = diagnosticJsonPreflight(suppliedContext, "input");
282
+ if (issues.length > 0)
283
+ invalid(issues[0].message);
284
+ }
285
+ const calculationContext = suppliedContext === undefined
286
+ ? undefined
287
+ : snapshotDiagnosticJson(suppliedContext);
288
+ const header = snapshotDiagnosticJson({
289
+ type: "header",
290
+ contractVersion: BOUNDED_REPLAY_CONTRACT_VERSION,
291
+ runId,
292
+ sourceArtifact,
293
+ measures,
294
+ ...(calculationContext === undefined ? {} : { calculationContext }),
295
+ });
296
+ yield line(header, limits.maximumInMemoryBytes);
297
+ const state = aggregates(measures);
298
+ const digest = createSha256();
299
+ let recordCount = 0;
300
+ for await (const external of records) {
301
+ throwIfCancelled(signal);
302
+ if (recordCount >= limits.maximumInputRecords)
303
+ invalid("Bounded replay exceeds maximumInputRecords");
304
+ recordCount += 1;
305
+ const preflight = diagnosticJsonPreflight(external, "input");
306
+ if (preflight.length > 0)
307
+ invalid(preflight[0].message);
308
+ if (!isDiagnosticPlainRecord(external.value) || !isDiagnosticPlainRecord(external.value.measures))
309
+ invalid("Bounded replay records require a measures object");
310
+ const owned = snapshotDiagnosticJson({ type: "record", record: external });
311
+ const parsedRecord = recordFrameSchema.safeParse(owned);
312
+ if (!parsedRecord.success)
313
+ invalid(`Bounded replay record is invalid: ${parsedRecord.error.issues[0]?.message ?? "schema mismatch"}`);
314
+ const bytes = line(parsedRecord.data, limits.maximumRecordBytes, "maximumRecordBytes");
315
+ digest.update(bytes);
316
+ acceptRecord(state, parsedRecord.data.record.value);
317
+ yield bytes;
318
+ }
319
+ const calculatedValues = values(state);
320
+ const recordDigest = digest.digest();
321
+ const identityValue = {
322
+ contractVersion: BOUNDED_REPLAY_CONTRACT_VERSION,
323
+ runId,
324
+ sourceArtifact,
325
+ measures,
326
+ ...(calculationContext === undefined ? {} : { calculationContext }),
327
+ recordCount,
328
+ recordDigest,
329
+ values: calculatedValues,
330
+ };
331
+ const trailer = snapshotDiagnosticJson({
332
+ type: "trailer",
333
+ recordCount,
334
+ recordDigest,
335
+ calculationIdentity: `fnv1a64-jcs-v1:${fnv1a64(canonicalJson(identityValue))}`,
336
+ values: calculatedValues,
337
+ });
338
+ yield line(trailer, limits.maximumInMemoryBytes);
339
+ }
340
+ async function* decodedLines(chunks, maximumBytes) {
341
+ const decoder = new TextDecoder("utf-8", { fatal: true });
342
+ let pending = "";
343
+ for await (const chunk of chunks) {
344
+ if (!(chunk instanceof Uint8Array) || chunk.byteLength > maximumBytes)
345
+ invalid("Invalid or oversized bounded replay chunk");
346
+ pending += decoder.decode(chunk, { stream: true });
347
+ if (encoder.encode(pending).byteLength > maximumBytes)
348
+ invalid("Bounded replay line exceeds maximumInMemoryBytes");
349
+ let boundary;
350
+ while ((boundary = pending.indexOf("\n")) >= 0) {
351
+ const text = pending.slice(0, boundary);
352
+ pending = pending.slice(boundary + 1);
353
+ yield { text, bytes: encoder.encode(`${text}\n`) };
354
+ }
355
+ }
356
+ pending += decoder.decode();
357
+ if (pending !== "")
358
+ invalid("Bounded replay ends with an incomplete frame");
359
+ }
360
+ /** Independently recomputes every bounded result and identity while reading one frame at a time. */
361
+ export async function verifyBoundedAnalysisReplay(input) {
362
+ const limits = validateLimits(input.limits);
363
+ const chunks = input.chunks;
364
+ const signal = input.signal;
365
+ const expectedSourceArtifactHandle = input.expectedSourceArtifact;
366
+ assertComputedDiagnosticArtifactDigest(expectedSourceArtifactHandle);
367
+ const expectedSourceArtifact = snapshotDiagnosticJson(expectedSourceArtifactHandle);
368
+ let header;
369
+ let trailer;
370
+ let state = [];
371
+ let recordCount = 0;
372
+ const digest = createSha256();
373
+ for await (const frame of decodedLines(chunks, limits.maximumInMemoryBytes)) {
374
+ throwIfCancelled(signal);
375
+ let parsed;
376
+ try {
377
+ parsed = JSON.parse(frame.text);
378
+ }
379
+ catch {
380
+ invalid("Bounded replay frame is not valid JSON");
381
+ }
382
+ const preflight = diagnosticJsonPreflight(parsed, "input");
383
+ if (preflight.length > 0 || !isDiagnosticPlainRecord(parsed))
384
+ invalid("Bounded replay frame is not plain JSON data");
385
+ if (parsed.type === "header") {
386
+ if (header !== undefined || recordCount > 0 || trailer !== undefined)
387
+ invalid("Bounded replay header is out of order");
388
+ const result = headerSchema.safeParse(parsed);
389
+ if (!result.success)
390
+ invalid(`Bounded replay header is invalid: ${result.error.issues[0]?.message ?? "schema mismatch"}`);
391
+ const measures = parseBoundedReplayMeasures(result.data.measures, limits);
392
+ header = snapshotDiagnosticJson(result.data);
393
+ state = aggregates(measures);
394
+ if (canonicalJson(header.sourceArtifact) !== canonicalJson(expectedSourceArtifact))
395
+ invalid("Bounded replay source artifact differs from the expected immutable source");
396
+ }
397
+ else if (parsed.type === "record") {
398
+ if (header === undefined || trailer !== undefined)
399
+ invalid("Bounded replay record is out of order");
400
+ if (frame.bytes.byteLength > limits.maximumRecordBytes)
401
+ invalid("Bounded replay record exceeds maximumRecordBytes");
402
+ const result = recordFrameSchema.safeParse(parsed);
403
+ if (!result.success)
404
+ invalid(`Bounded replay record is invalid: ${result.error.issues[0]?.message ?? "schema mismatch"}`);
405
+ if (recordCount >= limits.maximumInputRecords)
406
+ invalid("Bounded replay exceeds maximumInputRecords");
407
+ recordCount += 1;
408
+ digest.update(frame.bytes);
409
+ acceptRecord(state, result.data.record.value);
410
+ }
411
+ else if (parsed.type === "trailer") {
412
+ if (header === undefined || trailer !== undefined)
413
+ invalid("Bounded replay trailer is out of order");
414
+ const result = trailerSchema.safeParse(parsed);
415
+ if (!result.success)
416
+ invalid(`Bounded replay trailer is invalid: ${result.error.issues[0]?.message ?? "schema mismatch"}`);
417
+ trailer = snapshotDiagnosticJson(result.data);
418
+ }
419
+ else
420
+ invalid("Unknown bounded replay frame type");
421
+ }
422
+ if (header === undefined || trailer === undefined)
423
+ invalid("Bounded replay is truncated");
424
+ const calculatedValues = values(state);
425
+ const recordDigest = digest.digest();
426
+ const identityValue = {
427
+ contractVersion: BOUNDED_REPLAY_CONTRACT_VERSION,
428
+ runId: header.runId,
429
+ sourceArtifact: header.sourceArtifact,
430
+ measures: header.measures,
431
+ ...(header.calculationContext === undefined
432
+ ? {}
433
+ : { calculationContext: header.calculationContext }),
434
+ recordCount,
435
+ recordDigest,
436
+ values: calculatedValues,
437
+ };
438
+ const calculationIdentity = `fnv1a64-jcs-v1:${fnv1a64(canonicalJson(identityValue))}`;
439
+ if (trailer.recordCount !== recordCount || trailer.recordDigest !== recordDigest || trailer.calculationIdentity !== calculationIdentity || canonicalJson(trailer.values) !== canonicalJson(calculatedValues))
440
+ invalid("Bounded replay verification differs from its recorded trailer");
441
+ const receipt = snapshotDiagnosticJson({
442
+ contractVersion: BOUNDED_REPLAY_CONTRACT_VERSION,
443
+ runId: header.runId,
444
+ sourceArtifact: header.sourceArtifact,
445
+ ...(header.calculationContext === undefined
446
+ ? {}
447
+ : { calculationContext: header.calculationContext }),
448
+ recordCount,
449
+ recordDigest,
450
+ calculationIdentity,
451
+ values: calculatedValues,
452
+ });
453
+ verifiedBoundedReplayReceipts.add(receipt);
454
+ return receipt;
455
+ }
456
+ //# sourceMappingURL=customizationBoundedReplay.js.map
@@ -0,0 +1 @@
1
+ {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