package governance import "time" // JobFailure is one terminal-attempt dead-letter projection (P6). It never // replaces the original jobs audit row; it points at it. type JobFailure struct { ID string `json:"id"` JobID string `json:"job_id"` JobType string `json:"job_type"` PublicationID string `json:"publication_id,omitempty"` SourceItemID string `json:"source_item_id,omitempty"` ErrorCode string `json:"error_code"` Attempt int `json:"attempt"` MaxAttempts int `json:"max_attempts_at_failure"` ChangeSetID string `json:"change_set_id,omitempty"` Action string `json:"action,omitempty"` TargetKBID string `json:"target_kb_id,omitempty"` State string `json:"state"` CreatedAt time.Time `json:"created_at"` DocName string `json:"doc_name,omitempty"` LastError string `json:"last_error,omitempty"` } type JobFailureFilter struct { State string // open | requeued | abandoned | "" (defaults to open) Limit int Offset int } type JobFailurePage struct { Items []JobFailure `json:"items"` Total int `json:"total"` Limit int `json:"limit"` Offset int `json:"offset"` } const ( RetryStarted = "started" RetryAlreadyRunning = "already_running" RetryNotRetryable = "not_retryable" ) // RetryPublicationsBatchRequest is the server-side batch retry (P6): one // atomic operation covering 1..100 publications with per-item outcomes. type RetryPublicationsBatchRequest struct { PublicationIDs []string `json:"publication_ids"` OperatorRef string `json:"operator_ref"` Reason string `json:"reason"` Now time.Time `json:"-"` } type RetryOutcome struct { PublicationID string `json:"publication_id"` Result string `json:"result"` Detail string `json:"detail,omitempty"` } type RetryPublicationsBatchResult struct { BatchKey string `json:"batch_key"` Total int `json:"total"` Started int `json:"started"` AlreadyRunning int `json:"already_running"` NotRetryable int `json:"not_retryable"` Outcomes []RetryOutcome `json:"outcomes"` } // CancelOutcome constants reuse the retry vocabulary plus "cancelled". const ( CancelCancelled = "cancelled" ) // CancelPublicationsBatchRequest is the operator's "stop retrying" batch: // 1..100 failed/stalled publications move to 'cancelled', their queued // upload jobs are dropped and their open dead letters are abandoned. // Source records and spooled artifacts are untouched; re-marking the file // in 来源与目录 can still create a fresh publication later. type CancelPublicationsBatchRequest struct { PublicationIDs []string `json:"publication_ids"` OperatorRef string `json:"operator_ref"` Reason string `json:"reason"` Now time.Time `json:"-"` } // RequeueArtifactFetchRequest re-enqueues ONE terminal 源头取件 (artifact.fetch) // dead letter. The fetch job's idempotency key is derived from the version // ("artifact-fetch:"), and the failed attempt permanently occupies // it — so a plain re-mark of the same file resolves to the same version and its // ON CONFLICT DO NOTHING insert is silently swallowed. A requeue therefore opens // a new ROUND ("...:r") instead of replaying the original key. type RequeueArtifactFetchRequest struct { FailureID string OperatorRef string Reason string Now time.Time } type RequeueArtifactFetchResult struct { FailureID string `json:"failure_id"` JobID string `json:"job_id"` VersionID string `json:"version_id"` Round int `json:"round"` DocName string `json:"doc_name,omitempty"` AlreadyQueued bool `json:"already_queued"` }