@actuarial-ts/compliance 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 CHANGED
@@ -1,96 +1,60 @@
1
1
  # @actuarial-ts/compliance
2
2
 
3
- The compliance-support layer of the actuarial-ts SDK: the part no
4
- calculator ships. It turns an analysis into the documentation the
5
- Actuarial Standards of Practice ask for.
6
-
7
- - **Estimate metadata** (ASOP 43): intended purpose and measure, gross/net
8
- basis, LAE treatment, and the accounting / valuation / review dates — as
9
- typed, validated fields instead of tribal knowledge.
10
- - **Assumption ledger** (ASOPs 41/43/56): an immutable record of every
11
- selection, distinguishing machine defaults from human or agent judgment;
12
- judgment entries require a rationale.
13
- - **Disclosure generator** (ASOP 41): renders a methods-assumptions-and-data
14
- appendix from the analysis itself — written to the "another qualified
15
- actuary could appraise it" bar, deterministic to the byte.
16
- - **Model cards** (ASOP 56): intended use, specification, key assumptions,
17
- known weaknesses, and sensitivities for every method the SDK ships (a
18
- cross-package sync test enforces the completeness, so the registry can
19
- never silently fall behind core) — the
20
- "basic understanding" content an actuary relying on vendor models must
21
- hold and disclose.
22
- - **Reproducibility bundles** (ASOP 21 / 56): canonical serialization of
23
- inputs, parameters, and results with an integrity tag, so an analysis
24
- re-runs identically years later for an auditor or examiner.
25
- - **Diagnostics provenance composition**: `createDiagnosticsProvenance`
26
- snapshots formula-pack/metric versions, executable-definition metadata,
27
- layer configuration, exposure basis and scale, sparse/age conventions,
28
- cutoffs, caller-selected filters/groups, and caller-owned input IDs/hashes.
29
- - **Actual-vs-expected roll-forward**: expected emergence from the prior
30
- valuation's pattern versus actual, by origin.
31
-
32
- Everything here is pure, deterministic, and browser-safe: no clock reads,
33
- no randomness, no node builtins. Identical inputs produce byte-identical
34
- documents.
35
-
36
- ## Quickstart
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
+
5
+ ```bash
6
+ npm install @actuarial-ts/compliance@0.6.0 @actuarial-ts/core@0.6.0 @actuarial-ts/data@0.6.0 @actuarial-ts/interchange@0.6.0
7
+ ```
8
+
9
+ Node 20+, ESM.
10
+
11
+ ## Diagnostic provenance
12
+
13
+ `createDiagnosticRunIdentity` accepts only an owner-authenticated, completed data-package run. It does not accept caller-restated formulas, filters, review status, or result identities.
37
14
 
