feat(workbench): add dynamic task approval lifecycle

This commit is contained in:
2026-09-24 16:36:12 +08:00
parent db092b0f5e
commit ad813a7c16
35 changed files with 2956 additions and 564 deletions
+3 -20
View File
@@ -5,10 +5,7 @@ from datetime import datetime, timezone
from math import isfinite
from typing import Any
from app.domain.schemas.workbench_runtime import (
WorkbenchPersistedAlert,
WorkbenchRuntimeWorkOrder,
)
from app.domain.schemas.workbench_runtime import WorkbenchPersistedAlert
_ANALYSIS_TYPE_LABELS = {
"burst_analysis": "爆管分析",
@@ -39,14 +36,11 @@ async def build_workbench_runtime_snapshot(
analysis_runs: list[dict[str, Any]] | None = None,
latest_analysis_results: list[dict[str, Any]] | None = None,
latest_analysis_map_payload: dict[str, Any] | None = None,
work_order_storage_configured: bool = False,
work_orders: list[dict[str, Any]] | None = None,
alert_storage_configured: bool = False,
persisted_alerts: list[dict[str, Any]] | None = None,
scenario_availability: str | None = None,
artifact_availability: str | None = None,
schedule_availability: str | None = None,
work_order_availability: str | None = None,
alert_availability: str | None = None,
projection_degraded: bool = False,
clock: Callable[[], datetime] = lambda: datetime.now(timezone.utc),
@@ -62,14 +56,6 @@ async def build_workbench_runtime_snapshot(
if persisted_analysis_runs
else None
)
persisted_work_orders = [
WorkbenchRuntimeWorkOrder.model_validate(item).model_dump()
for item in (
(work_orders or [])[:100]
if work_order_storage_configured
else []
)
]
stored_alerts = [
WorkbenchPersistedAlert.model_validate(item)
for item in (
@@ -104,9 +90,7 @@ async def build_workbench_runtime_snapshot(
"ready" if latest_analysis else "not_configured"
)
resolved_schedule_availability = schedule_availability or "not_configured"
resolved_work_order_availability = work_order_availability or (
"ready" if work_order_storage_configured else "not_configured"
)
resolved_work_order_availability = "not_configured"
resolved_alert_availability = alert_availability or (
"ready" if alert_storage_configured else "not_configured"
)
@@ -125,7 +109,6 @@ async def build_workbench_runtime_snapshot(
"ready"
if (
source != "none"
or work_order_storage_configured
or alert_storage_configured
)
else "not_configured"
@@ -141,7 +124,7 @@ async def build_workbench_runtime_snapshot(
"alerts": projected_alerts,
"scenarios": scenarios,
"latest_analysis": latest_analysis,
"work_orders": persisted_work_orders,
"work_orders": [],
}