Feat v0.9.2 converter consolidation (#75)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m51s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 1m17s
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Has been skipped
CI/CD / test-runners (push) Has been skipped
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m51s
CI/CD / test-sqlite (push) Successful in 3m1s
CI/CD / build-and-deploy (push) Successful in 1m17s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #75.
This commit is contained in:
@@ -18,25 +18,6 @@ import (
|
||||
// MaxConsecutiveAutomated is the cycle guard limit for automated stages.
|
||||
const MaxConsecutiveAutomated = 10
|
||||
|
||||
// parseSnapshotStages handles both snapshot formats:
|
||||
// - Wrapped: {"stages": [...], "workflow": {...}} (from Publish handler)
|
||||
// - Legacy: [...] (from early tests)
|
||||
func parseSnapshotStages(raw json.RawMessage) ([]models.WorkflowStage, error) {
|
||||
// Try wrapped format first
|
||||
var wrapped struct {
|
||||
Stages []models.WorkflowStage `json:"stages"`
|
||||
}
|
||||
if err := json.Unmarshal(raw, &wrapped); err == nil && len(wrapped.Stages) > 0 {
|
||||
return wrapped.Stages, nil
|
||||
}
|
||||
// Fallback to flat array
|
||||
var stages []models.WorkflowStage
|
||||
if err := json.Unmarshal(raw, &stages); err != nil {
|
||||
return nil, fmt.Errorf("corrupt version snapshot: %w", err)
|
||||
}
|
||||
return stages, nil
|
||||
}
|
||||
|
||||
// Engine orchestrates workflow instance lifecycle.
|
||||
type Engine struct {
|
||||
stores store.Stores
|
||||
@@ -64,7 +45,7 @@ func (e *Engine) Start(ctx context.Context, workflowID string, initialData json.
|
||||
return nil, fmt.Errorf("no published version: %w", err)
|
||||
}
|
||||
|
||||
stages, err := parseSnapshotStages(ver.Snapshot)
|
||||
stages, err := models.ParseSnapshotStages(ver.Snapshot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -142,7 +123,7 @@ func (e *Engine) advanceInternal(ctx context.Context, instanceID string, stageDa
|
||||
return nil, fmt.Errorf("version not found: %w", err)
|
||||
}
|
||||
|
||||
stages, err := parseSnapshotStages(ver.Snapshot)
|
||||
stages, err := models.ParseSnapshotStages(ver.Snapshot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -348,7 +329,7 @@ func (e *Engine) AdvancePublic(ctx context.Context, entryToken string, stageData
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("version not found: %w", err)
|
||||
}
|
||||
stages, err := parseSnapshotStages(ver.Snapshot)
|
||||
stages, err := models.ParseSnapshotStages(ver.Snapshot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -383,7 +364,7 @@ func (e *Engine) SubmitSignoff(ctx context.Context, instanceID, userID, decision
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("version not found: %w", err)
|
||||
}
|
||||
stages, err := parseSnapshotStages(ver.Snapshot)
|
||||
stages, err := models.ParseSnapshotStages(ver.Snapshot)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -448,7 +429,7 @@ func CheckClaimRole(ctx context.Context, stores store.Stores, assignment *models
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
stages, parseErr := parseSnapshotStages(ver.Snapshot)
|
||||
stages, parseErr := models.ParseSnapshotStages(ver.Snapshot)
|
||||
if parseErr != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user