"""Lazy shared expander for card-driven rewrites that lack an agent reference. process_component_event is invoked by agent.py (over the 200-line edit limit, so its call signature is fixed) with no agent handle. Card actions that need a rewrite therefore share one process-wide expander built with the same factory as main.py. """ from __future__ import annotations from typing import Any _EXPANDER: Any = None def shared_expander() -> Any: global _EXPANDER if _EXPANDER is None: from ..resume_expansion import build_expander from ..settings import load_settings _EXPANDER = build_expander(load_settings()) return _EXPANDER