Spaces:
Runtime error
Runtime error
File size: 3,094 Bytes
1ffd0a4 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | """
Hard-coded constants for CIRO's deterministic decision logic.
What lives here
---------------
Constants that are NOT meant to be tuned per request or per environment β
they encode product decisions about how CIRO classifies and responds to
crises. Putting them in one module keeps risk-tiering, planning, and
the UI in lockstep about which types map to which tier.
What does NOT live here
-----------------------
Environment-driven config (API keys, feature flags, ports) β that
belongs in `core/config.py` (pydantic-settings). If a value is something
ops would change, it goes there, not here.
"""
from __future__ import annotations
# ββ Risk tiering ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#
# These sets define the response path a crisis takes after detection:
#
# LOW_RISK_TYPES β automated response (reroute, alert), no humans
# MEDIUM_HIGH_RISK_TYPES β requires crowd verification before any
# emergency dispatch
#
# Crisis types not in either set are treated as MEDIUM by the classifier
# (fail-safe default β never silently skip verification for an unknown
# type).
LOW_RISK_TYPES: frozenset[str] = frozenset({
"traffic_jam",
"rainfall",
"road_blockage",
})
MEDIUM_HIGH_RISK_TYPES: frozenset[str] = frozenset({
"flood",
"fire",
"accident",
"building_collapse",
"infrastructure_failure",
"infrastructure", # alias used by the detection taxonomy
"heatwave",
})
# Confidence threshold below which a high-risk crisis is downgraded to
# medium. The intent: "we are not confident enough to skip crowd
# verification, but we are confident enough to investigate further."
# Hard-coded β not configurable per request, per the phase doc's
# architectural constraint.
CONFIDENCE_THRESHOLD: float = 0.6
# ββ NGO escalation ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
#
# Severity score (1-5, from SituationReport) at or above which a confirmed
# crisis is escalated to registered NGOs. Hard-coded per the phase doc.
NGO_ESCALATION_THRESHOLD: int = 3
# Maps crisis type to the NGO categories that are relevant for that type.
# An NGO matches when it has at least one category from this list AND its
# coverage_areas overlap with the crisis location. Any crisis type not in
# this map is treated as requiring "disaster_relief" as a fallback.
NGO_CRISIS_TYPE_MAP: dict[str, list[str]] = {
"flood": ["disaster_relief", "rescue"],
"fire": ["fire_rescue", "medical"],
"accident": ["medical", "rescue"],
"building_collapse": ["rescue", "disaster_relief", "medical"],
"heatwave": ["medical", "community_welfare"],
"infrastructure_failure": ["disaster_relief"],
"infrastructure": ["disaster_relief"], # detection-agent alias
}
|