fix simulation reporting and research resilience

This commit is contained in:
2026-09-28 15:43:23 +08:00
parent 23297be2d7
commit a428214c53
25 changed files with 1488 additions and 244 deletions
+8 -3
View File
@@ -1,5 +1,6 @@
from __future__ import annotations
from fastapi import APIRouter, Request, HTTPException
from fastapi import APIRouter, Request, HTTPException
from app.services.narrator import REPORT_SCHEMA_VERSION
router = APIRouter(prefix="/api")
@@ -18,8 +19,12 @@ async def get_gallery_item(sim_id: str, request: Request):
raise HTTPException(404, "Simulation not found in gallery")
await store.increment_view_count(sim_id)
cached = await store.get_report(sim_id)
if cached and cached.get("status") == "ready":
return cached["report"]
if (
cached
and cached.get("status") == "ready"
and cached.get("report", {}).get("report_schema_version") == REPORT_SCHEMA_VERSION
):
return cached["report"]
narrator = request.app.state.narrator
report = await narrator.generate_report(sim_id, store)
if "error" not in report: