Threat Engine
Status & scope
- Module:
lens/threat/ - Milestone: Phase 2 (complete)
Purpose
Risk surface computation: weighted combination of threat layers into a spatiotemporal grid. Flood prediction via D8 flow accumulation. Bio-threat modeling via SIR epidemic simulation.
Public API
compute_risk_surface(layers, bbox, resolution) → RiskSurface
- Weighted composite of threat layers. Each cell: score 0.0–1.0.
compute_flood_extent(dem, precipitation, time_horizon) → FloodExtent
- D8 flow accumulation. Deterministic, explainable (Invariant 6).
- Returns GeoJSON polygon at T+6/12/24h.
compute_multi_base_spread(bases, params) → SpreadResult
- SIR epidemic model across multiple locations with transport links.
Cost Models (2 registered)
| Name | Function |
|---|---|
| risk_as_cost | risk_score × multiplier → traversal penalty |
| exposure_as_cost | exposure_hours / max_acceptable → cost ramp, inf at limit |
File Layout
lens/threat/
__init__.py
surface.py ← RiskSurface, weighted grid composition
flood.py ← D8 flow accumulation, FloodExtent
bio.py ← SIR model, multi-base spread
cost_models.py ← risk_as_cost, exposure_as_cost
Test References
- tests/test_risk_surface.py — weighted grid composition
- tests/test_flood.py — D8 flow, synthetic valley
- tests/test_signals.py — threat signal generation
DO NOT
- Use ML for flood prediction — D8 is deterministic and explainable
- Import platform services — standalone only
Depends on: component.prism.cost-primitives, component.prism.universal-lens-parser
Required by: component.prism.bayesian-posterior-engine