57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
"""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
|