103 lines
2.5 KiB
Python
103 lines
2.5 KiB
Python
from backend.events.bus import EventBus
|
|
from backend.metrics.observability import ObservabilityHub
|
|
from backend.metrics.node_state import NodeStateRegistry
|
|
|
|
from backend.api.build import build_endpoint
|
|
from backend.api.debugger import debugger_endpoint
|
|
from backend.api.replay import replay_endpoint
|
|
from backend.api.timeline import timeline_endpoint
|
|
from backend.api.nodes import nodes_endpoint
|
|
from backend.api.metrics import metrics_endpoint
|
|
from backend.api.autopsy import autopsy_endpoint
|
|
from backend.api.pipeline_control import pipeline_control_endpoint
|
|
from backend.api.ws import WebSocketStream
|
|
|
|
from backend.analysis.cause_graph import CauseGraphEngine
|
|
|
|
cause_graph = CauseGraphEngine()
|
|
|
|
# attach it to event bus stream
|
|
bus.subscribe(cause_graph.ingest)
|
|
|
|
|
|
|
|
from backend.analysis.cause_graph import CauseGraphEngine
|
|
|
|
cause_graph = CauseGraphEngine()
|
|
|
|
bus.subscribe(cause_graph.ingest)
|
|
|
|
# optional: also stream debug traces to UI
|
|
bus.subscribe(lambda e: cause_graph.emit_debug(e))
|
|
|
|
# =========================================================
|
|
# GLOBAL CORE SYSTEM INITIALIZATION (SINGLETON LAYER)
|
|
# =========================================================
|
|
|
|
bus = EventBus()
|
|
registry = NodeStateRegistry()
|
|
|
|
observability = ObservabilityHub(registry, bus)
|
|
observability.attach_bus()
|
|
|
|
ws_stream = WebSocketStream()
|
|
ws_stream.attach_bus(bus)
|
|
|
|
|
|
# =========================================================
|
|
# API REGISTRATION LAYER
|
|
# =========================================================
|
|
# (kept explicit so Cockpit / external callers can bind cleanly)
|
|
|
|
def build(spec, nodes, cluster=None, intelligence=None):
|
|
return build_endpoint(spec, nodes, cluster, intelligence)
|
|
|
|
|
|
def replay(session_id):
|
|
return replay_endpoint(session_id, registry)
|
|
|
|
|
|
def debugger(session_id):
|
|
return debugger_endpoint(session_id, registry, bus)
|
|
|
|
|
|
def timeline(session_id):
|
|
return timeline_endpoint(session_id)
|
|
|
|
|
|
def nodes():
|
|
return nodes_endpoint(registry)
|
|
|
|
|
|
def metrics():
|
|
return metrics_endpoint(registry)
|
|
|
|
|
|
def autopsy(session_id):
|
|
return autopsy_endpoint(session_id)
|
|
|
|
|
|
def pipeline_control(action, payload=None):
|
|
return pipeline_control_endpoint(action, payload, bus)
|
|
|
|
|
|
# =========================================================
|
|
# OPTIONAL: expose core objects for internal modules
|
|
# =========================================================
|
|
|
|
__all__ = [
|
|
"bus",
|
|
"registry",
|
|
"observability",
|
|
"ws_stream",
|
|
|
|
"build",
|
|
"replay",
|
|
"debugger",
|
|
"timeline",
|
|
"nodes",
|
|
"metrics",
|
|
"autopsy",
|
|
"pipeline_control",
|
|
]
|