-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: migrate WorkflowDefinitionVersion to generic VersionSnapshot[WorkflowDefinition] #1131
Copy link
Copy link
Open
Labels
prio:mediumShould do, but not blockingShould do, but not blockingscope:medium1-3 days of work1-3 days of worktype:refactorCode restructuring, cleanupCode restructuring, cleanupv0.7Minor version v0.7Minor version v0.7
Description
Context
Follow-up from #1113 (versioning infrastructure evaluation). The generic VersionSnapshot[T] infrastructure from #1076 is a strict superset of the bespoke WorkflowDefinitionVersion system. Migration is favorable:
| Aspect | Bespoke | Generic | Verdict |
|---|---|---|---|
| Content hash | None | SHA-256 dedup | Generic wins |
| Schema | Flattened fields | snapshot JSON blob |
Generic simpler |
created_by |
On version model | Already on WorkflowDefinition |
No data loss |
| Repository methods | 5 | 7 (incl. content_hash lookup) | Generic richer |
| Concurrent writes | Not handled | INSERT OR IGNORE + retry | Generic safer |
Scope
Delete (bespoke files)
src/synthorg/engine/workflow/version.py--WorkflowDefinitionVersionmodelsrc/synthorg/persistence/workflow_version_repo.py--WorkflowVersionRepositoryprotocolsrc/synthorg/persistence/sqlite/workflow_version_repo.py--SQLiteWorkflowVersionRepository
Create/Modify
src/synthorg/persistence/sqlite/backend.py-- AddSQLiteVersionRepository[WorkflowDefinition]factory- Schema migration -- New table with generic columns (entity_id, version, content_hash, snapshot, saved_by, saved_at), backfill from old table
src/synthorg/api/controllers/workflows.py-- UseVersioningService[WorkflowDefinition].snapshot_if_changed()src/synthorg/api/controllers/workflow_versions.py-- UseVersionRepository[WorkflowDefinition]src/synthorg/api/controllers/_workflow_helpers.py-- Removebuild_version_snapshot()src/synthorg/engine/workflow/diff.py-- Operate onVersionSnapshot[WorkflowDefinition]- Update all tests referencing old types
Benefits
- Content-addressable deduplication (skip no-change saves)
- Single implementation for all versioned entities
- Concurrent-write conflict resolution
- Consistent schema across versioned types
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
prio:mediumShould do, but not blockingShould do, but not blockingscope:medium1-3 days of work1-3 days of worktype:refactorCode restructuring, cleanupCode restructuring, cleanupv0.7Minor version v0.7Minor version v0.7