Skip to content

feat: add failure-mode decomposition to ruin output#1669

Merged
AlexFiliakov merged 32 commits into
mainfrom
develop
Jun 19, 2026
Merged

feat: add failure-mode decomposition to ruin output#1669
AlexFiliakov merged 32 commits into
mainfrom
develop

Conversation

@AlexFiliakov

Copy link
Copy Markdown
Owner

Summary

Promotes the current develop work to main. The headline change is a new failure-mode decomposition capability on the ruin output, alongside a CI lint fix and an extensive round of HJB optimization-notebook (No. 07) work.

This PR is titled feat: because it contains a feature commit (957e342); per the project's release rules, the PR title is the sole input python-semantic-release uses to determine the version bump and changelog entry on main. This will produce a minor version bump (pre-1.0, major_on_zero = false).

Changes

Features

  • Failure-mode decomposition of ruin (957e342): adds a reusable WidgetManufacturer.ruin_reason field populated at 9 trigger sites (first-wins, diagnostic-only), surfaced as part of the ruin output. Includes new test_ruin_reason.py (195 lines) and a Part-10b butterfly chart in notebook 07 decomposing ruin into plain-language causes (No-Insurance vs. HJB Adaptive).

Fixes

  • Restore the mypy lint gate (05e28a8): matplotlib removed the plt.cm.get_cmap accessor (deprecated in 3.7, removed in 3.9), which raised AttributeError at runtime and broke CI. Switched improved_tower_plot.py to the modern plt.colormaps[name] registry indexing already used elsewhere in the visualization package.

Docs & chore

  • Extensive HJB optimization notebook 07 work: recalibration, revision to engineering-economics (EE) language for actuaries, additional charts and diagnostics, SIR-grid plot sizing, max-wealth raised to $400M to avoid boundary distortion, and removal of the spurious 13b/13c exhibits.
  • Added an insurance primer (4b54a6c).
  • Library keyword metadata (0e6845a) and optimization-directory cleanup (b82958e).

Validation

  • mypy ergodic_insurance/ --ignore-missing-imports → Success, no issues in 347 source files.
  • black --check . → all files unchanged.
  • isort --check-only . → no changes needed.
  • pylint ergodic_insurance/ --fail-under=7.0 → rated 9.94/10 (exit 0).
  • Pre-commit hooks (black, isort, mypy, conventional-commit) passed on the fix commit.

…s relationship between E[X] and TAG in the simplified model
matplotlib removed the plt.cm.get_cmap accessor (deprecated since 3.7,
removed in 3.9), which raised AttributeError at runtime and broke the
mypy lint gate in CI. Switch to the modern plt.colormaps[name] registry
indexing already used elsewhere in the visualization package
(technical_plots.py).
@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown

Coverage Report

