Feat v0.3.0 workflow schema redesign + stage CRUD modernization
Some checks failed
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Successful in 5s
CI/CD / test-go-pg (pull_request) Failing after 1m56s
CI/CD / test-sqlite (pull_request) Successful in 2m47s
CI/CD / build-and-deploy (pull_request) Has been skipped
Some checks failed
CI/CD / detect-changes (pull_request) Successful in 4s
CI/CD / test-frontend (pull_request) Successful in 5s
CI/CD / test-go-pg (pull_request) Failing after 1m56s
CI/CD / test-sqlite (pull_request) Successful in 2m47s
CI/CD / build-and-deploy (pull_request) Has been skipped
Drop chat-era columns (persona_id, history_mode) from workflow_stages. Rename transition_rules → stage_config. Add audience, stage_type, starlark_hook, branch_rules columns. Update stage_mode CHECK to (form, review, delegated, automated). All Go stores, handlers, routing engine, Starlark module, and frontend editors updated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -152,26 +152,38 @@ func (s *WorkflowStore) CreateStage(ctx context.Context, st *models.WorkflowStag
|
||||
st.ID = store.NewID()
|
||||
st.CreatedAt = time.Now().UTC()
|
||||
formTpl := jsonOrEmpty(st.FormTemplate)
|
||||
transRules := jsonOrEmpty(st.TransitionRules)
|
||||
stageConfig := jsonOrEmpty(st.StageConfig)
|
||||
branchRules := jsonOrEmpty(st.BranchRules)
|
||||
stageMode := st.StageMode
|
||||
if stageMode == "" {
|
||||
stageMode = models.StageModeCustom
|
||||
stageMode = models.StageModeForm
|
||||
}
|
||||
audience := st.Audience
|
||||
if audience == "" {
|
||||
audience = models.AudienceTeam
|
||||
}
|
||||
stageType := st.StageType
|
||||
if stageType == "" {
|
||||
stageType = models.StageTypeSimple
|
||||
}
|
||||
_, err := DB.ExecContext(ctx, `
|
||||
INSERT INTO workflow_stages (id, workflow_id, ordinal, name, persona_id, assignment_team_id,
|
||||
form_template, stage_mode, history_mode, auto_transition, transition_rules,
|
||||
INSERT INTO workflow_stages (id, workflow_id, ordinal, name, assignment_team_id,
|
||||
form_template, stage_mode, audience, stage_type,
|
||||
auto_transition, stage_config, branch_rules, starlark_hook,
|
||||
surface_pkg_id, sla_seconds, created_at)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
st.ID, st.WorkflowID, st.Ordinal, st.Name, st.PersonaID, st.AssignmentTeamID,
|
||||
formTpl, stageMode, st.HistoryMode, boolToInt(st.AutoTransition), transRules,
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
st.ID, st.WorkflowID, st.Ordinal, st.Name, st.AssignmentTeamID,
|
||||
formTpl, stageMode, audience, stageType,
|
||||
boolToInt(st.AutoTransition), stageConfig, branchRules, st.StarlarkHook,
|
||||
st.SurfacePkgID, st.SLASeconds, st.CreatedAt.Format(time.RFC3339))
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *WorkflowStore) ListStages(ctx context.Context, workflowID string) ([]models.WorkflowStage, error) {
|
||||
rows, err := DB.QueryContext(ctx, `
|
||||
SELECT id, workflow_id, ordinal, name, persona_id, assignment_team_id,
|
||||
form_template, stage_mode, history_mode, auto_transition, transition_rules,
|
||||
SELECT id, workflow_id, ordinal, name, assignment_team_id,
|
||||
form_template, stage_mode, audience, stage_type,
|
||||
auto_transition, stage_config, branch_rules, starlark_hook,
|
||||
surface_pkg_id, sla_seconds, created_at
|
||||
FROM workflow_stages WHERE workflow_id = ?
|
||||
ORDER BY ordinal ASC`, workflowID)
|
||||
@@ -182,16 +194,17 @@ func (s *WorkflowStore) ListStages(ctx context.Context, workflowID string) ([]mo
|
||||
var result []models.WorkflowStage
|
||||
for rows.Next() {
|
||||
var stg models.WorkflowStage
|
||||
var formTpl, transRules string
|
||||
var formTpl, stageConfig, branchRules string
|
||||
var autoTrans int
|
||||
if err := rows.Scan(&stg.ID, &stg.WorkflowID, &stg.Ordinal, &stg.Name,
|
||||
&stg.PersonaID, &stg.AssignmentTeamID, &formTpl, &stg.StageMode,
|
||||
&stg.HistoryMode, &autoTrans, &transRules,
|
||||
&stg.AssignmentTeamID, &formTpl, &stg.StageMode, &stg.Audience, &stg.StageType,
|
||||
&autoTrans, &stageConfig, &branchRules, &stg.StarlarkHook,
|
||||
&stg.SurfacePkgID, &stg.SLASeconds, st(&stg.CreatedAt)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
stg.FormTemplate = json.RawMessage(formTpl)
|
||||
stg.TransitionRules = json.RawMessage(transRules)
|
||||
stg.StageConfig = json.RawMessage(stageConfig)
|
||||
stg.BranchRules = json.RawMessage(branchRules)
|
||||
stg.AutoTransition = autoTrans != 0
|
||||
result = append(result, stg)
|
||||
}
|
||||
@@ -200,19 +213,30 @@ func (s *WorkflowStore) ListStages(ctx context.Context, workflowID string) ([]mo
|
||||
|
||||
func (s *WorkflowStore) UpdateStage(ctx context.Context, st *models.WorkflowStage) error {
|
||||
formTpl := jsonOrEmpty(st.FormTemplate)
|
||||
transRules := jsonOrEmpty(st.TransitionRules)
|
||||
stageConfig := jsonOrEmpty(st.StageConfig)
|
||||
branchRules := jsonOrEmpty(st.BranchRules)
|
||||
stageMode := st.StageMode
|
||||
if stageMode == "" {
|
||||
stageMode = models.StageModeCustom
|
||||
stageMode = models.StageModeForm
|
||||
}
|
||||
audience := st.Audience
|
||||
if audience == "" {
|
||||
audience = models.AudienceTeam
|
||||
}
|
||||
stageType := st.StageType
|
||||
if stageType == "" {
|
||||
stageType = models.StageTypeSimple
|
||||
}
|
||||
_, err := DB.ExecContext(ctx, `
|
||||
UPDATE workflow_stages
|
||||
SET ordinal = ?, name = ?, persona_id = ?, assignment_team_id = ?,
|
||||
form_template = ?, stage_mode = ?, history_mode = ?, auto_transition = ?,
|
||||
transition_rules = ?, surface_pkg_id = ?, sla_seconds = ?
|
||||
SET ordinal = ?, name = ?, assignment_team_id = ?,
|
||||
form_template = ?, stage_mode = ?, audience = ?, stage_type = ?,
|
||||
auto_transition = ?, stage_config = ?, branch_rules = ?, starlark_hook = ?,
|
||||
surface_pkg_id = ?, sla_seconds = ?
|
||||
WHERE id = ?`,
|
||||
st.Ordinal, st.Name, st.PersonaID, st.AssignmentTeamID,
|
||||
formTpl, stageMode, st.HistoryMode, boolToInt(st.AutoTransition), transRules,
|
||||
st.Ordinal, st.Name, st.AssignmentTeamID,
|
||||
formTpl, stageMode, audience, stageType,
|
||||
boolToInt(st.AutoTransition), stageConfig, branchRules, st.StarlarkHook,
|
||||
st.SurfacePkgID, st.SLASeconds, st.ID)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user