resq_mcp.hce.service
HCE - Hybrid Coordination Engine. This module provides incident validation and mission parameter management:- Cross-reference Edge AI reports with other data sources
- Push authorized actions and risk parameters to drones
- Generate blockchain-linked strategy hashes for audit trails
annotations
hashlib
uuid
TYPE_CHECKING
Final
IncidentReport
IncidentValidation
MissionParameters
validate_incident
- Check report confidence level
- If confidence > 0.85: Auto-confirm (high-quality detection)
- If confidence <= 0.85: Cross-reference required
- Cross-reference with (production):
- PDIE pre-alerts (was disaster predicted?)
- Other sector scans (spatial correlation)
- Historical incident patterns
- Ground sensor networks
- Generate validation result with reasoning
- High-quality edge AI models (>95% precision on test set)
- Multi-sensor fusion (visual + thermal + LiDAR)
- Onboard confidence calibration
report- Incident report containing:- incident_id: Unique identifier
- source: Detection origin (edge_ai/human_report/sensor_network)
- sector_id: Geographic location
- detected_type: Incident classification
- confidence: Detection confidence (0.0-1.0)
- evidence_url: Optional IPFS/NeoFS evidence link
IncidentValidation- Validation result with:- incident_id: Original incident ID
- is_confirmed: True if validated, False if rejected
- validation_source: System that performed validation
- notes: Detailed reasoning for decision
Notes: Current implementation uses simple threshold logic. Production would integrate with PDIE correlation engine and multi-source fusion.from resq_mcp.hce.models import IncidentReport report = IncidentReport( … incident_id=“INC-123”, … source=“edge_ai”, … sector_id=“Sector-1”, … detected_type=“wildfire”, … confidence=0.92, … evidence_url=“neofs://evidence/fire_123.mp4” … ) validation = validate_incident(report) if validation.is_confirmed: … print(“Incident confirmed - trigger response”)
update_mission_params
- Each mission linked to blockchain strategy record (immutable audit)
- Authorized actions validated by ResQ-OS security layer on drone
- Risk tolerance enforced by flight controller firmware
- Unauthorized actions rejected before execution
- Authorized actions: What the drone is permitted to do autonomously (e.g., “autonomous_flight”, “payload_release_authorized”)
- Risk tolerance: Maximum acceptable risk (0.0-1.0)
- 0.9 = Urgent missions (aggressive routing, higher speeds)
- 0.5 = Standard missions (conservative, safety-first)
- Strategy hash: Blockchain transaction linking to strategy record (format: “0x” + SHA256 hex digest)
drone_id- Target drone identifier (e.g., “DRONE-Alpha”). Used in production to route parameters to specific unit.strategy_id- Approved strategy identifier from DTSOP (e.g., “STRAT-X1Y2Z3”). Used to generate blockchain hash and determine risk level.
MissionParameters- Complete parameter set with:- mission_id: Unique mission identifier
- target_sector: Assigned operational area
- authorized_actions: List of permitted autonomous actions
- risk_tolerance: Risk threshold (0.0-1.0)
- strategy_hash: Blockchain link (0xHEXDIGITS)
ErrorResponse- Error if drone unavailable or strategy invalid (future).
Blockchain Integration: Strategy hash links to Neo N3 transaction containing:params = update_mission_params( … drone_id=“DRONE-Alpha”, … strategy_id=“STRAT-URGENT-FIRE” … ) if isinstance(params, MissionParameters): … print(f”Mission: {params.mission_id}”) … print(f”Actions: {params.authorized_actions}”) … print(f”Risk: {params.risk_tolerance}”) … print(f”Blockchain: {params.strategy_hash}”)
- Strategy JSON (deployment plan, routes, success rate)
- Simulation proof CID (IPFS/NeoFS evidence)
- Timestamp and approving authority
- Provides immutable audit trail for post-incident review