feat: add workflow snapshot codec registry and strict sanitization

This commit is contained in:
2026-03-07 17:11:21 +03:00
parent 80a0ea8956
commit 3c6f74dadd
6 changed files with 115 additions and 6 deletions

View File

@@ -6,16 +6,17 @@ from app_runtime.workflow.persistence.workflow_repository import WorkflowReposit
class WorkflowPersistence:
def __init__(self, workflow_repository, checkpoint_repository) -> None:
def __init__(self, workflow_repository, checkpoint_repository, *, snapshot_sanitizer=None) -> None:
self._workflow_repository = workflow_repository
self._checkpoint_repository = checkpoint_repository
self._snapshot_sanitizer = WorkflowSnapshotSanitizer()
self._snapshot_sanitizer = snapshot_sanitizer or WorkflowSnapshotSanitizer()
@classmethod
def create_default(cls, connection_factory=None) -> "WorkflowPersistence":
def create_default(cls, connection_factory=None, *, snapshot_sanitizer=None) -> "WorkflowPersistence":
return cls(
workflow_repository=WorkflowRepository(connection_factory),
checkpoint_repository=CheckpointRepository(connection_factory),
snapshot_sanitizer=snapshot_sanitizer,
)
def start_run(self, workflow_name: str, start_at: str, snapshot: dict[str, object]) -> int: