@actuarial-ts/compliance 0.1.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/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +85 -0
- package/dist/ave.d.ts +74 -0
- package/dist/ave.d.ts.map +1 -0
- package/dist/ave.js +87 -0
- package/dist/ave.js.map +1 -0
- package/dist/bundle.d.ts +112 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +214 -0
- package/dist/bundle.js.map +1 -0
- package/dist/disclosure.d.ts +76 -0
- package/dist/disclosure.d.ts.map +1 -0
- package/dist/disclosure.js +204 -0
- package/dist/disclosure.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/ledger.d.ts +84 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +85 -0
- package/dist/ledger.js.map +1 -0
- package/dist/metadata.d.ts +63 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +138 -0
- package/dist/metadata.js.map +1 -0
- package/dist/modelCards.d.ts +30 -0
- package/dist/modelCards.d.ts.map +1 -0
- package/dist/modelCards.js +445 -0
- package/dist/modelCards.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# @actuarial-ts/compliance
|
|
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
|
+
- **Actual-vs-expected roll-forward**: expected emergence from the prior
|
|
26
|
+
valuation's pattern versus actual, by origin.
|
|
27
|
+
|
|
28
|
+
Everything here is pure, deterministic, and browser-safe: no clock reads,
|
|
29
|
+
no randomness, no node builtins. Identical inputs produce byte-identical
|
|
30
|
+
documents.
|
|
31
|
+
|
|
32
|
+
## Quickstart
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import { runChainLadder, runMack } from "@actuarial-ts/core";
|
|
36
|
+
import {
|
|
37
|
+
createLedger,
|
|
38
|
+
recordAssumption,
|
|
39
|
+
generateDisclosure,
|
|
40
|
+
} from "@actuarial-ts/compliance";
|
|
41
|
+
|
|
42
|
+
let ledger = createLedger();
|
|
43
|
+
ledger = recordAssumption(ledger, {
|
|
44
|
+
timestamp: "2026-01-05T10:05:00Z",
|
|
45
|
+
actor: "actuary",
|
|
46
|
+
field: "paid.tailFactor",
|
|
47
|
+
value: 1.02,
|
|
48
|
+
rationale: "Exponential-decay fit valid with R^2 0.97; judgmentally confirmed",
|
|
49
|
+
source: "fitted",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const cl = runChainLadder(paidTriangle, { selected, tailFactor: 1.02 });
|
|
53
|
+
const mack = runMack(paidTriangle, { selected, tailFactor: 1.02 });
|
|
54
|
+
|
|
55
|
+
const markdown = generateDisclosure({
|
|
56
|
+
metadata: {
|
|
57
|
+
intendedPurpose: "Estimate unpaid claims for year-end statutory reporting",
|
|
58
|
+
intendedMeasure: { kind: "central-estimate" },
|
|
59
|
+
basis: { grossNet: "gross", laeTreatment: "dcc-only" },
|
|
60
|
+
accountingDate: "2025-12-31",
|
|
61
|
+
valuationDate: "2025-12-31",
|
|
62
|
+
},
|
|
63
|
+
methods: [
|
|
64
|
+
{ methodId: "chainLadder", basisLabel: "paid", parameters: { selected, tailFactor: 1.02 }, resultSummary: { ultimate: cl.totals.ultimate, unpaid: cl.totals.unpaid } },
|
|
65
|
+
{ methodId: "mack", basisLabel: "paid", resultSummary: { standardError: mack.totals.standardError } },
|
|
66
|
+
],
|
|
67
|
+
ledger,
|
|
68
|
+
sdkVersion: "0.1.0",
|
|
69
|
+
generatedAt: "2026-01-05T10:15:00Z",
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## The honest claim
|
|
74
|
+
|
|
75
|
+
The ASB does not approve, certify, or endorse software, and no software can
|
|
76
|
+
be "ASOP-compliant" on its own — compliance is a property of a credentialed
|
|
77
|
+
actuary's work in context. This package is **designed to support the
|
|
78
|
+
actuary's compliance** with ASOP Nos. 41, 43, 23, 56, and 21 by generating
|
|
79
|
+
the disclosures, documentation, and audit artifacts those standards call
|
|
80
|
+
for. The generated documents are draft support material for the responsible
|
|
81
|
+
actuary to review, edit, and adopt.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Apache-2.0. Copyright 2026 Justin Morrey.
|
package/dist/ave.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actual-vs-expected roll-forward: the back-test that asks "did losses emerge
|
|
3
|
+
* between the prior and current valuations the way the prior analysis
|
|
4
|
+
* expected?" — the standard bridge exhibit for the ASOP 41 changes-from-prior
|
|
5
|
+
* discussion and for judging whether prior assumptions still hold (ASOP 43).
|
|
6
|
+
*
|
|
7
|
+
* Ground truth (per origin):
|
|
8
|
+
* - expectedEmergence = priorUltimate x (expectedPercentAtCurrent - expectedPercentAtPrior)
|
|
9
|
+
* - actualEmergence = currentLatest - priorLatest
|
|
10
|
+
* - difference = actualEmergence - expectedEmergence (positive = worse
|
|
11
|
+
* than expected on a loss basis)
|
|
12
|
+
* - ratio = actualEmergence / expectedEmergence, and null — never
|
|
13
|
+
* NaN or Infinity — when expectedEmergence is 0, matching core's
|
|
14
|
+
* null-safety philosophy (no factor, not an exception).
|
|
15
|
+
* - totals sum the rows; the total ratio follows the same null rule.
|
|
16
|
+
* - Suspicious inputs produce WARNINGS, not errors: a development pattern
|
|
17
|
+
* that goes backwards (expectedPercentAtCurrent < expectedPercentAtPrior)
|
|
18
|
+
* or a percent outside [0, 1.05] is reportable, but the arithmetic is still
|
|
19
|
+
* well-defined and the actuary decides what it means. (Slightly above 1 is
|
|
20
|
+
* legitimate: paid patterns can overshoot ultimate before salvage/subro.)
|
|
21
|
+
*
|
|
22
|
+
* Errors follow the package's ComplianceError style (see bundle.ts):
|
|
23
|
+
* `percentDevelopedFromCdfs` throws BAD_CDF on a non-positive or non-finite
|
|
24
|
+
* CDF because no percent-developed interpretation exists for it.
|
|
25
|
+
*
|
|
26
|
+
* These utilities are designed to support the actuary's compliance with
|
|
27
|
+
* ASOP Nos. 41 and 43; responsibility for compliance remains with the
|
|
28
|
+
* credentialed actuary.
|
|
29
|
+
*/
|
|
30
|
+
export interface AveInputRow {
|
|
31
|
+
/** Origin period label (e.g. "2021"). */
|
|
32
|
+
origin: string;
|
|
33
|
+
/** The prior analysis's selected ultimate for this origin. */
|
|
34
|
+
priorUltimate: number;
|
|
35
|
+
/** Latest observed value (paid or incurred, matching the pattern basis) at the prior valuation. */
|
|
36
|
+
priorLatest: number;
|
|
37
|
+
/** Latest observed value at the current valuation, same basis as priorLatest. */
|
|
38
|
+
currentLatest: number;
|
|
39
|
+
/** Prior analysis's expected percent developed at the prior valuation age (fraction). */
|
|
40
|
+
expectedPercentAtPrior: number;
|
|
41
|
+
/** Prior analysis's expected percent developed at the current valuation age (fraction). */
|
|
42
|
+
expectedPercentAtCurrent: number;
|
|
43
|
+
}
|
|
44
|
+
export interface AveResultRow {
|
|
45
|
+
origin: string;
|
|
46
|
+
expectedEmergence: number;
|
|
47
|
+
actualEmergence: number;
|
|
48
|
+
/** actualEmergence - expectedEmergence. */
|
|
49
|
+
difference: number;
|
|
50
|
+
/** actualEmergence / expectedEmergence; null when expectedEmergence is 0. */
|
|
51
|
+
ratio: number | null;
|
|
52
|
+
}
|
|
53
|
+
export interface AveRollForwardResult {
|
|
54
|
+
rows: AveResultRow[];
|
|
55
|
+
totals: {
|
|
56
|
+
expectedEmergence: number;
|
|
57
|
+
actualEmergence: number;
|
|
58
|
+
difference: number;
|
|
59
|
+
/** Total actual / total expected; null when total expected is 0. */
|
|
60
|
+
ratio: number | null;
|
|
61
|
+
};
|
|
62
|
+
warnings: string[];
|
|
63
|
+
}
|
|
64
|
+
/** Rolls the prior analysis forward and compares expected to actual emergence per origin. */
|
|
65
|
+
export declare function aveRollForward(rows: AveInputRow[]): AveRollForwardResult;
|
|
66
|
+
/**
|
|
67
|
+
* Percent developed per age from a CDF vector: percent[j] = 1 / cdfs[j]
|
|
68
|
+
* (cdfs[j] = cumulative factor from ages[j] to ultimate, tail included, per
|
|
69
|
+
* core's ChainLadderResult convention). Convenience for pattern-based callers
|
|
70
|
+
* building aveRollForward inputs. Throws ComplianceError("BAD_CDF") on a
|
|
71
|
+
* non-positive or non-finite CDF.
|
|
72
|
+
*/
|
|
73
|
+
export declare function percentDevelopedFromCdfs(cdfs: number[]): number[];
|
|
74
|
+
//# sourceMappingURL=ave.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ave.d.ts","sourceRoot":"","sources":["../src/ave.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,aAAa,EAAE,MAAM,CAAC;IACtB,mGAAmG;IACnG,WAAW,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2FAA2F;IAC3F,wBAAwB,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,2CAA2C;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,YAAY,EAAE,CAAC;IACrB,MAAM,EAAE;QACN,iBAAiB,EAAE,MAAM,CAAC;QAC1B,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,MAAM,CAAC;QACnB,oEAAoE;QACpE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;KACtB,CAAC;IACF,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAKD,6FAA6F;AAC7F,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,oBAAoB,CA0CxE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAOjE"}
|
package/dist/ave.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Actual-vs-expected roll-forward: the back-test that asks "did losses emerge
|
|
3
|
+
* between the prior and current valuations the way the prior analysis
|
|
4
|
+
* expected?" — the standard bridge exhibit for the ASOP 41 changes-from-prior
|
|
5
|
+
* discussion and for judging whether prior assumptions still hold (ASOP 43).
|
|
6
|
+
*
|
|
7
|
+
* Ground truth (per origin):
|
|
8
|
+
* - expectedEmergence = priorUltimate x (expectedPercentAtCurrent - expectedPercentAtPrior)
|
|
9
|
+
* - actualEmergence = currentLatest - priorLatest
|
|
10
|
+
* - difference = actualEmergence - expectedEmergence (positive = worse
|
|
11
|
+
* than expected on a loss basis)
|
|
12
|
+
* - ratio = actualEmergence / expectedEmergence, and null — never
|
|
13
|
+
* NaN or Infinity — when expectedEmergence is 0, matching core's
|
|
14
|
+
* null-safety philosophy (no factor, not an exception).
|
|
15
|
+
* - totals sum the rows; the total ratio follows the same null rule.
|
|
16
|
+
* - Suspicious inputs produce WARNINGS, not errors: a development pattern
|
|
17
|
+
* that goes backwards (expectedPercentAtCurrent < expectedPercentAtPrior)
|
|
18
|
+
* or a percent outside [0, 1.05] is reportable, but the arithmetic is still
|
|
19
|
+
* well-defined and the actuary decides what it means. (Slightly above 1 is
|
|
20
|
+
* legitimate: paid patterns can overshoot ultimate before salvage/subro.)
|
|
21
|
+
*
|
|
22
|
+
* Errors follow the package's ComplianceError style (see bundle.ts):
|
|
23
|
+
* `percentDevelopedFromCdfs` throws BAD_CDF on a non-positive or non-finite
|
|
24
|
+
* CDF because no percent-developed interpretation exists for it.
|
|
25
|
+
*
|
|
26
|
+
* These utilities are designed to support the actuary's compliance with
|
|
27
|
+
* ASOP Nos. 41 and 43; responsibility for compliance remains with the
|
|
28
|
+
* credentialed actuary.
|
|
29
|
+
*/
|
|
30
|
+
import { ComplianceError } from "./bundle.js";
|
|
31
|
+
/** Percents above this are flagged (slightly above 1 is legitimate; see doc block). */
|
|
32
|
+
const PERCENT_MAX = 1.05;
|
|
33
|
+
/** Rolls the prior analysis forward and compares expected to actual emergence per origin. */
|
|
34
|
+
export function aveRollForward(rows) {
|
|
35
|
+
const outRows = [];
|
|
36
|
+
const warnings = [];
|
|
37
|
+
let totalExpected = 0;
|
|
38
|
+
let totalActual = 0;
|
|
39
|
+
for (const row of rows) {
|
|
40
|
+
const pctPrior = row.expectedPercentAtPrior;
|
|
41
|
+
const pctCurrent = row.expectedPercentAtCurrent;
|
|
42
|
+
if (pctCurrent < pctPrior) {
|
|
43
|
+
warnings.push(`origin ${row.origin}: pattern goes backwards (expectedPercentAtCurrent ${pctCurrent} < expectedPercentAtPrior ${pctPrior})`);
|
|
44
|
+
}
|
|
45
|
+
for (const [name, pct] of [
|
|
46
|
+
["expectedPercentAtPrior", pctPrior],
|
|
47
|
+
["expectedPercentAtCurrent", pctCurrent],
|
|
48
|
+
]) {
|
|
49
|
+
if (pct < 0 || pct > PERCENT_MAX) {
|
|
50
|
+
warnings.push(`origin ${row.origin}: ${name} ${pct} outside [0, ${PERCENT_MAX}]`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const expectedEmergence = row.priorUltimate * (pctCurrent - pctPrior);
|
|
54
|
+
const actualEmergence = row.currentLatest - row.priorLatest;
|
|
55
|
+
const difference = actualEmergence - expectedEmergence;
|
|
56
|
+
const ratio = expectedEmergence === 0 ? null : actualEmergence / expectedEmergence;
|
|
57
|
+
outRows.push({ origin: row.origin, expectedEmergence, actualEmergence, difference, ratio });
|
|
58
|
+
totalExpected += expectedEmergence;
|
|
59
|
+
totalActual += actualEmergence;
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
rows: outRows,
|
|
63
|
+
totals: {
|
|
64
|
+
expectedEmergence: totalExpected,
|
|
65
|
+
actualEmergence: totalActual,
|
|
66
|
+
difference: totalActual - totalExpected,
|
|
67
|
+
ratio: totalExpected === 0 ? null : totalActual / totalExpected,
|
|
68
|
+
},
|
|
69
|
+
warnings,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Percent developed per age from a CDF vector: percent[j] = 1 / cdfs[j]
|
|
74
|
+
* (cdfs[j] = cumulative factor from ages[j] to ultimate, tail included, per
|
|
75
|
+
* core's ChainLadderResult convention). Convenience for pattern-based callers
|
|
76
|
+
* building aveRollForward inputs. Throws ComplianceError("BAD_CDF") on a
|
|
77
|
+
* non-positive or non-finite CDF.
|
|
78
|
+
*/
|
|
79
|
+
export function percentDevelopedFromCdfs(cdfs) {
|
|
80
|
+
return cdfs.map((cdf, index) => {
|
|
81
|
+
if (!Number.isFinite(cdf) || cdf <= 0) {
|
|
82
|
+
throw new ComplianceError("BAD_CDF", `cdf at index ${index} is ${cdf}; every CDF must be a finite number > 0`);
|
|
83
|
+
}
|
|
84
|
+
return 1 / cdf;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=ave.js.map
|
package/dist/ave.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ave.js","sourceRoot":"","sources":["../src/ave.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAuC9C,uFAAuF;AACvF,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,6FAA6F;AAC7F,MAAM,UAAU,cAAc,CAAC,IAAmB;IAChD,MAAM,OAAO,GAAmB,EAAE,CAAC;IACnC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,GAAG,CAAC,sBAAsB,CAAC;QAC5C,MAAM,UAAU,GAAG,GAAG,CAAC,wBAAwB,CAAC;QAChD,IAAI,UAAU,GAAG,QAAQ,EAAE,CAAC;YAC1B,QAAQ,CAAC,IAAI,CACX,UAAU,GAAG,CAAC,MAAM,sDAAsD,UAAU,6BAA6B,QAAQ,GAAG,CAC7H,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI;YACxB,CAAC,wBAAwB,EAAE,QAAQ,CAAC;YACpC,CAAC,0BAA0B,EAAE,UAAU,CAAC;SAChC,EAAE,CAAC;YACX,IAAI,GAAG,GAAG,CAAC,IAAI,GAAG,GAAG,WAAW,EAAE,CAAC;gBACjC,QAAQ,CAAC,IAAI,CAAC,UAAU,GAAG,CAAC,MAAM,KAAK,IAAI,IAAI,GAAG,gBAAgB,WAAW,GAAG,CAAC,CAAC;YACpF,CAAC;QACH,CAAC;QAED,MAAM,iBAAiB,GAAG,GAAG,CAAC,aAAa,GAAG,CAAC,UAAU,GAAG,QAAQ,CAAC,CAAC;QACtE,MAAM,eAAe,GAAG,GAAG,CAAC,aAAa,GAAG,GAAG,CAAC,WAAW,CAAC;QAC5D,MAAM,UAAU,GAAG,eAAe,GAAG,iBAAiB,CAAC;QACvD,MAAM,KAAK,GAAG,iBAAiB,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,eAAe,GAAG,iBAAiB,CAAC;QACnF,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,iBAAiB,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5F,aAAa,IAAI,iBAAiB,CAAC;QACnC,WAAW,IAAI,eAAe,CAAC;IACjC,CAAC;IAED,OAAO;QACL,IAAI,EAAE,OAAO;QACb,MAAM,EAAE;YACN,iBAAiB,EAAE,aAAa;YAChC,eAAe,EAAE,WAAW;YAC5B,UAAU,EAAE,WAAW,GAAG,aAAa;YACvC,KAAK,EAAE,aAAa,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,GAAG,aAAa;SAChE;QACD,QAAQ;KACT,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAc;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC7B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;YACtC,MAAM,IAAI,eAAe,CAAC,SAAS,EAAE,gBAAgB,KAAK,OAAO,GAAG,yCAAyC,CAAC,CAAC;QACjH,CAAC;QACD,OAAO,CAAC,GAAG,GAAG,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reproducibility bundle: canonical JSON serialization + a tiny integrity
|
|
3
|
+
* hash, so an analysis can state "these results came from exactly these
|
|
4
|
+
* inputs, parameters, and SDK versions" and a re-run can be byte-verified.
|
|
5
|
+
*
|
|
6
|
+
* Ground truth:
|
|
7
|
+
* - `canonicalJson` is the package's single equality oracle: object keys are
|
|
8
|
+
* sorted recursively, arrays keep their order, numbers render via
|
|
9
|
+
* `String(n)` except -0 which normalizes to "0" (so 0 and -0 never differ),
|
|
10
|
+
* and anything JSON cannot faithfully represent (undefined, functions,
|
|
11
|
+
* NaN/Infinity, bigint, symbol, non-plain objects such as Date/Map/Set,
|
|
12
|
+
* circular references) THROWS with the offending path instead of being
|
|
13
|
+
* silently dropped or coerced the way JSON.stringify would.
|
|
14
|
+
* - `fnv1a64` is an integrity aid, NOT a security control (see its doc block).
|
|
15
|
+
* - Timestamps are caller-supplied ISO strings; this module never reads a
|
|
16
|
+
* clock, so identical inputs yield byte-identical bundles.
|
|
17
|
+
* - Browser-safe: no node builtins (TextEncoder is a web-standard global).
|
|
18
|
+
*
|
|
19
|
+
* Error style for the whole package: `ComplianceError` with a registered
|
|
20
|
+
* machine code, mirroring core's `ReservingError` idiom. It lives here (not
|
|
21
|
+
* in its own module) because bundle.ts is the package's dependency-root
|
|
22
|
+
* module — ledger.ts already imports `canonicalJson` from it. Core's
|
|
23
|
+
* `RESERVING_ERROR_CODES` registry is a closed contract enforced against
|
|
24
|
+
* core's own source, and compliance failures (missing rationale, unsupported
|
|
25
|
+
* bundle values) are not reserving-input errors, so this package does not
|
|
26
|
+
* reuse `ReservingError`.
|
|
27
|
+
*
|
|
28
|
+
* These utilities are designed to support the actuary's compliance with
|
|
29
|
+
* ASOP No. 41 (documentation and reproducibility of the analysis);
|
|
30
|
+
* responsibility for compliance remains with the credentialed actuary.
|
|
31
|
+
*/
|
|
32
|
+
/**
|
|
33
|
+
* Every machine-readable code a ComplianceError can carry, across all modules
|
|
34
|
+
* of this package. Add the code here when introducing a new throw.
|
|
35
|
+
*/
|
|
36
|
+
export declare const COMPLIANCE_ERROR_CODES: readonly ["BAD_BUNDLE", "BAD_CDF", "MISSING_RATIONALE", "UNSUPPORTED_VALUE"];
|
|
37
|
+
export type ComplianceErrorCode = (typeof COMPLIANCE_ERROR_CODES)[number];
|
|
38
|
+
/** Thrown for invalid compliance input (unrepresentable bundle payloads, judgment without rationale, non-positive CDFs). */
|
|
39
|
+
export declare class ComplianceError extends Error {
|
|
40
|
+
readonly code: ComplianceErrorCode;
|
|
41
|
+
constructor(code: ComplianceErrorCode, message: string);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Deterministic JSON serialization: sorted object keys (recursively), arrays
|
|
45
|
+
* in order, no whitespace, -0 normalized to "0". Two structurally equal
|
|
46
|
+
* values always produce the same string regardless of key insertion order.
|
|
47
|
+
* Throws ComplianceError("UNSUPPORTED_VALUE") — with the offending path, e.g.
|
|
48
|
+
* "$.rows[2].ultimate" — for any value JSON cannot faithfully represent.
|
|
49
|
+
*/
|
|
50
|
+
export declare function canonicalJson(value: unknown): string;
|
|
51
|
+
/**
|
|
52
|
+
* FNV-1a 64-bit hash over the UTF-8 bytes of `text`, returned as a 16-hex-char
|
|
53
|
+
* string.
|
|
54
|
+
*
|
|
55
|
+
* This is an INTEGRITY AID for detecting accidental divergence between a
|
|
56
|
+
* bundle and a re-run. It is NOT a security control: FNV-1a is not collision
|
|
57
|
+
* resistant and offers no protection against deliberate tampering. Anyone
|
|
58
|
+
* needing tamper evidence must sign or cryptographically hash the payload
|
|
59
|
+
* (which is exactly why the full canonical payload — not just the hash — is
|
|
60
|
+
* stored on the bundle).
|
|
61
|
+
*/
|
|
62
|
+
export declare function fnv1a64(text: string): string;
|
|
63
|
+
export interface CreateBundleInput {
|
|
64
|
+
/** The data the analysis consumed (triangles, claims, exposures — anything canonicalizable). */
|
|
65
|
+
inputs: unknown;
|
|
66
|
+
/** The parameters/selections the analysis used (LDF selections, a-prioris, trends…). */
|
|
67
|
+
parameters: unknown;
|
|
68
|
+
/** The results the analysis produced; this is the segment verifyBundle re-checks. */
|
|
69
|
+
results: unknown;
|
|
70
|
+
/** Package versions the run used, e.g. { "@actuarial-ts/core": "0.1.0" }. */
|
|
71
|
+
sdkVersions: Record<string, string>;
|
|
72
|
+
/** Explicit seeds for any stochastic method (purity: no ambient randomness). */
|
|
73
|
+
seeds?: unknown;
|
|
74
|
+
/** Caller-supplied ISO timestamp (purity: no clock reads). */
|
|
75
|
+
createdAt: string;
|
|
76
|
+
}
|
|
77
|
+
export interface ReproducibilityBundle {
|
|
78
|
+
/** Canonical JSON of the full bundle body; the reproducibility record itself. */
|
|
79
|
+
payload: string;
|
|
80
|
+
/** fnv1a64(payload) — integrity aid, not a security control. */
|
|
81
|
+
hash: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Packages an analysis run into a reproducibility bundle. The payload is
|
|
85
|
+
* canonical, so two runs with structurally equal inputs produce byte-identical
|
|
86
|
+
* payloads (and therefore identical hashes) regardless of key insertion order.
|
|
87
|
+
* `seeds` is included only when provided (undefined would be unrepresentable).
|
|
88
|
+
*/
|
|
89
|
+
export declare function createBundle(input: CreateBundleInput): ReproducibilityBundle;
|
|
90
|
+
export interface VerifyBundleResult {
|
|
91
|
+
reproduced: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* First differing path (deterministic depth-first walk, object keys in
|
|
94
|
+
* sorted order), e.g. "$.rows[1].ultimate". Present only when not
|
|
95
|
+
* reproduced. A missing/extra object key reports the key's path; an array
|
|
96
|
+
* length mismatch reports the first index past the shared prefix; a type
|
|
97
|
+
* mismatch reports the node itself.
|
|
98
|
+
*/
|
|
99
|
+
mismatchPath?: string;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Verifies a re-run against a bundle: canonicalizes `rerunResults` and
|
|
103
|
+
* byte-compares it with the bundle's stored `results` segment. On mismatch,
|
|
104
|
+
* reports the FIRST differing path (see VerifyBundleResult.mismatchPath).
|
|
105
|
+
*
|
|
106
|
+
* Throws ComplianceError("BAD_BUNDLE") when the payload is not a valid bundle
|
|
107
|
+
* body, and propagates ComplianceError("UNSUPPORTED_VALUE") when
|
|
108
|
+
* `rerunResults` itself is not canonicalizable — a result that cannot be
|
|
109
|
+
* serialized cannot be verified.
|
|
110
|
+
*/
|
|
111
|
+
export declare function verifyBundle(bundle: ReproducibilityBundle, rerunResults: unknown): VerifyBundleResult;
|
|
112
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,8EAKzB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1E,4HAA4H;AAC5H,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;gBACvB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM;CAKvD;AA6DD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C;AAED,MAAM,WAAW,iBAAiB;IAChC,gGAAgG;IAChG,MAAM,EAAE,OAAO,CAAC;IAChB,wFAAwF;IACxF,UAAU,EAAE,OAAO,CAAC;IACpB,qFAAqF;IACrF,OAAO,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,qBAAqB;IACpC,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,qBAAqB,CAW5E;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,OAAO,CAAC;IACpB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAyBD;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,qBAAqB,EAAE,YAAY,EAAE,OAAO,GAAG,kBAAkB,CAerG"}
|