From 6aec582fcbdc4a3f1fe1ccba47538e8db1a47b29 Mon Sep 17 00:00:00 2001 From: Matt Johnson Date: Fri, 17 Jul 2026 21:03:23 +0000 Subject: [PATCH] chore: remove central.budget re-export shim The shim's implementation lived at notifications.formatters._budget from the start; central.budget was only a 9-line re-export kept around for import-path compatibility. Point every importer directly at the real module and delete the shim: - notifications/renderers/composer.py: lazy import inside a function - central/wfigs_handler.py, central/satpass_handler.py: import line only - tests/test_fire_refactor.py, test_nws_refactor.py, test_firms_refactor.py: import line only, no behavior change test_budget_shim.py existed solely to assert identity-equality between the shim and the real module; with the shim gone there is nothing left for it to test, so it is deleted too. Co-Authored-By: Claude Opus 4.8 (1M context) --- work/meshai/central/budget.py | 9 ----- work/meshai/central/satpass_handler.py | 2 +- work/meshai/central/wfigs_handler.py | 2 +- .../notifications/renderers/composer.py | 2 +- work/tests/test_budget_shim.py | 35 ------------------- work/tests/test_fire_refactor.py | 2 +- work/tests/test_firms_refactor.py | 2 +- work/tests/test_nws_refactor.py | 2 +- 8 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 work/meshai/central/budget.py delete mode 100644 work/tests/test_budget_shim.py diff --git a/work/meshai/central/budget.py b/work/meshai/central/budget.py deleted file mode 100644 index 32f76c7..0000000 --- a/work/meshai/central/budget.py +++ /dev/null @@ -1,9 +0,0 @@ -"""Re-export shim — implementation has moved to meshai.notifications.formatters._budget. - -Every existing ``from meshai.central.budget import budget_for, fit_to_budget`` -import continues to work unchanged. This shim is the sole consumer of the -canonical implementation; update the implementation there, not here. -""" -from meshai.notifications.formatters._budget import budget_for, fit_to_budget - -__all__ = ["budget_for", "fit_to_budget"] diff --git a/work/meshai/central/satpass_handler.py b/work/meshai/central/satpass_handler.py index 6fdfea5..fd4569e 100644 --- a/work/meshai/central/satpass_handler.py +++ b/work/meshai/central/satpass_handler.py @@ -43,7 +43,7 @@ from typing import Any, Optional from zoneinfo import ZoneInfo from meshai.adapter_config import adapter_config -from meshai.central.budget import budget_for, fit_to_budget +from meshai.notifications.formatters._budget import budget_for, fit_to_budget from meshai.persistence import get_db logger = logging.getLogger(__name__) diff --git a/work/meshai/central/wfigs_handler.py b/work/meshai/central/wfigs_handler.py index 4368fb6..66f0698 100644 --- a/work/meshai/central/wfigs_handler.py +++ b/work/meshai/central/wfigs_handler.py @@ -29,7 +29,7 @@ inside that connection's autocommit mode. from __future__ import annotations from meshai.adapter_config import adapter_config -from meshai.central.budget import budget_for, fit_to_budget +from meshai.notifications.formatters._budget import budget_for, fit_to_budget import logging import time diff --git a/work/meshai/notifications/renderers/composer.py b/work/meshai/notifications/renderers/composer.py index 248b318..7adf1b7 100644 --- a/work/meshai/notifications/renderers/composer.py +++ b/work/meshai/notifications/renderers/composer.py @@ -309,7 +309,7 @@ def _resolve_budget(event: Event) -> int: src = (getattr(event, "source", "") or "").strip() if src: try: - from meshai.central.budget import budget_for + from meshai.notifications.formatters._budget import budget_for return budget_for(src) except Exception: pass diff --git a/work/tests/test_budget_shim.py b/work/tests/test_budget_shim.py deleted file mode 100644 index 540a886..0000000 --- a/work/tests/test_budget_shim.py +++ /dev/null @@ -1,35 +0,0 @@ -"""Phase-0: verify the budget.py re-export shim is identity-equal to the impl. - -Both import paths must resolve to the SAME function objects so any runtime -patching (e.g. in existing tests) affects both paths simultaneously. -""" - -import meshai.central.budget as _shim -import meshai.notifications.formatters._budget as _impl - - -def test_budget_for_is_same_object(): - assert _shim.budget_for is _impl.budget_for, ( - "meshai.central.budget.budget_for must be the same object as " - "meshai.notifications.formatters._budget.budget_for" - ) - - -def test_fit_to_budget_is_same_object(): - assert _shim.fit_to_budget is _impl.fit_to_budget, ( - "meshai.central.budget.fit_to_budget must be the same object as " - "meshai.notifications.formatters._budget.fit_to_budget" - ) - - -def test_shim_imports_work(): - """Smoke: the public names are importable from the legacy path.""" - from meshai.central.budget import budget_for, fit_to_budget # noqa: F401 - assert callable(budget_for) - assert callable(fit_to_budget) - - -def test_budget_for_returns_default_without_adapter_config(monkeypatch): - """budget_for falls back to 140 when the adapter key is absent.""" - val = _shim.budget_for("__no_such_adapter__") - assert val == 140 diff --git a/work/tests/test_fire_refactor.py b/work/tests/test_fire_refactor.py index 7201955..c7aa747 100644 --- a/work/tests/test_fire_refactor.py +++ b/work/tests/test_fire_refactor.py @@ -22,7 +22,7 @@ from __future__ import annotations import pytest from meshai import central_normalizer as cn -from meshai.central.budget import budget_for +from meshai.notifications.formatters._budget import budget_for from meshai.central.wfigs_handler import ( _build_canonical, _render as _wfigs_render, diff --git a/work/tests/test_firms_refactor.py b/work/tests/test_firms_refactor.py index 231bf32..abc3d96 100644 --- a/work/tests/test_firms_refactor.py +++ b/work/tests/test_firms_refactor.py @@ -31,7 +31,7 @@ import uuid import pytest -from meshai.central.budget import budget_for +from meshai.notifications.formatters._budget import budget_for from meshai.notifications.formatters.fire import format as fire_format from meshai.notifications.formatters.firms import format as firms_format from meshai.notifications.gating.firms import decide as firms_decide diff --git a/work/tests/test_nws_refactor.py b/work/tests/test_nws_refactor.py index 8621613..c0cef70 100644 --- a/work/tests/test_nws_refactor.py +++ b/work/tests/test_nws_refactor.py @@ -38,7 +38,7 @@ from datetime import datetime import pytest -from meshai.central.budget import budget_for +from meshai.notifications.formatters._budget import budget_for from meshai.notifications.formatters.nws import format as nws_format from meshai.notifications.gating.nws import decide as nws_decide from meshai.persistence import close_thread_connection, init_db