38
15
  ```ts
39
- import { runChainLadder, runMack } from "@actuarial-ts/core";
40
- import {
41
- createLedger,
42
- recordAssumption,
43
- generateDisclosure,
44
- } from "@actuarial-ts/compliance";
45
-
46
- let ledger = createLedger();
47
- ledger = recordAssumption(ledger, {
48
- timestamp: "2026-01-05T10:05:00Z",
49
- actor: "actuary",
50
- field: "paid.tailFactor",
51
- value: 1.02,
52
- rationale: "Exponential-decay fit valid with R^2 0.97; judgmentally confirmed",
53
- source: "fitted",
54
- });
16
+ import { createBundle, createDiagnosticRunIdentity } from "@actuarial-ts/compliance";
17
+
18
+ if (outcome.status !== "completed") throw new Error(`diagnostics blocked at ${outcome.stage}`);
55
19
 
56
- const cl = runChainLadder(paidTriangle, { selected, tailFactor: 1.02 });
57
- const mack = runMack(paidTriangle, { selected, tailFactor: 1.02 });
58
-
59
- const markdown = generateDisclosure({
60
- metadata: {
61
- intendedPurpose: "Estimate unpaid claims for year-end statutory reporting",
62
- intendedMeasure: { kind: "central-estimate" },
63
- basis: { grossNet: "gross", laeTreatment: "dcc-only" },
64
- accountingDate: "2025-12-31",
65
- valuationDate: "2025-12-31",
66
- },
67
- methods: [
68
- { methodId: "chainLadder", basisLabel: "paid", parameters: { selected, tailFactor: 1.02 }, resultSummary: { ultimate: cl.totals.ultimate, unpaid: cl.totals.unpaid } },
69
- { methodId: "mack", basisLabel: "paid", resultSummary: { standardError: mack.totals.standardError } },
20
+ const provenance = await createDiagnosticRunIdentity({
21
+ completedRun: outcome,
22
+ artifacts: [
23
+ { id: "loss-run", scope: "input", assurance: "sdk-computed", bytes: lossRunBytes },
24
+ { id: "exposures", scope: "input", assurance: "sdk-computed", bytes: exposureBytes },
25
+ { id: "source-archive", scope: "input", assurance: "caller-declared", algorithm: "sha-256", value: archiveSha256, byteLength: archiveByteLength },
26
+ { id: "transform-script", scope: "preparation", assurance: "caller-declared", algorithm: "git-sha", value: transformCommit, byteLength: 0 },
70
27
  ],
71
- ledger,
72
- sdkVersion: "0.4.0",
73
- generatedAt: "2026-01-05T10:15:00Z",
28
+ lineage: [
29
+ { artifactId: "loss-run", inputArtifactIds: ["source-archive", "transform-script"] },
30
+ ],
31
+ });
32
+
33
+ const bundle = createBundle({
34
+ inputs,
35
+ parameters,
36
+ results: outcome.result,
37
+ sdkVersions: { ...provenance.manifest.packageVersions },
38
+ createdAt: "2026-09-03T00:00:00Z",
39
+ diagnosticRuns: [provenance],
40
+ wrap: { triangles: [], selections: [], results: [] },
74
41
  });
75
42
  ```
76
43
 
77
- Diagnostic numeric results remain independent of this package. When an audit
78
- record is needed, call `createDiagnosticsProvenance({ metrics, layers, ... })`
79
- and place the returned plain record in `createBundle(...).parameters` or an
80
- interchange document's `extensions`. Executable warning callbacks are excluded
81
- from the record; their metric definition version is retained. Hashing,
82
- timestamps, persistence, and signatures remain caller-owned.
44
+ SDK-computed evidence requires actual `Uint8Array` bytes and records SHA-256 plus exact byte length. Caller-declared digests remain explicitly unverified. All evidence is synchronously validated and copied before hashing. Source, dataset fallback, external transformation, layer-comparability rationale, and fail-override references must resolve to the correct artifact scope. Lineage must have unique producers, resolve completely, be acyclic, and contain no orphan evidence.
45
+
46
+ The manifest contains the complete normalized definition, preparation identity and input audit, filter, cutoffs, expected-grid identity, grouping, review identity, two-gate execution policy, artifact graph, and core/data/compliance versions. The provenance adds the authentic complete result and separate run, result-content, and run-result binding fingerprints. Creation verifies preparation integrity, regenerates review and both gates, reruns core, and compares normalized output before stamping.
47
+
48
+ The returned `VerifiedDiagnosticRunProvenance` is frozen and registered in private owner state. A cast, clone, or parsed JSON object cannot author a new bundle. Use `verifyDiagnosticRunIdentity(stored, sameRunAndEvidence)` to regenerate and authenticate stored provenance; it reports the first mismatching JSON path and returns regenerated authentic review text rather than trusting stored prose.
49
+
50
+ Wrapped bundles include one deduplicated typed `diagnostic-definition` document per definition and require the outer SDK versions/generator to agree with every run manifest. FNV-1a/JCS tags are deterministic integrity aids, not cryptographic authentication.
51
+
52
+ Material host judgments worth recording in the assumption ledger include amount basis and limit application, expense treatment, missingness, exposure timing, period convention, filters/grouping, communicated scale, and any policy that permits a failed review. Helpers never invent an actuary’s rationale.
83
53
 
84
- ## The honest claim
54
+ 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.
85
55
 
