Feat v0.3.1 instance + assignment tables and store
Some checks failed
CI/CD / detect-changes (pull_request) Successful in 5s
CI/CD / test-frontend (pull_request) Has been skipped
CI/CD / test-go-pg (pull_request) Failing after 2m32s
CI/CD / test-sqlite (pull_request) Successful in 2m58s
CI/CD / build-and-deploy (pull_request) Has been skipped

Add workflow execution layer: workflow_instances tracks running workflows
(stage, status, entry token), workflow_assignments tracks per-stage team
queue with optimistic-lock claim. 15 new store methods in PG + SQLite.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-27 18:41:03 +00:00
parent 965885a8f7
commit 1bf8422932
6 changed files with 667 additions and 7 deletions

View File

@@ -432,6 +432,76 @@ func evaluateFieldCondition(cond *FieldCondition, data map[string]interface{}) b
}
}
// ── Instance Status Constants ───────────────
const (
InstanceStatusActive = "active"
InstanceStatusCompleted = "completed"
InstanceStatusCancelled = "cancelled"
InstanceStatusStale = "stale"
InstanceStatusError = "error"
)
// ValidInstanceStatuses is the set of valid workflow instance status values.
var ValidInstanceStatuses = map[string]bool{
InstanceStatusActive: true,
InstanceStatusCompleted: true,
InstanceStatusCancelled: true,
InstanceStatusStale: true,
InstanceStatusError: true,
}
// ── Assignment Status Constants ─────────────
const (
AssignmentStatusUnassigned = "unassigned"
AssignmentStatusClaimed = "claimed"
AssignmentStatusCompleted = "completed"
AssignmentStatusCancelled = "cancelled"
)
// ValidAssignmentStatuses is the set of valid workflow assignment status values.
var ValidAssignmentStatuses = map[string]bool{
AssignmentStatusUnassigned: true,
AssignmentStatusClaimed: true,
AssignmentStatusCompleted: true,
AssignmentStatusCancelled: true,
}
// ── Workflow Instance ───────────────────────
// WorkflowInstance tracks a single execution of a workflow definition.
type WorkflowInstance struct {
ID string `json:"id"`
WorkflowID string `json:"workflow_id"`
WorkflowVersion int `json:"workflow_version"`
CurrentStage string `json:"current_stage"`
StageData json.RawMessage `json:"stage_data"`
Status string `json:"status"`
StartedBy string `json:"started_by"`
EntryToken *string `json:"entry_token,omitempty"`
Metadata json.RawMessage `json:"metadata"`
StageEnteredAt time.Time `json:"stage_entered_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
// ── Workflow Assignment ─────────────────────
// WorkflowAssignment tracks per-stage work items in the team queue.
type WorkflowAssignment struct {
ID string `json:"id"`
InstanceID string `json:"instance_id"`
Stage string `json:"stage"`
TeamID string `json:"team_id"`
AssignedTo *string `json:"assigned_to,omitempty"`
Status string `json:"status"`
ReviewData json.RawMessage `json:"review_data"`
ClaimedAt *time.Time `json:"claimed_at,omitempty"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
}
// ── Workflow Version (immutable snapshot) ───
// WorkflowVersion is an immutable snapshot of a workflow definition