@actuarial-ts/core 0.7.0 → 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.
Files changed (115) hide show
  1. package/README.md +46 -2
  2. package/dist/analysisRecipe.d.ts +55 -0
  3. package/dist/analysisRecipe.d.ts.map +1 -0
  4. package/dist/analysisRecipe.js +627 -0
  5. package/dist/analysisRecipe.js.map +1 -0
  6. package/dist/classifications.d.ts +30 -0
  7. package/dist/classifications.d.ts.map +1 -0
  8. package/dist/classifications.js +207 -0
  9. package/dist/classifications.js.map +1 -0
  10. package/dist/customizationContracts.d.ts +749 -0
  11. package/dist/customizationContracts.d.ts.map +1 -0
  12. package/dist/customizationContracts.js +19 -0
  13. package/dist/customizationContracts.js.map +1 -0
  14. package/dist/descriptiveStatistics.d.ts +8 -0
  15. package/dist/descriptiveStatistics.d.ts.map +1 -0
  16. package/dist/descriptiveStatistics.js +283 -0
  17. package/dist/descriptiveStatistics.js.map +1 -0
  18. package/dist/diagnosticAggregation.d.ts.map +1 -1
  19. package/dist/diagnosticAggregation.js +16 -0
  20. package/dist/diagnosticAggregation.js.map +1 -1
  21. package/dist/diagnosticFreeze.d.ts +4 -0
  22. package/dist/diagnosticFreeze.d.ts.map +1 -0
  23. package/dist/diagnosticFreeze.js +37 -0
  24. package/dist/diagnosticFreeze.js.map +1 -0
  25. package/dist/diagnosticIdentityStream.d.ts +4 -0
  26. package/dist/diagnosticIdentityStream.d.ts.map +1 -1
  27. package/dist/diagnosticIdentityStream.js +32 -2
  28. package/dist/diagnosticIdentityStream.js.map +1 -1
  29. package/dist/diagnosticPreparation.d.ts +21 -0
  30. package/dist/diagnosticPreparation.d.ts.map +1 -1
  31. package/dist/diagnosticPreparation.js +231 -19
  32. package/dist/diagnosticPreparation.js.map +1 -1
  33. package/dist/diagnosticReview.d.ts.map +1 -1
  34. package/dist/diagnosticReview.js +43 -25
  35. package/dist/diagnosticReview.js.map +1 -1
  36. package/dist/diagnosticReviewSources.d.ts.map +1 -1
  37. package/dist/diagnosticReviewSources.js +25 -4
  38. package/dist/diagnosticReviewSources.js.map +1 -1
  39. package/dist/diagnosticReviewStore.d.ts +2 -0
  40. package/dist/diagnosticReviewStore.d.ts.map +1 -1
  41. package/dist/diagnosticReviewStore.js +110 -36
  42. package/dist/diagnosticReviewStore.js.map +1 -1
  43. package/dist/diagnosticRunner.d.ts.map +1 -1
  44. package/dist/diagnosticRunner.js +1 -8
  45. package/dist/diagnosticRunner.js.map +1 -1
  46. package/dist/exposureEarning.d.ts +12 -0
  47. package/dist/exposureEarning.d.ts.map +1 -0
  48. package/dist/exposureEarning.js +276 -0
  49. package/dist/exposureEarning.js.map +1 -0
  50. package/dist/exposureMovements.d.ts +8 -0
  51. package/dist/exposureMovements.d.ts.map +1 -0
  52. package/dist/exposureMovements.js +70 -0
  53. package/dist/exposureMovements.js.map +1 -0
  54. package/dist/exposureRevisions.d.ts +13 -0
  55. package/dist/exposureRevisions.d.ts.map +1 -0
  56. package/dist/exposureRevisions.js +161 -0
  57. package/dist/exposureRevisions.js.map +1 -0
  58. package/dist/financialPipeline.d.ts +14 -0
  59. package/dist/financialPipeline.d.ts.map +1 -0
  60. package/dist/financialPipeline.js +75 -0
  61. package/dist/financialPipeline.js.map +1 -0
  62. package/dist/financialTerms.d.ts +20 -0
  63. package/dist/financialTerms.d.ts.map +1 -0
  64. package/dist/financialTerms.js +205 -0
  65. package/dist/financialTerms.js.map +1 -0
  66. package/dist/fnvAccumulator.d.ts.map +1 -1
  67. package/dist/fnvAccumulator.js +11 -5
  68. package/dist/fnvAccumulator.js.map +1 -1
  69. package/dist/historyPreparation.d.ts +8 -0
  70. package/dist/historyPreparation.d.ts.map +1 -0
  71. package/dist/historyPreparation.js +557 -0
  72. package/dist/historyPreparation.js.map +1 -0
  73. package/dist/index.d.ts +15 -2
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +15 -2
  76. package/dist/index.js.map +1 -1
  77. package/dist/policyPeriods.d.ts +29 -0
  78. package/dist/policyPeriods.d.ts.map +1 -0
  79. package/dist/policyPeriods.js +322 -0
  80. package/dist/policyPeriods.js.map +1 -0
  81. package/dist/populations.d.ts +11 -0
  82. package/dist/populations.d.ts.map +1 -0
  83. package/dist/populations.js +264 -0
  84. package/dist/populations.js.map +1 -0
  85. package/dist/reservingAdapter.d.ts +16 -0
  86. package/dist/reservingAdapter.d.ts.map +1 -0
  87. package/dist/reservingAdapter.js +74 -0
  88. package/dist/reservingAdapter.js.map +1 -0
  89. package/dist/version.d.ts +1 -1
  90. package/dist/version.js +1 -1
  91. package/package.json +2 -2
  92. package/src/analysisRecipe.ts +696 -0
  93. package/src/classifications.ts +231 -0
  94. package/src/customizationContracts.ts +763 -0
  95. package/src/descriptiveStatistics.ts +320 -0
  96. package/src/diagnosticAggregation.ts +16 -0
  97. package/src/diagnosticFreeze.ts +37 -0
  98. package/src/diagnosticIdentityStream.ts +37 -2
  99. package/src/diagnosticPreparation.ts +259 -26
  100. package/src/diagnosticReview.ts +49 -27
  101. package/src/diagnosticReviewSources.ts +22 -3
  102. package/src/diagnosticReviewStore.ts +139 -54
  103. package/src/diagnosticRunner.ts +1 -11
  104. package/src/exposureEarning.ts +314 -0
  105. package/src/exposureMovements.ts +78 -0
  106. package/src/exposureRevisions.ts +186 -0
  107. package/src/financialPipeline.ts +93 -0
  108. package/src/financialTerms.ts +263 -0
  109. package/src/fnvAccumulator.ts +11 -5
  110. package/src/historyPreparation.ts +645 -0
  111. package/src/index.ts +28 -1
  112. package/src/policyPeriods.ts +375 -0
  113. package/src/populations.ts +307 -0
  114. package/src/reservingAdapter.ts +98 -0
  115. package/src/version.ts +1 -1