86
- The ASB does not approve, certify, or endorse software, and no software can
87
- be "ASOP-compliant" on its own — compliance is a property of a credentialed
88
- actuary's work in context. This package is **designed to support the
89
- actuary's compliance** with ASOP Nos. 41, 43, 23, 56, 21, and 20 by generating
90
- the disclosures, documentation, and audit artifacts those standards call
91
- for. The generated documents are draft support material for the responsible
92
- actuary to review, edit, and adopt.
56
+ See the [formula catalog](https://github.com/yerromnitsuj/actng/blob/v0.6.0/docs/reference/diagnostic-formulas.md) and [migration guide](https://github.com/yerromnitsuj/actng/blob/v0.6.0/docs/migrations/0.6-generalized-diagnostics.md).
93
57
 
94
58
  ## License
95
59
 
96
- Apache-2.0. Copyright 2026 Justin Morrey.
60
+ Apache-2.0. See LICENSE and NOTICE.
package/dist/bundle.d.ts CHANGED
@@ -26,7 +26,10 @@
26
26
  * responsibility for compliance remains with the credentialed actuary.
27
27
  */
28
28
  import { canonicalJson, fnv1a64 } from "@actuarial-ts/core";
29
- import type { BundleDoc, MethodResultDoc, SelectionDoc, StochasticResultDoc, TriangleDoc } from "@actuarial-ts/interchange";
29
+ import { BundleDoc, MethodResultDoc, SelectionDoc, StochasticResultDoc, TriangleDoc } from "@actuarial-ts/interchange";
30
+ import type { VerifiedDiagnosticRunProvenance } from "./diagnosticRun.js";
31
+ export { ComplianceError, COMPLIANCE_ERROR_CODES, type ComplianceErrorCode } from "./errors.js";
32
+ export { COMPLIANCE_PACKAGE_VERSION } from "./version.js";
30
33
  export { canonicalJson, fnv1a64 };
31
34
  /**
32
35
  * The wrapped reproducibility bundle: the interchange BundleDoc (spec 3.2),
@@ -44,13 +47,6 @@ export type WrappedBundleDoc = BundleDoc;
44
47
  * of this package. Add the code here when introducing a new throw.
45
48
  * (UNSUPPORTED_VALUE moved to core's registry with canonicalJson in 0.2.0.)
46
49
  */
47
- export declare const COMPLIANCE_ERROR_CODES: readonly ["BAD_BUNDLE", "BAD_CDF", "MISSING_RATIONALE"];
48
- export type ComplianceErrorCode = (typeof COMPLIANCE_ERROR_CODES)[number];
49
- /** Thrown for invalid compliance input (bad bundles, judgment without rationale, non-positive CDFs). */
50
- export declare class ComplianceError extends Error {
51
- readonly code: ComplianceErrorCode;
52
- constructor(code: ComplianceErrorCode, message: string);
53
- }
54
50
  /**
55
51
  * The interchange version the wrapped form is written under. Kept in literal
56
52
  * sync with `@actuarial-ts/interchange`'s INTERCHANGE_SPEC_VERSION (the dep
@@ -58,14 +54,13 @@ export declare class ComplianceError extends Error {
58
54
  * test parses the emitted doc with the real interchange parser, which
59
55
  * refuses a wrong-major version — drift fails loudly.
60
56
  */
61
- export declare const WRAPPED_BUNDLE_INTERCHANGE_VERSION = "1.0.0";
57
+ export declare const WRAPPED_BUNDLE_INTERCHANGE_VERSION = "1.1.0";
62
58
  /**
63
59
  * This package's version, stamped into a wrapped bundle's `generator`
64
60
  * envelope field. A sync test asserts it matches package.json so it cannot
65
61
  * silently drift (mirroring interchange's INTERCHANGE_PACKAGE_VERSION
66
62
  * discipline).
67
63
  */
68
- export declare const COMPLIANCE_PACKAGE_VERSION = "0.4.0";
69
64
  /**
70
65
  * The interchange mirror for a wrapped bundle (spec 3.2): the triangles the
71
66
  * analysis consumed, the selections it applied, and the results it produced,
@@ -113,6 +108,8 @@ export interface CreateBundleInput {
113
108
  name: string;
114
109
  version: string;
115
110
  };
111
+ /** Authenticated diagnostic runs included in the canonical body and, when wrapped, as typed definition documents. */
112
+ diagnosticRuns?: readonly VerifiedDiagnosticRunProvenance[];
116
113
  }
