
    >~j                    *   d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ  ej        e          Zedd            Z ede	de          Ze                    ddg          dd            Ze                    e           dS )u   FastAPI application entrypoint.

Lifespan opens the DB pool and runs migrations before uvicorn accepts
connections — so a fresh container bootstraps its schema upgrade-ably and
does not have a "cold pool just before the first request" race.
    )annotationsN)asynccontextmanager)FastAPI__version__)router)db)setup_loggingappr   c               P  K   t                       t                              dt                     	 t	          j                     d {V  t	          j                     d {V }|r/t                              dd                    |                     nt                              d           n*# t          $ r t          	                    d           Y nw xY wd W V  	 t	          j
                     d {V  d S # t          $ r  t                              dd           Y d S w xY w)	Nz)city briefing agent starting (version %s)zmigrations applied: %sz, zmigrations up to datez:DB bootstrap failed; continuing without migrations appliedzdb close failedT)exc_info)r
   loggerinfor   r	   openmigratejoin	Exception	exceptionclosedebug)r   applieds     a/Users/abstractioneditor2/ai-workstation/projects/automation/show-city-briefing-agent/app/main.pylifespanr      sG     OOO
KK;[IIIWgii
$$$$$$ 	1KK0$))G2D2DEEEEKK/000 W W WUVVVVVW	EEEE7hjj 7 7 7&6666667s$   A=B0 0$CC C; ;&D%$D%u!   Max Amini — City Briefing Agentu   Daily pipeline: discover shows 7 days out → city intel → news → fact check → 20 GPT-4o crowd-work ideas → Claude top-10 → HTML → VPS → verify URL + Open Graph. Phase 12 — no email delivery.)titleversiondescriptionr   z/healthhealth)tagsreturndict[str, str]c                    K   dt           dS )Nok)statusr   r        r   r   r   7   s      {333r%   )r   r   )r   r    )__doc__
__future__r   logging
contextlibr   fastapir   r   r   app.api.routes_briefr   brief_routerapp.dbr	   app.loggingr
   	getLogger__name__r   r   getr   include_routerr$   r%   r   <module>r3      sC    # " " " " "  * * * * * *             7 7 7 7 7 7       % % % % % %		8	$	$ 7 7 7 7& g
-	C 	 	 	 ($$4 4 4 %$4   <          r%   