feat(replay): execute periodic diagnosis and hydraulic checks
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
"""Persisted business-clock task executions, independent of Agent sessions."""
|
||||
from typing import Literal
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import AwareDatetime, Field
|
||||
|
||||
from app.domain.schemas.shared import StrictModel
|
||||
|
||||
|
||||
class PeriodicTaskStep(StrictModel):
|
||||
id: str
|
||||
title: str
|
||||
status: Literal["pending", "running", "completed", "failed", "skipped"]
|
||||
detail: str = ""
|
||||
|
||||
|
||||
class PeriodicTaskMetric(StrictModel):
|
||||
id: str
|
||||
label: str
|
||||
value: str
|
||||
unit: str = ""
|
||||
status: Literal["normal", "attention", "critical"] = "normal"
|
||||
detail: str = ""
|
||||
|
||||
|
||||
class PeriodicTaskExecution(StrictModel):
|
||||
execution_id: UUID
|
||||
replay_id: UUID
|
||||
task_key: Literal["scada-diagnosis", "network-simulation"]
|
||||
title: str
|
||||
period_start: AwareDatetime
|
||||
period_end: AwareDatetime
|
||||
knowledge_cutoff: AwareDatetime
|
||||
batch_sequence: int = Field(ge=1)
|
||||
status: Literal["pending", "running", "completed", "failed"]
|
||||
conclusion: Literal["normal", "attention", "insufficient_data", "suspected_burst", "suspected_pollution"]
|
||||
summary: str
|
||||
steps: list[PeriodicTaskStep]
|
||||
metrics: list[PeriodicTaskMetric] = Field(default_factory=list)
|
||||
evidence: list[str] = Field(default_factory=list)
|
||||
data_gaps: list[str] = Field(default_factory=list)
|
||||
risk_signals: list[dict] = Field(default_factory=list)
|
||||
investigation_task_id: UUID | None = None
|
||||
calculation_job_id: UUID | None = None
|
||||
attempt: int = Field(default=1, ge=1)
|
||||
updated_at: AwareDatetime
|
||||
result: dict | None = None
|
||||
|
||||
|
||||
class PeriodicTaskPage(StrictModel):
|
||||
items: list[PeriodicTaskExecution]
|
||||
next_offset: int | None
|
||||
|
||||
|
||||
class PeriodicTaskRetry(StrictModel):
|
||||
request_id: UUID
|
||||
@@ -61,6 +61,7 @@ class ScadaReplayCreate(ReplayModel):
|
||||
device_ids: list[str] = Field(min_length=1, max_length=500)
|
||||
rules: list[ScadaReplayRule] = Field(min_length=1, max_length=30)
|
||||
quality_ranges: dict[str, ScadaQualityRange] = Field(default_factory=dict)
|
||||
scheduled_tasks_enabled: bool = False
|
||||
|
||||
@model_validator(mode="after")
|
||||
def configuration(self):
|
||||
@@ -130,6 +131,9 @@ class ScadaReplaySnapshot(ReplayModel):
|
||||
end_time: datetime
|
||||
monitoring_interval_seconds: int | None = Field(None, ge=60, le=31_536_000)
|
||||
step_pending: bool = False
|
||||
scheduled_tasks_enabled: bool = False
|
||||
periodic_pending: bool = False
|
||||
periodic_error: str | None = None
|
||||
monitoring_count: int = 0
|
||||
last_monitoring: ScadaMonitoringResult | None = None
|
||||
monitoring_config: ScadaMonitoringSettings | None = None
|
||||
|
||||
Reference in New Issue
Block a user