d-robotics b7f4924110 📊 Refresh acceptance priority statistics nightly
(cherry picked from commit fb4f6715bb58c1c512284d0651024ac890e6f896)
2026-11-18 20:29:20 +08:00

411 lines
30 KiB
Go

package store
import (
"context"
"droboticflow/internal/outputsnapshot"
"errors"
"time"
"droboticflow/internal/domain"
"droboticflow/internal/productionstats"
"droboticflow/internal/workforcestats"
)
var (
ErrDuplicateOrganizationSlug = errors.New("organization slug must be unique")
ErrDuplicateUserPhone = errors.New("user phone must be unique")
ErrSupplierImmutable = errors.New("supplier ownership cannot be changed")
)
type WorkerDispatchQuery struct {
Now time.Time
ExcludedWorkflowIDs []string
TriggerIn []domain.RunTrigger
TriggerNotIn []domain.RunTrigger
After *domain.RunSummaryCursor
Limit int
}
type WorkerRunCounts struct {
ActiveByWorkflow map[string]int
InflightByWorkflow map[string]int
ActiveTotal int
QueuedTotal int
}
type Store interface {
outputsnapshot.Backend
InsertClientMoviStat(context.Context, domain.ClientMoviStatRecord) error
ListClientMoviStats(context.Context, string, int) ([]domain.ClientMoviStatRecord, error)
LoadWorkforceStats(context.Context, string, workforcestats.Query) (workforcestats.Snapshot, error)
LoadAnnotationOutput(context.Context, string, []string) (workforcestats.OutputSnapshot, error)
GetProductionStatsScope(context.Context, string) (productionstats.Scope, error)
SaveProductionStatsScope(context.Context, string, productionstats.Scope, int) (bool, error)
LoadProductionStats(context.Context, string, []string) (productionstats.Snapshot, error)
GetReviewOperation(context.Context, string) (*domain.ReviewOperation, error)
FindReviewOperation(context.Context, string, string, string, string) (*domain.ReviewOperation, error)
CompareAndSwapReviewOperation(context.Context, domain.ReviewOperation, int) (bool, error)
UpdateAnnotationTaskForReview(context.Context, domain.AnnotationTaskRecord, domain.AnnotationTaskRecord) (bool, error)
UpdateHumanItemForReview(context.Context, domain.HumanItemRecord, int) (bool, error)
GetReviewDraft(context.Context, string) (*domain.ReviewDraft, error)
ArchiveReviewDraft(context.Context, domain.ReviewDraft) error
GetReviewDraftArchive(context.Context, string) (*domain.ReviewDraft, error)
GetReworkBaseline(context.Context, string) (*domain.ReworkBaselineRecord, error)
UpsertReworkBaseline(context.Context, domain.ReworkBaselineRecord) error
GetReworkHandling(context.Context, string) (*domain.ReworkHandlingRecord, error)
CompareAndSwapReworkHandling(context.Context, domain.ReworkHandlingRecord, int) (bool, error)
CompareAndSwapReviewDraft(context.Context, domain.ReviewDraft, int) (bool, error)
GetReviewContinuation(context.Context, string) (*domain.ReviewContinuation, error)
CompareAndSwapReviewContinuation(context.Context, domain.ReviewContinuation, int, *domain.ReviewSession) (bool, error)
GetReviewSession(context.Context, string) (*domain.ReviewSession, error)
CompareAndSwapReviewSession(context.Context, domain.ReviewSession, int) (bool, error)
Ready(context.Context) error
EnsureDefaultOrganization(context.Context) (*domain.OrganizationRecord, error)
ListOrganizations(context.Context) ([]domain.OrganizationRecord, error)
GetOrganization(context.Context, string) (*domain.OrganizationRecord, error)
UpsertOrganization(context.Context, domain.OrganizationRecord) error
DeleteOrganizationCascade(context.Context, string) (bool, error)
ListProjects(context.Context) ([]domain.ProjectRecord, error)
ListProjectsByOrganization(context.Context, string) ([]domain.ProjectRecord, error)
GetProject(context.Context, string) (*domain.ProjectRecord, error)
CreateProject(context.Context, domain.CreateProjectInput) (*domain.ProjectRecord, error)
DeleteProject(context.Context, string) (bool, error)
UpsertProject(context.Context, domain.ProjectRecord) error
MarkProjectDeleting(context.Context, string, string) error
CreateProjectDeletion(context.Context, domain.ProjectDeletionTask) (*domain.ProjectDeletionTask, error)
GetProjectDeletion(context.Context, string) (*domain.ProjectDeletionTask, error)
ListProjectDeletions(context.Context, string) ([]domain.ProjectDeletionTask, error)
ClaimProjectDeletion(context.Context, string, string, string, string) (*domain.ProjectDeletionTask, bool, error)
RenewProjectDeletion(context.Context, string, string, string) (bool, error)
SaveProjectDeletion(context.Context, domain.ProjectDeletionTask, string) (bool, error)
ListOperators(context.Context) ([]domain.OperatorRecord, error)
ListOperatorsByOrganization(context.Context, string) ([]domain.OperatorRecord, error)
GetOperator(context.Context, string) (*domain.OperatorRecord, error)
CreateOperator(context.Context, domain.CreateOperatorInput) (*domain.OperatorRecord, error)
DeleteOperator(context.Context, string) (bool, error)
UpsertOperator(context.Context, domain.OperatorRecord) error
ListBuiltinOperatorDeletions(context.Context) ([]domain.BuiltinOperatorDeletionRecord, error)
UpsertBuiltinOperatorDeletion(context.Context, domain.BuiltinOperatorDeletionRecord) error
ListWorkflowsByProject(context.Context, string) ([]domain.WorkflowRecord, error)
ListAllWorkflows(context.Context) ([]domain.WorkflowRecord, error)
ListAllWorkflowsByOrganization(context.Context, string) ([]domain.WorkflowRecord, error)
ListEnabledCaptureAutomations(context.Context, string) ([]domain.WorkflowRecord, error)
ListWorkerWorkflows(context.Context, []string, int) ([]domain.WorkflowRecord, error)
GetWorkflow(context.Context, string) (*domain.WorkflowRecord, error)
CreateWorkflow(context.Context, domain.CreateWorkflowInput) (*domain.WorkflowRecord, error)
DeleteWorkflow(context.Context, string) (bool, error)
UpsertWorkflow(context.Context, domain.WorkflowRecord) error
// UpdateWorkflowRunState updates only a workflow's run-state fields (status,
// lastRunId, updatedAt) via a field-level write. The worker holds a workflow
// snapshot for the entire duration of a run; using UpsertWorkflow (full-document
// $set) to bump run state would clobber concurrent PUT edits such as a node's
// containerCommand made while the run is in flight (a lost update). This method
// never touches Nodes/Edges, so PUT edits survive a long-running workflow.
UpdateWorkflowRunState(context.Context, string, domain.WorkflowStatus, string, string) error
GetWorkflowRuntimePolicy(context.Context, string) (*domain.WorkflowRuntimePolicyRecord, error)
UpdateWorkflowRuntimePolicyVersioned(context.Context, domain.WorkflowRuntimePolicyRecord, int) (bool, error)
ListTemplates(context.Context) ([]domain.TemplateRecord, error)
ListTemplatesByOrganization(context.Context, string) ([]domain.TemplateRecord, error)
GetTemplate(context.Context, string) (*domain.TemplateRecord, error)
CreateTemplate(context.Context, domain.CreateTemplateInput) (*domain.TemplateRecord, error)
DeleteTemplate(context.Context, string) (bool, error)
UpsertTemplate(context.Context, domain.TemplateRecord) error
ListWorkflowReleases(context.Context, string, domain.WorkflowReleaseQuery) ([]domain.WorkflowReleaseRecord, error)
GetWorkflowRelease(context.Context, string) (*domain.WorkflowReleaseRecord, error)
UpsertWorkflowRelease(context.Context, domain.WorkflowReleaseRecord) error
ListProjectWorkflowInstances(context.Context, string, domain.ProjectWorkflowInstanceQuery) ([]domain.ProjectWorkflowInstanceRecord, error)
GetProjectWorkflowInstance(context.Context, string) (*domain.ProjectWorkflowInstanceRecord, error)
UpsertProjectWorkflowInstance(context.Context, domain.ProjectWorkflowInstanceRecord) error
ListRuns(context.Context, string) ([]domain.RunRecord, error)
ListRunsByOrganization(context.Context, string, string) ([]domain.RunRecord, error)
ListRunArtifacts(context.Context, string) ([]domain.RunRecord, error)
ListRunArtifactsByOrganization(context.Context, string, string) ([]domain.RunRecord, error)
// ListRunArtifactsForProject scopes to runs whose projectId matches
// projectID directly, or whose workflowId is in workflowIDs. Used by
// project-deletion planning/verification so it doesn't have to scan
// every run in the organization (see account-phone-login-era perf fix:
// large orgs made the unscoped org-wide scan hang for minutes).
ListRunArtifactsForProject(ctx context.Context, organizationID string, projectID string, workflowIDs []string) ([]domain.RunRecord, error)
// ListRunsAcceptanceCandidates is the bounded point-query replacement for
// dashboardPOCReadiness's former full ListRuns scan (slow-page report S4):
// it returns only runs that can possibly carry a POC acceptance artifact
// (matching dashboardAcceptancePayloadFromArtifact's detection paths), most
// recently updated first, capped at limit. organizationID "" means unscoped,
// mirroring ListRuns.
ListRunsAcceptanceCandidates(ctx context.Context, organizationID string, limit int) ([]domain.RunRecord, error)
// ListRunsWorkflowCandidates is the bounded point-query replacement for the
// same scan's GPU-workflow-preflight half: runs whose workflowName or
// projectName matches one of the POC/live acceptance names, most recently
// updated first, capped at limit. organizationID "" means unscoped.
ListRunsWorkflowCandidates(ctx context.Context, organizationID string, workflowNames []string, projectNames []string, limit int) ([]domain.RunRecord, error)
// ListHumanBatchIDsAwaitingRelease backs the background release-partition
// sweeper that replaced the GET /api/human-batches read-path flush (S4):
// it returns the distinct batch IDs that still have accepted items without
// a release partition, i.e. exactly the batches flushHumanReleasePartitions
// could act on.
ListHumanBatchIDsAwaitingRelease(ctx context.Context) ([]string, error)
// ArchiveTerminalRuns sets ArchivedAt on every not-yet-archived run whose
// status is completed/failed/cancelled and whose EndedAt is older than
// olderThan. Archiving never deletes the record — it only excludes it
// from the org-wide scans (see ListRunArtifactsByOrganization) that
// would otherwise keep growing as an organization's run history grows
// unbounded; a run's data is only actually removed when its project is
// deleted. Returns the number of runs archived.
ArchiveTerminalRuns(ctx context.Context, olderThan time.Time) (int, error)
CountRunsByStatus(context.Context) (map[domain.RunStatus]int, error)
ListRunSummaries(context.Context, string) ([]domain.RunSummary, error)
ListRunSummariesByOrganization(context.Context, string, string) ([]domain.RunSummary, error)
ListRunSummariesPage(context.Context, domain.RunSummaryQuery) (domain.RunSummaryPage, error)
ListRunSummariesPageByOrganization(context.Context, string, domain.RunSummaryQuery) (domain.RunSummaryPage, error)
// Dispatch candidates are eligible FIFO records, independent of UI pagination.
ListQueuedRunsForDispatch(context.Context, WorkerDispatchQuery) ([]domain.RunSummary, error)
ListReconcileRunSummaries(context.Context, int) ([]domain.RunSummary, error)
CountWorkerRuns(context.Context) (WorkerRunCounts, error)
HasActiveRun(context.Context, string) (bool, error)
GetRun(context.Context, string) (*domain.RunRecord, error)
ListHumanRunDisplays(context.Context, []string) ([]domain.HumanRunDisplay, error)
ListHumanCaptureDisplays(context.Context, []string) ([]domain.HumanCaptureDisplay, error)
CreateRun(context.Context, string, domain.RunTrigger, ...string) (*domain.RunRecord, error)
CreateRunWithInputs(context.Context, string, domain.RunTrigger, map[string]domain.ArtifactPayload, ...string) (*domain.RunRecord, error)
ClaimNextQueuedRun(context.Context, string, time.Duration) (*domain.RunRecord, error)
ClaimQueuedRun(context.Context, string, string, time.Duration) (*domain.RunRecord, error)
AcquireRunLease(context.Context, string, string, time.Duration) (*domain.RunRecord, bool, error)
RenewRunLease(context.Context, string, string, time.Duration) (bool, error)
ReleaseRunLease(context.Context, string, string) error
RequestRunStop(context.Context, string, domain.RunStopMode) (*domain.RunRecord, error)
UpsertRun(context.Context, domain.RunRecord) error
UpdateRunProgress(context.Context, string, *domain.RunProgress) error
UpdateRunFailure(context.Context, string, *domain.RunFailure) error
// AppendNodeExecutionResourceSample pushes one resource sample onto a running
// node's resourceSeries in place, so the worker can stream live GPU metrics for
// custom-container operators during execution (their full series is otherwise
// only persisted at node completion). No-op when the run or node is absent.
AppendNodeExecutionResourceSample(context.Context, string, string, domain.ResourceSample) error
GetSourceState(context.Context, string, string, string) (*domain.SourceStateRecord, error)
ListSourceStates(context.Context, string, string) ([]domain.SourceStateRecord, error)
UpsertSourceState(context.Context, domain.SourceStateRecord) error
DeleteSourceState(context.Context, string, string, string) error
DeleteSourceStatesByWorkflow(context.Context, string) error
ListCaptureRecords(context.Context, string, string, int) ([]domain.CaptureRecord, error)
ListCaptureStatusPage(context.Context, string, int) ([]domain.CaptureRecord, error)
UpdateCaptureRunStatus(context.Context, domain.CaptureRecord, domain.CaptureRecord) (bool, error)
GetCaptureRecord(context.Context, string) (*domain.CaptureRecord, error)
GetCaptureRecordByWorkflowPrefix(context.Context, string, string) (*domain.CaptureRecord, error)
GetCaptureRecordByRunID(context.Context, string) (*domain.CaptureRecord, error)
UpsertCaptureRecord(context.Context, domain.CaptureRecord) error
SetCaptureSamplingDecisionIfAbsent(context.Context, string, domain.CaptureSamplingDecision) (bool, error)
ClaimCaptureRecordForLaunch(context.Context, string, string) (bool, error)
TransitionCaptureRecord(context.Context, string, domain.CaptureRecordStatus, domain.CaptureRecordStatus, domain.CaptureRecordStatus, domain.CaptureActionRecord) (bool, error)
GetRunByWorkflowTaskID(context.Context, string, string) (*domain.RunRecord, error)
ListCollectionTasks(context.Context, string) ([]domain.CollectionTaskRecord, error)
GetCollectionTask(context.Context, string) (*domain.CollectionTaskRecord, error)
UpsertCollectionTask(context.Context, domain.CollectionTaskRecord) error
UpsertDatasetVersion(context.Context, domain.DatasetVersionRecord) error
ListDatasetVersions(context.Context, string, domain.DataOperationsQuery) ([]domain.DatasetVersionRecord, error)
UpsertDataMetricFact(context.Context, domain.DataMetricFactRecord) error
ListDataMetricFactsPage(context.Context, string, domain.DataOperationsQuery) (domain.DataMetricFactPage, error)
GetDataOperationsSummary(context.Context, string, domain.DataOperationsQuery) (domain.DataOperationsSummary, error)
ListTrainingUsagePage(context.Context, string, domain.DataOperationsQuery) (domain.TrainingUsagePage, error)
ListDataOperationsBackfillRuns(context.Context, string, string, *domain.RunSummaryCursor, int) (domain.DataOperationsRunPage, error)
ListRunsNeedingMetricMaterialization(context.Context, int) ([]domain.RunRecord, error)
MarkNodeMetricsMaterialized(context.Context, string, string, int, string) error
ListAuditTasks(context.Context, string) ([]domain.AuditTaskRecord, error)
ListAuditTasksByOrganization(context.Context, string, string) ([]domain.AuditTaskRecord, error)
GetAuditTask(context.Context, string) (*domain.AuditTaskRecord, error)
CreateAuditTask(context.Context, domain.AuditTaskRecord) (*domain.AuditTaskRecord, error)
UpsertAuditTask(context.Context, domain.AuditTaskRecord) error
ListSamplingTasks(context.Context, string) ([]domain.SamplingTaskRecord, error)
ListSamplingTasksByOrganization(context.Context, string, string) ([]domain.SamplingTaskRecord, error)
GetSamplingTask(context.Context, string) (*domain.SamplingTaskRecord, error)
CreateSamplingTask(context.Context, domain.SamplingTaskRecord) (*domain.SamplingTaskRecord, error)
UpsertSamplingTask(context.Context, domain.SamplingTaskRecord) error
ListAnnotationWorkgroups(context.Context, string) ([]domain.AnnotationWorkgroupRecord, error)
GetAnnotationWorkgroup(context.Context, string) (*domain.AnnotationWorkgroupRecord, error)
UpsertAnnotationWorkgroup(context.Context, domain.AnnotationWorkgroupRecord) error
ListProjectAnnotationMemberships(context.Context, string, string) ([]domain.ProjectAnnotationMembershipRecord, error)
UpsertProjectAnnotationMembership(context.Context, domain.ProjectAnnotationMembershipRecord) error
DeleteProjectAnnotationMembership(context.Context, string) (bool, error)
ListSupplierDeletionRunReferences(context.Context) ([]domain.RunRecord, error)
PreviewSupplierDeletion(context.Context, string, string) (domain.SupplierDeletionPlan, error)
GetSupplierDeletion(context.Context, string) (*domain.SupplierDeletionTask, error)
ListSupplierDeletions(context.Context, string) ([]domain.SupplierDeletionTask, error)
BeginSupplierDeletion(context.Context, domain.SupplierDeletionTask) (*domain.SupplierDeletionTask, error)
ClaimSupplierDeletion(context.Context, string, string, string, string) (*domain.SupplierDeletionTask, bool, error)
SaveSupplierDeletion(context.Context, domain.SupplierDeletionTask, string) (bool, error)
RenewSupplierDeletion(context.Context, string, string, string) (bool, error)
ExecuteSupplierDeletionRecords(context.Context, domain.SupplierDeletionTask, string) error
CancelSupplierQueuedProcessing(context.Context, domain.SupplierDeletionPlan) error
SupplierIndexingActive(context.Context, domain.SupplierDeletionPlan) (bool, error)
ListSuppliers(context.Context, string) ([]domain.SupplierRecord, error)
GetSupplier(context.Context, string) (*domain.SupplierRecord, error)
ResolveAcceptanceSourceSuppliers(context.Context, string, []string) (map[string]string, error)
ReadAcceptanceSnapshot(context.Context, string) (*domain.AcceptanceSnapshot, error)
SaveAcceptanceSnapshot(context.Context, domain.AcceptanceSnapshot) error
VisitAcceptanceCandidates(context.Context, string, string, func([]domain.HumanItemRecord) error) error
ListAcceptancePriorities(context.Context, string) ([]domain.AcceptancePriority, error)
SaveAcceptancePriority(context.Context, domain.AcceptancePriority, int) (*domain.AcceptancePriority, error)
GetSupplierAcceptanceAuthorization(context.Context, string, string) (*domain.SupplierAcceptanceAuthorization, error)
SetSupplierAcceptanceAuthorization(context.Context, string, string, bool, int, string) (*domain.SupplierAcceptanceAuthorization, error)
ListReviewCandidates(context.Context, string, string, string, bool, int, int, ...string) ([]domain.HumanItemRecord, error)
SharedAcceptanceInventory(context.Context, string, string, string) ([]string, int, error)
UpsertSupplier(context.Context, domain.SupplierRecord) error
MutateSupplier(context.Context, string, string, string, bool) (*domain.SupplierRecord, error)
ListProjectMembers(context.Context, string, string) ([]domain.ProjectMemberRecord, error)
ListProjectMembersForUser(context.Context, string, string, string) ([]domain.ProjectMemberRecord, error)
ListSupplierProjectAuthorizations(context.Context, string, string) ([]domain.SupplierProjectAuthorization, error)
HasOpenSupplierDrainTask(context.Context, string, string, string, []string) (bool, error)
SetSupplierProjectAuthorization(context.Context, string, string, string, bool, string) (*domain.SupplierProjectAuthorization, error)
PreviewSupplierPoolConversion(context.Context, string, string, string) (SupplierPoolPreview, error)
ConvertSupplierPool(context.Context, string, string, string, string) (SupplierPoolConversionResult, error)
GetProjectMember(context.Context, string) (*domain.ProjectMemberRecord, error)
GetProjectMemberByProjectUser(context.Context, string, string, string) (*domain.ProjectMemberRecord, error)
UpsertProjectMember(context.Context, domain.ProjectMemberRecord) error
EnsureDefaultSupplier(context.Context, string) (*domain.SupplierRecord, error)
SyncDefaultSupplierProjectMembers(context.Context, string, string, string) error
DeleteProjectMember(context.Context, string) (bool, error)
ListAnnotationLabels(context.Context, string) ([]domain.AnnotationLabelRecord, error)
GetAnnotationLabel(context.Context, string) (*domain.AnnotationLabelRecord, error)
UpsertAnnotationLabel(context.Context, domain.AnnotationLabelRecord) error
GetProjectAnnotationLabels(context.Context, string) (*domain.ProjectAnnotationLabelsRecord, error)
UpsertProjectAnnotationLabels(context.Context, domain.ProjectAnnotationLabelsRecord) error
UpsertProjectSliceLabels(context.Context, domain.ProjectAnnotationLabelsRecord) error
UpsertProjectDiscardReasonLabels(context.Context, domain.ProjectAnnotationLabelsRecord) error
ListAnnotationTemplates(context.Context, string, string) ([]domain.AnnotationTemplateRecord, error)
GetAnnotationTemplate(context.Context, string) (*domain.AnnotationTemplateRecord, error)
UpsertAnnotationTemplate(context.Context, domain.AnnotationTemplateRecord) error
ListAnnotationTasks(context.Context, string, string) ([]domain.AnnotationTaskRecord, error)
ListAnnotationTasksFiltered(context.Context, string, AnnotationTaskFilter) ([]domain.AnnotationTaskRecord, error)
ListHumanItemsByLegacyTaskIDs(context.Context, string, []string) ([]domain.HumanItemRecord, error)
ListHumanItemDraftProgress(context.Context, string, []string) ([]domain.HumanItemDraftProgress, error)
GetAnnotationTask(context.Context, string) (*domain.AnnotationTaskRecord, error)
UpsertAnnotationTask(context.Context, domain.AnnotationTaskRecord) error
ListAnnotationRevisions(context.Context, string, string) ([]domain.AnnotationRevisionRecord, error)
ListAnnotationRevisionsByTaskIDs(context.Context, string, []string) ([]domain.AnnotationRevisionRecord, error)
UpsertAnnotationRevision(context.Context, domain.AnnotationRevisionRecord) error
DeleteAnnotationRevisions(context.Context, string, string) error
ListSliceRevisions(context.Context, string, string) ([]domain.SliceRevisionRecord, error)
ListSliceRevisionsByTaskIDs(context.Context, string, []string) ([]domain.SliceRevisionRecord, error)
// Progress reads return at most one compact revision per requested task.
// Annotation selection excludes system/zero revisions before latest wins.
ListLatestSliceProgressByTaskIDs(context.Context, string, []string) ([]domain.SliceRevisionRecord, error)
ListLatestAnnotationProgressByTaskIDs(context.Context, string, []string) ([]domain.AnnotationRevisionRecord, error)
UpsertSliceRevision(context.Context, domain.SliceRevisionRecord) error
DeleteSliceRevisions(context.Context, string, string) error
PruneAnnotationDataBefore(context.Context, string, string, int) error
RemoveRunArtifacts(context.Context, string, string, []string) error
ListAnnotationReviews(context.Context, string, string) ([]domain.AnnotationReviewRecord, error)
UpsertAnnotationReview(context.Context, domain.AnnotationReviewRecord) error
ListAnnotationWorklogEvents(context.Context, string, string) ([]domain.AnnotationWorklogEventRecord, error)
UpsertAnnotationWorklogEvent(context.Context, domain.AnnotationWorklogEventRecord) error
ListOrganizationPlugins(context.Context, string) ([]domain.OrganizationPluginRecord, error)
GetOrganizationPlugin(context.Context, string, string) (*domain.OrganizationPluginRecord, error)
UpsertOrganizationPlugin(context.Context, domain.OrganizationPluginRecord) error
ListHumanBatches(context.Context, string, domain.HumanBatchQuery) ([]domain.HumanBatchRecord, error)
// HasRawHumanAnnotationBatch reports whether any non-completed
// raw_human annotation-qa batch exists for the project without
// materializing the (potentially 12k+) batch documents.
HasRawHumanAnnotationBatch(context.Context, string, string) (bool, error)
ListHumanBatchAccessRecords(context.Context, string, []string) ([]domain.HumanBatchRecord, error)
GetHumanBatch(context.Context, string) (*domain.HumanBatchRecord, error)
UpsertHumanBatch(context.Context, domain.HumanBatchRecord) error
ListHumanItems(context.Context, string, domain.HumanItemQuery) ([]domain.HumanItemRecord, error)
VisitHumanPoolCountCandidates(context.Context, string, domain.HumanItemQuery, func([]domain.HumanItemRecord) error) error
CountAdminAnnotationPools(context.Context, string, AdminAnnotationPoolQuery) (AdminAnnotationPoolCounts, error)
ListAdminAnnotationPool(context.Context, string, AdminAnnotationPoolQuery) ([]domain.HumanItemRecord, error)
VisitAnnotationClaimCandidates(context.Context, string, string, func(domain.HumanItemRecord) (bool, error)) (bool, error)
ListAnnotationClaimCandidates(context.Context, string, string) ([]domain.HumanItemRecord, error)
CountAnnotationClaimCandidates(context.Context, string, AnnotationClaimCountQuery) (int, error)
GetHumanClaimReceipt(context.Context, string) (*HumanClaimReceipt, error)
AnnotationWorkBuffer(context.Context, string, string, string, int) (AnnotationWorkBuffer, error)
EnrichAnnotationSourceStatuses(context.Context, []domain.HumanItemRecord) error
AnnotationWorkBufferSummary(context.Context, string, string, string, int) (AnnotationWorkBuffer, error)
ResetDeletedAnnotatorTask(context.Context, domain.AnnotationTaskRecord) error
ClearReworkRoutingPending(context.Context, string, int) (bool, error)
MarkInheritedReworkPending(context.Context, domain.HumanItemRecord, int) (bool, error)
LoadInheritedReworkBaseline(context.Context, domain.HumanItemRecord) (*domain.ReworkBaselineRecord, error)
CommitHumanClaim(context.Context, HumanClaimCommit) (*domain.HumanItemRecord, error)
GetHumanItem(context.Context, string) (*domain.HumanItemRecord, error)
UpsertHumanItem(context.Context, domain.HumanItemRecord) error
UpdateHumanItemVersioned(context.Context, domain.HumanItemRecord, int) (bool, error)
ClaimHumanItemVersioned(context.Context, domain.HumanItemRecord, int, domain.UserRole) (bool, error)
ListHumanStageAttempts(context.Context, string, string) ([]domain.HumanStageAttemptRecord, error)
UpsertHumanStageAttempt(context.Context, domain.HumanStageAttemptRecord) error
ListReviewedHumanItemIDs(context.Context, string, string) ([]string, error)
ListLatestReviewEvents(context.Context, string, string, []string) (map[string]domain.HumanEventRecord, error)
ListHumanTraceSummaries(context.Context, string, []domain.HumanItemRecord) (map[string]domain.HumanTraceSummary, error)
ListHumanTraceEvents(context.Context, string, string) ([]domain.HumanEventRecord, error)
ListHumanEvents(context.Context, string, string) ([]domain.HumanEventRecord, error)
AppendHumanEvent(context.Context, domain.HumanEventRecord) error
AppendHumanEventOnce(context.Context, domain.HumanEventRecord) error
ListHumanRejects(context.Context, string, domain.HumanRejectQuery) ([]domain.HumanRejectRecord, error)
GetHumanReject(context.Context, string) (*domain.HumanRejectRecord, error)
UpsertHumanReject(context.Context, domain.HumanRejectRecord) error
UpdateHumanRejectVersioned(context.Context, domain.HumanRejectRecord, int) (bool, error)
ListReleasePartitions(context.Context, string, string) ([]domain.ReleasePartitionRecord, error)
GetReleasePartitionByUniqueKey(context.Context, string, string) (*domain.ReleasePartitionRecord, error)
ClaimReleasePartition(context.Context, string, string) (bool, error)
UpsertReleasePartition(context.Context, domain.ReleasePartitionRecord) error
ListDeliveryPackages(context.Context, string, domain.DeliveryPackageQuery) ([]domain.DeliveryPackageRecord, error)
GetDeliveryPackage(context.Context, string) (*domain.DeliveryPackageRecord, error)
UpsertDeliveryPackage(context.Context, domain.DeliveryPackageRecord) error
UpdateDeliveryPackageVersioned(context.Context, domain.DeliveryPackageRecord, int) (bool, error)
ListUsers(context.Context) ([]domain.UserRecord, error)
ListUsersByOrganization(context.Context, string) ([]domain.UserRecord, error)
ListProjectMemberUsers(context.Context, string, []string) ([]domain.UserRecord, error)
GetUser(context.Context, string) (*domain.UserRecord, error)
FindUserByPhone(context.Context, string) (*domain.UserRecord, error)
FindUserByLegacyEmail(context.Context, string) (*domain.UserRecord, error)
CreateUser(context.Context, domain.CreateUserInput) (*domain.UserRecord, error)
DeleteUser(context.Context, string) (bool, error)
UpsertUser(context.Context, domain.UserRecord) error
UpdateUser(context.Context, domain.UserRecord, domain.UserRecord) error
AccountHasPendingWork(context.Context, string, string, domain.UserRole) (bool, error)
CreateSession(context.Context, domain.SessionRecord) (*domain.SessionRecord, error)
GetSessionByTokenHash(context.Context, string) (*domain.SessionRecord, error)
DeleteSession(context.Context, string) (bool, error)
DeleteSessionsByUser(context.Context, string) error
ListStorageConnections(context.Context) ([]domain.StorageConnectionRecord, error)
ListStorageConnectionsByOrganization(context.Context, string) ([]domain.StorageConnectionRecord, error)
GetStorageConnection(context.Context, string) (*domain.StorageConnectionRecord, error)
CreateStorageConnection(context.Context, domain.CreateStorageConnectionInput) (*domain.StorageConnectionRecord, error)
DeleteStorageConnection(context.Context, string) (bool, error)
UpsertStorageConnection(context.Context, domain.StorageConnectionRecord) error
ListObjectStorageUploadSessions(context.Context, string, string) ([]domain.ObjectStorageUploadSessionRecord, error)
GetObjectStorageUploadSession(context.Context, string) (*domain.ObjectStorageUploadSessionRecord, error)
UpsertObjectStorageUploadSession(context.Context, domain.ObjectStorageUploadSessionRecord) error
DeleteExpiredObjectStorageUploadSessions(context.Context, string) (int64, error)
ListMongoConnections(context.Context) ([]domain.MongoConnectionRecord, error)
ListMongoConnectionsByOrganization(context.Context, string) ([]domain.MongoConnectionRecord, error)
GetMongoConnection(context.Context, string) (*domain.MongoConnectionRecord, error)
CreateMongoConnection(context.Context, domain.CreateMongoConnectionInput) (*domain.MongoConnectionRecord, error)
DeleteMongoConnection(context.Context, string) (bool, error)
UpsertMongoConnection(context.Context, domain.MongoConnectionRecord) error
GetSettings(context.Context) (*domain.SettingsRecord, error)
UpsertSettings(context.Context, domain.SettingsRecord) error
GetArtifactStorageSettings(context.Context, string) (domain.ArtifactStorageSettings, error)
UpsertArtifactStorageSettings(context.Context, string, domain.ArtifactStorageSettings) error
GetDashboardSummary(context.Context) (domain.DashboardSummary, error)
ListStorageBuckets(context.Context, string) ([]string, error)
ListStorageObjects(context.Context, string, string, string) ([]string, error)
GetDatabaseOverview(context.Context) (domain.DatabaseOverview, error)
QueryDatabaseCollection(context.Context, domain.DatabaseQueryInput) (domain.DatabaseQueryResult, error)
PatchDatabaseDocument(context.Context, string, string, map[string]any) (map[string]any, error)
UpsertDatabaseDocument(context.Context, string, map[string]any, map[string]any, map[string]any) (map[string]any, bool, error)
}