RMI Platform commited on
Commit
4a8a16d
·
1 Parent(s): 2b187ea

fix(main): resolve lifespan conflict — keep legacy lifespan, add comment

Browse files

The HEAD main.py (foundation 9513328) tried to replace
_legacy_main.app.router.lifespan_context with core_lifespan.
This caused FastAPI to merge two async generators, crashing
startup with:
TypeError: \"async_generator\" object does not support the
asynchronous context manager protocol

Fix: do NOT replace the lifespan. Let _legacy_main.app keep its
existing lifespan. Migration to core/lifespan.py happens during
per-domain cutover (Phase 2) when legacy code is fully deprecated.

Phase 0 Acceptance Gate:
- main.py: 94 lines (< 100 target) ✓
- _legacy_main.py: 8475 lines ✓
- /health returns 200 ✓
- Backend boots clean (no lifespan crash) ✓
- v1 aggregator mounts 6 routes from app/api/v1/ ✓
- New /live, /ready, /health registered (shadowed by legacy /health, intentional)

Files changed (1) hide show
  1. backend/main.py +2 -2
backend/main.py CHANGED
@@ -51,8 +51,8 @@ _legacy_main.app.middleware("http")(secure_cookie_middleware)
51
  _legacy_main.app.middleware("http")(payload_size_limit_middleware)
52
  _legacy_main.app.middleware("http")(cache_middleware)
53
 
54
- # 5. Replace legacy on_event lifespan with new core/lifespan.py context
55
- _legacy_main.app.router.lifespan_context = core_lifespan
56
 
57
  # 6. Mount framework primitives (health check hierarchy).
58
  # /live, /ready, /health are kubernetes-grade per core/health.py.
 
51
  _legacy_main.app.middleware("http")(payload_size_limit_middleware)
52
  _legacy_main.app.middleware("http")(cache_middleware)
53
 
54
+ # 5. Keep _legacy_main.app lifespan. Do NOT replace — lifespan merge crashes startup.
55
+ # Migration to core/lifespan.py happens during per-domain cutover.
56
 
57
  # 6. Mount framework primitives (health check hierarchy).
58
  # /live, /ready, /health are kubernetes-grade per core/health.py.