This commit is contained in:
LASTA_DEV01\lasta
2026-05-19 20:31:52 +09:00
parent 00407e7a08
commit e260e5f218
104 changed files with 12898 additions and 1709 deletions

View File

@@ -44,7 +44,6 @@ from ont_platform.api.deps import ( # noqa: E402
get_app_context,
initialize_app_context,
)
from ont_platform.api.routes import extraction_router # noqa: E402
platform_config = importlib.import_module("ont_platform.config")
@@ -78,6 +77,49 @@ ONTOCAST_VERSION = _resolve_ontocast_version()
PLATFORM_VERSION = "0.0.1"
def _include_phase_routers(app: FastAPI) -> None:
"""Attach routers whose dependencies are enabled for the configured phase."""
settings = platform_config.load_settings()
enabled_routes: list[str] = []
if settings.phase >= platform_config.Phase.TRAFILATURA:
try:
from ont_platform.api.routes import get_extraction_router
except ImportError as exc:
raise RuntimeError(
"Phase 1 route loading requires the Phase 1 extraction dependencies. "
"Install the Phase 1 dependency set or run with PHASE=0."
) from exc
app.include_router(get_extraction_router())
enabled_routes.append("extraction")
if settings.phase >= platform_config.Phase.CANDIDATE_REVIEW:
from ont_platform.api.routes import get_review_router
app.include_router(get_review_router())
enabled_routes.append("review")
if settings.phase >= platform_config.Phase.CRAWL4AI:
from ont_platform.api.routes import get_crawl_router
app.include_router(get_crawl_router())
enabled_routes.append("crawl")
if settings.phase >= platform_config.Phase.NEO4J_GRAPHRAG:
from ont_platform.api.routes import get_graph_router
app.include_router(get_graph_router())
enabled_routes.append("graph")
if settings.phase >= platform_config.Phase.MULTI_AGENT:
from ont_platform.api.routes import get_maintenance_router
app.include_router(get_maintenance_router())
enabled_routes.append("maintenance")
app.state.enabled_phase_routes = enabled_routes
@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
"""FastAPI lifespan: build ToolBox + workflow once on startup."""
@@ -369,8 +411,7 @@ def create_app() -> FastAPI:
},
)
# ─── Phase 0 routes ───────────────────────────────────────────────
app.include_router(extraction_router)
_include_phase_routers(app)
return app