package/README.md CHANGED
@@ -4,10 +4,15 @@ Pure, framework-free P&C actuarial math for TypeScript. It includes triangles, d
4
4
 
5
5
  The package is designed to support the actuary's compliance with the ASOPs; it does not make a work product compliant and is not “ASOP-approved.” The credentialed actuary remains responsible for data, assumptions, selections, review, and communication.
6
6
 
7
+ SDK 0.8 adds versioned loss history, irregular period and exposure contracts,
8
+ population statistics, shared financial terms, and deterministic recipe and
9
+ scenario execution. See the [0.8 adoption guide](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/migrations/0.8-reusable-customization.md)
10
+ and [customization reference](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/reference/reusable-customization.md).
11
+
7
12
  ## Install
8
13
 
9
14
  ```bash
10
- npm install @actuarial-ts/core@0.7.0
15
+ npm install @actuarial-ts/core@0.8.0
11
16
  ```
12
17
 
13
18
  ESM, TypeScript-first, zero runtime dependencies, Node 20+.
@@ -73,6 +78,45 @@ const prepared = prepareDiagnosticData({ definition: compiled, losses, exposures
73
78
  const result = runMetricDiagnostics({ prepared, groupMap: { fleet: "all-fleet" } });
74
79
  ```
75
80
 
81
+ ### Eager and compact paths
82
+
83
+ The example above uses the retained eager APIs. The additive compact APIs,
84
+ introduced in 0.7.0, expose the same numeric views while retaining complete audit
85
+ and identity evidence behind authenticated owners instead of eagerly expanding
86
+ it. Choose matching preparation, calculation, and maturity functions:
87
+
88
+ | Operation | Eager | Compact |
89
+ |---|---|---|
90
+ | Prepare inputs | `prepareDiagnosticData` | `prepareDiagnosticDataCompact` |
91
+ | Calculate metric views | `runMetricDiagnostics` | `runMetricDiagnosticsCompact` |
92
+ | Select one development age | `sameMaturity` | `sameMaturityCompact` |
93
+ | Select the latest common age across output groups | `commonMaturity` | `commonMaturityCompact` |
94
+
95
+ The original maturity signatures remain unchanged; compact results use the
96
+ separately named helpers, not casts to eager results. Development ages use the
97
+ result's declared age unit. Review evaluations are available through
98
+ `pageDiagnosticReviewEvaluations`, with source references separately available
99
+ through `pageDiagnosticReviewEvaluationSources`. Passing and not-evaluated
100
+ evaluations remain available; paging is not sampling.
101
+
102
+ Use owner-controlled identity documents and `iterateDiagnosticIdentityJson`
103
+ when complete canonical text is needed. `materializePreparedDiagnosticData` and
104
+ `materializeMetricDiagnosticsResult` intentionally expand the eager evidence;
105
+ they are explicit compatibility choices, not a memory-saving export path.
106
+ Cloning or parsing an owner does not recreate its authority. Compact storage is
107
+ not a dataset-capacity or bounded-memory guarantee for an entire application.
108
+
109
+ SDK 0.8 adds authenticated compact selection helpers for metric, source-group,
110
+ whole-origin, and valuation/age scopes. Eligible clean aggregate preparations
111
+ share immutable cells while preserving the same fresh preparation and result
112
+ identities; an ineligible scope returns `undefined` so the data gateway can use
113
+ ordinary preparation. These functions do not issue review or execution receipts.
114
+
115
+ These are lower-level calculation APIs. For a host import or analysis boundary
116
+ that enforces both review and metric execution policy, use the validated gateway
117
+ in `@actuarial-ts/data`. The runnable [compact adoption guide](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/migrations/0.7-compact-diagnostics.md)
118
+ covers the complete workflow and [streamed replay](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/reference/diagnostic-replay-stream.md).
119
+
76
120
  The six built-in formulas are basis-independent. The factory creates ten count instances plus six per amount basis (`10 + 6 × basisCount`): one basis produces 16, two produce 22. A `$250K`, primary, gross, net, or ceded calculation is represented by caller-declared amount measures and a structured `AmountBasisDefinition`; it does not need a separate capped formula. Claim-level caps use `claim-layer` derivations before aggregation. Pre-limited external values record their source/transformation instead of implying the SDK recreated an unavailable claim-level operation.
77
121
 
78
122
  All metrics are ratio-of-sums: measures are aggregated at source-group/origin/valuation, groups are mapped and merged, then division happens once. Measure-local `missing: "unknown" | "zero"` is explicit. Exposure timing is either `origin-static` or `valuation-specific`. Calendar and ordered axes derive normalized origins, valuations, development ages, and units; input rows cannot assert a trusted age.
@@ -88,7 +132,7 @@ numeric exposure values. This is a bounded capacity, not an unlimited scale clai
88
132
 
89
133
  Compilation validates the whole graph atomically: IDs, sources, role types, compatibility groups, development semantics, derivation acyclicity, expression limits, rule operands, basis/population references, and period coordinates. Authentic compiled/prepared objects are owner-branded and frozen. Formula, calculation, definition, preparation, and result identities are deterministic FNV-1a/JCS integrity aids—not cryptographic signatures.
90
134
 
91
- See the generated [formula and instance catalog](https://github.com/yerromnitsuj/actng/blob/v0.7.0/docs/reference/diagnostic-formulas.md) and [0.6 migration guide](https://github.com/yerromnitsuj/actng/blob/v0.7.0/docs/migrations/0.6-generalized-diagnostics.md).
135
+ See the generated [formula and instance catalog](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/reference/diagnostic-formulas.md) and [0.6 migration guide](https://github.com/yerromnitsuj/actng/blob/v0.8.0/docs/migrations/0.6-generalized-diagnostics.md).
92
136
 
93
137
  ## Main method families
94
138
 
@@ -0,0 +1,55 @@
1
+ import type { AnalysisDefinition, AnalysisRecipe, AnalysisResult, AnalysisScenario, AnalysisScenarioGrid, AnalysisScenarioDifference, AnalysisScenarioRun, AnalysisRollForward, AnalysisScenarioBridgeStep, AnalysisResultCache, CustomizationResourceLimits, CustomizationExposureObservation, ExposureAllocationTarget, ExposureRevisionSelection, HistoricalDatasetInput } from "./customizationContracts.js";
2
+ /** Executes the closed, deterministic recipe vocabulary over loss history and exposure inputs. */
3
+ export declare function runAnalysisRecipe(input: {
4
+ readonly history: HistoricalDatasetInput;
5
+ readonly definition: AnalysisDefinition;
6
+ readonly recipe: AnalysisRecipe;
7
+ readonly exposureObservations?: readonly CustomizationExposureObservation[];
8
+ readonly exposureTargets?: readonly ExposureAllocationTarget[];
9
+ readonly exposureRevisionSelection?: ExposureRevisionSelection;
10
+ readonly evaluationDate?: string;
11
+ }): AnalysisResult;
12
+ export declare function applyAnalysisScenario(definition: AnalysisDefinition, scenario: AnalysisScenario): AnalysisDefinition;
13
+ export declare function compareAnalysisResults(baseline: AnalysisResult, scenario: AnalysisResult): readonly AnalysisScenarioDifference[];
14
+ /** Runs a bounded list of controlled scenarios against one immutable baseline. */
15
+ export declare function runAnalysisScenarios(input: {
16
+ readonly history: HistoricalDatasetInput;
17
+ readonly definition: AnalysisDefinition;
18
+ readonly recipe: AnalysisRecipe;
19
+ readonly scenarios: readonly AnalysisScenario[];
20
+ readonly limits: Pick<CustomizationResourceLimits, "maximumActiveScenarios">;
21
+ readonly exposureObservations?: readonly CustomizationExposureObservation[];
22
+ readonly exposureTargets?: readonly ExposureAllocationTarget[];
23
+ readonly exposureRevisionSelection?: ExposureRevisionSelection;
24
+ readonly evaluationDate?: string;
25
+ }): readonly AnalysisScenarioRun[];
26
+ /** Expands a closed Cartesian parameter grid after proving its product is bounded. */
27
+ export declare function expandAnalysisScenarioGrid(grid: AnalysisScenarioGrid, limits: Pick<CustomizationResourceLimits, "maximumActiveScenarios">): readonly AnalysisScenario[];
28
+ /** Expands and runs a bounded parameter grid against one immutable baseline. */
29
+ export declare function runAnalysisScenarioGrid(input: Omit<Parameters<typeof runAnalysisScenarios>[0], "scenarios"> & {
30
+ readonly grid: AnalysisScenarioGrid;
31
+ }): readonly AnalysisScenarioRun[];
32
+ /** Complete dependency identity for exact full-result reuse, including lineage. */
33
+ export declare function analysisRecipeDependencyIdentity(input: Parameters<typeof runAnalysisRecipe>[0]): string;
34
+ /** Uses caller-owned cache storage; a hit is returned only for the complete dependency identity. */
35
+ export declare function runAnalysisRecipeCached(input: Parameters<typeof runAnalysisRecipe>[0] & {
36
+ readonly cache: AnalysisResultCache;
37
+ }): {
38
+ readonly cacheStatus: "hit" | "miss";
39
+ readonly dependencyIdentity: string;
40
+ readonly result: AnalysisResult;
41
+ };
42
+ /** Preserves the prior result and recipe while executing a later immutable valuation. */
43
+ export declare function rollForwardAnalysisRecipe(input: Parameters<typeof runAnalysisRecipe>[0] & {
44
+ readonly priorEvaluationDate: string;
45
+ readonly currentEvaluationDate: string;
46
+ }): AnalysisRollForward;
47
+ /** Applies explicitly ordered, one-change scenario steps and reports each incremental bridge. */
48
+ export declare function runAnalysisScenarioBridge(input: Parameters<typeof runAnalysisRecipe>[0] & {
49
+ readonly scenarios: readonly AnalysisScenario[];
50
+ readonly limits: Pick<CustomizationResourceLimits, "maximumActiveScenarios">;
51
+ }): {
52
+ readonly baseline: AnalysisResult;
53
+ readonly steps: readonly AnalysisScenarioBridgeStep[];
54
+ };
55
+ //# sourceMappingURL=anal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