Перенес workflow

This commit is contained in:
2026-03-05 11:46:05 +03:00
parent 4a0646bb14
commit 89c0d21e88
65 changed files with 1271 additions and 1640 deletions

View File

@@ -0,0 +1 @@
__all__: list[str] = []

View File

@@ -0,0 +1,16 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
@dataclass(slots=True)
class WorkflowContext:
payload: dict[str, Any]
state: dict[str, Any] = field(default_factory=dict)
def snapshot(self) -> dict[str, Any]:
return {
"payload": dict(self.payload),
"state": dict(self.state),
}

View File

@@ -0,0 +1,11 @@
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any
@dataclass(slots=True)
class StepResult:
transition: str = "success"
updates: dict[str, Any] = field(default_factory=dict)
status: str = "completed"

View File

@@ -0,0 +1,12 @@
from __future__ import annotations
from abc import ABC, abstractmethod
from app_runtime.workflow.contracts.context import WorkflowContext
from app_runtime.workflow.contracts.result import StepResult
class WorkflowStep(ABC):
@abstractmethod
def run(self, context: WorkflowContext) -> StepResult:
"""Run the step and return transition metadata."""

View File

@@ -0,0 +1,19 @@
from __future__ import annotations
from dataclasses import dataclass, field
from app_runtime.workflow.contracts.step import WorkflowStep
@dataclass(slots=True)
class WorkflowNode:
name: str
step: WorkflowStep
transitions: dict[str, str] = field(default_factory=dict)
@dataclass(slots=True)
class WorkflowDefinition:
name: str
start_at: str
nodes: dict[str, WorkflowNode]