JEDI / jedi /command /control.py
FerrellSyntheticIntelligence's picture
Upload jedi/command/control.py with huggingface_hub
146185a verified
Raw
History Blame Contribute Delete
5.25 kB
"""
JEDI Mission Control — Human operator interface.
The Mission Control is the operator's dashboard for:
- Creating and managing missions
- Deploying and monitoring nanobots
- Reviewing intelligence
- Making authorization decisions
- Emergency shutdown
"""
import json
import time
from typing import Dict, List, Optional
from ..core.engine import JEDIEngine, EngineState
from ..core.mission import Mission, MissionStatus
class MissionControl:
def __init__(self, engine: Optional[JEDIEngine] = None):
self.engine = engine or JEDIEngine()
self.operation_log = []
self.alerts = []
def new_mission(self, name: str, mission_type: str, target: Dict, objectives: List[str],
operator_id: str, jurisdiction: str, auth_ref: str) -> Dict:
"""Create a new mission through Mission Control."""
# Build authorization
from ..legal.gate import LegalGate, AuthorizationLevel
gate = LegalGate()
# Map mission types to authorization levels
level_map = {
"recon": AuthorizationLevel.RECON,
"defense": AuthorizationLevel.DEFEND,
"pentest": AuthorizationLevel.OFFEND,
"offense": AuthorizationLevel.OFFEND,
"attribution": AuthorizationLevel.ATTRIBUTION,
"sweep": AuthorizationLevel.RECON,
"forensics": AuthorizationLevel.OBSERVE,
}
auth = gate.create_authorization(
operator_id=operator_id,
level=level_map.get(mission_type, AuthorizationLevel.RECON),
jurisdiction=jurisdiction,
written_auth_ref=auth_ref,
mission_type=mission_type,
target=target,
)
# Build mission config
config = {
"name": name,
"type": mission_type,
"target": target,
"objectives": objectives,
"authorization": auth,
"roe": {
"proportionality_acknowledged": True,
"distinction_acknowledged": True,
"necessity_acknowledged": True,
}
}
mission = Mission(config)
mission.authorize(auth)
self._log(f"Mission '{name}' created: {mission.id}")
return {
"mission_id": mission.id,
"name": name,
"status": mission.status.value,
"authorization": auth,
"objectives": objectives,
}
def deploy_nanobot(self, mission_id: str, nanobot_type: str, target: Dict) -> Dict:
"""Deploy a nanobot to a mission target."""
result = self.engine.deploy_nanobot(nanobot_type, mission_id, target)
self._log(f"Deployed {nanobot_type} nanobot to mission {mission_id}")
return result
def deploy_swarm(self, mission_id: str, swarm_config: Dict) -> Dict:
"""Deploy a coordinated swarm of nanobots."""
from ..swarm.coordinator import SwarmCoordinator
swarm = SwarmCoordinator(f"swarm_{mission_id}")
deployed = []
for bot_config in swarm_config.get("nanobots", []):
result = self.deploy_nanobot(
mission_id,
bot_config.get("type", "scout"),
bot_config.get("target", {})
)
if "error" not in result:
swarm.add_member(result["bot_id"], bot_config.get("type", "scout"))
deployed.append(result)
return {
"swarm_id": swarm.swarm_id,
"deployed": deployed,
"total": len(deployed),
"status": "deployed" if deployed else "failed",
}
def get_sitrep(self) -> Dict:
"""Get a full situation report."""
return self.engine.get_situation_report()
def emergency_shutdown(self, reason: str, operator_id: str) -> Dict:
"""Execute emergency shutdown."""
self.engine.emergency_shutdown(reason)
self._log(f"EMERGENCY SHUTDOWN by {operator_id}: {reason}")
return {
"status": "shutdown",
"reason": reason,
"operator": operator_id,
"timestamp": time.time(),
}
def get_audit_trail(self) -> List[Dict]:
"""Get the full audit trail from all JEDI systems."""
engine_ledger = self.engine.ledger.export()
return engine_ledger
def _log(self, message: str):
self.operation_log.append({
"message": message,
"timestamp": time.time(),
})
def dashboard(self) -> Dict:
"""Generate dashboard overview."""
sitrep = self.get_sitrep()
return {
"engine_state": sitrep["engine_state"],
"threat_level": sitrep["threat_level"],
"active_missions": sitrep["active_missions"],
"deployed_nanobots": sitrep["deployed_nanobots"],
"uptime_hours": round(sitrep["uptime_seconds"] / 3600, 2),
"total_actions": sum(
d.get("actions", 0) for d in sitrep.get("mission_details", {}).values()
),
"alerts": self.alerts[-5:] if self.alerts else [],
}