117
114
  export interface ReproducibilityBundle {
118
115
  /** Canonical JSON of the full bundle body; the reproducibility record itself. */
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAC;AAEzC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,yDAIzB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,wGAAwG;AACxG,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;gBACvB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM;CAKvD;AAID;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC,UAAU,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,UAAU,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,WAAW,EAAE,CAAC;IACzB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,OAAO,EAAE,CAAC,eAAe,GAAG,mBAAmB,CAAC,EAAE,CAAC;CACpD;AAED,MAAM,WAAW,iBAAiB;IAChC,g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AAgB,EAChD,YAAY,EAAE,OAAO,GACpB,kBAAkB,CAEpB"}
package/dist/bundle.js CHANGED
@@ -26,26 +26,18 @@
26
26
  * responsibility for compliance remains with the credentialed actuary.
27
27
  */
28
28
  import { canonicalJson, fnv1a64 } from "@actuarial-ts/core";
29
+ import { INTERCHANGE_SPEC_VERSION, diagnosticDefinitionToDoc, } from "@actuarial-ts/interchange";
30
+ import { assertVerifiedDiagnosticRunProvenance, verifiedDefinitionForBundle } from "./diagnosticRun.js";
31
+ import { ComplianceError } from "./errors.js";
32
+ import { COMPLIANCE_PACKAGE_VERSION } from "./version.js";
33
+ export { ComplianceError, COMPLIANCE_ERROR_CODES } from "./errors.js";
34
+ export { COMPLIANCE_PACKAGE_VERSION } from "./version.js";
29
35
  export { canonicalJson, fnv1a64 };
30
36
  /**
31
37
  * Every machine-readable code a ComplianceError can carry, across all modules
32
38
  * of this package. Add the code here when introducing a new throw.
33
39
  * (UNSUPPORTED_VALUE moved to core's registry with canonicalJson in 0.2.0.)
34
40
  */
35
- export const COMPLIANCE_ERROR_CODES = [
36
- "BAD_BUNDLE",
37
- "BAD_CDF",
38
- "MISSING_RATIONALE",
39
- ];
40
- /** Thrown for invalid compliance input (bad bundles, judgment without rationale, non-positive CDFs). */
41
- export class ComplianceError extends Error {
42
- code;
43
- constructor(code, message) {
44
- super(message);
45
- this.name = "ComplianceError";
46
- this.code = code;
47
- }
48
- }
49
41
  /**
50
42
  * The interchange version the wrapped form is written under. Kept in literal
51
43
  * sync with `@actuarial-ts/interchange`'s INTERCHANGE_SPEC_VERSION (the dep
@@ -53,14 +45,7 @@ export class ComplianceError extends Error {
53
45
  * test parses the emitted doc with the real interchange parser, which
54
46
  * refuses a wrong-major version — drift fails loudly.
55
47
  */
56
- export const WRAPPED_BUNDLE_INTERCHANGE_VERSION = "1.0.0";
57
- /**
58
- * This package's version, stamped into a wrapped bundle's `generator`
59
- * envelope field. A sync test asserts it matches package.json so it cannot
60
- * silently drift (mirroring interchange's INTERCHANGE_PACKAGE_VERSION
61
- * discipline).
62
- */
63
- export const COMPLIANCE_PACKAGE_VERSION = "0.4.0";
48
+ export const WRAPPED_BUNDLE_INTERCHANGE_VERSION = INTERCHANGE_SPEC_VERSION;
64
49
  export function createBundle(input) {
65
50
  const body = {
66
51
  createdAt: input.createdAt,
@@ -71,6 +56,23 @@ export function createBundle(input) {
71
56
  };
72
57
  if (input.seeds !== undefined)
73
58
  body["seeds"] = input.seeds;
59
+ if (input.diagnosticRuns !== undefined) {
60
+ for (const run of input.diagnosticRuns)
61
+ assertVerifiedDiagnosticRunProvenance(run);
62
+ if (input.diagnosticRuns.length > 0) {
63
+ const expected = input.diagnosticRuns[0].manifest.packageVersions;
64
+ for (const [runIndex, run] of input.diagnosticRuns.entries()) {
65
+ if (canonicalJson(run.manifest.packageVersions) !== canonicalJson(expected))
66
+ throw new ComplianceError("BAD_DIAGNOSTIC_RUN", "Diagnostic runs disagree on SDK package versions", `$.diagnosticRuns[${runIndex}].manifest.packageVersions`);
67
+ }
68
+ for (const [name, version] of Object.entries(expected))
69
+ if (input.sdkVersions[name] !== version)
70
+ throw new ComplianceError("BAD_DIAGNOSTIC_RUN", `Outer sdkVersions must record ${name} at ${version}`, `$.sdkVersions.${name}`);
71
+ if (input.wrap !== undefined && input.generator !== undefined && (input.generator.name !== "@actuarial-ts/compliance" || input.generator.version !== COMPLIANCE_PACKAGE_VERSION))
72
+ throw new ComplianceError("BAD_DIAGNOSTIC_RUN", "Wrapped diagnostic bundles require the actual compliance generator stamp", "$.generator");
73
+ }
74
+ body["diagnosticRuns"] = input.diagnosticRuns;
75
+ }
74
76
  const payload = canonicalJson(body);
75
77
  const inner = { payload, hash: fnv1a64(payload) };
76
78
  if (input.wrap === undefined)
@@ -79,10 +81,19 @@ export function createBundle(input) {
79
81
  // tag is fnv1a64(canonicalJson({ bundle, interchange })) — exactly
80
82
  // interchange's semanticBodyOf for kind "bundle" (spec 3.2).
81
83
  const bundleSegment = { hash: inner.hash, payload: inner.payload };
84
+ const definitions = new Map();
85
+ for (const run of input.diagnosticRuns ?? []) {
86
+ const compiled = verifiedDefinitionForBundle(run);
87
+ definitions.set(run.definitionIdentities.definition, diagnosticDefinitionToDoc(compiled, {
88
+ createdAt: input.createdAt,
89
+ generator: { name: "@actuarial-ts/compliance", version: COMPLIANCE_PACKAGE_VERSION },
90
+ }));
91
+ }
82
92
  const interchange = {
83
93
  triangles: [...input.wrap.triangles],
84
94
  selections: [...input.wrap.selections],
85
95
  results: [...input.wrap.results],
96
+ ...(definitions.size === 0 ? {} : { diagnosticDefinitions: [...definitions.values()].sort((a, b) => a.diagnosticDefinition.identities.definition < b.diagnosticDefinition.identities.definition ? -1 : 1) }),
86
97
  };
87
98
  const wrapped = {
88
99
  interchangeVersion: WRAPPED_BUNDLE_INTERCHANGE_VERSION,
@@ -1 +1 @@
1
- {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAS5D,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC;AAclC;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,YAAY;IACZ,SAAS;IACT,mBAAmB;CACX,CAAC;AAIX,wGAAwG;AACxG,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAC/B,IAAI,CAAsB;IACnC,YAAY,IAAyB,EAAE,OAAe;QACpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAID;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAAG,OAAO,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,OAAO,CAAC;AA8ElD,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sonValue, type NormalizedDiagnosticDefinitionIdentity, type NormalizedDiagnosticPreparationIdentity, type NormalizedDiagnosticResultIdentity } from "@actuarial-ts/core";
2
+ import { type CompletedValidatedMetricDiagnosticsRun, type DiagnosticReviewIdentityBody, type DiagnosticReviewReceipt } from "@actuarial-ts/data";
3
+ export interface DiagnosticArtifactDigestBase {
4
+ readonly id: string;
5
+ readonly scope: "input" | "preparation";
6
+ readonly algorithm: string;
7
+ readonly value: string;
8
+ readonly byteLength: number;
9
+ }
10
+ export type DiagnosticArtifactDigest = DiagnosticArtifactDigestBase & {
11
+ readonly assurance: "sdk-computed" | "caller-declared";
12
+ };
13
+ export type DiagnosticArtifactEvidence = {
14
+ readonly id: string;
15
+ readonly scope: "input" | "preparation";
16
+ readonly assurance: "sdk-computed";
17
+ readonly bytes: Uint8Array;
18
+ } | {
19
+ readonly id: string;
20
+ readonly scope: "input" | "preparation";
21
+ readonly assurance: "caller-declared";
22
+ readonly algorithm: string;
23
+ readonly value: string;
24
+ readonly byteLength: number;
25
+ };
26
+ export interface DiagnosticPreparationLineage {
27
+ readonly artifactId: string;
28
+ readonly inputArtifactIds: readonly string[];
29
+ }
30
+ export interface DiagnosticRunManifest {
31
+ readonly definitionIntegrity: string;
32
+ readonly runPresetId: string | null;
33
+ readonly datasetArtifactId: string | null;
34
+ readonly packageVersions: Readonly<Record<string, string>>;
35
+ readonly preparation: DiagnosticDeepReadonly<NormalizedDiagnosticPreparationIdentity>;
36
+ readonly preparationFingerprint: string;
37
+ readonly expectedGridFingerprint: string | null;
38
+ readonly executionPolicy: {
39
+ readonly review: {
40
+ readonly body: DiagnosticReviewIdentityBody;
41
+ readonly reportFingerprint: string;
42
+ };
43
+ readonly gate: CompletedValidatedMetricDiagnosticsRun["gate"];
44
+ };
45
+ readonly groupMap: Readonly<Record<string, string>>;
46
+ readonly groupDimensions: Readonly<Record<string, CoreDiagnosticJsonValue>>;
47
+ readonly artifacts: readonly DiagnosticArtifactDigest[];
48
+ readonly lineage: readonly DiagnosticPreparationLineage[];
49
+ }
50
+ export type NormalizedDiagnosticRunManifestIdentity = DiagnosticDeepReadonly<DiagnosticRunManifest>;
51
+ export interface DiagnosticRunIdentity {
52
+ readonly runFingerprint: string;
53
+ readonly resultFingerprint: string;
54
+ readonly runResultFingerprint: string;
55
+ }
56
+ export interface DiagnosticRunProvenance extends DiagnosticRunIdentity {
57
+ readonly definition: DiagnosticDeepReadonly<NormalizedDiagnosticDefinitionIdentity>;
58
+ readonly definitionIdentities: {
59
+ readonly algorithm: "fnv1a64-jcs-v1";
60
+ readonly formulaById: Readonly<Record<string, string>>;
61
+ readonly calculationByInstanceId: Readonly<Record<string, string>>;
62
+ readonly definition: string;
63
+ };
64
+ readonly manifest: NormalizedDiagnosticRunManifestIdentity;
65
+ readonly review: DiagnosticReviewReceipt;
66
+ readonly result: DiagnosticDeepReadonly<NormalizedDiagnosticResultIdentity>;
67
+ }
68
+ declare const verifiedDiagnosticRunProvenanceBrand: unique symbol;
69
+ export interface VerifiedDiagnosticRunProvenance extends DiagnosticRunProvenance {
70
+ readonly [verifiedDiagnosticRunProvenanceBrand]: true;
71
+ }
72
+ export interface CreateDiagnosticRunIdentityInput {
73
+ readonly completedRun: CompletedValidatedMetricDiagnosticsRun;
74
+ readonly artifacts?: readonly DiagnosticArtifactEvidence[];
75
+ readonly lineage?: readonly DiagnosticPreparationLineage[];
76
+ }
77
+ export declare function createDiagnosticRunIdentity(input: CreateDiagnosticRunIdentityInput): Promise<VerifiedDiagnosticRunProvenance>;
78
+ export declare function assertVerifiedDiagnosticRunProvenance(value: unknown): asserts value is VerifiedDiagnosticRunProvenance;
79
+ /** @internal Bundle authoring uses owner state rather than trusting the public snapshot. */
80
+ export declare function verifiedDefinitionForBundle(value: VerifiedDiagnosticRunProvenance): CompiledDiagnosticDefinition;
81
+ export declare function verifyDiagnosticRunIdentity(candidate: unknown, input: CreateDiagnosticRunIdentityInput): Promise<VerifiedDiagnosticRunProvenance>;
82
+ export {};
83
+ //# s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