@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.
- package/README.md +46 -2
- package/dist/analysisRecipe.d.ts +55 -0
- package/dist/analysisRecipe.d.ts.map +1 -0
- package/dist/analysisRecipe.js +627 -0
- package/dist/analysisRecipe.js.map +1 -0
- package/dist/classifications.d.ts +30 -0
- package/dist/classifications.d.ts.map +1 -0
- package/dist/classifications.js +207 -0
- package/dist/classifications.js.map +1 -0
- package/dist/customizationContracts.d.ts +749 -0
- package/dist/customizationContracts.d.ts.map +1 -0
- package/dist/customizationContracts.js +19 -0
- package/dist/customizationContracts.js.map +1 -0
- package/dist/descriptiveStatistics.d.ts +8 -0
- package/dist/descriptiveStatistics.d.ts.map +1 -0
- package/dist/descriptiveStatistics.js +283 -0
- package/dist/descriptiveStatistics.js.map +1 -0
- package/dist/diagnosticAggregation.d.ts.map +1 -1
- package/dist/diagnosticAggregation.js +16 -0
- package/dist/diagnosticAggregation.js.map +1 -1
- package/dist/diagnosticFreeze.d.ts +4 -0
- package/dist/diagnosticFreeze.d.ts.map +1 -0
- package/dist/diagnosticFreeze.js +37 -0
- package/dist/diagnosticFreeze.js.map +1 -0
- package/dist/diagnosticIdentityStream.d.ts +4 -0
- package/dist/diagnosticIdentityStream.d.ts.map +1 -1
- package/dist/diagnosticIdentityStream.js +32 -2
- package/dist/diagnosticIdentityStream.js.map +1 -1
- package/dist/diagnosticPreparation.d.ts +21 -0
- package/dist/diagnosticPreparation.d.ts.map +1 -1
- package/dist/diagnosticPreparation.js +231 -19
- package/dist/diagnosticPreparation.js.map +1 -1
- package/dist/diagnosticReview.d.ts.map +1 -1
- package/dist/diagnosticReview.js +43 -25
- package/dist/diagnosticReview.js.map +1 -1
- package/dist/diagnosticReviewSources.d.ts.map +1 -1
- package/dist/diagnosticReviewSources.js +25 -4
- package/dist/diagnosticReviewSources.js.map +1 -1
- package/dist/diagnosticReviewStore.d.ts +2 -0
- package/dist/diagnosticReviewStore.d.ts.map +1 -1
- package/dist/diagnosticReviewStore.js +110 -36
- package/dist/diagnosticReviewStore.js.map +1 -1
- package/dist/diagnosticRunner.d.ts.map +1 -1
- package/dist/diagnosticRunner.js +1 -8
- package/dist/diagnosticRunner.js.map +1 -1
- package/dist/exposureEarning.d.ts +12 -0
- package/dist/exposureEarning.d.ts.map +1 -0
- package/dist/exposureEarning.js +276 -0
- package/dist/exposureEarning.js.map +1 -0
- package/dist/exposureMovements.d.ts +8 -0
- package/dist/exposureMovements.d.ts.map +1 -0
- package/dist/exposureMovements.js +70 -0
- package/dist/exposureMovements.js.map +1 -0
- package/dist/exposureRevisions.d.ts +13 -0
- package/dist/exposureRevisions.d.ts.map +1 -0
- package/dist/exposureRevisions.js +161 -0
- package/dist/exposureRevisions.js.map +1 -0
- package/dist/financialPipeline.d.ts +14 -0
- package/dist/financialPipeline.d.ts.map +1 -0
- package/dist/financialPipeline.js +75 -0
- package/dist/financialPipeline.js.map +1 -0
- package/dist/financialTerms.d.ts +20 -0
- package/dist/financialTerms.d.ts.map +1 -0
- package/dist/financialTerms.js +205 -0
- package/dist/financialTerms.js.map +1 -0
- package/dist/fnvAccumulator.d.ts.map +1 -1
- package/dist/fnvAccumulator.js +11 -5
- package/dist/fnvAccumulator.js.map +1 -1
- package/dist/historyPreparation.d.ts +8 -0
- package/dist/historyPreparation.d.ts.map +1 -0
- package/dist/historyPreparation.js +557 -0
- package/dist/historyPreparation.js.map +1 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/dist/policyPeriods.d.ts +29 -0
- package/dist/policyPeriods.d.ts.map +1 -0
- package/dist/policyPeriods.js +322 -0
- package/dist/policyPeriods.js.map +1 -0
- package/dist/populations.d.ts +11 -0
- package/dist/populations.d.ts.map +1 -0
- package/dist/populations.js +264 -0
- package/dist/populations.js.map +1 -0
- package/dist/reservingAdapter.d.ts +16 -0
- package/dist/reservingAdapter.d.ts.map +1 -0
- package/dist/reservingAdapter.js +74 -0
- package/dist/reservingAdapter.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/analysisRecipe.ts +696 -0
- package/src/classifications.ts +231 -0
- package/src/customizationContracts.ts +763 -0
- package/src/descriptiveStatistics.ts +320 -0
- package/src/diagnosticAggregation.ts +16 -0
- package/src/diagnosticFreeze.ts +37 -0
- package/src/diagnosticIdentityStream.ts +37 -2
- package/src/diagnosticPreparation.ts +259 -26
- package/src/diagnosticReview.ts +49 -27
- package/src/diagnosticReviewSources.ts +22 -3
- package/src/diagnosticReviewStore.ts +139 -54
- package/src/diagnosticRunner.ts +1 -11
- package/src/exposureEarning.ts +314 -0
- package/src/exposureMovements.ts +78 -0
- package/src/exposureRevisions.ts +186 -0
- package/src/financialPipeline.ts +93 -0
- package/src/financialTerms.ts +263 -0
- package/src/fnvAccumulator.ts +11 -5
- package/src/historyPreparation.ts +645 -0
- package/src/index.ts +28 -1
- package/src/policyPeriods.ts +375 -0
- package/src/populations.ts +307 -0
- package/src/reservingAdapter.ts +98 -0
- 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.
|
|
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.
|
|
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=analysisRecipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analysisRecipe.d.ts","sourceRoot":"","sources":["../src/analysisRecipe.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAElB,cAAc,EACd,cAAc,EAEd,gBAAgB,EAEhB,oBAAoB,EACpB,0BAA0B,EAC1B,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAE3B,gCAAgC,EAChC,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EAEvB,MAAM,6BAA6B,CAAC;AAmIrC,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE;IACvC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,SAAS,gCAAgC,EAAE,CAAC;IAC5E,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,wBAAwB,EAAE,CAAC;IAC/D,QAAQ,CAAC,yBAAyB,CAAC,E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