forked from longtao.wu/droboticflow
549 lines
30 KiB
Go
549 lines
30 KiB
Go
package domain
|
|
|
|
type HumanReleasePolicy string
|
|
|
|
const (
|
|
HumanReleaseAcceptedPartition HumanReleasePolicy = "accepted_partition"
|
|
HumanReleaseAllAccepted HumanReleasePolicy = "all_accepted"
|
|
)
|
|
|
|
type HumanBatchStatus string
|
|
|
|
const (
|
|
HumanBatchActive HumanBatchStatus = "active"
|
|
HumanBatchCompleted HumanBatchStatus = "completed"
|
|
HumanBatchBlocked HumanBatchStatus = "blocked"
|
|
)
|
|
|
|
type HumanItemStatus string
|
|
|
|
const (
|
|
HumanItemReady HumanItemStatus = "ready"
|
|
HumanItemClaimed HumanItemStatus = "claimed"
|
|
HumanItemInProgress HumanItemStatus = "in_progress"
|
|
HumanItemSubmitted HumanItemStatus = "submitted"
|
|
HumanItemRework HumanItemStatus = "rework"
|
|
HumanItemEscalated HumanItemStatus = "escalated"
|
|
HumanItemAccepted HumanItemStatus = "accepted"
|
|
HumanItemRejected HumanItemStatus = "rejected"
|
|
HumanItemCancelled HumanItemStatus = "cancelled"
|
|
)
|
|
|
|
type HumanStageKind string
|
|
|
|
const (
|
|
HumanStageAnnotation HumanStageKind = "annotation"
|
|
HumanStageReview HumanStageKind = "review"
|
|
HumanStageAcceptance HumanStageKind = "acceptance"
|
|
HumanStageApproval HumanStageKind = "approval"
|
|
)
|
|
|
|
type HumanDecision string
|
|
|
|
const (
|
|
HumanDecisionApproved HumanDecision = "approved"
|
|
HumanDecisionRejected HumanDecision = "rejected"
|
|
)
|
|
|
|
// Fanyu v5 keeps the two human editing concerns independently auditable. The
|
|
// names are part of the persisted HumanItem contract, so callers must not
|
|
// collapse them back into the historical split_annotation/quality_review
|
|
// aliases.
|
|
const (
|
|
FanyuV5StageCutAdjustment = "cut_adjustment"
|
|
FanyuV5StageCutReview = "cut_review"
|
|
FanyuV5StageSemanticAnnotation = "semantic_annotation"
|
|
FanyuV5StageSemanticReview = "semantic_review"
|
|
)
|
|
|
|
// Fanyu v5.8 restores the confirmed three-role production loop. The
|
|
// annotator owns one atomic cut+semantic submission, the quality reviewer
|
|
// reviews that complete submission, and a distinct acceptance reviewer owns
|
|
// the aggregate pre-package decision.
|
|
const (
|
|
FanyuV58StageAnnotationCombined = "annotation_combined"
|
|
FanyuV58StageQualityReview = "quality_review"
|
|
)
|
|
|
|
type PoseDeliveryDecision string
|
|
|
|
const (
|
|
PoseDeliveryInclude PoseDeliveryDecision = "include"
|
|
PoseDeliveryExclude PoseDeliveryDecision = "exclude"
|
|
)
|
|
|
|
type PoseDeliveryPolicy struct {
|
|
Headpose PoseDeliveryDecision `json:"headpose" bson:"headpose"`
|
|
Handpose PoseDeliveryDecision `json:"handpose" bson:"handpose"`
|
|
ReasonCodes []string `json:"reasonCodes,omitempty" bson:"reasonCodes,omitempty"`
|
|
}
|
|
|
|
type HumanStageDefinition struct {
|
|
ID string `json:"id" bson:"id"`
|
|
Label string `json:"label" bson:"label"`
|
|
Kind HumanStageKind `json:"kind" bson:"kind"`
|
|
RequiredRole string `json:"requiredRole" bson:"requiredRole"`
|
|
EditorSchema string `json:"editorSchema,omitempty" bson:"editorSchema,omitempty"`
|
|
RejectTargets []string `json:"rejectTargets,omitempty" bson:"rejectTargets,omitempty"`
|
|
// ConfirmOnly is used by the v5 aggregate pre-package acceptance work item.
|
|
// It forbids reject/reopen controls at the API boundary rather than relying
|
|
// on a frontend button being hidden.
|
|
ConfirmOnly bool `json:"confirmOnly,omitempty" bson:"confirmOnly,omitempty"`
|
|
}
|
|
|
|
type HumanSubjectRef struct {
|
|
ArtifactID string `json:"artifactId,omitempty" bson:"artifactId,omitempty"`
|
|
ItemKey string `json:"itemKey" bson:"itemKey"`
|
|
MediaType string `json:"mediaType,omitempty" bson:"mediaType,omitempty"`
|
|
Payload map[string]any `json:"payload,omitempty" bson:"payload,omitempty"`
|
|
}
|
|
|
|
type HumanTaskDisplayContext struct {
|
|
ProjectName string `json:"projectName,omitempty" bson:"-"`
|
|
WorkflowName string `json:"workflowName,omitempty" bson:"-"`
|
|
CaptureDirectories []string `json:"captureDirectories,omitempty" bson:"-"`
|
|
}
|
|
|
|
type HumanBatchRecord struct {
|
|
ProcessingScope string `json:"processingScope,omitempty" bson:"processingScope,omitempty"`
|
|
ProcessingProfile string `json:"processingProfile,omitempty" bson:"processingProfile,omitempty"`
|
|
ID string `json:"id" bson:"id"`
|
|
OrganizationID string `json:"organizationId" bson:"organizationId"`
|
|
PluginID string `json:"pluginId" bson:"pluginId"`
|
|
ProjectID string `json:"projectId" bson:"projectId"`
|
|
SupplierID string `json:"supplierId,omitempty" bson:"supplierId,omitempty"`
|
|
WorkflowID string `json:"workflowId" bson:"workflowId"`
|
|
RunID string `json:"runId" bson:"runId"`
|
|
ContractRevision string `json:"contractRevision,omitempty" bson:"contractRevision,omitempty"`
|
|
GateNodeID string `json:"gateNodeId" bson:"gateNodeId"`
|
|
Status HumanBatchStatus `json:"status" bson:"status"`
|
|
Stages []HumanStageDefinition `json:"stages" bson:"stages"`
|
|
ReleasePolicy HumanReleasePolicy `json:"releasePolicy" bson:"releasePolicy"`
|
|
PartitionMaxItems int `json:"partitionMaxItems" bson:"partitionMaxItems"`
|
|
PartitionMaxWaitSeconds int `json:"partitionMaxWaitSeconds" bson:"partitionMaxWaitSeconds"`
|
|
MaxReworkRounds int `json:"maxReworkRounds" bson:"maxReworkRounds"`
|
|
ItemCount int `json:"itemCount" bson:"itemCount"`
|
|
AcceptedCount int `json:"acceptedCount" bson:"acceptedCount"`
|
|
ReleasedCount int `json:"releasedCount" bson:"releasedCount"`
|
|
NextPartitionSequence int `json:"nextPartitionSequence" bson:"nextPartitionSequence"`
|
|
RequirePrePackageAcceptance bool `json:"requirePrePackageAcceptance,omitempty" bson:"requirePrePackageAcceptance,omitempty"`
|
|
SourceBatchID string `json:"sourceBatchId,omitempty" bson:"sourceBatchId,omitempty"`
|
|
CreatedAt string `json:"createdAt" bson:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt" bson:"updatedAt"`
|
|
}
|
|
|
|
// HumanReviewHistory is a read-only summary of the requesting user's last
|
|
// formal decision, not the current workflow state or a permission credential.
|
|
type HumanReviewHistory struct {
|
|
Decision string `json:"decision"`
|
|
StageID string `json:"stageId,omitempty"`
|
|
Revision int `json:"revision,omitempty"`
|
|
Round *int `json:"round,omitempty"`
|
|
ReviewedAt string `json:"reviewedAt,omitempty"`
|
|
}
|
|
|
|
type HumanTraceSummary struct {
|
|
Author string `json:"author"`
|
|
Supplier string `json:"supplier"`
|
|
Rejections *int `json:"rejections"`
|
|
}
|
|
|
|
// HumanPoolSearchMetadata contains only source-owned names. It is never public
|
|
// task content or a permission decision.
|
|
type HumanPoolSearchMetadata struct {
|
|
SearchText string `bson:"searchText,omitempty"`
|
|
TextVersion int `bson:"textVersion,omitempty"`
|
|
Source map[string]any `bson:"source"`
|
|
SourceVersion int `bson:"sourceVersion"`
|
|
SourceUpdatedAt string `bson:"sourceUpdatedAt"`
|
|
SourceItemKey string `bson:"sourceItemKey"`
|
|
SourceArtifactID string `bson:"sourceArtifactId"`
|
|
DurationSeconds float64 `bson:"durationSeconds"`
|
|
Schema int `bson:"schema"`
|
|
Text []string `bson:"text"`
|
|
PayloadDirectories []string `bson:"payloadDirectories"`
|
|
}
|
|
|
|
type AccountTaskHandoff struct {
|
|
UserID string `json:"-" bson:"userId"`
|
|
ActorID string `json:"-" bson:"actorId"`
|
|
Reset bool `json:"-" bson:"reset"`
|
|
Pending bool `json:"-" bson:"pending"`
|
|
RevisionFloor int `json:"-" bson:"revisionFloor"`
|
|
At string `json:"-" bson:"at"`
|
|
}
|
|
|
|
type HumanItemRecord struct {
|
|
QueryReplicaOmit bool `json:"-" bson:"-"`
|
|
AnnotationEpoch int `json:"-" bson:"annotationEpoch,omitempty"`
|
|
AccountHandoff *AccountTaskHandoff `json:"-" bson:"accountHandoff,omitempty"`
|
|
ReworkRoutingPending bool `json:"-" bson:"reworkRoutingPending,omitempty"`
|
|
InheritedRework bool `json:"inheritedRework,omitempty" bson:"inheritedRework,omitempty"`
|
|
PoolSearch *HumanPoolSearchMetadata `json:"-" bson:"poolSearch,omitempty"`
|
|
SourceValidationStatus string `json:"sourceValidationStatus,omitempty" bson:"-"`
|
|
TraceSummary *HumanTraceSummary `json:"traceSummary,omitempty" bson:"-"`
|
|
ReviewHistory *HumanReviewHistory `json:"reviewHistory,omitempty" bson:"-"`
|
|
CanClaim *bool `json:"canClaim,omitempty" bson:"-"`
|
|
AcceptanceClaim *AcceptanceClaimAccess `json:"acceptanceClaim,omitempty" bson:"acceptanceClaim,omitempty"`
|
|
ReviewHistoryStatus string `json:"reviewHistoryStatus,omitempty" bson:"-"`
|
|
ReviewOperationID string `json:"reviewOperationId,omitempty" bson:"reviewOperationId,omitempty"`
|
|
ProcessingJob *AnnotationProcessingJob `json:"-" bson:"processingJob,omitempty"`
|
|
ProcessingScope string `json:"processingScope,omitempty" bson:"processingScope,omitempty"`
|
|
ProcessingProfile string `json:"processingProfile,omitempty" bson:"processingProfile,omitempty"`
|
|
ID string `json:"id" bson:"id"`
|
|
OrganizationID string `json:"organizationId" bson:"organizationId"`
|
|
PluginID string `json:"pluginId" bson:"pluginId"`
|
|
BatchID string `json:"batchId" bson:"batchId"`
|
|
ProjectID string `json:"projectId" bson:"projectId"`
|
|
SupplierID string `json:"supplierId,omitempty" bson:"supplierId,omitempty"`
|
|
WorkflowID string `json:"workflowId" bson:"workflowId"`
|
|
RunID string `json:"runId" bson:"runId"`
|
|
GateNodeID string `json:"gateNodeId" bson:"gateNodeId"`
|
|
LegacyTaskID string `json:"legacyTaskId,omitempty" bson:"legacyTaskId,omitempty"`
|
|
LegacyAuditTaskID string `json:"legacyAuditTaskId,omitempty" bson:"legacyAuditTaskId,omitempty"`
|
|
Subject HumanSubjectRef `json:"subject" bson:"subject"`
|
|
CurrentStageID string `json:"currentStageId" bson:"currentStageId"`
|
|
Status HumanItemStatus `json:"status" bson:"status"`
|
|
AssignedUserID string `json:"assignedUserId,omitempty" bson:"assignedUserId,omitempty"`
|
|
ClaimRequestID string `json:"-" bson:"claimRequestId,omitempty"`
|
|
LegacyAssignment map[string]string `json:"legacyAssignment,omitempty" bson:"legacyAssignment,omitempty"`
|
|
WorkgroupID string `json:"-" bson:"workgroupId,omitempty"`
|
|
VendorID string `json:"-" bson:"vendorId,omitempty"`
|
|
CurrentRevision int `json:"currentRevision" bson:"currentRevision"`
|
|
ReviewRound int `json:"reviewRound" bson:"reviewRound"`
|
|
MaxReworkRounds int `json:"maxReworkRounds" bson:"maxReworkRounds"`
|
|
Version int `json:"version" bson:"version"`
|
|
LatestAuthorUserID string `json:"latestAuthorUserId,omitempty" bson:"latestAuthorUserId,omitempty"`
|
|
PendingCombinedSubmissionID string `json:"pendingCombinedSubmissionId,omitempty" bson:"pendingCombinedSubmissionId,omitempty"`
|
|
PendingCombinedPayloadSHA string `json:"pendingCombinedPayloadSha,omitempty" bson:"pendingCombinedPayloadSha,omitempty"`
|
|
ReleasePartitionID string `json:"releasePartitionId,omitempty" bson:"releasePartitionId,omitempty"`
|
|
ClaimedAt string `json:"claimedAt,omitempty" bson:"claimedAt,omitempty"`
|
|
SubmittedAt string `json:"submittedAt,omitempty" bson:"submittedAt,omitempty"`
|
|
AcceptanceSampleProbability *float64 `json:"acceptanceSampleProbability,omitempty" bson:"acceptanceSampleProbability,omitempty"`
|
|
AcceptanceSampleValue *float64 `json:"acceptanceSampleValue,omitempty" bson:"acceptanceSampleValue,omitempty"`
|
|
AcceptancePolicyRevision int `json:"acceptancePolicyRevision,omitempty" bson:"acceptancePolicyRevision,omitempty"`
|
|
AcceptedAt string `json:"acceptedAt,omitempty" bson:"acceptedAt,omitempty"`
|
|
AcceptedByUserID string `json:"acceptedByUserId,omitempty" bson:"acceptedByUserId,omitempty"`
|
|
RejectedAt string `json:"rejectedAt,omitempty" bson:"rejectedAt,omitempty"`
|
|
CancelledAt string `json:"cancelledAt,omitempty" bson:"cancelledAt,omitempty"`
|
|
CancelledByUserID string `json:"cancelledByUserId,omitempty" bson:"cancelledByUserId,omitempty"`
|
|
CancellationReason string `json:"cancellationReason,omitempty" bson:"cancellationReason,omitempty"`
|
|
CreatedAt string `json:"createdAt" bson:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt" bson:"updatedAt"`
|
|
Display *HumanTaskDisplayContext `json:"display,omitempty" bson:"-"`
|
|
}
|
|
|
|
// HumanItemDraftProgress carries only the progress-relevant slice of a human
|
|
// item's annotationDraft payload for task-pool list responses. Drafts are
|
|
// fetched per filtered task instead of being dragged through organization-wide
|
|
// list scans, so the pool page never decodes every draft in the org.
|
|
type HumanItemDraftProgress struct {
|
|
LegacyTaskID string `json:"legacyTaskId"`
|
|
SliceSegments []SliceSegment `json:"sliceSegments,omitempty"`
|
|
Segments []AnnotationSegment `json:"segments,omitempty"`
|
|
}
|
|
|
|
type HumanRejectStatus string
|
|
|
|
const (
|
|
HumanRejectOpen HumanRejectStatus = "open"
|
|
HumanRejectReopened HumanRejectStatus = "reopened"
|
|
HumanRejectResolved HumanRejectStatus = "resolved"
|
|
HumanRejectEscalated HumanRejectStatus = "escalated"
|
|
)
|
|
|
|
// HumanRejectRecord is the immutable workflow-visible rejection fact. Reopening
|
|
// an item updates only the reject lifecycle metadata and creates a new attempt;
|
|
// it never erases the original rejected decision, reason, or reviewer.
|
|
type HumanRejectRecord struct {
|
|
ID string `json:"id" bson:"id"`
|
|
OrganizationID string `json:"organizationId" bson:"organizationId"`
|
|
BatchID string `json:"batchId" bson:"batchId"`
|
|
ItemID string `json:"itemId" bson:"itemId"`
|
|
ProjectID string `json:"projectId" bson:"projectId"`
|
|
WorkflowID string `json:"workflowId" bson:"workflowId"`
|
|
RunID string `json:"runId" bson:"runId"`
|
|
StageID string `json:"stageId" bson:"stageId"`
|
|
AttemptRound int `json:"attemptRound" bson:"attemptRound"`
|
|
ReviewedRevision int `json:"reviewedRevision,omitempty" bson:"reviewedRevision,omitempty"`
|
|
RejectedByUserID string `json:"rejectedByUserId" bson:"rejectedByUserId"`
|
|
ReasonCodes []string `json:"reasonCodes" bson:"reasonCodes"`
|
|
ProblemSliceIDs []string `json:"problemSliceIds,omitempty" bson:"problemSliceIds,omitempty"`
|
|
Comment string `json:"comment" bson:"comment"`
|
|
AllowedReopenStages []string `json:"allowedReopenStages" bson:"allowedReopenStages"`
|
|
Status HumanRejectStatus `json:"status" bson:"status"`
|
|
Version int `json:"version" bson:"version"`
|
|
ReopenCount int `json:"reopenCount" bson:"reopenCount"`
|
|
ReopenedByUserID string `json:"reopenedByUserId,omitempty" bson:"reopenedByUserId,omitempty"`
|
|
ReopenTargetStageID string `json:"reopenTargetStageId,omitempty" bson:"reopenTargetStageId,omitempty"`
|
|
ReopenComment string `json:"reopenComment,omitempty" bson:"reopenComment,omitempty"`
|
|
ReopenedAt string `json:"reopenedAt,omitempty" bson:"reopenedAt,omitempty"`
|
|
CreatedAt string `json:"createdAt" bson:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt" bson:"updatedAt"`
|
|
Display *HumanTaskDisplayContext `json:"display,omitempty" bson:"-"`
|
|
}
|
|
|
|
type HumanStageAttemptRecord struct {
|
|
ID string `json:"id" bson:"id"`
|
|
OrganizationID string `json:"organizationId" bson:"organizationId"`
|
|
ItemID string `json:"itemId" bson:"itemId"`
|
|
StageID string `json:"stageId" bson:"stageId"`
|
|
Round int `json:"round" bson:"round"`
|
|
Status HumanItemStatus `json:"status" bson:"status"`
|
|
AssigneeUserID string `json:"assigneeUserId,omitempty" bson:"assigneeUserId,omitempty"`
|
|
SubmissionRef string `json:"submissionRef,omitempty" bson:"submissionRef,omitempty"`
|
|
ReviewedRevision int `json:"reviewedRevision,omitempty" bson:"reviewedRevision,omitempty"`
|
|
Decision HumanDecision `json:"decision,omitempty" bson:"decision,omitempty"`
|
|
RejectTargets []string `json:"rejectTargets,omitempty" bson:"rejectTargets,omitempty"`
|
|
ReasonCodes []string `json:"reasonCodes,omitempty" bson:"reasonCodes,omitempty"`
|
|
ProblemSliceIDs []string `json:"problemSliceIds,omitempty" bson:"problemSliceIds,omitempty"`
|
|
Comment string `json:"comment,omitempty" bson:"comment,omitempty"`
|
|
Version int `json:"version" bson:"version"`
|
|
CreatedAt string `json:"createdAt" bson:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt" bson:"updatedAt"`
|
|
}
|
|
|
|
type HumanEventRecord struct {
|
|
ID string `json:"id" bson:"id"`
|
|
OrganizationID string `json:"organizationId" bson:"organizationId"`
|
|
BatchID string `json:"batchId" bson:"batchId"`
|
|
ItemID string `json:"itemId" bson:"itemId"`
|
|
StageID string `json:"stageId" bson:"stageId"`
|
|
Round int `json:"round" bson:"round"`
|
|
EventType string `json:"eventType" bson:"eventType"`
|
|
ActorUserID string `json:"actorUserId,omitempty" bson:"actorUserId,omitempty"`
|
|
ItemVersion int `json:"itemVersion" bson:"itemVersion"`
|
|
Payload map[string]any `json:"payload,omitempty" bson:"payload,omitempty"`
|
|
RecoveryInput map[string]any `json:"-" bson:"recoveryInput,omitempty"`
|
|
CreatedAt string `json:"createdAt" bson:"createdAt"`
|
|
}
|
|
|
|
type ReleasePartitionStatus string
|
|
|
|
const (
|
|
ReleasePartitionPending ReleasePartitionStatus = "pending"
|
|
ReleasePartitionDispatching ReleasePartitionStatus = "dispatching"
|
|
ReleasePartitionDispatched ReleasePartitionStatus = "dispatched"
|
|
ReleasePartitionFailed ReleasePartitionStatus = "failed"
|
|
)
|
|
|
|
type ReleasePartitionRecord struct {
|
|
ID string `json:"id" bson:"id"`
|
|
OrganizationID string `json:"organizationId" bson:"organizationId"`
|
|
BatchID string `json:"batchId" bson:"batchId"`
|
|
GateNodeID string `json:"gateNodeId" bson:"gateNodeId"`
|
|
Sequence int `json:"sequence" bson:"sequence"`
|
|
UniqueKey string `json:"uniqueKey" bson:"uniqueKey"`
|
|
ManifestDigest string `json:"manifestDigest" bson:"manifestDigest"`
|
|
ManifestPath string `json:"manifestPath,omitempty" bson:"manifestPath,omitempty"`
|
|
ItemIDs []string `json:"itemIds" bson:"itemIds"`
|
|
Status ReleasePartitionStatus `json:"status" bson:"status"`
|
|
ChildRunID string `json:"childRunId,omitempty" bson:"childRunId,omitempty"`
|
|
CreatedAt string `json:"createdAt" bson:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt" bson:"updatedAt"`
|
|
}
|
|
|
|
type HumanBatchQuery struct {
|
|
PluginID string
|
|
ProjectID string
|
|
WorkflowID string
|
|
RunID string
|
|
Status HumanBatchStatus
|
|
}
|
|
|
|
// HumanItemCursor is the opaque continuation cursor for paginated human item
|
|
// lists, ordered by createdAt desc, id desc (mirroring RunSummaryCursor).
|
|
type HumanItemCursor struct {
|
|
CreatedAt string `json:"createdAt"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
type HumanItemQuery struct {
|
|
InheritedUnassigned bool
|
|
NeedsReworkRouting bool
|
|
|
|
// Server-derived necessary QC scope; nil is unrestricted, empty matches nothing.
|
|
AvailableProjectIDs []string
|
|
AvailableSupplierID *string
|
|
Search string
|
|
Capture string
|
|
Category string
|
|
ReviewedPool bool
|
|
// Server-populated review history scope; nil means unrestricted.
|
|
IDs []string
|
|
LegacyTaskID string
|
|
// Server-populated only; limits mine queries before loading heavy payloads.
|
|
ActorUserID string
|
|
// MinePoolOnly narrows the author arm to the existing human-items mine rule.
|
|
// Dedicated AnnotationView queries retain their own broader contracts.
|
|
MinePoolOnly bool
|
|
// Server-authorized annotator task list; applied before pagination.
|
|
AnnotationView string
|
|
// Server-only annotator visibility scope; retains actor history and non-annotation stage exceptions.
|
|
BlindAnnotationActorID string
|
|
PluginID string
|
|
BatchID string
|
|
ProjectID string
|
|
WorkflowID string
|
|
RunID string
|
|
CurrentStageID string
|
|
Status HumanItemStatus
|
|
// List-endpoint pagination knobs. Zero values keep the historical
|
|
// unpaginated behavior for internal callers (dashboard, batch reads).
|
|
Limit int
|
|
Cursor *HumanItemCursor
|
|
ListProjection bool
|
|
// PoolCandidateProjection omits payloads only during server-side eligibility filtering.
|
|
PoolCandidateProjection bool
|
|
// IdentityProjection is server-only and excludes all task payloads.
|
|
IdentityProjection bool
|
|
BufferSummaryProjection bool
|
|
// TaskListProjection serves the annotation-tasks list path: it drops the
|
|
// heavy payload sub-documents like ListProjection but keeps
|
|
// annotationDraft, which the handler reads to derive task progress.
|
|
TaskListProjection bool
|
|
// Pushdown filters mirroring the work-pool rules; used by the list
|
|
// endpoint so Mongo skips rows the handler would drop anyway.
|
|
UnassignedOnly bool
|
|
Statuses []HumanItemStatus
|
|
// StageIDs pushes a multi-stage filter into the store query. Role pools
|
|
// (available/all) previously filtered stages in-memory only, which left
|
|
// the database sorting the whole unassigned backlog (17k docs, ~7s per
|
|
// fetch round) before the handler dropped almost every row.
|
|
StageIDs []string
|
|
}
|
|
|
|
type HumanRejectQuery struct {
|
|
Limit int
|
|
BeforeTime string
|
|
BeforeID string
|
|
BatchID string
|
|
ItemID string
|
|
ProjectID string
|
|
WorkflowID string
|
|
RunID string
|
|
Status HumanRejectStatus
|
|
}
|
|
|
|
func DefaultAnnotationHumanStages() []HumanStageDefinition {
|
|
return []HumanStageDefinition{
|
|
{ID: "split_annotation", Label: "人工剪切", Kind: HumanStageAnnotation, RequiredRole: "cutter", EditorSchema: "temporal-segments/v1"},
|
|
{ID: "split_quality_review", Label: "剪切审核", Kind: HumanStageReview, RequiredRole: "annotator", RejectTargets: []string{"split_annotation"}},
|
|
{ID: "semantic_annotation", Label: "人工标注", Kind: HumanStageAnnotation, RequiredRole: "annotator", EditorSchema: "temporal-segments/v1"},
|
|
{ID: "quality_review", Label: "标注审核", Kind: HumanStageReview, RequiredRole: "quality_reviewer", RejectTargets: []string{"semantic_annotation", "split_annotation"}},
|
|
}
|
|
}
|
|
|
|
// DefaultFanyuV5HumanStages describes the supplier task-pool loop used after
|
|
// automatic rough cutting. A cut reviewer can return only to cut adjustment;
|
|
// a semantic reviewer can return to semantic annotation or, when the slice
|
|
// itself is wrong, all the way back to cut adjustment. The separate
|
|
// aggregate pre-package acceptance item remains confirm-only and is created
|
|
// only after every item reaches the end of this loop.
|
|
func DefaultFanyuV5HumanStages() []HumanStageDefinition {
|
|
return []HumanStageDefinition{
|
|
{ID: FanyuV5StageCutAdjustment, Label: "人工剪切调整", Kind: HumanStageAnnotation, RequiredRole: "cutter", EditorSchema: "temporal-segments/v1"},
|
|
{ID: FanyuV5StageCutReview, Label: "剪切审核", Kind: HumanStageReview, RequiredRole: "annotator", RejectTargets: []string{FanyuV5StageCutAdjustment}},
|
|
{ID: FanyuV5StageSemanticAnnotation, Label: "语义标注", Kind: HumanStageAnnotation, RequiredRole: "annotator", EditorSchema: "temporal-semantic-annotation/v2"},
|
|
{ID: FanyuV5StageSemanticReview, Label: "标注审核", Kind: HumanStageReview, RequiredRole: "quality_reviewer", RejectTargets: []string{FanyuV5StageSemanticAnnotation, FanyuV5StageCutAdjustment}},
|
|
}
|
|
}
|
|
|
|
func DefaultFanyuV58HumanStages() []HumanStageDefinition {
|
|
return []HumanStageDefinition{
|
|
{ID: FanyuV58StageAnnotationCombined, Label: "真实切分与语义标注", Kind: HumanStageAnnotation, RequiredRole: "annotator", EditorSchema: "temporal-semantic-annotation/v2"},
|
|
{ID: FanyuV58StageQualityReview, Label: "切分与标注审核", Kind: HumanStageReview, RequiredRole: "quality_reviewer", RejectTargets: []string{FanyuV58StageAnnotationCombined}},
|
|
}
|
|
}
|
|
|
|
func IsFanyuV58ThreeRoleHumanLoop(stages []HumanStageDefinition) bool {
|
|
return len(stages) == 2 &&
|
|
stages[0].ID == FanyuV58StageAnnotationCombined && stages[0].Kind == HumanStageAnnotation && stages[0].RequiredRole == "annotator" &&
|
|
stages[1].ID == FanyuV58StageQualityReview && stages[1].Kind == HumanStageReview && stages[1].RequiredRole == "quality_reviewer" &&
|
|
len(stages[1].RejectTargets) == 1 && stages[1].RejectTargets[0] == FanyuV58StageAnnotationCombined
|
|
}
|
|
|
|
// IsFanyuV5FourStageHumanLoop is deliberately strict: historical v5 combined
|
|
// batches stay readable through their legacy adapter while newly created v5
|
|
// work uses the independent cut and semantic review loop.
|
|
func IsFanyuV5FourStageHumanLoop(stages []HumanStageDefinition) bool {
|
|
if len(stages) != 4 {
|
|
return false
|
|
}
|
|
return stages[0].ID == FanyuV5StageCutAdjustment &&
|
|
stages[0].Kind == HumanStageAnnotation &&
|
|
stages[0].RequiredRole == "cutter" &&
|
|
stages[1].ID == FanyuV5StageCutReview &&
|
|
stages[1].Kind == HumanStageReview &&
|
|
stages[1].RequiredRole == "annotator" &&
|
|
stages[2].ID == FanyuV5StageSemanticAnnotation &&
|
|
stages[2].Kind == HumanStageAnnotation &&
|
|
stages[2].RequiredRole == "annotator" &&
|
|
stages[3].ID == FanyuV5StageSemanticReview &&
|
|
stages[3].Kind == HumanStageReview &&
|
|
stages[3].RequiredRole == "quality_reviewer"
|
|
}
|
|
|
|
// AnnotationRoleForHumanStage resolves historical stage aliases before configured roles.
|
|
func AnnotationRoleForHumanStage(stage HumanStageDefinition) AnnotationAssignmentRole {
|
|
switch stage.ID {
|
|
case "split_annotation", FanyuV5StageCutAdjustment:
|
|
return AnnotationRoleAnnotator
|
|
case "split_quality_review", FanyuV5StageCutReview, FanyuV5StageSemanticAnnotation:
|
|
return AnnotationRoleAnnotator
|
|
case "quality_review", FanyuV5StageSemanticReview:
|
|
return AnnotationRoleQualityReviewer
|
|
case "acceptance", "prepackage_acceptance":
|
|
if stage.RequiredRole == "acceptance_reviewer" {
|
|
return AnnotationRoleAcceptanceReviewer
|
|
}
|
|
return AnnotationRoleQualityReviewer
|
|
}
|
|
switch stage.RequiredRole {
|
|
case "cutter":
|
|
return AnnotationRoleAnnotator
|
|
case "quality_reviewer":
|
|
return AnnotationRoleQualityReviewer
|
|
case "acceptance_reviewer":
|
|
return AnnotationRoleAcceptanceReviewer
|
|
default:
|
|
return AnnotationRoleAnnotator
|
|
}
|
|
}
|
|
|
|
// PoolCandidate retains all eligibility and cursor fields without task content.
|
|
// It is internal to pool filtering; never send this record as a list response.
|
|
func (item HumanItemRecord) PoolCandidate() HumanItemRecord {
|
|
item.Subject.Payload = nil
|
|
if item.ProcessingJob != nil {
|
|
job := *item.ProcessingJob
|
|
job.Input = nil
|
|
item.ProcessingJob = &job
|
|
}
|
|
return item
|
|
}
|
|
|
|
// HumanRunDisplay is the persisted metadata used to label human tasks. It is
|
|
// deliberately independent of RunRecord: execution payloads remain detail-only.
|
|
type HumanRunDisplay struct {
|
|
ID string `json:"id" bson:"id"`
|
|
ProjectName string `json:"projectName" bson:"projectName"`
|
|
WorkflowName string `json:"workflowName" bson:"workflowName"`
|
|
TaskID string `json:"taskId" bson:"taskId"`
|
|
CaptureDirectories []string `json:"captureDirectories" bson:"captureDirectories"`
|
|
}
|
|
|
|
// HumanCaptureDisplay contains only the fields used to name an authorized task.
|
|
type HumanCaptureDisplay struct {
|
|
ID string `json:"id" bson:"id"`
|
|
CaptureID string `json:"captureId" bson:"captureId"`
|
|
Prefix string `json:"prefix" bson:"prefix"`
|
|
}
|
|
|
|
// PoolSearchCurrent also detects an old server writing a record without
|
|
// refreshing its derived summary during a rolling upgrade or rollback.
|
|
func (item HumanItemRecord) PoolSearchCurrent() bool {
|
|
m := item.PoolSearch
|
|
return m != nil && m.Schema == 1 && m.SourceVersion == item.Version && m.SourceUpdatedAt == item.UpdatedAt && m.SourceItemKey == item.Subject.ItemKey && m.SourceArtifactID == item.Subject.ArtifactID
|
|
}
|