🏠 Reinsurance Β· πŸ“Š The Cash-Flow Cube Β· πŸ›‘οΈ Ceding Through an Acceptance β†’


Every dimension of the cash-flow cube is a node type compiled live by the mesh, every dimension member is a node, and every cash flow is a node too. Nothing here was deployed β€” the mesh compiled these types from Source/ code nodes minutes before this page was written.

The dimensions β€” five node types, members are nodes

Dimension Node type Members
Currency Currency USD Β· EUR Β· CHF
Country Country US Β· GB Β· CH Β· JP
Line of business LineOfBusiness Property Β· Casualty Β· Marine
Cash-flow type CashflowType Premium Β· Commission Β· PaidLoss
Underwriting year UnderwritingYear 2023 Β· 2024 Β· 2025

Each dimension's content record is deliberately empty β€” identity is the node path, name and icon live on the node, and there is room to grow (FX rates on a currency, hierarchies on a line of business) without touching the cube:

public record Currency
{
}

The fact β€” a cash flow referencing its dimensions by path

A cash flow has no Id property β€” its identity is its path. Each dimension column stores a member node's path ([MeshNode] renders it as a picker in the edit form), and the value develops over time through DevelopmentDate:

public record Cashflow
{
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/Currency")]         public string Currency { get; init; }
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/Country")]          public string Country { get; init; }
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/LineOfBusiness")]   public string LineOfBusiness { get; init; }
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/CashflowType")]     public string CashflowType { get; init; }
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/UnderwritingYear")] public string UnderwritingYear { get; init; }
    public DateOnly DevelopmentDate { get; init; }
    [DisplayFormat(DataFormatString = "{0:N1}")] public double Value { get; init; }   // inflow +, outflow βˆ’
}

The cube holds 18 cash flows across four segments β€” browse them under Cashflow, for example Property US 2023 β€” Paid Loss dev 2024.

Slice & dice β€” net cash flow by line of business Γ— underwriting year

The cell below is live twice over: it executes in a kernel when the page loads, and it reads the fact nodes above live (Mesh.GetQuery) instead of re-typing their numbers β€” edit a cash flow and re-run the page, and the pivot follows. The 2023 Property cat year jumps out immediately:

Subscribers see this result live; below is the same worked example as a static table.

using System.Reactive.Linq;
using System.Text.Json;
using MeshWeaver.Graph;
using MeshWeaver.Layout.Pivot;

record Flow(string Lob, string Country, string Ccy, string Uwy, string Type, int Dev, double Value);

// The live fact nodes β€” one synced query; its first frame is a complete snapshot.
var facts = (await Mesh
    .GetQuery("cube-facts", "namespace:Reinsurance/Cashflow scope:children nodeType:Reinsurance/Cashflow")
    .FirstAsync()).ToArray();
if (facts.Length == 0)
    throw new InvalidOperationException(
        "No Reinsurance/Cashflow fact nodes found β€” is the Reinsurance plugin installed on this mesh?");

// Foreign type β†’ read the JSON shape (the kernel has no Cashflow type loaded).
JsonElement Prop(JsonElement e, string name) =>
    e.TryGetProperty(name, out var v) ? v
        : e.TryGetProperty(char.ToUpperInvariant(name[0]) + name[1..], out var u) ? u
        : throw new InvalidOperationException($"Cashflow content has no '{name}' property.");
string Leaf(JsonElement e, string name) => Prop(e, name).GetString()!.Split('/').Last();

var flows = facts
    .Select(n => n.Content)
    .OfType<JsonElement>()
    .Select(e => new Flow(
        Leaf(e, "lineOfBusiness"), Leaf(e, "country"), Leaf(e, "currency"),
        Leaf(e, "underwritingYear"), Leaf(e, "cashflowType"),
        DateOnly.Parse(Prop(e, "developmentDate").GetString()!).Year,
        Prop(e, "value").GetDouble()))
    .OrderBy(f => (f.Lob, f.Uwy, f.Type, f.Dev))
    .ToArray();
if (flows.Length == 0)
    throw new InvalidOperationException(
        $"{facts.Length} Cashflow nodes found but none carried readable content.");

flows.ToPivotGrid(pivot => pivot
    .GroupRowsBy(f => f.Lob)
    .GroupColumnsBy(f => f.Uwy)
    .Aggregate(f => f.Value, agg => agg.WithFunction(AggregateFunction.Sum))
    .WithRowTotals()
    .WithColumnTotals())

Net cash flow (m), summed over every fact node as the pivot sums them:

Line of business 2023 2024 Total
Casualty βˆ’2.0 β€” βˆ’2.0
Marine β€” βˆ’1.0 βˆ’1.0
Property βˆ’81.0 1.5 βˆ’79.5
Total βˆ’83.0 0.5 βˆ’82.5

The development axis β€” cash flows through time

All cells on a page share one kernel session, so this chart simply reuses flows from the pivot above β€” premium comes in early, losses pay out over the development years:

Subscribers see this result live; below is the same worked example as a static table.

using MeshWeaver.Layout.Chart;

flows
    .SliceBy(f => f.Dev)
    .SliceBy(f => f.Type)
    .ToStackedColumnChart(g => g.Sum(f => f.Value))
    .WithTitle("Cash flows by development year, stacked by type (m)")
Development year Premium Commission PaidLoss Total
2023 20.0 βˆ’5.0 βˆ’21.0 βˆ’6.0
2024 11.0 βˆ’2.5 βˆ’56.0 βˆ’47.5
2025 β€” β€” βˆ’29.0 βˆ’29.0

Where does the premium come from?

One more slice β€” reusing flows yet again, this time filtered:

Subscribers see this result live; below is the same worked example as a static table.

using MeshWeaver.Layout.Chart;

flows
    .Where(f => f.Type == "Premium")
    .SliceBy(f => f.Lob)
    .ToPieChart(g => g.Sum(f => f.Value))
    .WithTitle("Premium by line of business (m)")
Line of business Premium (m) Share
Property 18.0 58.1 %
Casualty 8.0 25.8 %
Marine 5.0 16.1 %
Total 31.0 100 %

And it is editable β€” a form for free

The form below is generated entirely from the record's attributes β€” each [MeshNode] column renders as a live picker over the real dimension nodes of this Space. No form code was written:

using System.ComponentModel.DataAnnotations;
using MeshWeaver.Layout;
using MeshWeaver.Domain;

record CashflowDraft
{
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/Currency")]         public string Currency { get; init; } = "Reinsurance/Currency/USD";
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/Country")]          public string Country { get; init; } = "Reinsurance/Country/US";
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/LineOfBusiness")]   public string LineOfBusiness { get; init; } = "Reinsurance/LineOfBusiness/Property";
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/CashflowType")]     public string CashflowType { get; init; } = "Reinsurance/CashflowType/Premium";
    [MeshNode("namespace:Reinsurance scope:descendants nodeType:Reinsurance/UnderwritingYear")] public string UnderwritingYear { get; init; } = "Reinsurance/UnderwritingYear/2025";
    public DateOnly DevelopmentDate { get; init; } = new DateOnly(2025, 12, 31);
    [DisplayFormat(DataFormatString = "{0:N1}")] public double Value { get; init; } = 10.0;
}

Mesh.Edit(new CashflowDraft(), "cashflowDraft")

Next: cede these cash flows through an acceptance β†’

Reconnecting…
The connection to the server was interrupted. Trying to restore it…
Trying again…
The connection could not be restored. Reloading the page…
The server was updated. Reloading the page to pick up the latest version.