[loop-cycle-1] refactor: split cascade.py into focused modules (#1342) (#1448)
Some checks failed
Tests / lint (push) Failing after 8s
Tests / test (push) Has been skipped

This commit was merged in pull request #1448.
This commit is contained in:
2026-03-24 18:39:06 +00:00
parent 008663ae58
commit 8a7a34499c
5 changed files with 622 additions and 552 deletions

View File

@@ -677,7 +677,7 @@ class TestVllmMlxProvider:
router.providers = [provider]
# Quota monitor downshifts to local (ACTIVE tier) — vllm_mlx should still be tried
with patch("infrastructure.router.cascade._quota_monitor") as mock_qm:
with patch("infrastructure.router.health._quota_monitor") as mock_qm:
mock_qm.select_model.return_value = "qwen3:14b"
mock_qm.check.return_value = None
@@ -713,7 +713,7 @@ class TestMetabolicProtocol:
router = CascadeRouter(config_path=Path("/nonexistent"))
router.providers = [self._make_anthropic_provider()]
with patch("infrastructure.router.cascade._quota_monitor") as mock_qm:
with patch("infrastructure.router.health._quota_monitor") as mock_qm:
# select_model returns cloud model → BURST tier
mock_qm.select_model.return_value = "claude-sonnet-4-6"
mock_qm.check.return_value = None
@@ -732,7 +732,7 @@ class TestMetabolicProtocol:
router = CascadeRouter(config_path=Path("/nonexistent"))
router.providers = [self._make_anthropic_provider()]
with patch("infrastructure.router.cascade._quota_monitor") as mock_qm:
with patch("infrastructure.router.health._quota_monitor") as mock_qm:
# select_model returns local 14B → ACTIVE tier
mock_qm.select_model.return_value = "qwen3:14b"
mock_qm.check.return_value = None
@@ -750,7 +750,7 @@ class TestMetabolicProtocol:
router = CascadeRouter(config_path=Path("/nonexistent"))
router.providers = [self._make_anthropic_provider()]
with patch("infrastructure.router.cascade._quota_monitor") as mock_qm:
with patch("infrastructure.router.health._quota_monitor") as mock_qm:
# select_model returns local 8B → RESTING tier
mock_qm.select_model.return_value = "qwen3:8b"
mock_qm.check.return_value = None
@@ -776,7 +776,7 @@ class TestMetabolicProtocol:
)
router.providers = [provider]
with patch("infrastructure.router.cascade._quota_monitor") as mock_qm:
with patch("infrastructure.router.health._quota_monitor") as mock_qm:
mock_qm.select_model.return_value = "qwen3:8b" # RESTING tier
with patch.object(router, "_call_ollama") as mock_call:
@@ -793,7 +793,7 @@ class TestMetabolicProtocol:
router = CascadeRouter(config_path=Path("/nonexistent"))
router.providers = [self._make_anthropic_provider()]
with patch("infrastructure.router.cascade._quota_monitor", None):
with patch("infrastructure.router.health._quota_monitor", None):
with patch.object(router, "_call_anthropic") as mock_call:
mock_call.return_value = {"content": "Cloud response", "model": "claude-sonnet-4-6"}
result = await router.complete(
@@ -1200,7 +1200,7 @@ class TestCascadeTierFiltering:
async def test_frontier_required_uses_anthropic(self):
router = self._make_router()
with patch("infrastructure.router.cascade._quota_monitor", None):
with patch("infrastructure.router.health._quota_monitor", None):
with patch.object(router, "_call_anthropic") as mock_call:
mock_call.return_value = {
"content": "frontier response",
@@ -1464,7 +1464,7 @@ class TestTrySingleProvider:
router = self._router()
provider = self._provider(ptype="anthropic")
errors: list[str] = []
with patch("infrastructure.router.cascade._quota_monitor") as mock_qm:
with patch("infrastructure.router.health._quota_monitor") as mock_qm:
mock_qm.select_model.return_value = "qwen3:14b" # non-cloud → ACTIVE tier
mock_qm.check.return_value = None
result = await router._try_single_provider(