Complete workflow state.
| 63 | |
| 64 | |
| 65 | class WorkflowState(BaseModel): |
| 66 | """Complete workflow state.""" |
| 67 | pipeline_id: str |
| 68 | phase: WorkflowPhase = WorkflowPhase.INITIAL |
| 69 | |
| 70 | # URLs |
| 71 | urls: List[URLInfo] = [] |
| 72 | urls_validated: bool = False |
| 73 | |
| 74 | # Schema |
| 75 | schema_fields: List[SchemaField] = [] |
| 76 | schema_validated: bool = False |
| 77 | |
| 78 | # Code |
| 79 | generated_code: str = "" |
| 80 | code_validated: bool = False |
| 81 | |
| 82 | # Execution |
| 83 | execution_results: List[Dict[str, Any]] = [] |
| 84 | execution_status: Optional[str] = None |
| 85 | |
| 86 | # Approval tracking |
| 87 | pending_approvals: List[ApprovalRequest] = [] |
| 88 | approval_history: List[ApprovalRequest] = [] |
| 89 | |
| 90 | # Workflow history |
| 91 | phase_transitions: List[WorkflowTransition] = [] |
| 92 | |
| 93 | # User modifications |
| 94 | user_modifications: List[Dict[str, Any]] = [] |
| 95 | |
| 96 | # Timestamps |
| 97 | created_at: datetime = Field(default_factory=datetime.utcnow) |
| 98 | updated_at: datetime = Field(default_factory=datetime.utcnow) |
| 99 | |
| 100 | # Metadata |
| 101 | created_by: str = "system" |
| 102 | last_modified_by: str = "system" |
| 103 | version: int = 1 |
| 104 | |
| 105 | def add_transition(self, to_phase: WorkflowPhase, reason: str = "", triggered_by: str = "system"): |
| 106 | """Add a phase transition to history.""" |
| 107 | transition = WorkflowTransition( |
| 108 | from_phase=self.phase, |
| 109 | to_phase=to_phase, |
| 110 | reason=reason, |
| 111 | triggered_by=triggered_by |
| 112 | ) |
| 113 | self.phase_transitions.append(transition) |
| 114 | self.phase = to_phase |
| 115 | self.updated_at = datetime.utcnow() |
| 116 | self.last_modified_by = triggered_by |
| 117 | |
| 118 | def add_user_modification(self, field: str, old_value: Any, new_value: Any, user: str = "user"): |
| 119 | """Track user modifications.""" |
| 120 | modification = { |
| 121 | "field": field, |
| 122 | "old_value": old_value, |
no outgoing calls
no test coverage detected