from enum import Enum from dataclasses import dataclass, asdict from typing import Optional, Dict, Any import time class EventType(str, Enum): NODE_UPDATE = "node_update" TASK_UPDATE = "task_update" PIPELINE_UPDATE = "pipeline_update" CACHE_UPDATE = "cache_update" FAILURE = "failure" DEBUG = "debug" REPLAY = "replay" @dataclass class FesterEvent: """ Canonical event used everywhere in the system. """ type: EventType timestamp: float node: Optional[str] action: Optional[str] state: Optional[str] # scheduling + explainability score: Optional[float] = None reason: Optional[str] = None # DAG / execution graph parent: Optional[str] = None target: Optional[str] = None # extensibility (NEVER bypass schema, extend here) meta: Optional[Dict[str, Any]] = None def create_event(**kwargs) -> dict: """ Always use this instead of raw dict events. Guarantees consistency across system. """ if "timestamp" not in kwargs: kwargs["timestamp"] = time.time() return asdict(FesterEvent(**kwargs))