[loop-cycle-28] [refactor] Split cascade.py — 1241 lines, largest module in codebase #1437

Closed
opened 2026-03-24 13:28:19 +00:00 by Timmy · 0 comments
Owner

Priority: High
Impact: Memory optimization and modularity for core routing infrastructure

Context:
cascade.py (1241 lines) is the largest module in the codebase and handles critical routing logic. This creates memory allocation hotspots and maintenance difficulties.

Proposed Split:

src/infrastructure/router/cascade/
├── __init__.py              # Main CascadeRouter class
├── provider_routing.py      # Provider selection and fallback logic  
├── request_processing.py    # Request transformation and preprocessing
├── response_handling.py     # Response processing and error handling
├── health_monitoring.py     # Provider health checks and scoring
└── memory_optimization.py   # Object pooling and caching logic

Acceptance Criteria:

  • Split 1241-line cascade.py into focused modules (~200 lines each)
  • Preserve all existing API contracts (no breaking changes)
  • Implement object pooling to reduce memory allocation
  • Add unit tests for each new module
  • Verify no performance regression

This is the single most impactful refactor for the codebase.

**Priority:** High **Impact:** Memory optimization and modularity for core routing infrastructure **Context:** cascade.py (1241 lines) is the largest module in the codebase and handles critical routing logic. This creates memory allocation hotspots and maintenance difficulties. **Proposed Split:** ``` src/infrastructure/router/cascade/ ├── __init__.py # Main CascadeRouter class ├── provider_routing.py # Provider selection and fallback logic ├── request_processing.py # Request transformation and preprocessing ├── response_handling.py # Response processing and error handling ├── health_monitoring.py # Provider health checks and scoring └── memory_optimization.py # Object pooling and caching logic ``` **Acceptance Criteria:** - Split 1241-line cascade.py into focused modules (~200 lines each) - Preserve all existing API contracts (no breaking changes) - Implement object pooling to reduce memory allocation - Add unit tests for each new module - Verify no performance regression This is the single most impactful refactor for the codebase.
kimi was assigned by Timmy 2026-03-24 13:28:19 +00:00
kimi was unassigned by Timmy 2026-03-24 19:18:22 +00:00
Timmy closed this issue 2026-03-24 21:54:02 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1437