insurance.claim-reserve Unreviewed
Claim reserve history: paid, recovered, outstanding and incurred after each transaction, and the movement.
1.0.1 · published 2026-10-03 by charlie · Anterra
Pinned by 14 tests, run in TypeScript, Python and Rust.
Unreviewed. This capability’s implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified actuary has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.
Not professional advice. This capability calculates insurance figures from published rules. It is a software component for developers, not financial advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed in its README, and have an actuary review how you use it, before anyone relies on the output. Provided “as is” under its licence, without warranty.
What it does
The history of one claim's figures: after each transaction, what has been paid, what has been recovered, the outstanding case reserve, the incurred total and the movement in incurred.
incurred = paid - recovered + outstanding
For example
claim_reserve_history(transactions ×6, GBP)→ ×6 a claim's life: reserve, part payment, strengthening, an overpayment of the reserve, a recovery, closureclaim_reserve_history(, GBP)→ no transactions, no positionsclaim_reserve_history(transactions ×2, GBP)→ ×2 a claim withdrawn: the reserve released to nil is a negative movement
The function
The same function in TypeScript, Python and Rust, pinned by the same tests. Pick your language; the choice follows you around the registry.
def claim_reserve_history(transactions: Sequence[ClaimTransaction], currency: str) -> List[ReservePosition]
| transactions | ClaimTransaction[] | one claim's transactions in date order; same-day ones in the order they happened |
| currency | string | the claim's currency |
| returns | ReservePosition[] | the claim's position after each transaction, in the same order |
The types it declares, generated into your project
ClaimTransactionKind = Literal["reserve", "payment", "recovery"]
@dataclass(frozen=True)
class ClaimTransaction:
"""One event on a claim."""
date: str
#: reserve sets the outstanding estimate; payment pays; recovery brings money back
kind: ClaimTransactionKind
#: reserve: the new outstanding estimate, 0 or more; payment and recovery: more than 0
amount: Money
@dataclass(frozen=True)
class ReservePosition:
"""The claim after one transaction."""
date: str
kind: ClaimTransactionKind
#: paid to date
paid: Money
#: salvage and subrogation recovered to date
recovered: Money
#: the case reserve: what is still expected to be paid
outstanding: Money
#: paid minus recovered plus outstanding
incurred: Money
#: the change in incurred this transaction made
movement: Money
Your code names it in one line, in the file that uses it
from fune.insurance.claim_reserve import claim_reserve_history # insurance.claim-reserve@^1
Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
from typing import List, Optional, Sequence
from .dates_add_days import epoch_day_from_iso ← from dates.add-days ^1.0.0 · built alongside by fune
from .insurance_claim_reserve_types import ClaimTransaction, ReservePosition
from .money_amount import assert_same_currency, money ← from money.amount ^1.0.0 · built alongside by fune
def claim_reserve_history(transactions: Sequence[ClaimTransaction], currency: str) -> List[ReservePosition]:
"""A claim's position after each transaction: paid, recovered, the
outstanding case reserve, and incurred = paid - recovered + outstanding.
A payment erodes the outstanding reserve by what it pays, never below
zero: a payment larger than the reserve raises incurred by the excess,
which is how an under-reserved claim shows up. A reserve transaction sets
the outstanding estimate outright. The movement is what each transaction
did to incurred, the figure that goes through the accounts.
"""
zero = money(0, currency)
paid = 0
recovered = 0
outstanding = 0
incurred = 0
previous_day: Optional[int] = None
previous_date = ""
out: List[ReservePosition] = []
for t in transactions:
day = epoch_day_from_iso(t.date)
if previous_day is not None and day < previous_day:
raise ValueError("transactions must be in date order: %s comes after %s" % (t.date, previous_date))
previous_day = day
previous_date = t.date
assert_same_currency(zero, t.amount)
if t.kind == "reserve":
if t.amount.minor < 0:
raise ValueError("a reserve must not be negative, received %d on %s" % (t.amount.minor, t.date))
outstanding = t.amount.minor
elif t.kind in ("payment", "recovery"):
if t.amount.minor <= 0:
raise ValueError("a %s must be more than zero, received %d on %s" % (t.kind, t.amount.minor, t.date))
if t.kind == "payment":
paid += t.amount.minor
outstanding = max(outstanding - t.amount.minor, 0)
else:
recovered += t.amount.minor
else:
raise ValueError('unknown transaction kind "%s": use reserve, payment or recovery' % (t.kind,))
now = paid - recovered + outstanding
out.append(
ReservePosition(
date=t.date,
kind=t.kind,
paid=money(paid, currency),
recovered=money(recovered, currency),
outstanding=money(outstanding, currency),
incurred=money(now, currency),
movement=money(now - incurred, currency),
)
)
incurred = now
return outInstall
fune build
With that line in your source, in a Python project (language python in fune.project), fune build resolves it and its 2 dependencies, pins them in fune.lock, downloads only the Python package of each, and builds the code above into your project’s .fune/build, one readable file per capability with a header linking back here. Or pin a range in fune.project and build in one step:
fune add insurance.claim-reserve
The manifest, vectors and README with only the Python implementation. Install it without the registry with fune add ./insurance.claim-reserve-1.0.1-python.fune, or fetch it from a terminal with fune pull insurance.claim-reserve@1.0.1:python.
The whole function, every language, is one file too: insurance.claim-reserve-1.0.1.fune, 28,921 bytes, sha256 36fadf22a15bc9a0a8ff4a780f9c86d616fdf776b90d5c8689674c66f2246539. It installs into a project of any language.
Customise it in your app
The seams this capability offers. Put a marker directly above a function of your own and fune build wires it into the built code; the package on the registry is not changed, the built file’s header lists it under CUSTOMISED, and fune hooks lists every hook in the project. How hooks work.
before — your function gets the arguments and returns them, changed or not, or throws to refuse the call.
# fune: before insurance.claim-reserve
after — your function gets the result and the arguments, and returns the final result.
# fune: after insurance.claim-reserve
replace — inside this capability’s code only, calls to a dependency go to your function, with the same signature. Other capabilities that use it are unaffected; write in * to replace it everywhere.
# fune: replace dates.add-days in insurance.claim-reserve
# fune: replace money.amount in insurance.claim-reserve
step — your function runs at a numbered point inside the function’s body, receives the in-scope values it names as parameters, and may return replacements. List the points with fune show insurance.claim-reserve --steps.
# fune: step insurance.claim-reserve after <n|label>
Tests
A version published now needs at least 8 tests for every function, and one that expects the error for each function that throws; the registry refuses it otherwise. fune verify --all runs each case in TypeScript, Python and Rust, and a project runs them again with fune verify. This page lists the cases; it does not run them. The exact JSON is vectors.json.
| Case | Arguments | Expected | |
|---|---|---|---|
| a claim's life: reserve, part payment, strengthening, an overpayment of the reserve, a recovery, closure | transactions ×6, GBP | → | ×6 |
| no transactions, no positions | , GBP | → | |
| a claim withdrawn: the reserve released to nil is a negative movement | transactions ×2, GBP | → | ×2 |
| a payment with no reserve set raises incurred by the whole payment | transactions ×1, GBP | → | ×1 |
| a payment within the reserve moves nothing | transactions ×2, GBP | → | ×2 |
| a reserve cut after a payment | transactions ×3, GBP | → | ×3 |
| recoveries can take incurred below zero on a claim recovered in full with costs | transactions ×2, GBP | → | ×2 |
| transactions out of date order are refused | transactions ×2, GBP | → | error: transactions must be in date order: 2026-01-01 comes after 2026-02-01 |
| a negative reserve is refused | transactions ×1, GBP | → | error: a reserve must not be negative |
| a zero payment is refused | transactions ×1, GBP | → | error: a payment must be more than zero |
Show the other 4 tests
| Case | Arguments | Expected | |
|---|---|---|---|
| a negative recovery is refused | transactions ×1, GBP | → | error: a recovery must be more than zero |
| an unknown kind is refused | transactions ×1, GBP | → | error: unknown transaction kind |
| a transaction in another currency is refused | transactions ×1, GBP | → | error: currency mismatch |
| a malformed date is refused | transactions ×1, GBP | → | error: is not a real calendar date |
More from the author
## Transactions
- **reserve**: the claims handler's new estimate of what is still to be paid. It sets `outstanding` outright (0 closes the claim or releases the reserve). - **payment**: money paid out. It adds to `paid` and erodes `outstanding` by the same amount, never below zero. A payment within the reserve therefore leaves incurred unchanged; one larger than the reserve raises incurred by the difference, which is how an under-reserved claim shows up. - **recovery**: salvage, subrogation or third-party recoveries received. They reduce net incurred. A claim recovered in full with costs can show negative incurred.
`movement` is the change in incurred made by each transaction: the figure that goes through the claims account for the period, and what a development triangle is built from. Summing the movements in a period gives that period's incurred movement.
Transactions must be in date order; same-day transactions keep the order given, so a payment and the reserve change that follows it on one day come out as two positions. Dates are checked as real calendar dates.
Not covered: IBNR and other reserves not held against a specific claim, reserve currency conversion, and claims handling expenses (pass them as payments if your reporting counts them in incurred).
## Before you rely on this
**Not professional advice.** This capability calculates insurance figures from published rules. It is a software component for developers, not financial advice. Rules change and every rate here has an effective date. Check that the dates cover your case. Verify results against the official sources listed above, and have an actuary review how you use it, before anyone relies on the output. Provided "as is" under its licence, without warranty.
**Unreviewed.** This capability's implementations agree in every language and pass its published test vectors, which were worked out from the official sources cited. But no qualified actuary has yet checked those vectors, or confirmed that the capability covers the cases it claims. Treat it as a draft. Do not use it for real people, money or decisions without your own expert review. Once a qualified reviewer signs off, this notice is replaced with their name, qualification and the date. Each new version needs fresh sign-off.
1.0.1 marks it unreviewed. The code and the tests are unchanged.
Files
| Path | Bytes |
|---|---|
| README.md | 2,627 |
| impl/python.py | 2,622 |
| impl/rust.rs | 3,848 |
| impl/typescript.ts | 2,514 |
| vectors.json | 11,487 |