# app/state.py from typing import Optional from app.logging_setup import get_engine_logger _engine_singleton = None def set_rules_engine(engine) -> None: """Install the process-global rules engine.""" global _engine_singleton _engine_singleton = engine get_engine_logger().info("[state] engine set id=%s count=%s", hex(id(engine)), len(getattr(engine, "rules", []))) def get_rules_engine() -> Optional[object]: """Return the process-global rules engine, or None if not set yet.""" return _engine_singleton