You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Follow-up to #2 / #5. The module split landed the structural separation (one place for router lifecycle, no cross-file duplication, concern-named files), but two of #2's original goals were deliberately deferred to keep that pass mechanical and behaviour-preserving:
functions are still large (no <40-line target met)
proxy.py is still ~720 lines (the <100-line entry-point target was not met)
As discussed, the current code separates concerns by file but is still only so-so for code search / readability — the big handlers are monoliths, so grepping for a behaviour lands you in the middle of a 240-line function rather than a focused, well-named unit.
Goals
Improve simplification and code-search clarity without behaviour changes (same mechanical discipline as #2: byte-identical logic, verified by AST diff + live smoke test).
Tasks
Split proxy_request (~240 lines in proxy.py) into named, greppable helpers — e.g. dead-worker retry, upstream forward, streaming-response wiring, request/response logging.
Split ChatRouterManager.recover_worker (~190 lines in router_manager.py) into focused steps (probe / cycle / reload / verify).
Slim the proxy.py entry point toward <100 lines by moving chat handlers (proxy_request, embed_forward, models_handler, props_handler) and preset generation (pick_setup, _model_preset_section, write_preset) into dedicated modules.
router_http free-function dedup — extract the repeated auth-header + POST/poll boilerplate in _status / unload / _load_locked into shared helpers (the one Phase-2 item intentionally skipped; care needed to preserve ChatRouterManager's exact _loaded_at timing).
Code-search clarity — consistent section markers, function-level docstrings on the new smaller units, and a short module-map (or expand CLAUDE.md's) so "where does X live" is answerable by grep/symbol search.
Acceptance
No function >40 lines (best effort), proxy.py entry point <100 lines.
Follow-up to #2 / #5. The module split landed the structural separation (one place for router lifecycle, no cross-file duplication, concern-named files), but two of #2's original goals were deliberately deferred to keep that pass mechanical and behaviour-preserving:
<40-line target met)proxy.pyis still ~720 lines (the<100-line entry-point target was not met)As discussed, the current code separates concerns by file but is still only so-so for code search / readability — the big handlers are monoliths, so grepping for a behaviour lands you in the middle of a 240-line function rather than a focused, well-named unit.
Goals
Improve simplification and code-search clarity without behaviour changes (same mechanical discipline as #2: byte-identical logic, verified by AST diff + live smoke test).
Tasks
proxy_request(~240 lines inproxy.py) into named, greppable helpers — e.g. dead-worker retry, upstream forward, streaming-response wiring, request/response logging.ChatRouterManager.recover_worker(~190 lines inrouter_manager.py) into focused steps (probe / cycle / reload / verify).proxy.pyentry point toward<100lines by moving chat handlers (proxy_request,embed_forward,models_handler,props_handler) and preset generation (pick_setup,_model_preset_section,write_preset) into dedicated modules.router_httpfree-function dedup — extract the repeated auth-header + POST/poll boilerplate in_status/unload/_load_lockedinto shared helpers (the one Phase-2 item intentionally skipped; care needed to preserveChatRouterManager's exact_loaded_attiming).CLAUDE.md's) so "where does X live" is answerable by grep/symbol search.Acceptance
>40lines (best effort),proxy.pyentry point<100lines.