diff --git a/.codex-plugin/plugin.json b/.codex-plugin/plugin.json index e2ae6c5d..f6e4f867 100644 --- a/.codex-plugin/plugin.json +++ b/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "rag-reviewer", - "version": "0.3.2+codex.9d551e36d655", + "version": "0.3.3+codex.9aa7a5c3958b", "description": "Agentic PR review: hybrid RAG + code graph via MCP, review skills for Codex", "repository": "https://github.com/mimfort/rag_for_git", "license": "MIT", diff --git a/plugin/.claude-plugin/plugin.json b/plugin/.claude-plugin/plugin.json index 5e8b8ae7..70da0947 100644 --- a/plugin/.claude-plugin/plugin.json +++ b/plugin/.claude-plugin/plugin.json @@ -1,5 +1,5 @@ { "name": "rag-reviewer", - "version": "0.3.2", + "version": "0.3.3", "description": "Agentic PR review: hybrid RAG + code graph via MCP, review skills for Claude Code" } diff --git a/plugin/.codex-plugin/plugin.json b/plugin/.codex-plugin/plugin.json index add8c9b3..81e86b26 100644 --- a/plugin/.codex-plugin/plugin.json +++ b/plugin/.codex-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "rag-reviewer", - "version": "0.3.2+codex.9d551e36d655", + "version": "0.3.3+codex.9aa7a5c3958b", "description": "Agentic PR review: hybrid RAG + code graph via MCP, review skills for Codex", "repository": "https://github.com/mimfort/rag_for_git", "license": "MIT", diff --git a/reviewer/web/app.py b/reviewer/web/app.py index 84819503..abdb8c2a 100644 --- a/reviewer/web/app.py +++ b/reviewer/web/app.py @@ -33,12 +33,15 @@ def create_app(settings: Settings) -> FastAPI: """Создать и настроить FastAPI-приложение. - - Инициализирует ReviewHistory и schema (fail-soft: если БД недоступна, - сервер всё равно стартует с предупреждением). + - Инициализирует ReviewHistory; схема создаётся на старте сервера в lifespan + (fail-soft: если БД недоступна, сервер всё равно стартует с предупреждением). - Монтирует API-роутер (/api/*). - Монтирует собранный SPA на / (если dist существует) или отдаёт заглушку. - Настраивает CORS для dev-сервера Vite (:5173). - При завершении работы закрывает пул соединений к Postgres. + + Пул Postgres создаётся лениво (init_schema — в lifespan, не в теле фабрики), + поэтому простое конструирование приложения к БД не подключается. """ history = ReviewHistory( settings.pg_dsn, @@ -48,6 +51,16 @@ def create_app(settings: Settings) -> FastAPI: @asynccontextmanager async def _lifespan(app: FastAPI): + # История прогонов: инициализация схемы на старте (fail-soft). + try: + history.init_schema() + except Exception as exc: + log.warning( + "Не удалось инициализировать схему БД истории (%s). " + "Убедитесь, что Postgres запущен: docker compose up -d. " + "API-эндпоинты вернут ошибку 500 до подключения к БД.", + exc, + ) yield history.close() @@ -67,18 +80,7 @@ async def _lifespan(app: FastAPI): allow_headers=["*"], ) - # История прогонов - try: - history.init_schema() - except Exception as exc: - log.warning( - "Не удалось инициализировать схему БД истории (%s). " - "Убедитесь, что Postgres запущен: docker compose up -d. " - "API-эндпоинты вернут ошибку 500 до подключения к БД.", - exc, - ) - - # API-роутер + # API-роутер (схема БД инициализируется в lifespan на старте сервера) app.include_router(make_router(history, settings)) # Статика / SPA