Name Stmts Miss Cover
__init__.py 89 21 76%
_compare_strategies.py 98 3 97%
_run_analysis.py 227 10 96%
_version.py 1 0 100%
_warnings.py 5 0 100%
accrual_manager.py 156 1 99%
accuracy_validator.py 275 18 93%
adaptive_stopping.py 307 1 99%
batch_processor.py 315 3 99%
benchmarking.py 265 78 71%
bootstrap_analysis.py 262 1 99%
business_optimizer.py 513 7 99%
claim_development.py 395 36 91%
claim_liability.py 69 7 90%
config/__init__.py 18 4 78%
config/constants.py 2 0 100%
config/core.py 188 6 97%
config/exceptions.py 5 0 100%
config/insurance.py 64 0 100%
config/manufacturer.py 178 0 100%
config/market.py 76 0 100%
config/optimizer.py 34 0 100%
config/presets.py 60 0 100%
config/reporting.py 38 0 100%
config/simulation.py 49 0 100%
config/utils.py 13 0 100%
config_compat.py 22 7 68%
config_loader.py 128 5 96%
config_manager.py 218 12 94%
config_migrator.py 166 13 92%
convergence.py 168 3 98%
convergence_advanced.py 271 0 100%
convergence_plots.py 308 4 99%
decimal_utils.py 50 3 94%
decision_engine.py 886 19 98%
ergodic_analyzer.py 117 1 99%
ergodic_types.py 123 0 100%
examples/__init__.py 0 0 100%
examples/__main__.py 9 9 0%
examples/benchmark_parallel.py 142 142 0%
examples/demo_claim_development.py 120 120 0%
examples/demo_collateral_management.py 79 79 0%
examples/demo_config_practical.py 167 167 0%
examples/demo_config_v2.py 155 155 0%
examples/demo_excel_reports.py 105 105 0%
examples/demo_insurance_pricing.py 183 183 0%
examples/demo_manufacturer.py 69 69 0%
examples/demo_stochastic.py 144 144 0%
examples/improved_retention_optimization.py 129 129 0%
examples/simple_retention_optimization.py 114 114 0%
examples/test_notebook_comprehensive.py 113 1 99%
examples/test_notebook_fixes.py 57 5 91%
examples/test_smart_annotations.py 97 2 98%
excel_reporter.py 503 16 97%
exposure_base.py 267 6 98%
financial_statements.py 787 16 98%
gpu_backend.py 88 4 95%
gpu_mc_engine.py 320 12 96%
gpu_objective.py 251 13 95%
hjb_quadrature.py 248 5 98%
hjb_solver.py 928 38 96%
insurance.py 118 0 100%
insurance_accounting.py 104 0 100%
insurance_pricing.py 299 9 97%
insurance_program.py 601 12 98%
integrated_analysis.py 101 0 100%
internals.py 4 0 100%
ledger.py 359 2 99%
loss_distributions.py 424 3 99%
manufacturer.py 402 26 94%
manufacturer_balance_sheet.py 350 15 96%
manufacturer_claims.py 354 14 96%
manufacturer_income.py 96 10 90%
manufacturer_metrics.py 130 5 96%
manufacturer_solvency.py 208 10 95%
monte_carlo.py 793 13 98%
monte_carlo_worker.py 89 0 100%
optimal_control.py 311 5 98%
optimization.py 334 2 99%
parallel_executor.py 322 21 93%
parameter_sweep.py 303 9 97%
pareto_frontier.py 376 13 97%
performance_optimizer.py 274 14 95%
progress_monitor.py 174 3 98%
reporting/__init__.py 10 0 100%
reporting/cache_manager.py 440 4 99%
reporting/config.py 92 0 100%
reporting/executive_report.py 185 0 100%
reporting/formatters.py 227 0 100%
reporting/insight_extractor.py 219 0 100%
reporting/report_builder.py 223 6 97%
reporting/scenario_comparator.py 242 2 99%
reporting/table_generator.py 254 1 99%
reporting/technical_report.py 173 0 100%
reporting/validator.py 211 0 100%
result_aggregator.py 246 4 98%
risk_metrics.py 461 26 94%
ruin_probability.py 290 0 100%
safe_pickle.py 101 1 99%
scenario_analysis.py 65 0 100%
scenario_manager.py 162 1 99%
sensitivity.py 278 7 97%
sensitivity_visualization.py 184 1 99%
simulation.py 307 0 100%
statistical_tests.py 165 14 92%
stochastic_processes.py 73 0 100%
strategy_backtester.py 199 0 100%
summary_statistics.py 516 10 98%
tax_handler.py 105 7 93%
tests/__init__.py 0 0 100%
tests/conftest.py 36 2 94%
tests/integration/__init__.py 0 0 100%
tests/integration/test_claim_development_wrapper.py 19 0 100%
tests/integration/test_critical_integrations.py 428 104 76%
tests/integration/test_financial_integration.py 180 3 98%
tests/integration/test_fixtures.py 152 56 63%
tests/integration/test_helpers.py 163 114 30%
tests/integration/test_insurance_stack.py 249 1 99%
tests/integration/test_parallel_worker.py 10 0 100%
tests/integration/test_simulation_pipeline.py 311 76 76%
tests/test_accrual_integration.py 149 0 100%
tests/test_accrual_manager.py 252 0 100%
tests/test_accuracy_validator.py 322 0 100%
tests/test_adaptive_stopping.py 245 6 98%
tests/test_autocorrelation_fft_380.py 116 36 69%
tests/test_balance_sheet_cash_depreciation.py 150 0 100%
tests/test_balance_sheet_classification.py 109 0 100%
tests/test_batch_processor.py 344 0 100%
tests/test_batch_processor_coverage.py 272 0 100%
tests/test_benchmarking.py 348 293 16%
tests/test_bootstrap.py 416 0 100%
tests/test_bootstrap_analysis_coverage.py 108 0 100%
tests/test_bootstrap_ci_seed_bug400.py 23 0 100%
tests/test_business_optimizer.py 388 0 100%
tests/test_cache_manager.py 530 36 93%
tests/test_capex.py 145 0 100%
tests/test_cash_flow_statement.py 136 0 100%
tests/test_cash_reconciliation.py 116 0 100%
tests/test_claim_development.py 776 26 97%
tests/test_claim_reestimation_ledger.py 191 0 100%
tests/test_closing_entry_depreciation.py 163 0 100%
tests/test_cogs_opex_ledger_entries.py 113 0 100%
tests/test_config.py 243 0 100%
tests/test_config_compat.py 74 2 97%
tests/test_config_loader.py 228 1 99%
tests/test_config_manager.py 256 1 99%
tests/test_config_manager_coverage.py 201 0 100%
tests/test_config_manager_security.py 106 0 100%
tests/test_config_migrator.py 109 7 94%
tests/test_config_v2.py 348 0 100%
tests/test_config_v2_integration.py 24 0 100%
tests/test_config_validation.py 112 0 100%
tests/test_convergence_advanced.py 190 9 95%
tests/test_convergence_advanced_coverage.py 198 0 100%
tests/test_convergence_bug350.py 77 1 99%
tests/test_convergence_bug396.py 49 0 100%
tests/test_convergence_bug476.py 69 0 100%
tests/test_convergence_ess.py 250 9 96%
tests/test_convergence_extended.py 203 1 99%
tests/test_convergence_plots.py 177 0 100%
tests/test_coverage_gaps_batch1.py 299 0 100%
tests/test_coverage_gaps_batch2.py 381 0 100%
tests/test_coverage_gaps_batch3.py 364 0 100%
tests/test_coverage_gaps_batch4.py 369 1 99%
tests/test_coverage_gaps_parallel_executor.py 375 0 100%
tests/test_decision_engine.py 772 0 100%
tests/test_decision_engine_edge_cases.py 323 2 99%
tests/test_decision_engine_scenarios.py 197 5 97%
tests/test_deep_copy.py 252 0 100%
tests/test_depreciation_tracking.py 169 3 98%
tests/test_dividend_ledger_entries.py 143 5 97%
tests/test_dividend_phantom_payments.py 194 1 99%
tests/test_dta_dtl_and_capex.py 196 0 100%
tests/test_dta_valuation_allowance.py 254 0 100%
tests/test_dynamic_premium_scaling.py 109 0 100%
tests/test_end_to_end.py 191 41 79%
tests/test_equity_consistency.py 90 1 99%
tests/test_ergodic_analyzer.py 222 0 100%
tests/test_ergodic_analyzer_coverage.py 383 0 100%
tests/test_excel_reporter.py 278 6 98%
tests/test_execution_semantics.py 204 0 100%
tests/test_executive_visualizations.py 259 1 99%
tests/test_exposure_base.py 248 0 100%
tests/test_exposure_base_coverage.py 211 0 100%
tests/test_facility_limit_insolvency.py 368 4 99%
tests/test_figure_factory.py 347 0 100%
tests/test_financial_statements.py 541 3 99%
tests/test_financial_statements_coverage.py 320 0 100%
tests/test_fixtures.py 87 28 68%
tests/test_going_concern.py 373 0 100%
tests/test_gpu_backend.py 263 0 100%
tests/test_gpu_cpu_parity.py 77 0 100%
tests/test_gpu_mc_engine.py 407 0 100%
tests/test_gpu_objective.py 380 1 99%
tests/test_hjb_numerical.py 1119 0 100%
tests/test_hjb_quadrature.py 537 1 99%
tests/test_hjb_solver.py 1099 6 99%
tests/test_imports.py 90 3 97%
tests/test_industry_configs.py 150 0 100%
tests/test_industry_switching.py 94 0 100%
tests/test_insight_extractor.py 313 4 99%
tests/test_insurance.py 289 0 100%
tests/test_insurance_accounting.py 151 0 100%
tests/test_insurance_coverage.py 77 0 100%
tests/test_insurance_pricing.py 538 0 100%
tests/test_insurance_pricing_coverage.py 125 0 100%
tests/test_insurance_program.py 865 10 99%
tests/test_insurance_program_coverage.py 269 0 100%
tests/test_integration.py 245 38 84%
tests/test_issue_355_ruin_attribution.py 106 0 100%
tests/test_issue_357.py 131 0 100%
tests/test_jackknife_and_multi_bootstrap.py 146 0 100%
tests/test_lae_tracking.py 189 0 100%
tests/test_layer_pricing.py 225 0 100%
tests/test_ledger.py 463 0 100%
tests/test_ledger_coverage.py 119 0 100%
tests/test_limit_types.py 147 0 100%
tests/test_loss_cost_trends.py 99 0 100%
tests/test_loss_distributions.py 532 12 98%
tests/test_loss_distributions_coverage.py 111 0 100%
tests/test_manufacturer.py 794 2 99%
tests/test_manufacturer_coverage.py 212 2 99%
tests/test_manufacturer_methods.py 320 0 100%
tests/test_metrics_double_tax.py 82 0 100%
tests/test_misc_gaps_coverage.py 676 2 99%
tests/test_monte_carlo.py 560 96 83%
tests/test_monte_carlo_coverage.py 628 3 99%
tests/test_monte_carlo_extended.py 190 13 93%
tests/test_monte_carlo_parallel.py 211 7 97%
tests/test_monte_carlo_trajectory_storage.py 86 0 100%
tests/test_monte_carlo_worker_config.py 212 0 100%
tests/test_nb07_basis_reconciliation.py 57 0 100%
tests/test_nb07_sensitivity.py 138 5 96%
tests/test_negative_cash_reclassification.py 143 0 100%
tests/test_nol_carryforward.py 313 0 100%
tests/test_optimal_control.py 327 0 100%
tests/test_optimization.py 410 14 97%
tests/test_optimization_coverage.py 136 4 97%
tests/test_optimizer_config.py 110 0 100%
tests/test_parallel_executor.py 304 173 43%
tests/test_parallel_executor_coverage.py 344 71 79%
tests/test_parallel_independence.py 112 0 100%
tests/test_parameter_combinations.py 303 20 93%
tests/test_parameter_sweep.py 283 8 97%
tests/test_pareto_frontier.py 183 1 99%
tests/test_pareto_frontier_coverage.py 171 1 99%
tests/test_performance.py 329 271 18%
tests/test_performance_optimizer.py 416 2 99%
tests/test_periodic_ruin_tracking.py 119 0 100%
tests/test_premium_amortization.py 97 0 100%
tests/test_pricing_scenarios.py 126 0 100%
tests/test_print_warnings_382.py 230 2 99%
tests/test_progress_callback.py 121 0 100%
tests/test_progress_monitor.py 228 0 100%
tests/test_progress_monitor_coverage.py 153 0 100%
tests/test_properties.py 107 0 100%
tests/test_recovery_accounting.py 203 0 100%
tests/test_report_builder_security.py 179 8 96%
tests/test_report_generation.py 367 21 94%
tests/test_reporting_coverage.py 878 7 99%
tests/test_reserve_development.py 286 0 100%
tests/test_result_aggregation.py 606 1 99%
tests/test_result_aggregator_coverage.py 133 0 100%
tests/test_retention_calculation.py 177 0 100%
tests/test_revenue_ar_accrual.py 85 0 100%
tests/test_risk_metrics.py 473 15 97%
tests/test_risk_metrics_coverage.py 487 0 100%
tests/test_roe_insurance.py 168 0 100%
tests/test_ruin_probability.py 331 10 97%
tests/test_ruin_probability_coverage.py 123 0 100%
tests/test_ruin_reason.py 96 0 100%
tests/test_run_analysis.py 248 0 100%
tests/test_safe_pickle_coverage.py 310 0 100%
tests/test_scenario_batch.py 339 14 96%
tests/test_scenario_comparator.py 188 0 100%
tests/test_scenario_manager.py 290 0 100%
tests/test_sensitivity.py 272 0 100%
tests/test_sensitivity_coverage.py 204 1 99%
tests/test_sensitivity_visualization.py 176 0 100%
tests/test_setup.py 29 2 93%
tests/test_shared_memory_hmac.py 134 0 100%
tests/test_simulation.py 302 6 98%
tests/test_simulation_coverage.py 504 1 99%
tests/test_sir_collateral_mode.py 99 0 100%
tests/test_skipped_slow_tests.py 163 131 20%
tests/test_std_ddof1_bug478.py 66 0 100%
tests/test_stochastic.py 215 0 100%
tests/test_stochastic_claim_development.py 228 0 100%
tests/test_strategy_backtester_coverage.py 455 0 100%
tests/test_summary_statistics_coverage.py 707 0 100%
tests/test_table_generation.py 290 3 99%
tests/test_tax_handling.py 251 0 100%
tests/test_tax_nol_mutation_guard.py 104 0 100%
tests/test_technical_plots.py 448 3 99%
tests/test_trajectory_storage.py 341 21 94%
tests/test_trends.py 354 2 99%
tests/test_typed_scenario_results.py 221 0 100%
tests/test_validation_metrics_coverage.py 104 0 100%
tests/test_visualization.py 223 0 100%
tests/test_visualization_comprehensive.py 386 0 100%
tests/test_visualization_extended.py 517 3 99%
tests/test_visualization_factory.py 374 0 100%
tests/test_visualization_gaps_coverage.py 969 2 99%
tests/test_visualization_namespace.py 201 0 100%
tests/test_visualization_simple.py 189 1 99%
tests/test_walk_forward.py 497 23 95%
tests/test_working_capital_calculation.py 144 1 99%
tests/test_working_capital_changes.py 100 0 100%
tests/test_working_capital_timing.py 75 0 100%
trajectory_storage.py 242 3 99%
trends.py 197 3 98%
validation_metrics.py 124 0 100%
visualization/__init__.py 25 0 100%
visualization/annotations.py 283 11 96%
visualization/batch_plots.py 206 0 100%
visualization/core.py 70 0 100%
visualization/executive_plots.py 813 21 97%
visualization/export.py 97 5 95%
visualization/figure_factory.py 295 33 89%
visualization/improved_tower_plot.py 153 153 0%
visualization/interactive_plots.py 83 0 100%
visualization/style_manager.py 181 6 97%
visualization/technical_plots.py 811 42 95%
visualization_infra/__init__.py 3 0 100%
visualization_infra/figure_factory.py 254 9 96%
visualization_infra/style_manager.py 180 0 100%
visualization_legacy.py 678 678 0%
walk_forward_validator.py 396 16 96%
TOTAL 80568 4980 94%

Coverage threshold (80%): PASSED

The Part-10b ruin-path figure in 07_hjb_insurance_optimization.ipynb
wrapped its plt.subplots(...) call across two lines with dpi=150 on the
continuation line. test_nb07_sensitivity.test_every_figure_creation_sets_dpi_150
scans line-by-line and requires dpi=150 on the same physical line as the
plt.subplots( call, so it flagged this as the only test failure in CI.
Move dpi=150 onto the subplots line (net zero-char change). No other
figure-creation call in the notebook is affected.
@AlexFiliakov AlexFiliakov merged commit e5e21bf into main Jun 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant