Skip to main content

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
The current implementation is stubbed for development and returns simulated data.

annotations

hashlib

uuid

TYPE_CHECKING

Final

IncidentReport

IncidentValidation

MissionParameters

validate_incident

def validate_incident(report: IncidentReport) -> IncidentValidation
Cross-reference and validate an incident report from Edge AI or other sources. Part of HCE (Hybrid Coordination Engine) system. Prevents false positives by validating reports against multiple data sources before triggering full response protocols. Validation Process:
  1. Check report confidence level
  • If confidence > 0.85: Auto-confirm (high-quality detection)
  • If confidence <= 0.85: Cross-reference required
  1. Cross-reference with (production):
  • PDIE pre-alerts (was disaster predicted?)
  • Other sector scans (spatial correlation)
  • Historical incident patterns
  • Ground sensor networks
  1. Generate validation result with reasoning
Auto-Confirmation Threshold: Reports with confidence > 0.85 are auto-confirmed because:
  • High-quality edge AI models (>95% precision on test set)
  • Multi-sensor fusion (visual + thermal + LiDAR)
  • Onboard confidence calibration
Arguments:
  • 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
Returns:
  • 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
Example:
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”)
Notes: Current implementation uses simple threshold logic. Production would integrate with PDIE correlation engine and multi-source fusion.

update_mission_params

def update_mission_params(
        drone_id: str,
        strategy_id: str,
        is_urgent: bool = False) -> MissionParameters | ErrorResponse
Push new authorized mission parameters to a specific drone. Part of HCE system. Defines the authorized action space and risk parameters for autonomous drone operations following strategy approval. Security Model:
  • 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
Mission Parameters Include:
  • 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)
Arguments:
  • 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.
Returns:
  • 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).
Example:
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}”)
Blockchain Integration: Strategy hash links to Neo N3 transaction containing:
  • 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
Notes: Current implementation generates mock blockchain hash. Production would submit actual transaction to Neo N3 testnet/mainnet.