@actuarial-ts/compliance 0.5.0 → 0.6.1

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.
@@ -0,0 +1,106 @@
1
+ import { type DiagnosticDeepReadonly, type CompiledDiagnosticDefinition, type JsonValue as CoreDiagnosticJsonValue, type NormalizedDiagnosticDefinitionIdentity, type NormalizedDiagnosticPreparationIdentity, type MetricDiagnosticsResult } 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 value: string;
6
+ readonly scope: "input" | "preparation";
7
+ }
8
+ export type DiagnosticArtifactDigest = DiagnosticArtifactDigestBase & ({
9
+ readonly assurance: "sdk-computed";
10
+ readonly algorithm: "sha256";
11
+ readonly byteLength: number;
12
+ } | {
13
+ readonly assurance: "caller-declared";
14
+ readonly algorithm: string;
15
+ });
16
+ export type DiagnosticArtifactEvidence = {
17
+ readonly id: string;
18
+ readonly scope: "input" | "preparation";
19
+ readonly assurance: "sdk-computed";
20
+ readonly bytes: Uint8Array;
21
+ } | {
22
+ readonly id: string;
23
+ readonly scope: "input" | "preparation";
24
+ readonly assurance: "caller-declared";
25
+ readonly algorithm: string;
26
+ readonly value: string;
27
+ };
28
+ export interface DiagnosticPreparationLineage {
29
+ readonly outputArtifactId: string;
30
+ readonly inputArtifactIds: readonly string[];
31
+ readonly transformationArtifactIds: readonly string[];
32
+ }
33
+ export interface DiagnosticRunManifest {
34
+ readonly definitionIntegrity: string;
35
+ readonly runPresetId: string | null;
36
+ readonly datasetArtifactId: string | null;
37
+ readonly preparationFingerprint: string;
38
+ readonly inputArtifacts: readonly DiagnosticArtifactDigest[];
39
+ readonly preparationArtifacts: readonly DiagnosticArtifactDigest[];
40
+ readonly preparationLineage: readonly DiagnosticPreparationLineage[];
41
+ readonly inputAudit: DiagnosticDeepReadonly<NormalizedDiagnosticPreparationIdentity["inputAudit"]>;
42
+ readonly filter: DiagnosticDeepReadonly<NormalizedDiagnosticPreparationIdentity["filter"]>;
43
+ readonly groupMap: Readonly<Record<string, string>>;
44
+ readonly groupDimensions: Readonly<Record<string, CoreDiagnosticJsonValue>>;
45
+ readonly completePeriodCutoffs: DiagnosticDeepReadonly<NormalizedDiagnosticPreparationIdentity["completePeriodCutoffs"]>;
46
+ readonly expectedCellGridFingerprint: string | null;
47
+ readonly executionPolicy: {
48
+ readonly review: DiagnosticReviewReceipt;
49
+ readonly gate: CompletedValidatedMetricDiagnosticsRun["gate"];
50
+ };
51
+ readonly engine: {
52
+ readonly packages: {
53
+ readonly core: string;
54
+ readonly data: string;
55
+ readonly compliance: string;
56
+ };
57
+ readonly algorithmVersion: "diagnostics-1";
58
+ };
59
+ }
60
+ export type NormalizedDiagnosticRunManifestIdentity = DiagnosticDeepReadonly<Omit<DiagnosticRunManifest, "executionPolicy"> & {
61
+ readonly executionPolicy: {
62
+ readonly review: {
63
+ readonly body: DiagnosticReviewIdentityBody;
64
+ readonly reportFingerprint: string;
65
+ };
66
+ readonly gate: DiagnosticRunManifest["executionPolicy"]["gate"];
67
+ };
68
+ }>;
69
+ export interface DiagnosticRunIdentity {
70
+ readonly runFingerprint: string;
71
+ readonly resultFingerprint: string;
72
+ readonly runResultFingerprint: string;
73
+ }
74
+ export interface DiagnosticRunProvenance extends DiagnosticRunIdentity {
75
+ readonly definition: {
76
+ readonly definition: DiagnosticDeepReadonly<NormalizedDiagnosticDefinitionIdentity>;
77
+ readonly identities: {
78
+ readonly algorithm: "fnv1a64-jcs-v1";
79
+ readonly formulaById: Readonly<Record<string, string>>;
80
+ readonly calculationByInstanceId: Readonly<Record<string, string>>;
81
+ readonly definition: string;
82
+ };
83
+ };
84
+ readonly manifest: DiagnosticDeepReadonly<DiagnosticRunManifest>;
85
+ readonly review: DiagnosticReviewReceipt;
86
+ readonly result: DiagnosticDeepReadonly<MetricDiagnosticsResult>;
87
+ }
88
+ declare const verifiedDiagnosticRunProvenanceBrand: unique symbol;
89
+ export interface VerifiedDiagnosticRunProvenance extends DiagnosticRunProvenance {
90
+ readonly [verifiedDiagnosticRunProvenanceBrand]: true;
91
+ }
92
+ export interface CreateDiagnosticRunIdentityInput {
93
+ readonly completedRun: CompletedValidatedMetricDiagnosticsRun;
94
+ readonly inputArtifacts: readonly DiagnosticArtifactEvidence[];
95
+ readonly preparationArtifacts: readonly DiagnosticArtifactEvidence[];
96
+ readonly preparationLineage: readonly DiagnosticPreparationLineage[];
97
+ }
98
+ export declare function createDiagnosticRunIdentity(input: CreateDiagnosticRunIdentityInput): Promise<VerifiedDiagnosticRunProvenance>;
99
+ export declare function assertVerifiedDiagnosticRunProvenance(value: unknown): asserts value is VerifiedDiagnosticRunProvenance;
100
+ /** Verify serialized evidence by replaying the owning core/data public workflows. */
101
+ export declare function serializedDiagnosticRunMismatch(value: unknown, path?: string): string | null;
102
+ /** @internal Bundle authoring uses owner state rather than trusting the public snapshot. */
103
+ export declare function verifiedDefinitionForBundle(value: VerifiedDiagnosticRunProvenance): CompiledDiagnosticDefinition;
104
+ export declare function verifyDiagnosticRunIdentity(candidate: unknown, input: CreateDiagnosticRunIdentityInput): Promise<VerifiedDiagnosticRunProvenance>;
105
+ export {};
106
+ //# sourceMappingURL=diagnosticRun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnosticRun.d.ts","sourceRoot":"","sources":["../src/diagnosticRun.ts"],"names":[],"mappings":"AAAA,OAAO,EAUL,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EAEjC,KAAK,SAAS,IAAI,uBAAuB,EACzC,KAAK,sCAAsC,EAC3C,KAAK,uCAAuC,EAE5C,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAML,KAAK,sCAAsC,EAC3C,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAI5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