package model import ( "encoding/json" "time" "github.com/google/uuid" ) const ( StatusPending = "pending" StatusRunning = "running" StatusDone = "done" StatusFailed = "failed" StatusCancelled = "cancelled" ) type Job struct { ID uuid.UUID `json:"id"` OwnerService string `json:"owner_service"` OwnerRef string `json:"owner_ref"` TaskType string `json:"task_type"` ModelProfile string `json:"model_profile"` Priority int `json:"priority"` Status string `json:"status"` Attempts int `json:"attempts"` MaxAttempts int `json:"max_attempts"` Input json.RawMessage `json:"input"` Result json.RawMessage `json:"result,omitempty"` ErrorCode *string `json:"error_code,omitempty"` ErrorMessage *string `json:"error_message,omitempty"` ScheduledAt time.Time `json:"scheduled_at"` StartedAt *time.Time `json:"started_at,omitempty"` CompletedAt *time.Time `json:"completed_at,omitempty"` WorkerID *string `json:"worker_id,omitempty"` HeartbeatAt *time.Time `json:"heartbeat_at,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` IdempotencyKey *string `json:"idempotency_key,omitempty"` } type JobSummary struct { ID uuid.UUID `json:"id"` OwnerService string `json:"owner_service"` OwnerRef string `json:"owner_ref"` TaskType string `json:"task_type"` ModelProfile string `json:"model_profile"` Priority int `json:"priority"` Status string `json:"status"` Attempts int `json:"attempts"` MaxAttempts int `json:"max_attempts"` ErrorCode *string `json:"error_code,omitempty"` ErrorMessage *string `json:"error_message,omitempty"` ScheduledAt time.Time `json:"scheduled_at"` StartedAt *time.Time `json:"started_at,omitempty"` CompletedAt *time.Time `json:"completed_at,omitempty"` WorkerID *string `json:"worker_id,omitempty"` HeartbeatAt *time.Time `json:"heartbeat_at,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` } type CreateJob struct { OwnerService string `json:"owner_service"` OwnerRef string `json:"owner_ref"` TaskType string `json:"task_type"` ModelProfile string `json:"model_profile"` Priority int `json:"priority"` MaxAttempts int `json:"max_attempts"` Input json.RawMessage `json:"input"` ScheduledAt *time.Time `json:"scheduled_at,omitempty"` IdempotencyKey *string `json:"idempotency_key,omitempty"` } type ClaimJobs struct { WorkerID string `json:"worker_id"` TaskTypes []string `json:"task_types"` ModelProfiles []string `json:"model_profiles"` Limit int `json:"limit"` } type CompleteJob struct { Result json.RawMessage `json:"result"` } type FailJob struct { ErrorCode string `json:"error_code"` ErrorMessage string `json:"error_message"` } type JobFilter struct { OwnerService string `json:"owner_service,omitempty"` OwnerRef string `json:"owner_ref,omitempty"` TaskType string `json:"task_type,omitempty"` ModelProfile string `json:"model_profile,omitempty"` Statuses []string `json:"statuses,omitempty"` ErrorCodes []string `json:"error_codes,omitempty"` Limit int `json:"limit,omitempty"` Offset int `json:"offset,omitempty"` } type BatchActionResult struct { Updated int `json:"updated"` } type QueueStat struct { TaskType string `json:"task_type"` ModelProfile string `json:"model_profile"` Status string `json:"status"` Total int64 `json:"total"` } type ErrorStat struct { OwnerService string `json:"owner_service,omitempty"` TaskType string `json:"task_type"` ModelProfile string `json:"model_profile"` ErrorCode string `json:"error_code"` Total int64 `json:"total"` Last24h int64 `json:"last_24h"` } type TranscriptionComparisonStat struct { Provider string `json:"provider"` Model string `json:"model,omitempty"` Attempts int64 `json:"attempts"` Success int64 `json:"success"` Failed int64 `json:"failed"` SuccessRate float64 `json:"success_rate"` Wins int64 `json:"wins"` Last24hAttempts int64 `json:"last_24h_attempts"` Last24hSuccess int64 `json:"last_24h_success"` AvgDurationMS int64 `json:"avg_duration_ms"` P50DurationMS int64 `json:"p50_duration_ms"` AvgTextChars int64 `json:"avg_text_chars"` LastAt *time.Time `json:"last_at,omitempty"` } type OwnerStat struct { OwnerService string `json:"owner_service"` TaskType string `json:"task_type"` ModelProfile string `json:"model_profile"` Status string `json:"status"` Total int64 `json:"total"` } type Stats struct { At time.Time `json:"at"` Queues []QueueStat `json:"queues"` Owners []OwnerStat `json:"owners,omitempty"` Errors []ErrorStat `json:"errors,omitempty"` }