Files
alfred/alfred/infrastructure/persistence/memory/stm/components/workflow.py
T
francwa de02bdea06 git commit -m "feat: major architectural refactor
- Refactor memory system (episodic/STM/LTM with components)
- Implement complete subtitle domain (scanner, matcher, placer)
- Add YAML workflow infrastructure
- Externalize knowledge base (patterns, release groups)
- Add comprehensive testing suite
- Create manual testing CLIs"
2026-05-11 21:33:37 +02:00

54 lines
1.6 KiB
Python

"""Workflow — tracks the current in-progress agent task."""
import logging
from dataclasses import dataclass
from datetime import datetime
logger = logging.getLogger(__name__)
@dataclass
class Workflow:
current: dict | None = None
def start(self, workflow_type: str, target: dict) -> None:
self.current = {
"type": workflow_type,
"target": target,
"stage": "started",
"started_at": datetime.now().isoformat(),
}
logger.info(f"Workflow: Started '{workflow_type}'")
def update_stage(self, stage: str) -> None:
if self.current:
self.current["stage"] = stage
logger.debug(f"Workflow: Stage -> {stage}")
def end(self) -> None:
if self.current:
logger.info(f"Workflow: Ended '{self.current.get('type')}'")
self.current = None
def clear(self) -> None:
self.current = None
@classmethod
def describe(cls) -> dict:
return {
"name": "Workflow",
"tier": "stm",
"access": "read-write",
"description": (
"Tracks the current in-progress multi-step task. "
"Read to know what you are currently doing and what stage you are at. "
"Write to start, advance, or end a workflow as you execute steps."
),
"fields": {
"current": "Active workflow dict with keys: type, target, stage, started_at. None if idle.",
},
}
def to_dict(self) -> dict | None:
return self.current