Skip to content

Decompose the insurance monolith (~ 3300 LOC) into claim, policy and registry modules #717

Description

@nanaf6203-bit

Problem Statement

contracts/insurance/src/lib.rs mixes premium calculation, claim evidence handling, fraud detection, risk assessment, Sybil heuristics, premium property tests, and lazy reinsurance in one ~3300-line file.

Why it matters

Insurance has the highest gas surface and audit complexity in the workspace; the monolith blocks unit-level coverage targets and complicates independent verifier reviews.

Technical Context

  • mod premium_engine — premium math.
  • mod claim_pipeline — claim submission + evidence.
  • mod fraud_detection — fraud heuristics.
  • mod risk_assessment — risk scoring.
  • mod sybil_defense — anti-Sybil mapping.
  • mod lazy_reinsurance — quarterly reinsurance lookups.

Expected Outcome

  • Each sub-module has its own message group.
  • Sub-modules are randomly accessible via contract.feature_x() calls.
  • Public API surface unchanged.
  • Storage layout preserved or migrated via documented mapping.

Acceptance Criteria

  1. Every existing #[ink::test] continues to pass.
  2. Each sub-module independently exports at least one message.
  3. cargo doc --no-deps renders an unambiguous doc-tree.
  4. cargo clippy reduces warnings materially (target: ≥ 30 fewer).

Implementation Notes

Split by message-level boundaries: each sub-module owns its storage map and re-exports. Use storage::Mapping::default() defaults for non-init constructors.

Files or modules likely to be affected

contracts/insurance/src/lib.rs, new split files.

Dependencies

#3 (do the same for property-management first to learn).

Difficulty level

HARD.

Estimated effort

XL (~3 engineer-weeks).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions