Help us shape the future of Go! Take the 2026 Go Developer Survey

repository

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDeploymentIdentityMissing  = errors.New("database has business records but no deployment identity")
	ErrDeploymentIdentityMismatch = errors.New("database belongs to another Filecoin wallet or network")
)
View Source
var (
	ErrTaskDataCorrupted     = errors.New("task data is corrupted")
	ErrTaskIdentityContended = errors.New("task identity is busy")
	ErrRepositoryContended   = errors.New("database transaction is busy")
)

Cross-table corruption is distinct from retryable transaction contention.

View Source
var (
	ErrTaskEffectAlreadyAdmitted = errors.New("task effect already admitted for this attempt")
	ErrTaskOperationUnresolved   = errors.New("previous task operation is unresolved")
)
View Source
var (
	ErrWalletOperationConflict      = errors.New("wallet operation request conflicts with existing operation")
	ErrWalletOperationInvalidAmount = errors.New("wallet operation amount must be a positive integer string")
)
View Source
var ErrAlreadyCurrent = errors.New("already current")

ErrAlreadyCurrent is returned when a restore would not change the current object representation.

View Source
var ErrAlreadyExists = errors.New("already exists")

ErrAlreadyExists is returned when an insert violates a unique constraint.

View Source
var ErrConflict = errors.New("conflict")

ErrConflict is returned when a compare-and-restore operation sees stale state.

View Source
var ErrContentCleanupInProgress = errors.New("storage content is being cleaned up")

ErrContentCleanupInProgress reports that a write names content whose cleanup has started or already deleted it. The bytes have to be written again once the cleanup finishes, which then creates new content.

View Source
var ErrContentCleanupNotReady = errors.New("storage content cleanup is waiting for other work")

ErrContentCleanupNotReady reports that a finished cleanup cannot delete its content yet because other work still needs the rows.

View Source
var ErrInvalidInput = errors.New("invalid input")

ErrInvalidInput is returned when repository input fails validation.

View Source
var ErrNoRemovalRoom = errors.New("data set deletion queue has no room")
View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when a CAS update matches zero rows (entity missing or wrong state).

View Source
var ErrPermanentDeleteStorageBusy = fmt.Errorf("permanent delete blocked by storage work: %w", ErrConflict)

ErrPermanentDeleteStorageBusy reports that a permanent delete cannot yet cancel storage work without risking a remote write. It remains compatible with ErrConflict for existing callers.

View Source
var ErrReplicaTargetLowered = fmt.Errorf("lowering the replica target is not supported: %w", ErrInvalidInput)

ErrReplicaTargetLowered reports an attempt to reduce a bucket's replica target. It stays an ErrInvalidInput so existing handling still applies, but it is distinguishable because the reason a caller needs to hear is specific.

View Source
var ErrS3AccountNameExists = errors.New("S3 account name already exists")
View Source
var ErrTaskLeaseLost = errors.New("task lease lost")

ErrTaskLeaseLost reports that a claim generation is stale or its lease can no longer be proven valid.

Functions

func PrefixUpperBound added in v0.1.1

func PrefixUpperBound(prefix string) (string, bool)

PrefixUpperBound returns the first key beyond all keys with prefix.

Types

type AbandonCommitRequestInput

type AbandonCommitRequestInput struct {
	RequestID string
	// TaskID names the request's task. Zero is allowed only while collecting;
	// a sealed request requires its owning task.
	TaskID int64
	Reason string
	Now    time.Time
}

AbandonCommitRequestInput settles a request that can never land.

type AcquireReplacementItemInput

type AcquireReplacementItemInput struct {
	ReplacementID int64
	ItemID        int64
}

type AdminSessionRepository

type AdminSessionRepository interface{ adminsession.Store }

AdminSessionRepository stores active browser sessions.

type AdmitRemovalSendInput added in v0.1.1

type AdmitRemovalSendInput struct {
	RequestID     string
	TaskID        int64
	SendNo        int
	CopyIDs       []int64
	AttemptedAt   time.Time
	QueueLength   int
	SnapshotBlock uint64
}

type AdoptLegacyCleanupCopyInput added in v0.1.1

type AdoptLegacyCleanupCopyInput struct {
	ContentID       int64
	Generation      int64
	ContentTaskID   int64
	CopyID          int64
	AttemptedAt     time.Time
	RetryOfTxHash   string
	TransactionHash string
	Identity        storagepipeline.ExecutionIdentity
	Enqueue         EnqueueRemovalTask
	Now             time.Time
}

type AttachReplacementTargetCopyInput

type AttachReplacementTargetCopyInput struct {
	ReplacementID int64
	ItemID        int64
	ContentID     int64
}

type AuthorizeReplacementInput

type AuthorizeReplacementInput struct {
	BucketID             int64
	SourceDataSetID      int64
	SelectionMode        storagereplacement.SelectionMode
	TargetProviderID     types.OnChainID
	ClientRequestID      string
	PriceListFingerprint string
	Preflight            *ReplacementPreflight
}

AuthorizeReplacementInput is one operator confirmation.

type BackfillClientDataSetIDInput

type BackfillClientDataSetIDInput struct {
	ID              int64
	DataSetID       types.OnChainID
	ClientDataSetID types.OnChainID
}

type BeginCommitSubmissionInput

type BeginCommitSubmissionInput struct {
	RequestID string
	TaskID    int64
	Now       time.Time
}

BeginCommitSubmissionInput moves a ready request to submitted before its first send of this period.

type BeginIngressStoreProgressInput

type BeginIngressStoreProgressInput struct {
	CopyID     int64
	Generation int64
	TaskID     int64
	Attempt    int
}

type BeginTerminationAttemptInput

type BeginTerminationAttemptInput struct {
	ReplacementID     int64
	DataSetID         int64
	Generation        int64
	TaskID            int64
	Role              storagereplacement.TerminationRole
	AttemptNo         int64
	PreviousAttemptNo int64
	// ResumeUnresolved lets a successor take over the latest attempt while it
	// holds no transaction evidence, which only an operator's Retry authorizes
	// after the attempt's relayed request stayed unresolved.
	ResumeUnresolved bool
	AttemptedAt      time.Time
}

type BindDeploymentIdentityInput

type BindDeploymentIdentityInput struct {
	Payer   string
	ChainID int64
}

type BindReadableUploadForVersionInput

type BindReadableUploadForVersionInput struct {
	ContentID int64
	BucketID  int64
	VersionID string
}

type BindReadableUploadInput

type BindReadableUploadInput struct {
	ContentID int64
	BucketID  int64
}

type BucketACLSnapshot

type BucketACLSnapshot struct {
	Name   string             `bun:"name"`
	Status model.BucketStatus `bun:"status"`
	ACL    []byte             `bun:"acl"`
}

BucketACLSnapshot holds the minimal bucket fields needed for ACL owner scans.

type BucketObjectStats

type BucketObjectStats struct {
	Count     int64 `bun:"count"`
	TotalSize int64 `bun:"total_size"`
}

BucketObjectStats holds aggregate object metrics for a single bucket.

type BucketRepository

type BucketRepository interface {
	Create(ctx context.Context, bucket *model.Bucket) error
	GetByName(ctx context.Context, name string) (*model.Bucket, error)
	GetByID(ctx context.Context, id int64) (*model.Bucket, error)
	GetNamesByIDs(ctx context.Context, ids []int64) (map[int64]string, error)
	ListActive(ctx context.Context) ([]model.Bucket, error)
	// List returns all buckets regardless of status.
	List(ctx context.Context) ([]model.Bucket, error)
	// ListACLs returns the minimal bucket fields needed to derive ACL owners.
	ListACLs(ctx context.Context) ([]BucketACLSnapshot, error)
	// CountByStatus returns bucket counts grouped by status.
	CountByStatus(ctx context.Context) ([]BucketStatusCount, error)
	// UpdateStatus atomically transitions bucket status using CAS.
	UpdateStatus(ctx context.Context, id int64, from, to model.BucketStatus) error
	// PromoteReadyIfProvisioned marks a provisioning bucket ready once enough current data sets are ready.
	PromoteReadyIfProvisioned(ctx context.Context, id int64, requiredDataSets int) (bool, error)
	// LockByID holds the bucket row until the caller's transaction ends. A
	// transaction that also locks the bucket's data sets takes it first.
	LockByID(ctx context.Context, id int64) error
	// SetACL stores the bucket ACL JSON blob used by VersityGW access control.
	SetACL(ctx context.Context, name string, acl []byte) error
	// SetOwnerAndACL stores both the authoritative owner and compatible ACL.
	SetOwnerAndACL(ctx context.Context, name string, ownerAccessKey *string, acl []byte) error
	// UpdateCopyPolicy locks and updates the independently optional bucket policy fields.
	UpdateCopyPolicy(ctx context.Context, input UpdateBucketCopyPolicyInput) (*model.Bucket, error)
	// SetDefaultCopies stores the bucket replica target. Nil resets it to the
	// caller-supplied configured default.
	SetDefaultCopies(ctx context.Context, name string, copies *int) error
	// ActiveReplicaSlots returns the ascending copy indexes the bucket still
	// accepts new writes on. Decommissioned slots keep their rows for history
	// but never take a new data set.
	ActiveReplicaSlots(ctx context.Context, bucketID int64) ([]int, error)
	// CountByOwner returns bucket count for the authoritative owner access key.
	CountByOwner(ctx context.Context, ownerAccessKey string) (int, error)
	// AggregateCountsByOwner returns bucket counts grouped by authoritative owner access key.
	AggregateCountsByOwner(ctx context.Context) (map[string]int, error)
	// CountStorageDataSets returns provider-scoped data set count.
	CountStorageDataSets(ctx context.Context) (int, error)
}

BucketRepository defines persistence operations for Bucket entities.

type BucketStatusCount

type BucketStatusCount struct {
	Status string `bun:"status"`
	Count  int64  `bun:"count"`
}

BucketStatusCount holds a bucket count grouped by status.

type BucketStorageHealthAffectedVersion

type BucketStorageHealthAffectedVersion struct {
	Version                  model.ObjectVersion
	RiskDataSets             []BucketStorageHealthRiskDataSet
	ReadableAlternativeCount int
}

type BucketStorageHealthAffectedVersionPage

type BucketStorageHealthAffectedVersionPage struct {
	Versions            []BucketStorageHealthAffectedVersion
	HasMore             bool
	NextKeyMarker       string
	NextVersionIDMarker string
	NextCreatedAtMarker time.Time
}

type BucketStorageHealthAffectedVersionsInput

type BucketStorageHealthAffectedVersionsInput struct {
	BucketID        int64
	LocalDataSetID  int64
	Prefix          string
	Key             string
	KeyMarker       string
	VersionIDMarker string
	CreatedAtMarker time.Time
	StaleBefore     time.Time
	Limit           int
}

type BucketStorageHealthRiskDataSet

type BucketStorageHealthRiskDataSet struct {
	LocalDataSetID     int64                      `bun:"local_data_set_id"`
	BucketID           int64                      `bun:"bucket_id"`
	CopyIndex          int                        `bun:"copy_index"`
	ProviderID         types.OnChainID            `bun:"provider_id"`
	DataSetID          *types.OnChainID           `bun:"data_set_id"`
	ClientDataSetID    *types.OnChainID           `bun:"client_data_set_id"`
	LocalStatus        model.StorageDataSetStatus `bun:"local_status"`
	ObservationStatus  *observability.Status      `bun:"observation_status"`
	ObservationMissing bool                       `bun:"observation_missing"`
	ObservationStale   bool                       `bun:"observation_stale"`
	ReasonCodes        []observability.ReasonCode `bun:"reason_codes"`
	LastCheckedAt      *time.Time                 `bun:"last_checked_at"`
	LastError          *string                    `bun:"last_error"`
}

type BucketStorageHealthSummary

type BucketStorageHealthSummary struct {
	BucketID                   int64 `bun:"bucket_id"`
	AbnormalDataSets           int   `bun:"abnormal_data_sets"`
	AffectedVersionsCapped     int
	AffectedVersionsCap        int
	AffectedVersionsExceedsCap bool
	LocalStatusNotReady        bool `bun:"local_status_not_ready"`
	ObservationMissing         bool `bun:"observation_missing"`
	ObservationStale           bool `bun:"observation_stale"`
	ObservationUnavailable     bool `bun:"observation_unavailable"`
	ObservationDegraded        bool `bun:"observation_degraded"`
	ObservationUnknown         bool `bun:"observation_unknown"`
	ReasonCodes                []observability.ReasonCode
	LastCheckedAt              *time.Time `bun:"last_checked_at"`
}

type BunAdminSessionRepo

type BunAdminSessionRepo struct {
	// contains filtered or unexported fields
}

func (*BunAdminSessionRepo) Create

func (r *BunAdminSessionRepo) Create(ctx context.Context, session *adminsession.Session) error

func (*BunAdminSessionRepo) Delete

func (r *BunAdminSessionRepo) Delete(ctx context.Context, hash string) error

func (*BunAdminSessionRepo) DeleteExpired

func (r *BunAdminSessionRepo) DeleteExpired(ctx context.Context, now time.Time, limit int) (int64, error)

func (*BunAdminSessionRepo) ExtendActive

func (r *BunAdminSessionRepo) ExtendActive(ctx context.Context, hash string, now, expiresAt time.Time) (bool, error)

func (*BunAdminSessionRepo) GetActive

func (r *BunAdminSessionRepo) GetActive(ctx context.Context, hash string, now time.Time) (*adminsession.Session, error)

type BunBucketRepo

type BunBucketRepo struct {
	// contains filtered or unexported fields
}

BunBucketRepo implements BucketRepository using Bun ORM.

func (*BunBucketRepo) ActiveReplicaSlots

func (r *BunBucketRepo) ActiveReplicaSlots(ctx context.Context, bucketID int64) ([]int, error)

ActiveReplicaSlots lists the copy indexes still open for new writes.

func (*BunBucketRepo) AggregateCountsByOwner

func (r *BunBucketRepo) AggregateCountsByOwner(ctx context.Context) (map[string]int, error)

func (*BunBucketRepo) CountByOwner

func (r *BunBucketRepo) CountByOwner(ctx context.Context, ownerAccessKey string) (int, error)

func (*BunBucketRepo) CountByStatus

func (r *BunBucketRepo) CountByStatus(ctx context.Context) ([]BucketStatusCount, error)

func (*BunBucketRepo) CountStorageDataSets

func (r *BunBucketRepo) CountStorageDataSets(ctx context.Context) (int, error)

func (*BunBucketRepo) Create

func (r *BunBucketRepo) Create(ctx context.Context, bucket *model.Bucket) error

Create inserts a bucket together with the replica slots its durability policy asks for, so a bucket never exists without the slots its data sets bind to.

func (*BunBucketRepo) GetByID

func (r *BunBucketRepo) GetByID(ctx context.Context, id int64) (*model.Bucket, error)

func (*BunBucketRepo) GetByName

func (r *BunBucketRepo) GetByName(ctx context.Context, name string) (*model.Bucket, error)

func (*BunBucketRepo) GetNamesByIDs

func (r *BunBucketRepo) GetNamesByIDs(ctx context.Context, ids []int64) (map[int64]string, error)

func (*BunBucketRepo) List

func (r *BunBucketRepo) List(ctx context.Context) ([]model.Bucket, error)

func (*BunBucketRepo) ListACLs

func (r *BunBucketRepo) ListACLs(ctx context.Context) ([]BucketACLSnapshot, error)

func (*BunBucketRepo) ListActive

func (r *BunBucketRepo) ListActive(ctx context.Context) ([]model.Bucket, error)

func (*BunBucketRepo) LockByID

func (r *BunBucketRepo) LockByID(ctx context.Context, id int64) error

func (*BunBucketRepo) PromoteReadyIfProvisioned

func (r *BunBucketRepo) PromoteReadyIfProvisioned(ctx context.Context, id int64, requiredDataSets int) (bool, error)

func (*BunBucketRepo) SetACL

func (r *BunBucketRepo) SetACL(ctx context.Context, name string, acl []byte) error

func (*BunBucketRepo) SetDefaultCopies

func (r *BunBucketRepo) SetDefaultCopies(ctx context.Context, name string, copies *int) error

func (*BunBucketRepo) SetOwnerAndACL

func (r *BunBucketRepo) SetOwnerAndACL(ctx context.Context, name string, ownerAccessKey *string, acl []byte) error

func (*BunBucketRepo) UpdateCopyPolicy

func (r *BunBucketRepo) UpdateCopyPolicy(ctx context.Context, input UpdateBucketCopyPolicyInput) (*model.Bucket, error)

func (*BunBucketRepo) UpdateStatus

func (r *BunBucketRepo) UpdateStatus(ctx context.Context, id int64, from, to model.BucketStatus) error

type BunCacheEvictionRepo

type BunCacheEvictionRepo struct {
	// contains filtered or unexported fields
}

func (*BunCacheEvictionRepo) ActiveEvictionBytes

func (r *BunCacheEvictionRepo) ActiveEvictionBytes(ctx context.Context) (int64, error)

func (*BunCacheEvictionRepo) AuthorizeDeletion

func (r *BunCacheEvictionRepo) AuthorizeDeletion(
	ctx context.Context,
	contentID, generation, taskID int64,
	expectedAccess *time.Time,
) (*cacheeviction.AuthorizedDeletion, error)

func (*BunCacheEvictionRepo) BindDurabilityTask

func (r *BunCacheEvictionRepo) BindDurabilityTask(ctx context.Context, bucketID, generation, taskID int64) error

func (*BunCacheEvictionRepo) BindEvictionTask

func (r *BunCacheEvictionRepo) BindEvictionTask(ctx context.Context, contentID, generation, taskID int64) error

func (*BunCacheEvictionRepo) CompleteBucketDurability

func (r *BunCacheEvictionRepo) CompleteBucketDurability(ctx context.Context, bucketID, generation, taskID int64) error

func (*BunCacheEvictionRepo) DeletionRecorded

func (r *BunCacheEvictionRepo) DeletionRecorded(ctx context.Context, contentID, generation int64) (bool, error)

func (*BunCacheEvictionRepo) GetCacheEntry

func (r *BunCacheEvictionRepo) GetCacheEntry(ctx context.Context, contentID int64) (*model.ObjectCache, error)

func (*BunCacheEvictionRepo) ListBucketDurabilityCandidates

func (r *BunCacheEvictionRepo) ListBucketDurabilityCandidates(ctx context.Context, bucketID, generation, taskID int64, limit int) ([]model.StorageContent, error)

func (*BunCacheEvictionRepo) ListLRUCandidates

func (r *BunCacheEvictionRepo) ListLRUCandidates(ctx context.Context, limit int, after ...CacheLRUCursor) ([]cacheeviction.Candidate, error)

func (*BunCacheEvictionRepo) NextBucketDurabilityCandidate

func (r *BunCacheEvictionRepo) NextBucketDurabilityCandidate(ctx context.Context, bucketID, generation, taskID int64) (*model.StorageContent, error)

func (*BunCacheEvictionRepo) NextDurabilityGeneration

func (r *BunCacheEvictionRepo) NextDurabilityGeneration(ctx context.Context, bucketID int64) (int64, error)

func (*BunCacheEvictionRepo) NextEvictionGeneration

func (r *BunCacheEvictionRepo) NextEvictionGeneration(ctx context.Context, contentID int64) (int64, error)

func (*BunCacheEvictionRepo) PrepareEviction

func (r *BunCacheEvictionRepo) PrepareEviction(ctx context.Context, contentID int64) (CacheEvictionReservation, error)

PrepareEviction locks one cache entry and either reuses its matching live eviction or reserves the next generation for the caller to enqueue and bind before its surrounding transaction commits.

func (*BunCacheEvictionRepo) ReclaimableLRUBytes

func (r *BunCacheEvictionRepo) ReclaimableLRUBytes(ctx context.Context) (int64, error)

func (*BunCacheEvictionRepo) RecordDeletion

func (r *BunCacheEvictionRepo) RecordDeletion(ctx context.Context, contentID, generation, taskID int64) error

func (*BunCacheEvictionRepo) ReleaseBucketDurability added in v0.1.1

func (r *BunCacheEvictionRepo) ReleaseBucketDurability(ctx context.Context, bucketID, generation, taskID int64) error

func (*BunCacheEvictionRepo) ReleaseEviction

func (r *BunCacheEvictionRepo) ReleaseEviction(ctx context.Context, contentID, generation, taskID int64) error

func (*BunCacheEvictionRepo) TransferDurabilityTaskOwner

func (r *BunCacheEvictionRepo) TransferDurabilityTaskOwner(ctx context.Context, id, generation, oldID, newID int64) error

func (*BunCacheEvictionRepo) TransferEvictionTaskOwner

func (r *BunCacheEvictionRepo) TransferEvictionTaskOwner(ctx context.Context, id, generation, oldID, newID int64) error

type BunCacheLocalRepo added in v0.1.1

type BunCacheLocalRepo struct {
	// contains filtered or unexported fields
}

func NewBunCacheLocalRepo added in v0.1.1

func NewBunCacheLocalRepo(db bun.IDB) *BunCacheLocalRepo

func (*BunCacheLocalRepo) DeleteQuarantinedIfSafe added in v0.1.1

func (r *BunCacheLocalRepo) DeleteQuarantinedIfSafe(ctx context.Context, contentID int64, remove func() error) (bool, error)

DeleteQuarantinedIfSafe holds the durability decision through a single-file deletion. The caller holds the content deletion gate before its transaction.

func (*BunCacheLocalRepo) ListStates added in v0.1.1

func (r *BunCacheLocalRepo) ListStates(ctx context.Context, contentIDs []int64) (map[int64]CacheLocalState, error)

func (*BunCacheLocalRepo) RestorePresence added in v0.1.1

func (r *BunCacheLocalRepo) RestorePresence(ctx context.Context, observed CacheLocalState) (bool, error)

type BunDeploymentIdentityRepo

type BunDeploymentIdentityRepo struct {
	// contains filtered or unexported fields
}

func (*BunDeploymentIdentityRepo) BindOrVerify

type BunMultipartRepo

type BunMultipartRepo struct {
	// contains filtered or unexported fields
}

BunMultipartRepo implements MultipartUploadRepository using Bun ORM.

func (*BunMultipartRepo) CountActiveByBucket

func (r *BunMultipartRepo) CountActiveByBucket(ctx context.Context, bucketID int64) (int64, error)

func (*BunMultipartRepo) Create

func (r *BunMultipartRepo) Create(ctx context.Context, upload *model.MultipartUpload) error

func (*BunMultipartRepo) CreatePart

func (r *BunMultipartRepo) CreatePart(ctx context.Context, part *model.MultipartPart) error

CreatePart upserts a part record. If the same (upload_id, part_number) exists, its bytes are replaced but created_at keeps the first upload's time: a re-uploaded part is the same part, not a new one.

func (*BunMultipartRepo) Delete

func (r *BunMultipartRepo) Delete(ctx context.Context, uploadID string) error

func (*BunMultipartRepo) DeleteParts

func (r *BunMultipartRepo) DeleteParts(ctx context.Context, uploadID string) error

func (*BunMultipartRepo) DeletePartsExcept

func (r *BunMultipartRepo) DeletePartsExcept(ctx context.Context, uploadID string, keep []int) error

func (*BunMultipartRepo) GetByUploadID

func (r *BunMultipartRepo) GetByUploadID(ctx context.Context, uploadID string) (*model.MultipartUpload, error)

func (*BunMultipartRepo) GetParts

func (r *BunMultipartRepo) GetParts(ctx context.Context, uploadID string, partNumberMarker, maxParts int) ([]model.MultipartPart, error)

func (*BunMultipartRepo) GetPartsByNumbers

func (r *BunMultipartRepo) GetPartsByNumbers(ctx context.Context, uploadID string, numbers []int) ([]model.MultipartPart, error)

func (*BunMultipartRepo) ListByBucket

func (r *BunMultipartRepo) ListByBucket(
	ctx context.Context,
	bucketID int64,
	prefix, keyMarker, uploadIDMarker string,
	maxUploads int,
) ([]model.MultipartUpload, error)

func (*BunMultipartRepo) ReleaseInterruptedCompletions

func (r *BunMultipartRepo) ReleaseInterruptedCompletions(ctx context.Context) (int64, error)

ReleaseInterruptedCompletions returns every completing upload to initiated. A completion commits completed together with the version it creates, so an upload still completing when the process starts belongs to a completion that never finished; its parts are still on disk. bucket_id leads the only index on status, so the filter names it to let that index serve the scan.

func (*BunMultipartRepo) SetStatus

func (r *BunMultipartRepo) SetStatus(ctx context.Context, uploadID string, from, to model.MultipartStatus) error

SetStatus atomically transitions a multipart upload from one status to another (CAS). Returns an error if the upload is not in the expected 'from' status.

type BunObjectRepo

type BunObjectRepo struct {
	// contains filtered or unexported fields
}

BunObjectRepo implements ObjectRepository using Bun ORM.

func (*BunObjectRepo) AggregateByBucket

func (r *BunObjectRepo) AggregateByBucket(ctx context.Context) (map[int64]BucketObjectStats, error)

AggregateByBucket returns current object count and total size for all buckets in a single query.

func (*BunObjectRepo) BucketStats

func (r *BunObjectRepo) BucketStats(ctx context.Context, bucketID int64) (BucketObjectStats, error)

BucketStats returns current object count and total size for a single bucket.

func (*BunObjectRepo) ClearContentCachePresence

func (r *BunObjectRepo) ClearContentCachePresence(ctx context.Context, contentID int64) error

func (*BunObjectRepo) ContentIsUnreferenced

func (r *BunObjectRepo) ContentIsUnreferenced(ctx context.Context, contentID int64) (bool, error)

ContentIsUnreferenced reports whether any live object version still points at the content, so callers outside a deletion transaction can decide whether releasing its cached bytes is safe.

func (*BunObjectRepo) CountByBucket

func (r *BunObjectRepo) CountByBucket(ctx context.Context, bucketID int64) (int64, error)

CountByBucket returns the number of current objects in a bucket.

func (*BunObjectRepo) CountByState

func (r *BunObjectRepo) CountByState(ctx context.Context) ([]ObjectStateCount, error)

func (*BunObjectRepo) CreateDeleteMarkerAndSetCurrent

func (r *BunObjectRepo) CreateDeleteMarkerAndSetCurrent(ctx context.Context, bucketID int64, key string, versionID string, conditions ...ObjectCondition) (*model.ObjectVersion, error)

func (*BunObjectRepo) CreateRestoredVersionAndSetCurrent

func (r *BunObjectRepo) CreateRestoredVersionAndSetCurrent(ctx context.Context, version *model.ObjectVersion, sourceVersionID, expectedCurrentVersionID string) (int64, error)

func (*BunObjectRepo) CreateVersionAndSetCurrent

func (r *BunObjectRepo) CreateVersionAndSetCurrent(ctx context.Context, version *model.ObjectVersion, conditions ...ObjectCondition) (int64, error)

func (*BunObjectRepo) CreateVersionAndSetCurrentIfChanged

func (r *BunObjectRepo) CreateVersionAndSetCurrentIfChanged(ctx context.Context, version *model.ObjectVersion) (ObjectVersionWriteResult, error)

func (*BunObjectRepo) DeleteDeletedObjectPermanently

func (r *BunObjectRepo) DeleteDeletedObjectPermanently(ctx context.Context, input DeleteDeletedObjectInput) (DeleteDeletedObjectResult, error)

func (*BunObjectRepo) DeleteMarkerVersion

func (r *BunObjectRepo) DeleteMarkerVersion(ctx context.Context, bucketID int64, key string, versionID string, conditions ...ObjectCondition) error

func (*BunObjectRepo) DeleteObjectVersionPermanently

func (r *BunObjectRepo) DeleteObjectVersionPermanently(ctx context.Context, input DeleteObjectVersionInput) (DeleteObjectVersionResult, error)

func (*BunObjectRepo) GetContentFileSample

func (r *BunObjectRepo) GetContentFileSample(ctx context.Context, contentID int64) (*ContentFileSample, error)

func (*BunObjectRepo) GetCurrentVersionByBucketAndKey

func (r *BunObjectRepo) GetCurrentVersionByBucketAndKey(ctx context.Context, bucketID int64, key string) (*model.ObjectVersion, error)

func (*BunObjectRepo) GetCurrentVersionByObjectID

func (r *BunObjectRepo) GetCurrentVersionByObjectID(ctx context.Context, objectID int64) (*model.ObjectVersion, error)

func (*BunObjectRepo) GetObjectByBucketAndKey

func (r *BunObjectRepo) GetObjectByBucketAndKey(ctx context.Context, bucketID int64, key string) (*model.Object, error)

func (*BunObjectRepo) GetObjectByID

func (r *BunObjectRepo) GetObjectByID(ctx context.Context, id int64) (*model.Object, error)

func (*BunObjectRepo) GetVersionByBucketKeyAndID

func (r *BunObjectRepo) GetVersionByBucketKeyAndID(ctx context.Context, bucketID int64, key string, versionID string) (*model.ObjectVersion, error)

func (*BunObjectRepo) GetVersionByID

func (r *BunObjectRepo) GetVersionByID(ctx context.Context, versionID string) (*model.ObjectVersion, error)

func (*BunObjectRepo) ListCurrentVersionsByBucket

func (r *BunObjectRepo) ListCurrentVersionsByBucket(ctx context.Context, bucketID int64, prefix string, afterKey string, maxKeys int) ([]model.ObjectVersion, error)

func (*BunObjectRepo) ListCurrentVersionsByBucketAtOrAfter

func (r *BunObjectRepo) ListCurrentVersionsByBucketAtOrAfter(ctx context.Context, bucketID int64, prefix string, fromKey string, maxKeys int) ([]model.ObjectVersion, error)

func (*BunObjectRepo) ListRecoverableDeleteMarkers

func (r *BunObjectRepo) ListRecoverableDeleteMarkers(ctx context.Context, bucketID int64, prefix string, afterKey string, maxKeys int) ([]RecoverableDeleteMarker, error)

func (*BunObjectRepo) ListVersionsByBucket

func (r *BunObjectRepo) ListVersionsByBucket(ctx context.Context, bucketID int64, prefix string, keyMarker string, versionIDMarker string, maxKeys int) ([]ObjectVersionListItem, error)

func (*BunObjectRepo) ListVersionsByBucketAtOrAfter added in v0.1.1

func (r *BunObjectRepo) ListVersionsByBucketAtOrAfter(ctx context.Context, bucketID int64, prefix, fromKey string, maxKeys int) ([]ObjectVersionListItem, error)

func (*BunObjectRepo) ListVersionsByKey

func (r *BunObjectRepo) ListVersionsByKey(ctx context.Context, bucketID int64, key string, afterVersionID string, maxKeys int) ([]ObjectVersionListItem, error)

func (*BunObjectRepo) OverviewSnapshot

func (r *BunObjectRepo) OverviewSnapshot(ctx context.Context) (ObjectOverviewSnapshot, error)

func (*BunObjectRepo) RecordContentCacheAccess

func (r *BunObjectRepo) RecordContentCacheAccess(ctx context.Context, contentID int64, accessedAt time.Time) error

RecordContentCacheAccess advances LRU recency for one content payload without asserting that its bytes are present.

func (*BunObjectRepo) RecordContentCacheCommit

func (r *BunObjectRepo) RecordContentCacheCommit(ctx context.Context, contentID int64, accessedAt time.Time) error

RecordContentCacheCommit marks a freshly written cache file present and advances its recency in the same write.

func (*BunObjectRepo) ReleaseContentCacheIfUnreferenced

func (r *BunObjectRepo) ReleaseContentCacheIfUnreferenced(
	ctx context.Context,
	contentID int64,
	release func() error,
) (bool, error)

func (*BunObjectRepo) RestoreCurrentDeleteMarkerStack

func (r *BunObjectRepo) RestoreCurrentDeleteMarkerStack(ctx context.Context, bucketID int64, key string, currentMarkerVersionID string) (*model.ObjectVersion, error)

func (*BunObjectRepo) SetVersionCachePresence

func (r *BunObjectRepo) SetVersionCachePresence(ctx context.Context, versionID string, inCache bool) error

func (*BunObjectRepo) TotalSizeByBucket

func (r *BunObjectRepo) TotalSizeByBucket(ctx context.Context, bucketID int64) (int64, error)

TotalSizeByBucket returns the sum of current object sizes in a bucket.

type BunObservabilityRepo

type BunObservabilityRepo struct {
	// contains filtered or unexported fields
}

func (*BunObservabilityRepo) GetDataSetStatesByLocalIDs

func (r *BunObservabilityRepo) GetDataSetStatesByLocalIDs(ctx context.Context, localIDs []int64) (map[int64]observability.DataSetState, error)

func (*BunObservabilityRepo) GetProviderSubject

func (r *BunObservabilityRepo) GetProviderSubject(ctx context.Context, id types.OnChainID) (*ProviderSubject, error)

func (*BunObservabilityRepo) GetProviderTierSnapshot

func (r *BunObservabilityRepo) GetProviderTierSnapshot(ctx context.Context, tier string) (*observability.ProviderTierSnapshot, error)

func (*BunObservabilityRepo) ListDataSetStates

func (*BunObservabilityRepo) ListProviderStates

func (*BunObservabilityRepo) OverviewStorageStates

OverviewStorageStates scopes health to local dependencies without changing global observations.

func (*BunObservabilityRepo) ProviderProfiles

func (*BunObservabilityRepo) RecordApprovedProviders

func (r *BunObservabilityRepo) RecordApprovedProviders(ctx context.Context, startedAt time.Time, ids []types.OnChainID) (time.Time, error)

RecordApprovedProviders stores a complete approved-tier read and returns the collection time the stored snapshot carries, which is a newer read's time when that read already committed.

func (*BunObservabilityRepo) RecordEndorsedProviders

func (r *BunObservabilityRepo) RecordEndorsedProviders(ctx context.Context, startedAt time.Time, ids []types.OnChainID) (time.Time, error)

RecordEndorsedProviders is RecordApprovedProviders for the endorsed tier.

func (*BunObservabilityRepo) ReplaceDataSetStates

func (r *BunObservabilityRepo) ReplaceDataSetStates(ctx context.Context, checkedAt time.Time, states []observability.DataSetState) error

func (*BunObservabilityRepo) ReplaceProviderStates

func (r *BunObservabilityRepo) ReplaceProviderStates(ctx context.Context, checkedAt time.Time, states []observability.ProviderState) error

func (*BunObservabilityRepo) UpsertProviderObservation

func (r *BunObservabilityRepo) UpsertProviderObservation(ctx context.Context, checkedAt time.Time, state observability.ProviderState) error

type BunProviderUploadSpeedRepo

type BunProviderUploadSpeedRepo struct {
	// contains filtered or unexported fields
}

func (*BunProviderUploadSpeedRepo) Begin

func (r *BunProviderUploadSpeedRepo) Begin(ctx context.Context, providerID, hash string, taskID int64) error

func (*BunProviderUploadSpeedRepo) BeginIfDue

func (r *BunProviderUploadSpeedRepo) BeginIfDue(ctx context.Context, providerID, hash string, taskID int64, testedBefore time.Time, nonMeasuredCodes []string) error

func (*BunProviderUploadSpeedRepo) FailActiveTask

func (r *BunProviderUploadSpeedRepo) FailActiveTask(ctx context.Context, taskID int64, failureCode string) error

func (*BunProviderUploadSpeedRepo) Finish

func (r *BunProviderUploadSpeedRepo) Finish(ctx context.Context, providerID string, taskID int64, state providerbenchmark.State, sampleBytes, durationMS, bytesPerSecond int64, failureCode string) error

func (*BunProviderUploadSpeedRepo) Get

func (*BunProviderUploadSpeedRepo) ListByProviderIDs

func (r *BunProviderUploadSpeedRepo) ListByProviderIDs(ctx context.Context, ids []string) (map[string]providerbenchmark.Result, error)

func (*BunProviderUploadSpeedRepo) ListLastSuccessByProviderURLs

func (r *BunProviderUploadSpeedRepo) ListLastSuccessByProviderURLs(ctx context.Context, hashes map[string]string) (map[string]providerbenchmark.SuccessfulMeasurement, error)

ListLastSuccessByProviderURLs reads completed measurements for the requested URL fingerprints.

func (*BunProviderUploadSpeedRepo) TransferTaskOwner

func (r *BunProviderUploadSpeedRepo) TransferTaskOwner(ctx context.Context, oldID, newID int64) error

type BunS3AccountRepo

type BunS3AccountRepo struct {
	// contains filtered or unexported fields
}

BunS3AccountRepo implements S3AccountRepository using Bun ORM.

func (*BunS3AccountRepo) Create

func (r *BunS3AccountRepo) Create(ctx context.Context, account *model.S3Account) error

func (*BunS3AccountRepo) Delete

func (r *BunS3AccountRepo) Delete(ctx context.Context, accessKey string) error

func (*BunS3AccountRepo) GetByAccessKey

func (r *BunS3AccountRepo) GetByAccessKey(ctx context.Context, accessKey string) (*model.S3Account, error)

func (*BunS3AccountRepo) GetRoot

func (r *BunS3AccountRepo) GetRoot(ctx context.Context) (*model.S3Account, error)

func (*BunS3AccountRepo) ListNonRoot

func (r *BunS3AccountRepo) ListNonRoot(ctx context.Context) ([]model.S3Account, error)

func (*BunS3AccountRepo) LockByAccessKey

func (r *BunS3AccountRepo) LockByAccessKey(ctx context.Context, accessKey string) (*model.S3Account, error)

func (*BunS3AccountRepo) Update

func (r *BunS3AccountRepo) Update(ctx context.Context, accessKey string, update S3AccountUpdate) error

type BunStorageCleanupRepo

type BunStorageCleanupRepo struct {
	// contains filtered or unexported fields
}

func (*BunStorageCleanupRepo) AuthorizeTask

func (r *BunStorageCleanupRepo) AuthorizeTask(ctx context.Context, contentID, generation, taskID int64) ([]model.StorageCleanupCopy, error)

func (*BunStorageCleanupRepo) BindTask

func (r *BunStorageCleanupRepo) BindTask(ctx context.Context, contentID, generation, taskID int64) error

func (*BunStorageCleanupRepo) CleanupHasObjectReferences

func (r *BunStorageCleanupRepo) CleanupHasObjectReferences(ctx context.Context, contentID int64) (bool, error)

func (*BunStorageCleanupRepo) FinalizeContent

func (r *BunStorageCleanupRepo) FinalizeContent(ctx context.Context, contentID, generation, taskID int64) error

FinalizeContent deletes the current-state rows of content whose remote cleanup finished: its cache record, its copies, and the content row. Commit, pull, replacement, cleanup, and deletion ledgers keep their rows and name the content by value. Unresolved pulls or other unfinished work return ErrContentCleanupNotReady. It must run in the caller's transaction.

func (*BunStorageCleanupRepo) MarkCopyUnsupported

func (r *BunStorageCleanupRepo) MarkCopyUnsupported(ctx context.Context, id int64, message string) error

func (*BunStorageCleanupRepo) ReauthorizeFailedCopies added in v0.1.1

func (r *BunStorageCleanupRepo) ReauthorizeFailedCopies(ctx context.Context, contentID, generation, taskID int64) error

func (*BunStorageCleanupRepo) TransferTaskOwner

func (r *BunStorageCleanupRepo) TransferTaskOwner(ctx context.Context, id, generation, oldID, newID int64) error

func (*BunStorageCleanupRepo) UploadHasObjectReferences

func (r *BunStorageCleanupRepo) UploadHasObjectReferences(ctx context.Context, contentID int64) (bool, error)

type BunStorageContentRepo

type BunStorageContentRepo struct {
	// contains filtered or unexported fields
}

func (*BunStorageContentRepo) AbandonCommitRequest

func (r *BunStorageContentRepo) AbandonCommitRequest(ctx context.Context, input AbandonCommitRequestInput) ([]model.StorageCopy, error)

AbandonCommitRequest settles the request as abandoned and releases its members. Sealed members that were waiting to register return to piece_ready; the caller decides whether each joins another request or fails. It returns the members as they were before release.

func (*BunStorageContentRepo) AbandonMigrationPull

func (r *BunStorageContentRepo) AbandonMigrationPull(ctx context.Context, copyID, generation, taskID int64, pullAttemptID string) error

func (*BunStorageContentRepo) AuthorizeCopyTask

func (r *BunStorageContentRepo) AuthorizeCopyTask(ctx context.Context, copyID, generation, taskID, claimGeneration int64) (*model.StorageCopy, error)

func (*BunStorageContentRepo) AuthorizeDataSetEnsureTask

func (r *BunStorageContentRepo) AuthorizeDataSetEnsureTask(ctx context.Context, dataSetID, taskID int64) (*model.StorageDataSet, error)

func (*BunStorageContentRepo) AuthorizeDataSetRetirementTask

func (r *BunStorageContentRepo) AuthorizeDataSetRetirementTask(ctx context.Context, dataSetID, generation, taskID int64) (*model.StorageDataSet, error)

func (*BunStorageContentRepo) BackfillClientDataSetID

func (r *BunStorageContentRepo) BackfillClientDataSetID(ctx context.Context, input BackfillClientDataSetIDInput) error

func (*BunStorageContentRepo) BeginCommitSubmission

func (r *BunStorageContentRepo) BeginCommitSubmission(ctx context.Context, input BeginCommitSubmissionInput) error

BeginCommitSubmission records that the request is about to be sent. It refuses with storagecommit.ErrNotEligible unless the request is the oldest eligible ready request of a data set that has room and still takes commits.

func (*BunStorageContentRepo) BeginIngressStoreProgress

func (r *BunStorageContentRepo) BeginIngressStoreProgress(ctx context.Context, input BeginIngressStoreProgressInput) (*model.StorageCopy, error)

BeginIngressStoreProgress starts a fresh, fenced progress attempt on the Store copy. The caller runs this in the same transaction as the task checkpoint that authorizes the provider request.

func (*BunStorageContentRepo) BindCopyTask

func (r *BunStorageContentRepo) BindCopyTask(ctx context.Context, copyID, generation, taskID int64) error

func (*BunStorageContentRepo) BindDataSetEnsureTask

func (r *BunStorageContentRepo) BindDataSetEnsureTask(ctx context.Context, dataSetID, taskID int64) error

func (*BunStorageContentRepo) BindDataSetRetirementTask

func (r *BunStorageContentRepo) BindDataSetRetirementTask(ctx context.Context, dataSetID, generation, taskID int64) error

func (*BunStorageContentRepo) BindReadableUploadForContent

func (r *BunStorageContentRepo) BindReadableUploadForContent(ctx context.Context, input BindReadableUploadInput) ([]ObjectVersionRef, error)

BindReadableUploadForContent records that one content became readable at a provider. Versions already point at the content from creation, so this only settles the content row and reports the versions it backs.

func (*BunStorageContentRepo) BindReadableUploadForVersion

func (r *BunStorageContentRepo) BindReadableUploadForVersion(ctx context.Context, input BindReadableUploadForVersionInput) ([]ObjectVersionRef, error)

BindReadableUploadForVersion is BindReadableUploadForContent scoped to the refs of a single version.

func (*BunStorageContentRepo) CommitQueueState

func (r *BunStorageContentRepo) CommitQueueState(ctx context.Context, storageDataSetID int64, now time.Time) (CommitQueueState, error)

CommitQueueState reads the data set's registration queue at now.

func (*BunStorageContentRepo) CompleteCopyTask

func (r *BunStorageContentRepo) CompleteCopyTask(ctx context.Context, copyID, generation, taskID int64) error

func (*BunStorageContentRepo) CompleteDataSetEnsureTask

func (r *BunStorageContentRepo) CompleteDataSetEnsureTask(ctx context.Context, dataSetID, taskID int64) error

func (*BunStorageContentRepo) CompleteDataSetRetirementTask

func (r *BunStorageContentRepo) CompleteDataSetRetirementTask(ctx context.Context, dataSetID, generation, taskID int64) error

func (*BunStorageContentRepo) ConfirmCommitRequest

func (r *BunStorageContentRepo) ConfirmCommitRequest(ctx context.Context, input ConfirmCommitRequestInput) ([]model.StorageCopy, error)

ConfirmCommitRequest settles the request and commits every member, including one still being transferred again: the chain already holds its piece. It returns the members as they were before settlement. A replay of the same confirmation returns the members again and changes nothing.

func (*BunStorageContentRepo) ContentPipelineState

func (r *BunStorageContentRepo) ContentPipelineState(ctx context.Context, contentID int64) (model.ObjectState, error)

GetIngressCopy returns the copy that performs the ingress transfer for this content, or nil when there is none. Progress lives there rather than on the content shared by every replica. ContentPipelineState derives how far a content has travelled from its copy rows. Nothing stores this: a stored column would be a second copy of facts the copies already own, and the two would drift.

func (*BunStorageContentRepo) CopyRetryStates

func (r *BunStorageContentRepo) CopyRetryStates(ctx context.Context, copyIDs []int64) (map[int64]CopyRetryState, error)

CopyRetryStates batches the facts for display; callers must recheck admission.

func (*BunStorageContentRepo) CountCommitBacklog

func (r *BunStorageContentRepo) CountCommitBacklog(ctx context.Context, storageDataSetID int64) (int, error)

CountCommitBacklog counts the copies transferred to a data set that wait for a request that has not been sent.

func (*BunStorageContentRepo) CountCurrentGenerationCopySlots

func (r *BunStorageContentRepo) CountCurrentGenerationCopySlots(ctx context.Context, contentID int64) (int, error)

CountCurrentGenerationCopySlots counts logical replica slots, not physical generation rows.

func (*BunStorageContentRepo) CountStoppedCommitAttentionByDataSet

func (r *BunStorageContentRepo) CountStoppedCommitAttentionByDataSet(ctx context.Context) (map[int64]int64, error)

CountStoppedCommitAttentionByDataSet counts, per data set, the flagged requests whose task stopped for an operator.

func (*BunStorageContentRepo) CreateCollectingCommitRequest

func (r *BunStorageContentRepo) CreateCollectingCommitRequest(ctx context.Context, input CreateCommitRequestInput) error

CreateCollectingCommitRequest inserts a collecting request and adds the copies to it.

func (*BunStorageContentRepo) CreateUploadCopiesForBindings

func (r *BunStorageContentRepo) CreateUploadCopiesForBindings(ctx context.Context, contentID int64, copies []UploadCopyBindingInput) error

func (*BunStorageContentRepo) DataSetCreationStopped

func (r *BunStorageContentRepo) DataSetCreationStopped(ctx context.Context, id int64) (bool, error)

func (*BunStorageContentRepo) DiscardOrphanedContent

func (r *BunStorageContentRepo) DiscardOrphanedContent(ctx context.Context, contentID int64, release func() error) (bool, error)

DiscardOrphanedContent deletes content no object version has ever named, after release removes its cached file. The file goes first: if the row delete then fails, a row without a file is left for the next discard, and a later write of the same bytes commits its own file before naming the row. The reverse order could leave a file that nothing names. It reports whether the content was deleted.

func (*BunStorageContentRepo) DropCommitEvidence

func (r *BunStorageContentRepo) DropCommitEvidence(ctx context.Context, requestID string, taskID int64, lastError string, now time.Time) error

DropCommitEvidence forgets a receipt that did not describe the request. The request stays submitted: only its nonce can tell whether a send landed.

func (*BunStorageContentRepo) EnsureContent

EnsureContent returns the content row for one byte payload in a bucket, creating it if this is the first time those bytes are written. A uniqueness conflict returns the existing row unchanged: the requested-copy target is set when a version first names the content, not here. A finishing cleanup or the discard of a failed write can delete the conflicting row before it is read; the insert is then tried again.

func (*BunStorageContentRepo) EnsureDataSetBinding

func (*BunStorageContentRepo) FinalizeUploadIfTargetCopiesMet

func (r *BunStorageContentRepo) FinalizeUploadIfTargetCopiesMet(ctx context.Context, input FinalizeUploadInput) (bool, []ObjectVersionRef, error)

func (*BunStorageContentRepo) GetByID

func (r *BunStorageContentRepo) GetByID(ctx context.Context, contentID int64) (*model.StorageContent, error)

func (*BunStorageContentRepo) GetByIDs

func (r *BunStorageContentRepo) GetByIDs(ctx context.Context, contentIDs []int64) (map[int64]model.StorageContent, error)

func (*BunStorageContentRepo) GetCommitBatch

func (r *BunStorageContentRepo) GetCommitBatch(ctx context.Context, requestID string) (*CommitBatch, error)

func (*BunStorageContentRepo) GetCommitRequest

func (r *BunStorageContentRepo) GetCommitRequest(ctx context.Context, requestID string) (*storagecommit.Request, error)

GetCommitRequest loads one request.

func (*BunStorageContentRepo) GetCommitSubject

func (r *BunStorageContentRepo) GetCommitSubject(ctx context.Context, requestID string) (*StorageSubject, error)

func (*BunStorageContentRepo) GetContentSubject

func (r *BunStorageContentRepo) GetContentSubject(ctx context.Context, id int64) (*StorageSubject, error)

func (*BunStorageContentRepo) GetCopySubject

func (r *BunStorageContentRepo) GetCopySubject(ctx context.Context, id int64) (*StorageSubject, error)

func (*BunStorageContentRepo) GetDataSetBindingByCopyIndex

func (r *BunStorageContentRepo) GetDataSetBindingByCopyIndex(ctx context.Context, bucketID int64, copyIndex int) (*model.StorageDataSet, error)

GetDataSetBindingByCopyIndex returns the generation that currently owns the slot. Historical generations stay readable but never receive new writes.

func (*BunStorageContentRepo) GetDataSetBindingByID

func (r *BunStorageContentRepo) GetDataSetBindingByID(ctx context.Context, id int64) (*model.StorageDataSet, error)

func (*BunStorageContentRepo) GetDataSetSubject

func (r *BunStorageContentRepo) GetDataSetSubject(ctx context.Context, id int64) (*StorageSubject, error)

func (*BunStorageContentRepo) GetIngressCopy

func (r *BunStorageContentRepo) GetIngressCopy(ctx context.Context, contentID int64) (*model.StorageCopy, error)

func (*BunStorageContentRepo) GetLastAbandonedPullAttempt

func (r *BunStorageContentRepo) GetLastAbandonedPullAttempt(ctx context.Context, contentID, storageDataSetID int64) (*storagepull.Attempt, error)

func (*BunStorageContentRepo) GetLiveVersionForUpload

func (r *BunStorageContentRepo) GetLiveVersionForUpload(ctx context.Context, contentID int64) (*model.ObjectVersion, error)

func (*BunStorageContentRepo) GetPullAttempt

func (r *BunStorageContentRepo) GetPullAttempt(ctx context.Context, attemptID string, contentID, storageDataSetID int64) (*storagepull.Attempt, error)

GetPullAttempt requires the copy identity as well as the checkpoint's ID.

func (*BunStorageContentRepo) GetUnresolvedPullAttempt

func (r *BunStorageContentRepo) GetUnresolvedPullAttempt(ctx context.Context, contentID, storageDataSetID int64) (*storagepull.Attempt, error)

GetUnresolvedPullAttempt recovers evidence retained independently of a task.

func (*BunStorageContentRepo) GetUploadCopy

func (r *BunStorageContentRepo) GetUploadCopy(ctx context.Context, contentID int64, copyIndex int) (*model.StorageCopy, error)

GetUploadCopy resolves a slot to the copy on its current generation, so a task that carries only (upload, slot) can never address a replaced or a not-yet-activated generation.

func (*BunStorageContentRepo) GetUploadCopyByID

func (r *BunStorageContentRepo) GetUploadCopyByID(ctx context.Context, id int64) (*model.StorageCopy, error)

func (*BunStorageContentRepo) GetUploadCopyForDataSet

func (r *BunStorageContentRepo) GetUploadCopyForDataSet(ctx context.Context, contentID, storageDataSetID int64) (*model.StorageCopy, error)

GetUploadCopyForDataSet addresses one concrete generation, which is how replacement work targets the new provider while the old one still exists.

func (*BunStorageContentRepo) GetUploadProvenance

func (r *BunStorageContentRepo) GetUploadProvenance(ctx context.Context, contentID int64) (*StorageContentProvenance, error)

func (*BunStorageContentRepo) HasCacheDependentCommitMembers

func (r *BunStorageContentRepo) HasCacheDependentCommitMembers(ctx context.Context, requestID string) (bool, error)

func (*BunStorageContentRepo) HasReadableCommittedCopy

func (r *BunStorageContentRepo) HasReadableCommittedCopy(ctx context.Context, contentID int64) (bool, error)

func (*BunStorageContentRepo) IsPendingReplacementCopy

func (r *BunStorageContentRepo) IsPendingReplacementCopy(ctx context.Context, copyID int64) (bool, error)

func (*BunStorageContentRepo) JoinCollectingCommitRequest

func (r *BunStorageContentRepo) JoinCollectingCommitRequest(ctx context.Context, input JoinCommitRequestInput) (string, int, error)

JoinCollectingCommitRequest adds the copy to the oldest collecting request of its data set with a live task. It returns the request and its member count, or ErrNotFound when no such request exists.

The data set stays locked until the caller's transaction ends, so a caller that then creates a request on ErrNotFound does so before any other copy of the data set looks for one: copies transferred together share a request. The joining copy belongs to no request yet, so no holder of the data set lock waits for it.

func (*BunStorageContentRepo) ListBucketStorageHealthSummaries

func (r *BunStorageContentRepo) ListBucketStorageHealthSummaries(ctx context.Context, bucketID int64, staleBefore time.Time, affectedVersionCap int) ([]BucketStorageHealthSummary, error)

func (*BunStorageContentRepo) ListCommitAttention

func (r *BunStorageContentRepo) ListCommitAttention(ctx context.Context, limit int) ([]storagecommit.AttentionRecord, error)

ListCommitAttention lists submitted requests flagged for attention, oldest flag first.

func (*BunStorageContentRepo) ListCommitAttentionForTasks

func (r *BunStorageContentRepo) ListCommitAttentionForTasks(ctx context.Context, taskIDs []int64) ([]storagecommit.AttentionRecord, error)

ListCommitAttentionForTasks lists the flagged requests driven by the tasks.

func (*BunStorageContentRepo) ListCommitBatchMembers

func (r *BunStorageContentRepo) ListCommitBatchMembers(ctx context.Context, requestID string) ([]CommitBatchMember, error)

func (*BunStorageContentRepo) ListCommitBatches

func (r *BunStorageContentRepo) ListCommitBatches(ctx context.Context, filter CommitBatchFilter) ([]CommitBatch, error)

func (*BunStorageContentRepo) ListCommitRequestMembers

func (r *BunStorageContentRepo) ListCommitRequestMembers(ctx context.Context, requestID string) ([]CommitRequestMember, error)

ListCommitRequestMembers returns the copies that belong to a request: sealed members in position order, then collecting members in the order they became ready.

func (*BunStorageContentRepo) ListCommitRequestPieces

func (r *BunStorageContentRepo) ListCommitRequestPieces(ctx context.Context, requestID string) ([]storagecommit.RequestPiece, error)

ListCommitRequestPieces returns a sealed request's pieces in position order.

func (*BunStorageContentRepo) ListCopies

func (r *BunStorageContentRepo) ListCopies(ctx context.Context, contentID int64) ([]model.StorageCopy, error)

func (*BunStorageContentRepo) ListDataSetBindings

func (r *BunStorageContentRepo) ListDataSetBindings(ctx context.Context, bucketID int64) ([]model.StorageDataSet, error)

ListDataSetBindings returns every generation, including retired ones, because callers need the full provider history as well as the current write targets.

func (*BunStorageContentRepo) ListDataSetSummaries

func (r *BunStorageContentRepo) ListDataSetSummaries(ctx context.Context, bucketID int64) ([]StorageDataSetSummary, error)

func (*BunStorageContentRepo) ListInFlightCopiesForDataSet

func (r *BunStorageContentRepo) ListInFlightCopiesForDataSet(ctx context.Context, storageDataSetID int64) ([]model.StorageCopy, error)

ListInFlightCopiesForDataSet lists every copy that may still write to the data set, including copies whose content no live version needs.

func (*BunStorageContentRepo) ListIncompleteCopiesForDataSet

func (r *BunStorageContentRepo) ListIncompleteCopiesForDataSet(ctx context.Context, storageDataSetID int64) ([]model.StorageCopy, error)

func (*BunStorageContentRepo) ListOrphanedContents

func (r *BunStorageContentRepo) ListOrphanedContents(ctx context.Context, createdBefore time.Time, afterID int64, limit int) ([]OrphanedContent, error)

ListOrphanedContents pages through content created before createdBefore that no object version has ever named.

func (*BunStorageContentRepo) ListReadableCommittedCopies

func (r *BunStorageContentRepo) ListReadableCommittedCopies(ctx context.Context, contentID int64) ([]ReadableStorageCopy, error)

func (*BunStorageContentRepo) ListReadyBucketProviderIDs

func (r *BunStorageContentRepo) ListReadyBucketProviderIDs(ctx context.Context) ([]string, error)

func (*BunStorageContentRepo) LockForCopyCreation

func (r *BunStorageContentRepo) LockForCopyCreation(ctx context.Context, contentID int64) (*model.StorageContent, error)

LockForCopyCreation holds the content lock until the caller's transaction ends and rejects content reserved for cleanup.

func (*BunStorageContentRepo) MarkCommitRequestAttention

func (r *BunStorageContentRepo) MarkCommitRequestAttention(ctx context.Context, requestID string, taskID int64, code storagecommit.AttentionCode, now time.Time) error

MarkCommitRequestAttention flags a submitted request. The first code it is flagged with is kept until a receipt or a settlement clears it.

func (*BunStorageContentRepo) MarkDataSetCreating

func (r *BunStorageContentRepo) MarkDataSetCreating(ctx context.Context, input MarkDataSetCreatingInput) error

MarkDataSetCreating records a creation request that went out. A generation that replacement drained while the request was in flight stays draining; the request is still recorded so the data set it creates can be resolved.

func (*BunStorageContentRepo) MarkDataSetDraining

func (r *BunStorageContentRepo) MarkDataSetDraining(ctx context.Context, id int64, lastError string) error

func (*BunStorageContentRepo) MarkDataSetReady

func (r *BunStorageContentRepo) MarkDataSetReady(ctx context.Context, input MarkDataSetReadyInput) error

func (*BunStorageContentRepo) MarkUploadCopyFailed

func (r *BunStorageContentRepo) MarkUploadCopyFailed(ctx context.Context, input MarkUploadCopyFailedInput) error

func (*BunStorageContentRepo) MarkUploadCopyPieceReady

func (r *BunStorageContentRepo) MarkUploadCopyPieceReady(ctx context.Context, input MarkUploadCopyPieceReadyInput) error

MarkUploadCopyPieceReady records a finished transfer. A copy waiting in no signed request becomes piece_ready; a signed member sent back to transfer returns to committing, its request's registering state.

func (*BunStorageContentRepo) NextCopyWorkGeneration

func (r *BunStorageContentRepo) NextCopyWorkGeneration(ctx context.Context, copyID int64) (int64, error)

func (*BunStorageContentRepo) NextDataSetRetirementGeneration

func (r *BunStorageContentRepo) NextDataSetRetirementGeneration(ctx context.Context, dataSetID int64) (int64, error)

func (*BunStorageContentRepo) NextFinalizableCopyForDataSet

func (r *BunStorageContentRepo) NextFinalizableCopyForDataSet(ctx context.Context, storageDataSetID int64) (*model.StorageCopy, error)

func (*BunStorageContentRepo) PendingUploadPlansForReplica

func (r *BunStorageContentRepo) PendingUploadPlansForReplica(ctx context.Context, bucketID int64, copyIndex int) ([]int64, error)

func (*BunStorageContentRepo) PromotePendingIngress

func (r *BunStorageContentRepo) PromotePendingIngress(ctx context.Context, contentID int64) (*model.StorageCopy, error)

func (*BunStorageContentRepo) ProviderDataSetLoads

func (r *BunStorageContentRepo) ProviderDataSetLoads(ctx context.Context, ids []types.OnChainID) (map[string]int, error)

func (*BunStorageContentRepo) RecordCommitResend

func (r *BunStorageContentRepo) RecordCommitResend(ctx context.Context, input CommitSendInput) error

RecordCommitResend records that the request is about to be sent again.

func (*BunStorageContentRepo) RecordCommitSubmission

func (r *BunStorageContentRepo) RecordCommitSubmission(ctx context.Context, input CommitSubmissionInput) error

RecordCommitSubmission keeps the receipt of the latest send. The first receipt answers whatever attention an unacknowledged send was flagged with.

func (*BunStorageContentRepo) RecordCommitSubmitFailure

func (r *BunStorageContentRepo) RecordCommitSubmitFailure(ctx context.Context, input CommitSubmitFailureInput) error

func (*BunStorageContentRepo) RecordDataSetClientID

func (r *BunStorageContentRepo) RecordDataSetClientID(ctx context.Context, id, ensureTaskID int64, clientDataSetID types.OnChainID) error

func (*BunStorageContentRepo) RecordDataSetCreationError

func (r *BunStorageContentRepo) RecordDataSetCreationError(ctx context.Context, id, taskID int64, message string) error

RecordDataSetCreationError keeps why a creation request whose outcome is unknown failed. It changes nothing once another task owns the data set or the creation has moved on; creation evidence and readiness clear it.

func (*BunStorageContentRepo) RecordIngressStoreProgress

func (r *BunStorageContentRepo) RecordIngressStoreProgress(ctx context.Context, input RecordIngressStoreProgressInput) (*model.StorageCopy, error)

func (*BunStorageContentRepo) ReleaseMemberTransfer

func (r *BunStorageContentRepo) ReleaseMemberTransfer(ctx context.Context, input ReleaseMemberTransferInput) error

ReleaseMemberTransfer ends the transfer task of a signed member that could not be transferred again. The member keeps its place in its request, whose task can read the chain and decides what becomes of it, so that task is woken.

func (*BunStorageContentRepo) ReopenFailedIngressForPull

func (r *BunStorageContentRepo) ReopenFailedIngressForPull(ctx context.Context, contentID int64) ([]model.StorageCopy, error)

func (*BunStorageContentRepo) ReopenFailedUploadCopy

func (r *BunStorageContentRepo) ReopenFailedUploadCopy(ctx context.Context, copyID int64) error

func (*BunStorageContentRepo) ReplaceCopyTask

func (r *BunStorageContentRepo) ReplaceCopyTask(ctx context.Context, copyID, generation, taskID, nextGeneration, nextTaskID int64) error

func (*BunStorageContentRepo) RequestCommitSeal

func (r *BunStorageContentRepo) RequestCommitSeal(ctx context.Context, requestID string) (*storagecommit.Request, error)

RequestCommitSeal records collection intent; the existing task owns signing.

func (*BunStorageContentRepo) ReservePullRequest

func (r *BunStorageContentRepo) ReservePullRequest(ctx context.Context, input ReservePullRequestInput) error

ReservePullRequest records a provider-side copy request before it is sent. The attempt lives in its own ledger row, so a crash between writing it and sending it leaves a fully identified operation recovery can observe instead of nullable columns that may be half written.

func (*BunStorageContentRepo) ResumeFailedStoreCopy

func (r *BunStorageContentRepo) ResumeFailedStoreCopy(ctx context.Context, input ResumeFailedStoreCopyInput) error

ResumeFailedStoreCopy requires the cache read gate and a checkpoint whose upload session has been validated by the transfer owner.

func (*BunStorageContentRepo) RetryFailedCopy

func (r *BunStorageContentRepo) RetryFailedCopy(ctx context.Context, copyID int64) (*model.StorageCopy, error)

RetryFailedCopy requires the shared cache gate before entering its transaction. The bucket policy lock also serializes replacement authorization and activation.

func (*BunStorageContentRepo) ReturnCommitMembersToTransfer

func (r *BunStorageContentRepo) ReturnCommitMembersToTransfer(ctx context.Context, requestID string, taskID int64, copyIDs []int64, now time.Time) error

ReturnCommitMembersToTransfer sends sealed members whose pieces the provider dropped back to transfer. They keep their positions, so the request is sent whole again once every member is transferred.

func (*BunStorageContentRepo) ReturnCommitRequestToReady

func (r *BunStorageContentRepo) ReturnCommitRequestToReady(ctx context.Context, input ReturnCommitRequestInput) error

func (*BunStorageContentRepo) SealCommitRequest

func (r *BunStorageContentRepo) SealCommitRequest(ctx context.Context, input SealCommitRequestInput) ([]int64, error)

SealCommitRequest records the request's signature and its members' positions. Every signed member must still be waiting in the request; copies that joined after the members were read are returned to the caller, outside any request, so they can join the next one.

func (*BunStorageContentRepo) SetCopyCacheRestore

func (r *BunStorageContentRepo) SetCopyCacheRestore(ctx context.Context, copyID, generation, taskID int64, pullAttemptID, lastError string) error

SetCopyCacheRestore is fenced by the copy task and cache availability. Locking the cache entry before the content uses the same order as eviction.

func (*BunStorageContentRepo) TransferCommitTaskOwner

func (r *BunStorageContentRepo) TransferCommitTaskOwner(ctx context.Context, id string, oldID, newID int64) error

func (*BunStorageContentRepo) TransferCopyTaskOwner

func (r *BunStorageContentRepo) TransferCopyTaskOwner(ctx context.Context, id, generation, oldID, newID int64) error

func (*BunStorageContentRepo) TransferEnsureTaskOwner

func (r *BunStorageContentRepo) TransferEnsureTaskOwner(ctx context.Context, id, generation, oldID, newID int64) error

func (*BunStorageContentRepo) TransferRetireTaskOwner

func (r *BunStorageContentRepo) TransferRetireTaskOwner(ctx context.Context, id, generation, oldID, newID int64) error

func (*BunStorageContentRepo) WakeCacheDependentCommitTasks

func (r *BunStorageContentRepo) WakeCacheDependentCommitTasks(ctx context.Context) error

func (*BunStorageContentRepo) WakeCollectingCommitTask

func (r *BunStorageContentRepo) WakeCollectingCommitTask(ctx context.Context, requestID string) error

WakeCollectingCommitTask wakes collection after a join unless the queue is blocked.

func (*BunStorageContentRepo) WakeCommitRequestTask

func (r *BunStorageContentRepo) WakeCommitRequestTask(ctx context.Context, requestID string) error

WakeCommitRequestTask makes one request's task runnable.

type BunStorageRemovalRepo added in v0.1.1

type BunStorageRemovalRepo struct {
	// contains filtered or unexported fields
}

func (*BunStorageRemovalRepo) AbandonRemovalRequest added in v0.1.1

func (r *BunStorageRemovalRepo) AbandonRemovalRequest(ctx context.Context, input RemovalRequestInput) error

func (*BunStorageRemovalRepo) AdmitRemovalSend added in v0.1.1

func (r *BunStorageRemovalRepo) AdmitRemovalSend(ctx context.Context, input AdmitRemovalSendInput) error

func (*BunStorageRemovalRepo) AdoptLegacyCleanupCopy added in v0.1.1

func (*BunStorageRemovalRepo) ClearRemovalAttention added in v0.1.1

func (r *BunStorageRemovalRepo) ClearRemovalAttention(ctx context.Context, input RemovalRequestInput) error

func (*BunStorageRemovalRepo) DetachMembers added in v0.1.1

func (r *BunStorageRemovalRepo) DetachMembers(ctx context.Context, input RemovalMembersInput) error

func (*BunStorageRemovalRepo) GetRemovalRequest added in v0.1.1

func (r *BunStorageRemovalRepo) GetRemovalRequest(ctx context.Context, id string) (*storageremoval.Request, error)

func (*BunStorageRemovalRepo) JoinOrCreateCollecting added in v0.1.1

func (r *BunStorageRemovalRepo) JoinOrCreateCollecting(ctx context.Context, input JoinRemovalInput) (*storageremoval.Request, error)

func (*BunStorageRemovalRepo) ListRemovalBatchesForTasks added in v0.1.1

func (r *BunStorageRemovalRepo) ListRemovalBatchesForTasks(ctx context.Context, ids []int64) ([]storageremoval.TaskBatch, error)

func (*BunStorageRemovalRepo) ListRemovalMembers added in v0.1.1

func (r *BunStorageRemovalRepo) ListRemovalMembers(ctx context.Context, id string) ([]model.StorageCleanupCopy, error)

func (*BunStorageRemovalRepo) ListRemovalSends added in v0.1.1

func (r *BunStorageRemovalRepo) ListRemovalSends(ctx context.Context, id string) ([]storageremoval.Send, error)

func (*BunStorageRemovalRepo) MarkMemberFailed added in v0.1.1

func (r *BunStorageRemovalRepo) MarkMemberFailed(ctx context.Context, input RemovalMembersInput) error

func (*BunStorageRemovalRepo) MarkMembersRemoved added in v0.1.1

func (r *BunStorageRemovalRepo) MarkMembersRemoved(ctx context.Context, input RemovalMembersInput) error

func (*BunStorageRemovalRepo) MarkQueuedWithoutSend added in v0.1.1

func (r *BunStorageRemovalRepo) MarkQueuedWithoutSend(ctx context.Context, input RemovalQueuedInput) error

func (*BunStorageRemovalRepo) MarkRemovalQueued added in v0.1.1

func (r *BunStorageRemovalRepo) MarkRemovalQueued(ctx context.Context, input RemovalQueuedInput) error

func (*BunStorageRemovalRepo) MarkRemovalReverted added in v0.1.1

func (r *BunStorageRemovalRepo) MarkRemovalReverted(ctx context.Context, input RemovalRequestInput) error

func (*BunStorageRemovalRepo) RecordSendReceipt added in v0.1.1

func (r *BunStorageRemovalRepo) RecordSendReceipt(ctx context.Context, input RemovalSendEvidenceInput) error

func (*BunStorageRemovalRepo) RecordSendRefused added in v0.1.1

func (r *BunStorageRemovalRepo) RecordSendRefused(ctx context.Context, input RemovalSendEvidenceInput) error

func (*BunStorageRemovalRepo) RecordSendSubmission added in v0.1.1

func (r *BunStorageRemovalRepo) RecordSendSubmission(ctx context.Context, input RemovalSendEvidenceInput) error

func (*BunStorageRemovalRepo) RecordSendUnsent added in v0.1.1

func (r *BunStorageRemovalRepo) RecordSendUnsent(ctx context.Context, input RemovalSendEvidenceInput) error

func (*BunStorageRemovalRepo) SealRemovalRequest added in v0.1.1

func (r *BunStorageRemovalRepo) SealRemovalRequest(ctx context.Context, input SealRemovalInput) error

func (*BunStorageRemovalRepo) SetRemovalAttention added in v0.1.1

func (r *BunStorageRemovalRepo) SetRemovalAttention(ctx context.Context, input RemovalAttentionInput) error

func (*BunStorageRemovalRepo) SettleRemovalRequest added in v0.1.1

func (r *BunStorageRemovalRepo) SettleRemovalRequest(ctx context.Context, input RemovalRequestInput) error

func (*BunStorageRemovalRepo) TransferRemovalTaskOwner added in v0.1.1

func (r *BunStorageRemovalRepo) TransferRemovalTaskOwner(ctx context.Context, id string, oldTaskID, newTaskID int64) error

type BunStorageReplacementRepo

type BunStorageReplacementRepo struct {
	// contains filtered or unexported fields
}

BunStorageReplacementRepo persists operator-approved provider replacements.

func (*BunStorageReplacementRepo) AbandonUncreatedCopiesBatch

func (r *BunStorageReplacementRepo) AbandonUncreatedCopiesBatch(ctx context.Context, replacementID, generation, taskID int64, limit int) (bool, error)

AbandonUncreatedCopiesBatch transfers local obligations before releasing old copy fences. The caller fences this transaction with the live engine claim.

func (*BunStorageReplacementRepo) AcquireItem

func (*BunStorageReplacementRepo) AcquireItemsForCoordinator

func (r *BunStorageReplacementRepo) AcquireItemsForCoordinator(ctx context.Context, replacementID, generation, taskID, afterID int64, limit int) (ReplacementItemBatch, error)

func (*BunStorageReplacementRepo) Activate

func (r *BunStorageReplacementRepo) Activate(ctx context.Context, replacementID, generation, taskID int64) error

Activate is the single atomic switch: the target starts receiving writes and the source retires locally or starts draining its remote service.

func (*BunStorageReplacementRepo) AttachTargetCopy

AttachTargetCopy resolves the copy an item already names. Seeding created both the item and its pending copy, so this only reads back the binding the item was born with and refuses an item that belongs to another content.

func (*BunStorageReplacementRepo) Authorize

Authorize is the only way a replacement comes into existence. It records domain authorization and topology state only; TaskService binds the coordinator in the caller's transaction.

func (*BunStorageReplacementRepo) AuthorizeTask

func (r *BunStorageReplacementRepo) AuthorizeTask(ctx context.Context, replacementID, generation, taskID int64) (*storagereplacement.Replacement, error)

func (*BunStorageReplacementRepo) BeginRetirement

func (r *BunStorageReplacementRepo) BeginRetirement(ctx context.Context, replacementID int64) error

func (*BunStorageReplacementRepo) BeginTerminationAttempt

func (r *BunStorageReplacementRepo) BeginTerminationAttempt(ctx context.Context, input BeginTerminationAttemptInput) error

BeginTerminationAttempt admits one request for the current retirement owner. A new attempt requires a reverted predecessor; repeating its admission is inert. A released attempt is admitted again in place, by its task or a successor, and so is an unresolved one by a successor when ResumeUnresolved.

func (*BunStorageReplacementRepo) BindTask

func (r *BunStorageReplacementRepo) BindTask(ctx context.Context, replacementID, generation, taskID int64) error

func (*BunStorageReplacementRepo) CompleteAbandonedTargetTermination

func (r *BunStorageReplacementRepo) CompleteAbandonedTargetTermination(ctx context.Context, replacementID int64) error

CompleteAbandonedTargetTermination retires the superseded target once its end of term has been recorded, refusing to retire one that has none. It never touches the replacement record, which stays superseded, and it refuses a generation that still owns its slot.

func (*BunStorageReplacementRepo) CompleteRetirement

func (r *BunStorageReplacementRepo) CompleteRetirement(ctx context.Context, replacementID int64, observedEpoch int64) error

CompleteRetirement re-runs every predicate inside its own transaction, so a caller outside the worker cannot retire a source that is still needed.

func (*BunStorageReplacementRepo) CompleteTask

func (r *BunStorageReplacementRepo) CompleteTask(ctx context.Context, replacementID, generation, taskID int64) error

func (*BunStorageReplacementRepo) CompleteWithoutRemoteSource

func (r *BunStorageReplacementRepo) CompleteWithoutRemoteSource(ctx context.Context, replacementID, generation, taskID int64) error

CompleteWithoutRemoteSource cannot bypass retirement of an existing service.

func (*BunStorageReplacementRepo) CountAbandonedTargetSoleCopies

func (r *BunStorageReplacementRepo) CountAbandonedTargetSoleCopies(ctx context.Context, targetDataSetID int64) (int, error)

CountAbandonedTargetSoleCopies reports how many uploads would lose their only readable copy if this generation's service ended. An abandoned target holds partially migrated data that the retiring source should still have, so the answer is normally zero; anything else means terminating it would destroy the last copy of something.

func (*BunStorageReplacementRepo) EnsureTaskReplacement

func (r *BunStorageReplacementRepo) EnsureTaskReplacement(ctx context.Context, taskID int64) (*storagereplacement.Replacement, error)

func (*BunStorageReplacementRepo) EvaluateRetirementGate

func (r *BunStorageReplacementRepo) EvaluateRetirementGate(ctx context.Context, replacementID int64, observedEpoch *int64) (RetirementGate, error)

EvaluateRetirementGate answers one question: can this source stop existing without losing anything? Pass a nil observedEpoch to evaluate everything except the epoch, which must be read outside a transaction.

func (*BunStorageReplacementRepo) FailForEngineTask

func (r *BunStorageReplacementRepo) FailForEngineTask(ctx context.Context, taskID int64, lastError string) error

FailForEngineTask records on the replacement that the Engine failed its current coordinator claim itself. A replacement resumes only through the Data Sets retry, which accepts a failed or cleanup-attention replacement, so the failure lands there. A coordinator that no longer owns the replacement changes nothing.

func (*BunStorageReplacementRepo) GetActiveForDataSet

func (r *BunStorageReplacementRepo) GetActiveForDataSet(ctx context.Context, dataSetID int64) (*storagereplacement.Replacement, error)

func (*BunStorageReplacementRepo) GetByClientRequestID

func (r *BunStorageReplacementRepo) GetByClientRequestID(
	ctx context.Context,
	bucketID int64,
	clientRequestID string,
) (*storagereplacement.Replacement, error)

func (*BunStorageReplacementRepo) GetByID

func (*BunStorageReplacementRepo) GetReplacementSubject

func (r *BunStorageReplacementRepo) GetReplacementSubject(ctx context.Context, id int64) (*ReplacementSubject, error)

func (*BunStorageReplacementRepo) HandOverSourceWritesBatch

func (r *BunStorageReplacementRepo) HandOverSourceWritesBatch(ctx context.Context, replacementID, generation, taskID int64, limit int) ([]model.StorageCopy, bool, error)

HandOverSourceWritesBatch moves unsigned writes still bound to an activated remote source to its target. A sealed registration member or a copy with an unresolved pull attempt carries a signed authorization and stays until its outcome is known. The caller fences this transaction with the live engine claim.

func (*BunStorageReplacementRepo) HasInProgressForDataSet

func (r *BunStorageReplacementRepo) HasInProgressForDataSet(ctx context.Context, dataSetID int64) (bool, error)

HasInProgressForDataSet covers both generations a replacement owns. The target matters as much as the source: in-place recovery would otherwise queue repair work on the generation the coordinator is actively writing, and the two would race over the same copy row. It excludes operator-paused failed and attention states so that generation can still recover and repair in place; the replacement nevertheless retains its source, target, and slot identity.

func (*BunStorageReplacementRepo) HasUnsignedSourceWrites

func (r *BunStorageReplacementRepo) HasUnsignedSourceWrites(ctx context.Context, sourceDataSetID int64) (bool, error)

HasUnsignedSourceWrites reports whether a source has writes that can be handed over.

func (*BunStorageReplacementRepo) InspectItem

AcquireItem re-derives the current domain snapshot. Replacement items are ledgers, not workers; task claim and lease state never appears here.

func (*BunStorageReplacementRepo) ListActive

func (r *BunStorageReplacementRepo) ListActive(ctx context.Context, afterID int64, limit int) ([]storagereplacement.Replacement, error)

func (*BunStorageReplacementRepo) ListForBucket

func (r *BunStorageReplacementRepo) ListForBucket(ctx context.Context, bucketID int64, limit int) ([]storagereplacement.Replacement, error)

ListForBucket returns the whole replacement history, newest first, so the API can present a stable order.

func (*BunStorageReplacementRepo) ListPendingReplacementItemsAfter

func (r *BunStorageReplacementRepo) ListPendingReplacementItemsAfter(ctx context.Context, replacementID, afterID int64, limit int) ([]storagereplacement.Item, error)

func (*BunStorageReplacementRepo) ListTerminationAttempts

func (r *BunStorageReplacementRepo) ListTerminationAttempts(ctx context.Context, replacementIDs []int64) ([]storagereplacement.TerminationAttempt, error)

func (*BunStorageReplacementRepo) ListUnscheduledSuperseded

func (r *BunStorageReplacementRepo) ListUnscheduledSuperseded(ctx context.Context, successorID int64) ([]storagereplacement.Replacement, error)

func (*BunStorageReplacementRepo) LockCoordinatorProgress

func (r *BunStorageReplacementRepo) LockCoordinatorProgress(ctx context.Context, replacementID, generation, taskID int64) (*storagereplacement.Replacement, error)

func (*BunStorageReplacementRepo) LockCoordinatorTask

func (r *BunStorageReplacementRepo) LockCoordinatorTask(ctx context.Context, replacementID, generation, taskID int64) (*storagereplacement.Replacement, error)

LockCoordinatorTask holds the replacement's domain fence for transaction-local writes.

func (*BunStorageReplacementRepo) MarkCleanupAttention

func (r *BunStorageReplacementRepo) MarkCleanupAttention(ctx context.Context, replacementID int64, lastError string) error

MarkCleanupAttention is committed in the same transaction that stops the coordinator task, so automatic retry can never resume suppressed cleanup. Marking a replacement that already waits for attention only refreshes its error, so a retried task that stops again for the same reason can still settle.

func (*BunStorageReplacementRepo) MarkFailed

func (r *BunStorageReplacementRepo) MarkFailed(
	ctx context.Context,
	replacementID int64,
	reason *storagereplacement.FailureReason,
	lastError string,
) error

func (*BunStorageReplacementRepo) MarkInitializationFailed

func (r *BunStorageReplacementRepo) MarkInitializationFailed(ctx context.Context, id, generation, taskID, childID int64, message string) error

func (*BunStorageReplacementRepo) MarkMigrating

func (r *BunStorageReplacementRepo) MarkMigrating(ctx context.Context, replacementID int64) error

func (*BunStorageReplacementRepo) MarkReplacementItemAttention

func (r *BunStorageReplacementRepo) MarkReplacementItemAttention(ctx context.Context, replacementID, itemID int64, lastError string) error

func (*BunStorageReplacementRepo) MarkReplacementItemCancelled

func (r *BunStorageReplacementRepo) MarkReplacementItemCancelled(ctx context.Context, replacementID, itemID int64) error

func (*BunStorageReplacementRepo) MarkReplacementItemCopied

func (r *BunStorageReplacementRepo) MarkReplacementItemCopied(ctx context.Context, replacementID, itemID, targetCopyID int64) error

func (*BunStorageReplacementRepo) MarkWaiting

func (r *BunStorageReplacementRepo) MarkWaiting(ctx context.Context, replacementID int64, reason storagereplacement.WaitReason) error

MarkWaiting records a recoverable pause. It never consumes retry budget and is never reported as a failure.

func (*BunStorageReplacementRepo) NextPendingReplacementItem

func (r *BunStorageReplacementRepo) NextPendingReplacementItem(ctx context.Context, replacementID int64) (*storagereplacement.Item, error)

func (*BunStorageReplacementRepo) Preflight

func (r *BunStorageReplacementRepo) Preflight(ctx context.Context, dataSetID int64) (*ReplacementPreflight, error)

func (*BunStorageReplacementRepo) PrepareCoordinatorRetry

func (r *BunStorageReplacementRepo) PrepareCoordinatorRetry(ctx context.Context, id, generation, taskID int64) (*model.StorageDataSet, error)

func (*BunStorageReplacementRepo) RecordTerminationEvidence

func (r *BunStorageReplacementRepo) RecordTerminationEvidence(ctx context.Context, input RecordTerminationEvidenceInput) error

RecordTerminationEvidence preserves each attempt's immutable transaction pair and receipt outcome. The service epoch is independent of any failed attempt.

func (*BunStorageReplacementRepo) RecordTerminationUnsent added in v0.1.1

func (r *BunStorageReplacementRepo) RecordTerminationUnsent(ctx context.Context, input RecordTerminationEvidenceInput) error

RecordTerminationUnsent releases the latest admission after the current retirement owner proved that no transaction from it can land. Releasing again is inert; an attempt with any transaction evidence cannot be released.

func (*BunStorageReplacementRepo) ReplacementExecution

func (r *BunStorageReplacementRepo) ReplacementExecution(
	ctx context.Context,
	replacementID int64,
) (storagereplacement.ExecutionSnapshot, error)

func (*BunStorageReplacementRepo) ReplacementProgresses

func (r *BunStorageReplacementRepo) ReplacementProgresses(
	ctx context.Context,
	replacementIDs []int64,
) (map[int64]storagereplacement.ProgressSnapshot, error)

func (*BunStorageReplacementRepo) ResumeCoordinatorTask

func (r *BunStorageReplacementRepo) ResumeCoordinatorTask(ctx context.Context, id, generation, oldID, newID int64) error

func (*BunStorageReplacementRepo) Retry

Retry resumes the same approved target. The phase is re-derived from the data rather than remembered, so a retry always restarts at the stage the replacement actually reached.

func (*BunStorageReplacementRepo) RetryEligibility

func (r *BunStorageReplacementRepo) RetryEligibility(ctx context.Context, replacementID int64) error

func (*BunStorageReplacementRepo) SeedMigrationBatch

func (r *BunStorageReplacementRepo) SeedMigrationBatch(ctx context.Context, replacementID int64, limit int) (int, bool, error)

func (*BunStorageReplacementRepo) SourceEligibility

func (r *BunStorageReplacementRepo) SourceEligibility(ctx context.Context, dataSetID int64) (*model.StorageDataSet, bool, error)

SourceEligibility is shared by presentation, preflight, and authorization. The bool distinguishes a local handoff from replacement of a remote service.

func (*BunStorageReplacementRepo) TransferTaskOwner

func (r *BunStorageReplacementRepo) TransferTaskOwner(ctx context.Context, id, generation, oldID, newID int64) error

type BunTaskRepo

type BunTaskRepo struct {
	// contains filtered or unexported fields
}

BunTaskRepo is the persistence boundary used by TaskService and Engine.

func (*BunTaskRepo) AcknowledgeFailed

func (r *BunTaskRepo) AcknowledgeFailed(ctx context.Context, id int64) error

func (*BunTaskRepo) AcknowledgeFailedForSubject

func (r *BunTaskRepo) AcknowledgeFailedForSubject(ctx context.Context, subjectType, subjectKey string) (int, error)

func (*BunTaskRepo) AcknowledgeFailedMatching

func (r *BunTaskRepo) AcknowledgeFailedMatching(ctx context.Context, filter TaskAcknowledgeFilter) (int, error)

func (*BunTaskRepo) AdmitEffect

func (r *BunTaskRepo) AdmitEffect(ctx context.Context, id, generation int64, key string, checkpoint json.RawMessage) error

func (*BunTaskRepo) AppendEvent

func (r *BunTaskRepo) AppendEvent(ctx context.Context, taskID int64, eventType string, details json.RawMessage) error

func (*BunTaskRepo) ClaimNext

func (r *BunTaskRepo) ClaimNext(ctx context.Context, leaseDuration time.Duration, filter TaskClaimFilter) (*model.Task, error)

func (*BunTaskRepo) CountByScope

func (r *BunTaskRepo) CountByScope(ctx context.Context, scope TaskScope) ([]TaskStatusCount, error)

func (*BunTaskRepo) CountFailedMatching

func (r *BunTaskRepo) CountFailedMatching(ctx context.Context, filter TaskAcknowledgeFilter) (int, error)

func (*BunTaskRepo) CountOverviewActivePipeline

func (r *BunTaskRepo) CountOverviewActivePipeline(ctx context.Context) ([]TaskPipelineCount, error)

func (*BunTaskRepo) CountUnacknowledgedFailed

func (r *BunTaskRepo) CountUnacknowledgedFailed(ctx context.Context) (int64, error)

func (*BunTaskRepo) Enqueue

func (r *BunTaskRepo) Enqueue(ctx context.Context, task *model.Task) (*model.Task, bool, error)

func (*BunTaskRepo) GetByID

func (r *BunTaskRepo) GetByID(ctx context.Context, id int64) (*model.Task, error)

func (*BunTaskRepo) GetByIdentity

func (r *BunTaskRepo) GetByIdentity(ctx context.Context, taskType model.TaskType, subjectType, subjectKey string, generation int64) (*model.Task, error)

func (*BunTaskRepo) GetDirectSuccessor

func (r *BunTaskRepo) GetDirectSuccessor(ctx context.Context, id int64) (*model.Task, error)

func (*BunTaskRepo) GetForUpdate

func (r *BunTaskRepo) GetForUpdate(ctx context.Context, id int64) (*model.Task, error)

func (*BunTaskRepo) LatestForSubject

func (r *BunTaskRepo) LatestForSubject(ctx context.Context, subjectType, subjectKey string, types ...model.TaskType) (*model.Task, error)

func (*BunTaskRepo) LatestForSubjects

func (r *BunTaskRepo) LatestForSubjects(ctx context.Context, subjectType string, subjectKeys []string, types ...model.TaskType) (map[string]model.Task, error)

func (*BunTaskRepo) List

func (r *BunTaskRepo) List(ctx context.Context, filter TaskListFilter) (TaskPage, error)

func (*BunTaskRepo) ListCurrentFailedForSubject

func (r *BunTaskRepo) ListCurrentFailedForSubject(ctx context.Context, subjectType, subjectKey string, beforeID int64, limit int, types ...model.TaskType) (TaskPage, error)

func (*BunTaskRepo) ListEvents

func (r *BunTaskRepo) ListEvents(ctx context.Context, taskID, beforeID int64, limit int) ([]model.TaskEvent, error)

func (*BunTaskRepo) ListHistory

func (r *BunTaskRepo) ListHistory(ctx context.Context, anchorID, beforeID int64, limit int) (TaskPage, error)

func (*BunTaskRepo) MarkWorkStarted

func (r *BunTaskRepo) MarkWorkStarted(ctx context.Context, id, generation int64, startedAt time.Time) error

MarkWorkStarted preserves the first operation time under the live claim fence.

func (*BunTaskRepo) ObserveOperation

func (r *BunTaskRepo) ObserveOperation(ctx context.Context, id, generation int64, key string) (time.Time, error)

func (*BunTaskRepo) PreviousStoreCheckpoints

func (r *BunTaskRepo) PreviousStoreCheckpoints(ctx context.Context, copyID, taskID int64) ([]model.Task, error)

func (*BunTaskRepo) RenewLease

func (r *BunTaskRepo) RenewLease(ctx context.Context, id, generation int64, leaseDuration time.Duration) (time.Time, error)

func (*BunTaskRepo) ResolveOperation

func (r *BunTaskRepo) ResolveOperation(ctx context.Context, id, generation int64, key string) error

func (*BunTaskRepo) Settle

func (r *BunTaskRepo) Settle(ctx context.Context, id, generation int64, transition TaskTransition) error

func (*BunTaskRepo) ShortenLease

func (r *BunTaskRepo) ShortenLease(ctx context.Context, id, generation int64, duration time.Duration) error

func (*BunTaskRepo) SupersedeTerminal

func (r *BunTaskRepo) SupersedeTerminal(ctx context.Context, id int64) error

func (*BunTaskRepo) ValidateClaim

func (r *BunTaskRepo) ValidateClaim(ctx context.Context, id, generation int64) error

func (*BunTaskRepo) WakePending

func (r *BunTaskRepo) WakePending(ctx context.Context, ids []int64) (int, error)

func (*BunTaskRepo) WakePendingOfTypes

func (r *BunTaskRepo) WakePendingOfTypes(ctx context.Context, ids []int64, types []model.TaskType, skipWaitReasons []string) (int, error)

WakePendingOfTypes applies type and wait-reason authorization in the update.

func (*BunTaskRepo) WriteCheckpoint

func (r *BunTaskRepo) WriteCheckpoint(ctx context.Context, id, generation int64, checkpoint json.RawMessage) error

type BunTaskScheduleRepo

type BunTaskScheduleRepo struct {
	// contains filtered or unexported fields
}

func (*BunTaskScheduleRepo) Ensure

func (r *BunTaskScheduleRepo) Ensure(ctx context.Context, key string, nextRunAt time.Time) error

func (*BunTaskScheduleRepo) GetByTaskID

func (r *BunTaskScheduleRepo) GetByTaskID(ctx context.Context, taskID int64) (*model.TaskSchedule, error)

func (*BunTaskScheduleRepo) GetForUpdate

func (r *BunTaskScheduleRepo) GetForUpdate(ctx context.Context, key string) (*model.TaskSchedule, error)

func (*BunTaskScheduleRepo) ListDue

func (r *BunTaskScheduleRepo) ListDue(ctx context.Context, now time.Time) ([]model.TaskSchedule, error)

func (*BunTaskScheduleRepo) ScheduleNext

func (r *BunTaskScheduleRepo) ScheduleNext(ctx context.Context, key string, taskID int64, nextRunAt time.Time) error

func (*BunTaskScheduleRepo) SetHead

func (r *BunTaskScheduleRepo) SetHead(ctx context.Context, key string, expectedGeneration, generation int64, expectedTaskID, taskID *int64, nextRunAt time.Time) error

type BunWalletOperationRepo

type BunWalletOperationRepo struct {
	// contains filtered or unexported fields
}

func (*BunWalletOperationRepo) BindTask

func (r *BunWalletOperationRepo) BindTask(ctx context.Context, id, taskID int64) error

func (*BunWalletOperationRepo) CreateOrGet

CreateOrGet records a wallet request once per client request ID. A request that loses a race to the same ID gets the winner's operation: the conflict never raises an error, which on PostgreSQL would abort the caller's transaction before the winner could be read.

func (*BunWalletOperationRepo) GetByID

func (*BunWalletOperationRepo) GetOperationSubject

func (r *BunWalletOperationRepo) GetOperationSubject(ctx context.Context, id int64) (*model.WalletOperation, error)

func (*BunWalletOperationRepo) ListRecent

func (r *BunWalletOperationRepo) ListRecent(ctx context.Context, limit int) ([]model.WalletOperation, error)

func (*BunWalletOperationRepo) MarkBroadcastAttempted

func (r *BunWalletOperationRepo) MarkBroadcastAttempted(ctx context.Context, id, taskID int64) error

func (*BunWalletOperationRepo) MarkConfirmed

func (r *BunWalletOperationRepo) MarkConfirmed(ctx context.Context, id, taskID int64, txHash string) error

func (*BunWalletOperationRepo) MarkConfirmedWithoutTransaction

func (r *BunWalletOperationRepo) MarkConfirmedWithoutTransaction(ctx context.Context, id, taskID int64) error

func (*BunWalletOperationRepo) MarkFailed

func (r *BunWalletOperationRepo) MarkFailed(ctx context.Context, id, taskID int64, lastError string) error

func (*BunWalletOperationRepo) MarkSubmissionUnknown added in v0.1.1

func (r *BunWalletOperationRepo) MarkSubmissionUnknown(ctx context.Context, id, taskID int64, lastError string) error

MarkSubmissionUnknown stops a submitted operation whose transaction can no longer land when what took its place is unknown. Its transaction evidence is kept.

func (*BunWalletOperationRepo) MarkSubmitted

func (r *BunWalletOperationRepo) MarkSubmitted(ctx context.Context, id, taskID int64, txHash string) error

func (*BunWalletOperationRepo) MarkUnknown

func (r *BunWalletOperationRepo) MarkUnknown(ctx context.Context, id, taskID int64, lastError string) error

func (*BunWalletOperationRepo) RecordConfirmationError

func (r *BunWalletOperationRepo) RecordConfirmationError(ctx context.Context, id, taskID int64, lastError string) error

func (*BunWalletOperationRepo) RecordSubmission

func (r *BunWalletOperationRepo) RecordSubmission(ctx context.Context, id, taskID int64, txHash string, signedTransaction []byte, lastError string) error

RecordSubmission only fills missing transaction evidence or repeats it unchanged.

func (*BunWalletOperationRepo) ReopenUnsentForRetry added in v0.1.1

func (r *BunWalletOperationRepo) ReopenUnsentForRetry(ctx context.Context, id, oldTaskID, newTaskID int64) error

func (*BunWalletOperationRepo) TransferTaskOwner

func (r *BunWalletOperationRepo) TransferTaskOwner(ctx context.Context, id, oldID, newID int64) error

type CacheEvictionRepository

type CacheEvictionRepository interface {
	// GetCacheEntry returns the residency record for one content payload.
	GetCacheEntry(ctx context.Context, contentID int64) (*model.ObjectCache, error)
	NextEvictionGeneration(ctx context.Context, contentID int64) (int64, error)
	PrepareEviction(ctx context.Context, contentID int64) (CacheEvictionReservation, error)
	BindEvictionTask(ctx context.Context, contentID, generation, taskID int64) error
	TransferEvictionTaskOwner(ctx context.Context, contentID, generation, oldTaskID, newTaskID int64) error
	ListLRUCandidates(ctx context.Context, limit int, after ...CacheLRUCursor) ([]cacheeviction.Candidate, error)
	ActiveEvictionBytes(ctx context.Context) (int64, error)
	ReclaimableLRUBytes(ctx context.Context) (int64, error)
	AuthorizeDeletion(ctx context.Context, contentID, generation, taskID int64, expectedAccess *time.Time) (*cacheeviction.AuthorizedDeletion, error)
	RecordDeletion(ctx context.Context, contentID, generation, taskID int64) error
	DeletionRecorded(ctx context.Context, contentID, generation int64) (bool, error)
	ReleaseEviction(ctx context.Context, contentID, generation, taskID int64) error

	NextDurabilityGeneration(ctx context.Context, bucketID int64) (int64, error)
	BindDurabilityTask(ctx context.Context, bucketID, generation, taskID int64) error
	TransferDurabilityTaskOwner(ctx context.Context, bucketID, generation, oldTaskID, newTaskID int64) error
	// NextBucketDurabilityCandidate returns the next cached content in the
	// bucket that now satisfies the bucket's minimum durability. It no longer
	// promotes any lifecycle state: pipeline position is derived from the copy
	// rows, so there is nothing to advance, only cache to reclaim.
	NextBucketDurabilityCandidate(ctx context.Context, bucketID, generation, taskID int64) (*model.StorageContent, error)
	ListBucketDurabilityCandidates(ctx context.Context, bucketID, generation, taskID int64, limit int) ([]model.StorageContent, error)
	CompleteBucketDurability(ctx context.Context, bucketID, generation, taskID int64) error
	// ReleaseBucketDurability ends the bucket's reconciliation without
	// requiring its candidates to be released, for policies that never release
	// cache after upload.
	ReleaseBucketDurability(ctx context.Context, bucketID, generation, taskID int64) error
}

Cache residency is keyed by content, not by object version: identical bytes written under several keys share one local file, so one eviction decision covers every version that references them.

type CacheEvictionReservation

type CacheEvictionReservation struct {
	Generation   int64
	ActiveTaskID *int64
}

type CacheLRUCursor

type CacheLRUCursor struct {
	AccessedAt time.Time
	ContentID  int64
}

type CacheLocalRepository added in v0.1.1

type CacheLocalRepository interface {
	ListStates(context.Context, []int64) (map[int64]CacheLocalState, error)
	RestorePresence(context.Context, CacheLocalState) (bool, error)
	DeleteQuarantinedIfSafe(context.Context, int64, func() error) (bool, error)
}

type CacheLocalState added in v0.1.1

type CacheLocalState struct {
	ContentID                int64
	BucketName               string
	Checksum                 string
	ContentSize              int64
	InCache                  bool
	Referenced               bool
	CacheOperationGeneration int64
	CachePresenceGeneration  int64
	CacheActiveTaskID        *int64
}

CacheLocalState is the content identity and residency observed before checking a file. The generations fence a later presence update against cache work.

type CommitBatch

type CommitBatch struct {
	storagecommit.Request
	BucketName    string
	ProviderID    idtypes.OnChainID
	ProviderName  *string
	DataSetID     *idtypes.OnChainID
	MemberCount   int
	TotalBytes    *int64
	OldestReadyAt *time.Time
	TaskStatus    *model.TaskStatus
	TaskMessage   *string
	TaskError     *string
}

type CommitBatchFilter

type CommitBatchFilter struct {
	Status          storagecommit.RequestStatus
	Limit           int
	BeforeCreatedAt time.Time
	BeforeRequestID string
}

type CommitBatchMember

type CommitBatchMember struct {
	ContentID int64
	PieceCID  string
	Size      *int64
}

type CommitQueueState

type CommitQueueState struct {
	Submitted int
	// ReadyHead is the ready request that may be sent next, if any.
	ReadyHead string
}

CommitQueueState reports submission capacity and the next ready request.

type CommitRequestMember

type CommitRequestMember struct {
	model.StorageCopy
	PieceCID string `bun:"member_piece_cid"`
}

CommitRequestMember is a copy of a request together with its content's piece CID.

type CommitSendInput

type CommitSendInput struct {
	RequestID string
	TaskID    int64
	Sends     int
	Now       time.Time
}

CommitSendInput names one send of a submitted request: Sends is the count it was recorded with.

type CommitSubmissionInput

type CommitSubmissionInput struct {
	CommitSendInput
	TxHash    string
	StatusURL string
}

CommitSubmissionInput is the provider's receipt for one send.

type CommitSubmitFailureInput

type CommitSubmitFailureInput struct {
	CommitSendInput
	Message string
}

CommitSubmitFailureInput keeps the provider's reply to a send whose outcome stayed unknown.

type ConfirmCommitRequestInput

type ConfirmCommitRequestInput struct {
	RequestID       string
	TaskID          int64
	ConfirmedTxHash string
	FirstPieceID    idtypes.OnChainID
	// RetrievalURLs are the members' retrieval URLs in position order.
	RetrievalURLs []string
	Now           time.Time
}

ConfirmCommitRequestInput settles a request the chain proved.

type ContentFileSample

type ContentFileSample struct {
	BucketID      int64
	Key           string
	Size          int64
	Source        string
	OtherVersions int64
}

ContentFileSample identifies one version of shared bytes without loading its history.

type CopyRetryBlockedError

type CopyRetryBlockedError struct {
	Block storagepipeline.CopyRetryBlock
}

func (*CopyRetryBlockedError) Error

func (e *CopyRetryBlockedError) Error() string

func (*CopyRetryBlockedError) Unwrap

func (e *CopyRetryBlockedError) Unwrap() error

type CopyRetryState

type CopyRetryState struct {
	CopyID     int64
	Available  bool
	Block      storagepipeline.CopyRetryBlock
	NextMethod model.StorageCopyTransferMethod
}

type CreateCommitRequestInput

type CreateCommitRequestInput struct {
	RequestID        string
	TaskID           int64
	StorageDataSetID int64
	CopyIDs          []int64
	Now              time.Time
}

CreateCommitRequestInput starts a collecting request driven by TaskID.

type CreateWalletOperationInput

type CreateWalletOperationInput struct {
	Type            model.WalletOperationType
	ClientRequestID string
	Amount          string
}

type DatabaseMetricsSnapshot

type DatabaseMetricsSnapshot struct {
	Tasks   []TaskStatusCount
	Objects []ObjectStateCount
}

type DeleteDeletedObjectInput

type DeleteDeletedObjectInput struct {
	BucketID              int64
	Key                   string
	DeleteMarkerVersionID string
}

type DeleteDeletedObjectResult

type DeleteDeletedObjectResult struct {
	Key                   string
	DeleteMarkerVersionID string
	DataVersionsDeleted   int
	DeleteMarkersDeleted  int
	DeletedVersions       []DeletedObjectVersionSnapshot
	StorageCleanups       []StorageCleanupReservation
}

type DeleteObjectVersionInput

type DeleteObjectVersionInput struct {
	BucketID  int64
	Key       string
	VersionID string
	Condition ObjectCondition
}

type DeleteObjectVersionResult

type DeleteObjectVersionResult struct {
	DeletionID     int64
	ContentID      *int64
	StorageCleanup *StorageCleanupReservation
}

type DeletedObjectVersionSnapshot

type DeletedObjectVersionSnapshot struct {
	VersionID string
	ContentID *int64
}

type DeploymentIdentityRepository

type DeploymentIdentityRepository interface {
	BindOrVerify(context.Context, BindDeploymentIdentityInput) (*model.DeploymentIdentity, error)
}

type EnqueueRemovalTask added in v0.1.1

type EnqueueRemovalTask func(context.Context, *Repositories, storageremoval.Input) (int64, error)

type EnsureContentInput

type EnsureContentInput struct {
	BucketID        int64
	ContentSize     int64
	Checksum        string
	RequestedCopies int
}

type EnsureDataSetBindingInput

type EnsureDataSetBindingInput struct {
	BucketID           int64
	ProviderID         types.OnChainID
	CopyIndex          int
	CreatedByContentID int64
}

type FinalizeUploadInput

type FinalizeUploadInput struct {
	ContentID int64
}

func NewFinalizeUploadInput

func NewFinalizeUploadInput(contentID int64) FinalizeUploadInput

type JoinCommitRequestInput

type JoinCommitRequestInput struct {
	CopyID           int64
	StorageDataSetID int64
	Now              time.Time
}

JoinCommitRequestInput adds one transferred copy to a collecting request of its data set.

type JoinRemovalInput added in v0.1.1

type JoinRemovalInput struct {
	ContentID        int64
	Generation       int64
	ContentTaskID    int64
	StorageDataSetID int64
	CopyIDs          []int64
	Identity         storagepipeline.ExecutionIdentity
	Enqueue          EnqueueRemovalTask
	Now              time.Time
}

type MarkDataSetCreatingInput

type MarkDataSetCreatingInput struct {
	ConfirmedTxHash string
	ID              int64
	TxHash          string
	StatusURL       string
	ClientDataSetID *types.OnChainID
}

type MarkDataSetReadyInput

type MarkDataSetReadyInput struct {
	TxHash          string
	ConfirmedTxHash string
	ID              int64
	DataSetID       types.OnChainID
	ClientDataSetID *types.OnChainID
}

type MarkUploadCopyFailedInput

type MarkUploadCopyFailedInput struct {
	StorageCopyID int64
	ContentID     int64
	CopyIndex     int
	LastError     string
	// PullAttemptID abandons the unresolved provider pull in the same
	// transaction as the copy failure. Empty means this was not a pull failure.
	PullAttemptID string
}

MarkUploadCopyFailedInput names the copy that failed. Without the id the failure resolves through the replica slot, which after an activation is a different generation than the one the write was bound to: the failure would either land on the replacement's copy or update nothing at all, leaving the original stuck mid-transfer and holding retirement open.

type MarkUploadCopyPieceReadyInput

type MarkUploadCopyPieceReadyInput struct {
	StorageCopyID       int64
	RequireEligibleCopy bool
	ContentID           int64
	CopyIndex           int
	PieceCID            string
	PieceID             *types.OnChainID
	RetrievalURL        string
	// PullAttemptID resolves the pull ledger row in the same transaction that
	// records the piece. Leaving it empty is how an ingress store settles, since
	// no request was sent to a source provider.
	PullAttemptID string
}

StorageCopyID names the exact copy row to write. A task that was queued before the current data set generation took over must still land on the generation it actually stored to, so addressing is separate from the eligibility guards below.

RequireEligibleCopy makes the write refuse a failed copy, a deleted object, or a copy that no longer matches, instead of reporting no rows. Coordinators that own one specific copy set it; ordinary upload stages stay idempotent.

type MultipartUploadRepository

type MultipartUploadRepository interface {
	Create(ctx context.Context, upload *model.MultipartUpload) error
	GetByUploadID(ctx context.Context, uploadID string) (*model.MultipartUpload, error)
	ListByBucket(ctx context.Context, bucketID int64, prefix, keyMarker, contentIDMarker string, maxUploads int) ([]model.MultipartUpload, error)
	// CountActiveByBucket returns initiated/completing multipart uploads for the given bucket.
	CountActiveByBucket(ctx context.Context, bucketID int64) (int64, error)
	// SetStatus atomically transitions status using CAS (compare-and-swap) to prevent races.
	SetStatus(ctx context.Context, contentID string, from, to model.MultipartStatus) error
	// ReleaseInterruptedCompletions returns uploads left completing by a stopped
	// process to initiated. It must run before the process accepts requests.
	ReleaseInterruptedCompletions(ctx context.Context) (int64, error)
	Delete(ctx context.Context, contentID string) error

	// Part operations
	CreatePart(ctx context.Context, part *model.MultipartPart) error
	GetParts(ctx context.Context, contentID string, partNumberMarker, maxParts int) ([]model.MultipartPart, error)
	GetPartsByNumbers(ctx context.Context, contentID string, numbers []int) ([]model.MultipartPart, error)
	// DeletePartsExcept removes the parts a completion did not assemble.
	DeletePartsExcept(ctx context.Context, uploadID string, keep []int) error
	DeleteParts(ctx context.Context, contentID string) error
}

MultipartUploadRepository defines persistence operations for multipart upload entities.

type ObjectAttentionCount

type ObjectAttentionCount struct {
	NeedsAttention int64 `bun:"needs_attention"`
	Unavailable    int64 `bun:"unavailable"`
}

type ObjectCondition added in v0.1.1

type ObjectCondition func(*model.ObjectVersion) error

ObjectCondition evaluates a locked version, or nil when the key has no current version. It must be pure because a transaction may be replayed.

type ObjectOverviewSnapshot

type ObjectOverviewSnapshot struct {
	States    []ObjectStateAggregate
	Attention ObjectAttentionCount
}

type ObjectRepository

type ObjectRepository interface {
	GetContentFileSample(ctx context.Context, contentID int64) (*ContentFileSample, error)
	CreateVersionAndSetCurrent(ctx context.Context, version *model.ObjectVersion, conditions ...ObjectCondition) (objectID int64, err error)
	CreateVersionAndSetCurrentIfChanged(ctx context.Context, version *model.ObjectVersion) (ObjectVersionWriteResult, error)
	// CreateRestoredVersionAndSetCurrent creates a new current data version only
	// when the selected source still exists and the expected version is current.
	CreateRestoredVersionAndSetCurrent(ctx context.Context, version *model.ObjectVersion, sourceVersionID, expectedCurrentVersionID string) (objectID int64, err error)
	CreateDeleteMarkerAndSetCurrent(ctx context.Context, bucketID int64, key, versionID string, conditions ...ObjectCondition) (*model.ObjectVersion, error)
	DeleteMarkerVersion(ctx context.Context, bucketID int64, key, versionID string, conditions ...ObjectCondition) error
	DeleteObjectVersionPermanently(ctx context.Context, input DeleteObjectVersionInput) (DeleteObjectVersionResult, error)
	DeleteDeletedObjectPermanently(ctx context.Context, input DeleteDeletedObjectInput) (DeleteDeletedObjectResult, error)
	// ClearContentCachePresence records that a content payload no longer has
	// cached bytes on this node.
	ClearContentCachePresence(ctx context.Context, contentID int64) error
	// ReleaseContentCacheIfUnreferenced locks the content row, rechecks live
	// references, and invokes release before clearing cache presence in the
	// same transaction. The callback must be idempotent.
	ReleaseContentCacheIfUnreferenced(ctx context.Context, contentID int64, release func() error) (bool, error)
	// ContentIsUnreferenced reports whether any live object version still
	// points at the content.
	ContentIsUnreferenced(ctx context.Context, contentID int64) (bool, error)
	// RestoreCurrentDeleteMarkerStack is the admin trash restore path: it removes
	// the current delete marker stack until the latest data version becomes current,
	// unlike S3 versioned delete which removes only one specified delete marker.
	RestoreCurrentDeleteMarkerStack(ctx context.Context, bucketID int64, key, currentMarkerVersionID string) (*model.ObjectVersion, error)
	GetObjectByID(ctx context.Context, id int64) (*model.Object, error)
	GetObjectByBucketAndKey(ctx context.Context, bucketID int64, key string) (*model.Object, error)
	GetCurrentVersionByObjectID(ctx context.Context, objectID int64) (*model.ObjectVersion, error)
	GetCurrentVersionByBucketAndKey(ctx context.Context, bucketID int64, key string) (*model.ObjectVersion, error)
	GetVersionByID(ctx context.Context, versionID string) (*model.ObjectVersion, error)
	GetVersionByBucketKeyAndID(ctx context.Context, bucketID int64, key, versionID string) (*model.ObjectVersion, error)
	ListCurrentVersionsByBucket(ctx context.Context, bucketID int64, prefix, afterKey string, maxKeys int) ([]model.ObjectVersion, error)
	ListCurrentVersionsByBucketAtOrAfter(ctx context.Context, bucketID int64, prefix, fromKey string, maxKeys int) ([]model.ObjectVersion, error)
	ListVersionsByBucket(ctx context.Context, bucketID int64, prefix, keyMarker, versionIDMarker string, maxKeys int) ([]ObjectVersionListItem, error)
	ListVersionsByBucketAtOrAfter(ctx context.Context, bucketID int64, prefix, fromKey string, maxKeys int) ([]ObjectVersionListItem, error)
	ListVersionsByKey(ctx context.Context, bucketID int64, key, afterVersionID string, maxKeys int) ([]ObjectVersionListItem, error)
	ListRecoverableDeleteMarkers(ctx context.Context, bucketID int64, prefix, afterKey string, maxKeys int) ([]RecoverableDeleteMarker, error)
	SetVersionCachePresence(ctx context.Context, versionID string, inCache bool) error
	// RecordContentCacheAccess advances LRU recency for one content payload
	// without changing whether its bytes are present.
	RecordContentCacheAccess(ctx context.Context, contentID int64, accessedAt time.Time) error
	// RecordContentCacheCommit marks a newly written cache file present and
	// advances its recency in the same write.
	RecordContentCacheCommit(ctx context.Context, contentID int64, accessedAt time.Time) error
	// CountByState returns object counts grouped by state.
	CountByState(ctx context.Context) ([]ObjectStateCount, error)
	OverviewSnapshot(ctx context.Context) (ObjectOverviewSnapshot, error)
	// CountByBucket returns the number of current objects in a bucket.
	CountByBucket(ctx context.Context, bucketID int64) (int64, error)
	// TotalSizeByBucket returns the sum of current object sizes in a bucket.
	TotalSizeByBucket(ctx context.Context, bucketID int64) (int64, error)
	// BucketStats returns object count and total size for a single bucket in a single query.
	BucketStats(ctx context.Context, bucketID int64) (BucketObjectStats, error)
	// AggregateByBucket returns object count and total size for all buckets in a single query.
	AggregateByBucket(ctx context.Context) (map[int64]BucketObjectStats, error)
}

ObjectRepository defines persistence operations for object identities and versions.

type ObjectStateAggregate

type ObjectStateAggregate struct {
	State     string `bun:"state"`
	Count     int64  `bun:"count"`
	TotalSize int64  `bun:"total_size"`
}

ObjectStateAggregate holds object count and total size grouped by state.

type ObjectStateCount

type ObjectStateCount struct {
	State string `bun:"state"`
	Count int64  `bun:"count"`
}

ObjectStateCount holds an object count grouped by state.

type ObjectVersionListItem

type ObjectVersionListItem struct {
	model.ObjectVersion `bun:",extend"`
}

ObjectVersionListItem represents one object version row in listing queries.

type ObjectVersionRef

type ObjectVersionRef struct {
	ObjectID  int64  `bun:"object_id"`
	VersionID string `bun:"version_id"`
	ContentID *int64 `bun:"content_id"`
}

ObjectVersionRef identifies a version and its current object row.

type ObjectVersionWriteResult

type ObjectVersionWriteResult struct {
	ObjectID  int64
	VersionID string
	ETag      string
	Created   bool
}

ObjectVersionWriteResult reports whether a write created a new version or reused the current version.

type ObservabilityRepository

type ObservabilityRepository interface {
	GetProviderSubject(ctx context.Context, id types.OnChainID) (*ProviderSubject, error)
	// RecordApprovedProviders and RecordEndorsedProviders return the collection
	// time the stored tier snapshot carries after the write.
	RecordApprovedProviders(context.Context, time.Time, []types.OnChainID) (time.Time, error)
	RecordEndorsedProviders(context.Context, time.Time, []types.OnChainID) (time.Time, error)
	ProviderProfiles(context.Context, []types.OnChainID) (map[string]observability.ProviderProfile, error)
	GetProviderTierSnapshot(context.Context, string) (*observability.ProviderTierSnapshot, error)
	UpsertProviderObservation(context.Context, time.Time, observability.ProviderState) error
	OverviewStorageStates(ctx context.Context) ([]model.StorageDataSet, []observability.ProviderState, []observability.DataSetState, *time.Time, *time.Time, error)
	ReplaceProviderStates(ctx context.Context, checkedAt time.Time, states []observability.ProviderState) error
	ListProviderStates(ctx context.Context, opts observability.ListOptions) (observability.ProviderStatePage, error)
	ReplaceDataSetStates(ctx context.Context, checkedAt time.Time, states []observability.DataSetState) error
	ListDataSetStates(ctx context.Context, opts observability.ListOptions) (observability.DataSetStatePage, error)
	GetDataSetStatesByLocalIDs(ctx context.Context, localIDs []int64) (map[int64]observability.DataSetState, error)
}

type OrphanedContent

type OrphanedContent struct {
	ContentID  int64  `bun:"content_id"`
	BucketName string `bun:"bucket_name"`
}

OrphanedContent is content no object version has ever named.

type ProviderSubject

type ProviderSubject struct {
	ProviderID types.OnChainID
	Name       string
	ServiceURL string
}

type ReadableStorageCopy

type ReadableStorageCopy struct {
	ContentID      int64           `bun:"content_id"`
	PieceCID       string          `bun:"piece_cid"`
	CopyIndex      int             `bun:"copy_index"`
	ProviderID     types.OnChainID `bun:"provider_id"`
	DataSetID      types.OnChainID `bun:"data_set_id"`
	PieceID        types.OnChainID `bun:"piece_id"`
	TransferMethod string          `bun:"transfer_method"`
	RetrievalURL   string          `bun:"retrieval_url"`
}

type RecordIngressStoreProgressInput

type RecordIngressStoreProgressInput struct {
	CopyID        int64
	Generation    int64
	TaskID        int64
	Attempt       int
	BytesUploaded int64
}

type RecordTerminationEvidenceInput

type RecordTerminationEvidenceInput struct {
	ReplacementID   int64
	DataSetID       int64
	Generation      int64
	TaskID          int64
	Role            storagereplacement.TerminationRole
	AttemptNo       int64
	TxHash          string
	ConfirmedTxHash string
	ReceiptStatus   *uint64
	Epoch           *int64
}

type RecoverableDeleteMarker

type RecoverableDeleteMarker struct {
	Marker         model.ObjectVersion
	RestoreVersion model.ObjectVersion
}

RecoverableDeleteMarker pairs a current delete marker with the data version that would become current if the marker stack is restored.

type ReleaseMemberTransferInput

type ReleaseMemberTransferInput struct {
	StorageCopyID int64
	ContentID     int64
	Generation    int64
	TaskID        int64
	LastError     string
	PullAttemptID string
}

ReleaseMemberTransferInput names the transfer task of a signed member that gave up.

type RemovalAttentionInput added in v0.1.1

type RemovalAttentionInput struct {
	RequestID string
	TaskID    int64
	Code      storageremoval.AttentionCode
	Message   string
	Now       time.Time
}

type RemovalMembersInput added in v0.1.1

type RemovalMembersInput struct {
	RequestID string
	TaskID    int64
	CopyIDs   []int64
	Message   string
	Detach    bool
	Now       time.Time
}

type RemovalQueuedInput added in v0.1.1

type RemovalQueuedInput struct {
	RequestID   string
	TaskID      int64
	QueuedAt    time.Time
	QueuedBlock uint64
}

type RemovalRequestInput added in v0.1.1

type RemovalRequestInput struct {
	RequestID string
	TaskID    int64
	Message   string
	Now       time.Time
}

type RemovalSendEvidenceInput added in v0.1.1

type RemovalSendEvidenceInput struct {
	RequestID       string
	TaskID          int64
	SendNo          int
	TxHash          string
	ConfirmedTxHash string
	ReceiptStatus   *int64
	Message         string
	Now             time.Time
}

type ReplacementItemBatch

type ReplacementItemBatch struct {
	Items      []ReplacementItemSnapshot
	LastItemID int64
	Scanned    int
}

type ReplacementItemSnapshot

type ReplacementItemSnapshot struct {
	Replacement storagereplacement.Replacement
	Item        storagereplacement.Item
	Source      model.StorageDataSet
	Target      model.StorageDataSet
	Upload      model.StorageContent
	Version     model.ObjectVersion
}

ReplacementItemSnapshot is the consistent view one migration item needs.

type ReplacementPreflight

type ReplacementPreflight struct {
	Source  model.StorageDataSet
	Targets []ReplacementTargetCheck
}

ReplacementPreflight freezes the local identities checked outside the transaction.

type ReplacementSubject

type ReplacementSubject struct {
	BucketID         int64
	CopyIndex        int
	SourceProviderID types.OnChainID
	TargetProviderID types.OnChainID
}

type ReplacementTargetCheck

type ReplacementTargetCheck struct {
	Replacement storagereplacement.Replacement
	DataSet     model.StorageDataSet
}

ReplacementTargetCheck couples the unresolved target identity with its replacement fence.

type Repositories

type Repositories struct {
	AdminSessions       AdminSessionRepository
	DeploymentIdentity  DeploymentIdentityRepository
	Buckets             BucketRepository
	S3Accounts          S3AccountRepository
	Objects             ObjectRepository
	Contents            StorageContentRepository
	Replacements        StorageReplacementRepository
	StorageCleanup      StorageCleanupRepository
	StorageRemoval      StorageRemovalRepository
	Tasks               TaskRepository
	TaskSchedules       TaskScheduleRepository
	CacheEvictions      CacheEvictionRepository
	CacheLocal          CacheLocalRepository
	Multiparts          MultipartUploadRepository
	WalletOperations    WalletOperationRepository
	Observability       ObservabilityRepository
	ProviderUploadSpeed ProviderUploadSpeedRepository
	// contains filtered or unexported fields
}

Repositories aggregates all repository implementations, providing a single dependency for service/backend layers. The WithTx helper executes a callback inside a database transaction with a clone of Repositories backed by the tx.

func NewRepositories

func NewRepositories(db bun.IDB) *Repositories

NewRepositories constructs a Repositories with concrete Bun-backed implementations.

func (*Repositories) DatabaseMetrics

func (r *Repositories) DatabaseMetrics(ctx context.Context) (DatabaseMetricsSnapshot, error)

DatabaseMetrics reads a complete sample without permitting database writes.

func (*Repositories) EnrichProviderCandidates

func (r *Repositories) EnrichProviderCandidates(ctx context.Context, in *providerselect.Inventory) error

func (*Repositories) IsTransaction

func (r *Repositories) IsTransaction() bool

IsTransaction identifies repositories backed by the caller's Bun transaction.

func (*Repositories) ProviderRankingSpeeds

func (r *Repositories) ProviderRankingSpeeds(ctx context.Context, ids []types.OnChainID) (map[string]int64, error)

ProviderRankingSpeeds reads measurements matching each provider's profile URL.

func (*Repositories) ProviderSelectionState

func (r *Repositories) ProviderSelectionState(ctx context.Context, bucketID, sourceID int64, admission providerselect.Admission) (map[string]providerselect.ExclusionReason, bool, error)

ProviderSelectionState uses the existing binding and replacement ledgers. Failed replacements remain reservations because their accepted target can retry.

func (*Repositories) ValidateProviderSelection

func (r *Repositories) ValidateProviderSelection(ctx context.Context, bucketID, sourceID int64, admission providerselect.Admission, targets []types.OnChainID) error

ValidateProviderSelection runs inside the caller's bucket-locked transaction.

func (*Repositories) WithTx

func (r *Repositories) WithTx(ctx context.Context, fn func(txRepos *Repositories) error) error

WithTx runs fn inside a database transaction. The callback receives a *Repositories whose repository implementations are all backed by the same tx. If fn returns nil the transaction is committed; otherwise it is rolled back.

type ReservePullRequestInput

type ReservePullRequestInput struct {
	CopyID     int64
	Generation int64
	TaskID     int64
	AttemptID  string
	// On-chain identity is optional at the type level because zero is a legal
	// value: the first piece of a data set is piece 0. Presence is nil-checked.
	SourceProviderID   *types.OnChainID
	SourceDataSetID    *types.OnChainID
	SourcePieceID      *types.OnChainID
	SourcePieceCID     string
	SourceRetrievalURL string
	ExtraDataHex       string
}

ReservePullRequestInput records one provider-side copy request before it is sent. AttemptID is the ledger row's identity and SourcePieceCID names the piece being fetched, which is not the same as the content's own CID.

type ResumeFailedStoreCopyInput

type ResumeFailedStoreCopyInput struct {
	CopyID           int64
	Generation       int64
	SourceTaskID     int64
	TaskID           int64
	SourceCheckpoint json.RawMessage
	Checkpoint       json.RawMessage
}

type RetirementGate

type RetirementGate struct {
	CoverageGaps     int
	SourceWrites     int
	ActiveAttempts   int
	WaitingItems     int
	SlotOwned        bool
	EpochReached     bool
	TerminationEpoch *int64
	// Blockers names the failing predicates in evaluation order.
	Blockers []string
}

RetirementGate reports each safety predicate separately so a recoverable block can wait while a structural one raises operator attention.

func (RetirementGate) Passed

func (g RetirementGate) Passed() bool

Passed reports whether every predicate is satisfied.

type RetryReplacementInput

type RetryReplacementInput struct {
	ReplacementID int64
}

type ReturnCommitRequestInput

type ReturnCommitRequestInput struct {
	RequestID string
	TaskID    int64
	// Refused counts a provider refusal; false means the send never left
	// this process.
	Refused     bool
	SubmitError string
	RetryAt     time.Time
	Now         time.Time
}

ReturnCommitRequestInput sends a submitted request back to ready after the period's only send provably produced no transaction.

type S3AccountRepository

type S3AccountRepository interface {
	Create(ctx context.Context, account *model.S3Account) error
	GetByAccessKey(ctx context.Context, accessKey string) (*model.S3Account, error)
	GetRoot(ctx context.Context) (*model.S3Account, error)
	ListNonRoot(ctx context.Context) ([]model.S3Account, error)
	Update(ctx context.Context, accessKey string, update S3AccountUpdate) error
	Delete(ctx context.Context, accessKey string) error
	LockByAccessKey(ctx context.Context, accessKey string) (*model.S3Account, error)
}

S3AccountRepository defines persistence operations for S3 IAM accounts.

type S3AccountUpdate

type S3AccountUpdate struct {
	SecretKey *string
	Name      *string
	Role      auth.Role
}

S3AccountUpdate holds mutable S3 account fields.

type SealCommitRequestInput

type SealCommitRequestInput struct {
	RequestID string
	TaskID    int64
	// Members are the copies the request was signed for, in position order.
	Members      []SealMember
	ExtraDataHex string
	Now          time.Time
}

SealCommitRequestInput freezes a collecting request into the signed set.

type SealMember

type SealMember struct {
	CopyID    int64
	ContentID int64
	PieceCID  string
}

SealMember is one copy a request was signed for.

type SealRemovalInput added in v0.1.1

type SealRemovalInput struct {
	RequestID string
	TaskID    int64
	MaxPieces int
	Now       time.Time
}

type StorageCleanupRepository

type StorageCleanupRepository interface {
	BindTask(ctx context.Context, contentID, generation, taskID int64) error
	TransferTaskOwner(ctx context.Context, contentID, generation, oldTaskID, newTaskID int64) error
	AuthorizeTask(ctx context.Context, contentID, generation, taskID int64) ([]model.StorageCleanupCopy, error)
	MarkCopyUnsupported(ctx context.Context, id int64, message string) error
	UploadHasObjectReferences(ctx context.Context, contentID int64) (bool, error)
	CleanupHasObjectReferences(ctx context.Context, contentID int64) (bool, error)
	// FinalizeContent deletes a cleaned-up content's current-state rows: its
	// cache record, its copies, and the content row. Ledgers keep theirs.
	FinalizeContent(ctx context.Context, contentID, generation, taskID int64) error
	ReauthorizeFailedCopies(ctx context.Context, contentID, generation, taskID int64) error
}

type StorageCleanupReservation

type StorageCleanupReservation struct {
	ContentID  int64
	Generation int64
	TaskID     *int64
}

type StorageContentProvenance

type StorageContentProvenance struct {
	Upload model.StorageContent
	Copies []model.StorageCopy
	// IngressCopy is the copy that performed the ingress transfer, when one
	// exists. Progress belongs to that transfer rather than to the content.
	IngressCopy *model.StorageCopy
}

type StorageContentRepository

type StorageContentRepository interface {
	GetContentSubject(ctx context.Context, id int64) (*StorageSubject, error)
	GetCopySubject(ctx context.Context, id int64) (*StorageSubject, error)
	GetDataSetSubject(ctx context.Context, id int64) (*StorageSubject, error)
	GetCommitSubject(ctx context.Context, requestID string) (*StorageSubject, error)
	EnsureContent(ctx context.Context, input EnsureContentInput) (*model.StorageContent, error)
	// ListOrphanedContents and DiscardOrphanedContent find and delete content
	// no object version has ever named, left by a write whose version
	// transaction never committed.
	ListOrphanedContents(ctx context.Context, createdBefore time.Time, afterID int64, limit int) ([]OrphanedContent, error)
	DiscardOrphanedContent(ctx context.Context, contentID int64, release func() error) (bool, error)
	GetByID(ctx context.Context, contentID int64) (*model.StorageContent, error)
	GetByIDs(ctx context.Context, contentIDs []int64) (map[int64]model.StorageContent, error)
	GetIngressCopy(ctx context.Context, contentID int64) (*model.StorageCopy, error)
	// ContentPipelineState derives pipeline position from the copy rows.
	ContentPipelineState(ctx context.Context, contentID int64) (model.ObjectState, error)
	BeginIngressStoreProgress(ctx context.Context, input BeginIngressStoreProgressInput) (*model.StorageCopy, error)
	RecordIngressStoreProgress(ctx context.Context, input RecordIngressStoreProgressInput) (*model.StorageCopy, error)
	GetUploadProvenance(ctx context.Context, contentID int64) (*StorageContentProvenance, error)
	ListCopies(ctx context.Context, contentID int64) ([]model.StorageCopy, error)
	CountCurrentGenerationCopySlots(ctx context.Context, contentID int64) (int, error)
	ListReadableCommittedCopies(ctx context.Context, contentID int64) ([]ReadableStorageCopy, error)
	IsPendingReplacementCopy(ctx context.Context, copyID int64) (bool, error)
	HasReadableCommittedCopy(ctx context.Context, contentID int64) (bool, error)
	ListBucketStorageHealthSummaries(ctx context.Context, bucketID int64, staleBefore time.Time, affectedVersionCap int) ([]BucketStorageHealthSummary, error)
	ListBucketStorageHealthAffectedVersions(ctx context.Context, input BucketStorageHealthAffectedVersionsInput) (BucketStorageHealthAffectedVersionPage, error)
	ListDataSetBindings(ctx context.Context, bucketID int64) ([]model.StorageDataSet, error)
	ListReadyBucketProviderIDs(ctx context.Context) ([]string, error)
	ListDataSetSummaries(ctx context.Context, bucketID int64) ([]StorageDataSetSummary, error)
	// PendingUploadPlansForReplica finds replacement waits for the frozen
	// copy policy that includes this slot. The caller wakes them through TaskService.
	PendingUploadPlansForReplica(ctx context.Context, bucketID int64, copyIndex int) ([]int64, error)
	GetDataSetBindingByID(ctx context.Context, id int64) (*model.StorageDataSet, error)
	GetDataSetBindingByCopyIndex(ctx context.Context, bucketID int64, copyIndex int) (*model.StorageDataSet, error)
	EnsureDataSetBinding(ctx context.Context, input EnsureDataSetBindingInput) (*model.StorageDataSet, error)
	ProviderDataSetLoads(context.Context, []types.OnChainID) (map[string]int, error)
	MarkDataSetCreating(ctx context.Context, input MarkDataSetCreatingInput) error
	RecordDataSetCreationError(ctx context.Context, id, taskID int64, message string) error
	// RecordDataSetClientID ties a generation to the client data set ID of its
	// create request before sending, under the expected ensure fence. The ID
	// never changes later.
	RecordDataSetClientID(ctx context.Context, id, ensureTaskID int64, clientDataSetID types.OnChainID) error
	MarkDataSetReady(ctx context.Context, input MarkDataSetReadyInput) error
	BackfillClientDataSetID(ctx context.Context, input BackfillClientDataSetIDInput) error
	MarkDataSetDraining(ctx context.Context, id int64, lastError string) error
	LockForCopyCreation(ctx context.Context, contentID int64) (*model.StorageContent, error)
	CreateUploadCopiesForBindings(ctx context.Context, contentID int64, copies []UploadCopyBindingInput) error
	GetUploadCopy(ctx context.Context, contentID int64, copyIndex int) (*model.StorageCopy, error)
	GetUploadCopyByID(ctx context.Context, id int64) (*model.StorageCopy, error)
	GetLiveVersionForUpload(ctx context.Context, contentID int64) (*model.ObjectVersion, error)
	ListIncompleteCopiesForDataSet(ctx context.Context, storageDataSetID int64) ([]model.StorageCopy, error)
	ListInFlightCopiesForDataSet(ctx context.Context, storageDataSetID int64) ([]model.StorageCopy, error)
	BindDataSetEnsureTask(ctx context.Context, dataSetID, taskID int64) error
	TransferEnsureTaskOwner(ctx context.Context, dataSetID, generation, oldTaskID, newTaskID int64) error
	// DataSetCreationStopped includes local sources whose replacement revoked
	// creation even though they still own the slot.
	DataSetCreationStopped(ctx context.Context, id int64) (bool, error)
	AuthorizeDataSetEnsureTask(ctx context.Context, dataSetID, taskID int64) (*model.StorageDataSet, error)
	CompleteDataSetEnsureTask(ctx context.Context, dataSetID, taskID int64) error
	NextCopyWorkGeneration(ctx context.Context, copyID int64) (int64, error)
	BindCopyTask(ctx context.Context, copyID, generation, taskID int64) error
	TransferCopyTaskOwner(ctx context.Context, copyID, generation, oldTaskID, newTaskID int64) error
	AuthorizeCopyTask(ctx context.Context, copyID, generation, taskID, claimGeneration int64) (*model.StorageCopy, error)
	ReservePullRequest(ctx context.Context, input ReservePullRequestInput) error
	GetPullAttempt(ctx context.Context, attemptID string, contentID, storageDataSetID int64) (*storagepull.Attempt, error)
	GetUnresolvedPullAttempt(ctx context.Context, contentID, storageDataSetID int64) (*storagepull.Attempt, error)
	CopyRetryStates(ctx context.Context, copyIDs []int64) (map[int64]CopyRetryState, error)
	RetryFailedCopy(ctx context.Context, copyID int64) (*model.StorageCopy, error)
	ResumeFailedStoreCopy(ctx context.Context, input ResumeFailedStoreCopyInput) error
	GetLastAbandonedPullAttempt(ctx context.Context, contentID, storageDataSetID int64) (*storagepull.Attempt, error)
	SetCopyCacheRestore(ctx context.Context, copyID, generation, taskID int64, pullAttemptID, lastError string) error
	AbandonMigrationPull(ctx context.Context, copyID, generation, taskID int64, pullAttemptID string) error
	PromotePendingIngress(ctx context.Context, contentID int64) (*model.StorageCopy, error)
	ReopenFailedIngressForPull(ctx context.Context, contentID int64) ([]model.StorageCopy, error)
	ReplaceCopyTask(ctx context.Context, copyID, generation, taskID, nextGeneration, nextTaskID int64) error
	CompleteCopyTask(ctx context.Context, copyID, generation, taskID int64) error
	NextDataSetRetirementGeneration(ctx context.Context, dataSetID int64) (int64, error)
	BindDataSetRetirementTask(ctx context.Context, dataSetID, generation, taskID int64) error
	TransferRetireTaskOwner(ctx context.Context, dataSetID, generation, oldTaskID, newTaskID int64) error
	AuthorizeDataSetRetirementTask(ctx context.Context, dataSetID, generation, taskID int64) (*model.StorageDataSet, error)
	CompleteDataSetRetirementTask(ctx context.Context, dataSetID, generation, taskID int64) error
	// GetUploadCopyForDataSet addresses one concrete data set generation.
	GetUploadCopyForDataSet(ctx context.Context, contentID, storageDataSetID int64) (*model.StorageCopy, error)
	NextFinalizableCopyForDataSet(ctx context.Context, storageDataSetID int64) (*model.StorageCopy, error)
	MarkUploadCopyPieceReady(ctx context.Context, input MarkUploadCopyPieceReadyInput) error
	ReopenFailedUploadCopy(ctx context.Context, copyID int64) error
	// Commit requests. Every mutation names the request's task; see
	// storage_commit_repo.go for the lifecycle.
	JoinCollectingCommitRequest(ctx context.Context, input JoinCommitRequestInput) (string, int, error)
	CreateCollectingCommitRequest(ctx context.Context, input CreateCommitRequestInput) error
	GetCommitRequest(ctx context.Context, requestID string) (*storagecommit.Request, error)
	TransferCommitTaskOwner(ctx context.Context, requestID string, oldTaskID, newTaskID int64) error
	ListCommitRequestPieces(ctx context.Context, requestID string) ([]storagecommit.RequestPiece, error)
	ListCommitRequestMembers(ctx context.Context, requestID string) ([]CommitRequestMember, error)
	CommitQueueState(ctx context.Context, storageDataSetID int64, now time.Time) (CommitQueueState, error)
	SealCommitRequest(ctx context.Context, input SealCommitRequestInput) ([]int64, error)
	BeginCommitSubmission(ctx context.Context, input BeginCommitSubmissionInput) error
	RecordCommitResend(ctx context.Context, input CommitSendInput) error
	RecordCommitSubmission(ctx context.Context, input CommitSubmissionInput) error
	RecordCommitSubmitFailure(ctx context.Context, input CommitSubmitFailureInput) error
	ReturnCommitRequestToReady(ctx context.Context, input ReturnCommitRequestInput) error
	DropCommitEvidence(ctx context.Context, requestID string, taskID int64, lastError string, now time.Time) error
	MarkCommitRequestAttention(ctx context.Context, requestID string, taskID int64, code storagecommit.AttentionCode, now time.Time) error
	ConfirmCommitRequest(ctx context.Context, input ConfirmCommitRequestInput) ([]model.StorageCopy, error)
	AbandonCommitRequest(ctx context.Context, input AbandonCommitRequestInput) ([]model.StorageCopy, error)
	ReturnCommitMembersToTransfer(ctx context.Context, requestID string, taskID int64, copyIDs []int64, now time.Time) error
	WakeCommitRequestTask(ctx context.Context, requestID string) error
	WakeCollectingCommitTask(ctx context.Context, requestID string) error
	HasCacheDependentCommitMembers(ctx context.Context, requestID string) (bool, error)
	WakeCacheDependentCommitTasks(ctx context.Context) error
	RequestCommitSeal(ctx context.Context, requestID string) (*storagecommit.Request, error)
	ListCommitBatches(ctx context.Context, filter CommitBatchFilter) ([]CommitBatch, error)
	GetCommitBatch(ctx context.Context, requestID string) (*CommitBatch, error)
	ListCommitBatchMembers(ctx context.Context, requestID string) ([]CommitBatchMember, error)
	ReleaseMemberTransfer(ctx context.Context, input ReleaseMemberTransferInput) error
	// CountCommitBacklog counts the copies transferred to a data set that wait
	// for a request that has not been sent.
	CountCommitBacklog(ctx context.Context, storageDataSetID int64) (int, error)
	ListCommitAttention(ctx context.Context, limit int) ([]storagecommit.AttentionRecord, error)
	ListCommitAttentionForTasks(ctx context.Context, taskIDs []int64) ([]storagecommit.AttentionRecord, error)
	CountStoppedCommitAttentionByDataSet(ctx context.Context) (map[int64]int64, error)
	MarkUploadCopyFailed(ctx context.Context, input MarkUploadCopyFailedInput) error
	BindReadableUploadForContent(ctx context.Context, input BindReadableUploadInput) ([]ObjectVersionRef, error)
	BindReadableUploadForVersion(ctx context.Context, input BindReadableUploadForVersionInput) ([]ObjectVersionRef, error)
	FinalizeUploadIfTargetCopiesMet(ctx context.Context, input FinalizeUploadInput) (bool, []ObjectVersionRef, error)
}

type StorageDataSetSummary

type StorageDataSetSummary struct {
	ID                            int64                      `bun:"id"`
	BucketID                      int64                      `bun:"bucket_id"`
	BucketName                    string                     `bun:"bucket_name"`
	CopyIndex                     int                        `bun:"copy_index"`
	Generation                    int64                      `bun:"generation"`
	IsCurrent                     bool                       `bun:"is_current"`
	ReplacementHasLateServiceRisk bool                       `bun:"replacement_has_late_service_risk"`
	ProviderID                    types.OnChainID            `bun:"provider_id"`
	DataSetID                     *types.OnChainID           `bun:"data_set_id"`
	ClientDataSetID               *types.OnChainID           `bun:"client_data_set_id"`
	TxHash                        *string                    `bun:"tx_hash"`
	ConfirmedTxHash               *string                    `bun:"confirmed_tx_hash"`
	Status                        model.StorageDataSetStatus `bun:"status"`
	CreatedByContentID            *int64                     `bun:"created_by_content_id"`
	CommittedCopies               int64                      `bun:"committed_copies"`
	ReadableCopies                int64                      `bun:"readable_copies"`
	PhysicalBytes                 int64                      `bun:"physical_bytes"`
	ReferencedVersions            int64                      `bun:"referenced_versions"`
	CurrentVersions               int64                      `bun:"current_versions"`
	CreatedAt                     time.Time                  `bun:"created_at"`
	UpdatedAt                     time.Time                  `bun:"updated_at"`
}

type StorageRemovalRepository added in v0.1.1

type StorageRemovalRepository interface {
	GetRemovalRequest(context.Context, string) (*storageremoval.Request, error)
	ListRemovalMembers(context.Context, string) ([]model.StorageCleanupCopy, error)
	ListRemovalSends(context.Context, string) ([]storageremoval.Send, error)
	ListRemovalBatchesForTasks(context.Context, []int64) ([]storageremoval.TaskBatch, error)
	JoinOrCreateCollecting(context.Context, JoinRemovalInput) (*storageremoval.Request, error)
	SealRemovalRequest(context.Context, SealRemovalInput) error
	DetachMembers(context.Context, RemovalMembersInput) error
	MarkMembersRemoved(context.Context, RemovalMembersInput) error
	MarkMemberFailed(context.Context, RemovalMembersInput) error
	AdmitRemovalSend(context.Context, AdmitRemovalSendInput) error
	RecordSendSubmission(context.Context, RemovalSendEvidenceInput) error
	RecordSendRefused(context.Context, RemovalSendEvidenceInput) error
	RecordSendUnsent(context.Context, RemovalSendEvidenceInput) error
	RecordSendReceipt(context.Context, RemovalSendEvidenceInput) error
	MarkRemovalReverted(context.Context, RemovalRequestInput) error
	MarkRemovalQueued(context.Context, RemovalQueuedInput) error
	MarkQueuedWithoutSend(context.Context, RemovalQueuedInput) error
	SettleRemovalRequest(context.Context, RemovalRequestInput) error
	AbandonRemovalRequest(context.Context, RemovalRequestInput) error
	SetRemovalAttention(context.Context, RemovalAttentionInput) error
	ClearRemovalAttention(context.Context, RemovalRequestInput) error
	TransferRemovalTaskOwner(context.Context, string, int64, int64) error
	AdoptLegacyCleanupCopy(context.Context, AdoptLegacyCleanupCopyInput) (*storageremoval.Request, error)
}

type StorageReplacementRepository

type StorageReplacementRepository interface {
	// SourceEligibility shares local admission with presentation and authorization;
	// its boolean distinguishes a source without a ready remote service.
	SourceEligibility(ctx context.Context, dataSetID int64) (*model.StorageDataSet, bool, error)
	// Preflight snapshots the source and unresolved targets for authorization.
	Preflight(ctx context.Context, dataSetID int64) (*ReplacementPreflight, error)
	// RetryEligibility is read-only; Retry rechecks the same target admission.
	RetryEligibility(ctx context.Context, replacementID int64) error
	GetReplacementSubject(ctx context.Context, id int64) (*ReplacementSubject, error)
	// Authorize records one confirmed replacement, creates the target data set
	// generation, and supersedes eligible stopped predecessors. The caller must
	// enqueue and bind the new and unscheduled predecessor coordinators in the same transaction.
	Authorize(ctx context.Context, input AuthorizeReplacementInput) (*storagereplacement.Replacement, bool, error)
	// Retry resumes failed or cleanup-attention work on the same approved
	// target. Choosing a different provider requires a new authorization.
	Retry(ctx context.Context, input RetryReplacementInput) (*storagereplacement.Replacement, error)
	BindTask(ctx context.Context, replacementID, generation, taskID int64) error
	TransferTaskOwner(ctx context.Context, replacementID, generation, oldTaskID, newTaskID int64) error
	ResumeCoordinatorTask(ctx context.Context, replacementID, generation, oldTaskID, newTaskID int64) error
	PrepareCoordinatorRetry(ctx context.Context, replacementID, generation, taskID int64) (*model.StorageDataSet, error)
	MarkInitializationFailed(ctx context.Context, replacementID, generation, taskID, childID int64, message string) error
	EnsureTaskReplacement(ctx context.Context, taskID int64) (*storagereplacement.Replacement, error)
	AuthorizeTask(ctx context.Context, replacementID, generation, taskID int64) (*storagereplacement.Replacement, error)
	CompleteTask(ctx context.Context, replacementID, generation, taskID int64) error

	GetByID(ctx context.Context, id int64) (*storagereplacement.Replacement, error)
	GetByClientRequestID(ctx context.Context, bucketID int64, clientRequestID string) (*storagereplacement.Replacement, error)
	ListForBucket(ctx context.Context, bucketID int64, limit int) ([]storagereplacement.Replacement, error)
	// ListUnscheduledSuperseded returns predecessors fenced by this confirmation.
	// The caller must enqueue and bind their cleanup coordinators in the same transaction.
	ListUnscheduledSuperseded(ctx context.Context, successorID int64) ([]storagereplacement.Replacement, error)
	GetActiveForDataSet(ctx context.Context, dataSetID int64) (*storagereplacement.Replacement, error)
	// HasInProgressForDataSet reports whether recovery must leave this data set
	// alone. Operator-paused failed or attention work does not count as actively
	// progressing, so a stuck slot can still repair in place; its replacement
	// identity remains reserved until retry, supersession, or completion.
	HasInProgressForDataSet(ctx context.Context, dataSetID int64) (bool, error)
	ListActive(ctx context.Context, afterID int64, limit int) ([]storagereplacement.Replacement, error)

	// Activate makes the ready target current and retires or drains the source
	// under the coordinator's generation and domain fence. The caller protects
	// settlement with its engine claim; row count is independent of bucket history.
	Activate(ctx context.Context, replacementID, generation, taskID int64) error
	SeedMigrationBatch(ctx context.Context, replacementID int64, limit int) (inserted int, done bool, err error)
	LockCoordinatorProgress(ctx context.Context, replacementID, generation, taskID int64) (*storagereplacement.Replacement, error)
	LockCoordinatorTask(ctx context.Context, replacementID, generation, taskID int64) (*storagereplacement.Replacement, error)
	ListPendingReplacementItemsAfter(ctx context.Context, replacementID, afterID int64, limit int) ([]storagereplacement.Item, error)
	AcquireItemsForCoordinator(ctx context.Context, replacementID, generation, taskID, afterID int64, limit int) (ReplacementItemBatch, error)
	NextPendingReplacementItem(ctx context.Context, replacementID int64) (*storagereplacement.Item, error)
	MarkReplacementItemCopied(ctx context.Context, replacementID, itemID, targetCopyID int64) error
	MarkReplacementItemCancelled(ctx context.Context, replacementID, itemID int64) error
	MarkReplacementItemAttention(ctx context.Context, replacementID, itemID int64, lastError string) error
	ReplacementExecution(ctx context.Context, replacementID int64) (storagereplacement.ExecutionSnapshot, error)
	ReplacementProgresses(ctx context.Context, replacementIDs []int64) (map[int64]storagereplacement.ProgressSnapshot, error)
	AcquireItem(ctx context.Context, input AcquireReplacementItemInput) (*ReplacementItemSnapshot, error)
	InspectItem(ctx context.Context, input AcquireReplacementItemInput) (*ReplacementItemSnapshot, error)
	AttachTargetCopy(ctx context.Context, input AttachReplacementTargetCopyInput) (*model.StorageCopy, error)

	MarkMigrating(ctx context.Context, replacementID int64) error
	MarkWaiting(ctx context.Context, replacementID int64, reason storagereplacement.WaitReason) error
	// MarkFailed revalidates durable target refusal under the same lock as ready
	// binding; a stale refusal returns ErrConflict and must be reevaluated.
	MarkFailed(ctx context.Context, replacementID int64, reason *storagereplacement.FailureReason, lastError string) error
	MarkCleanupAttention(ctx context.Context, replacementID int64, lastError string) error
	FailForEngineTask(ctx context.Context, taskID int64, lastError string) error
	BeginRetirement(ctx context.Context, replacementID int64) error
	BeginTerminationAttempt(ctx context.Context, input BeginTerminationAttemptInput) error
	RecordTerminationEvidence(ctx context.Context, input RecordTerminationEvidenceInput) error
	RecordTerminationUnsent(ctx context.Context, input RecordTerminationEvidenceInput) error
	ListTerminationAttempts(ctx context.Context, replacementIDs []int64) ([]storagereplacement.TerminationAttempt, error)
	CompleteAbandonedTargetTermination(ctx context.Context, replacementID int64) error
	// EvaluateRetirementGate reports every blocker by name so the API and UI can
	// explain why a source is still held.
	EvaluateRetirementGate(ctx context.Context, replacementID int64, observedEpoch *int64) (RetirementGate, error)
	// CompleteRetirement re-runs the whole gate inside its own transaction and
	// refuses premature completion even when called outside the worker.
	CompleteRetirement(ctx context.Context, replacementID, observedEpoch int64) error
	// AbandonUncreatedCopiesBatch transfers live, frozen slot obligations only
	// after activation and under the coordinator fence. The caller must protect
	// the transaction with its current engine claim.
	AbandonUncreatedCopiesBatch(ctx context.Context, replacementID, generation, taskID int64, limit int) (bool, error)
	// HandOverSourceWritesBatch moves unsigned writes still bound to an
	// activated remote source to the target under the coordinator fence and
	// returns target copies for scheduling. The caller must protect the
	// transaction with its current engine claim.
	HandOverSourceWritesBatch(ctx context.Context, replacementID, generation, taskID int64, limit int) ([]model.StorageCopy, bool, error)
	HasUnsignedSourceWrites(ctx context.Context, sourceDataSetID int64) (bool, error)
	// CompleteWithoutRemoteSource rechecks readable coverage and settled old
	// work under the coordinator fence; the caller protects its engine claim.
	// No remote termination evidence is required.
	CompleteWithoutRemoteSource(ctx context.Context, replacementID, generation, taskID int64) error

	// CountAbandonedTargetSoleCopies counts the copies that only the target a
	// later confirmation replaced still holds. CompleteAbandonedTargetTermination
	// refuses to retire that target while any remain.
	CountAbandonedTargetSoleCopies(ctx context.Context, targetDataSetID int64) (int, error)
}

StorageReplacementRepository owns operator-approved provider replacement: its state machine, the bounded migration cursor, and the retirement safety gate. Every state change is a compare-and-set so a superseded or stale caller is refused rather than silently applied.

type StorageSubject

type StorageSubject struct {
	BucketID       int64
	ContentID      int64
	Size           *int64
	CopyIndex      *int
	LocalDataSetID *int64
	DataSetID      *types.OnChainID
	ProviderID     *types.OnChainID
	ContentCount   *int64
}

StorageSubject contains the identity fields needed to describe storage work.

type TaskAcknowledgeFilter

type TaskAcknowledgeFilter struct {
	Type         model.TaskType
	FailedBefore time.Time
}

TaskAcknowledgeFilter selects the failures one bulk confirmation covers. The cutoff is what the operator saw: failures recorded after it stay visible.

type TaskClaimFilter

type TaskClaimFilter struct {
	ExcludedTypes   []string
	ExcludedTaskIDs []int64
}

TaskClaimFilter excludes tasks that cannot be admitted by the local engine.

type TaskListFilter

type TaskListFilter struct {
	Scope        TaskScope
	Type         model.TaskType
	Status       model.TaskStatus
	Acknowledged *bool
	BeforeID     int64
	Limit        int
}

type TaskObservationPatch

type TaskObservationPatch struct {
	State *model.TaskObservation
}

TaskObservationPatch changes only the observation state. A nil State clears it.

type TaskPage

type TaskPage struct {
	Tasks        []model.Task
	NextBeforeID int64
}

type TaskPipelineCount

type TaskPipelineCount struct {
	Pipeline string `bun:"pipeline"`
	Status   string `bun:"status"`
	Count    int64  `bun:"count"`
}

type TaskRepository

type TaskRepository interface {
	Enqueue(ctx context.Context, task *model.Task) (*model.Task, bool, error)
	GetByID(ctx context.Context, id int64) (*model.Task, error)
	GetForUpdate(ctx context.Context, id int64) (*model.Task, error)
	GetDirectSuccessor(ctx context.Context, id int64) (*model.Task, error)
	SupersedeTerminal(ctx context.Context, id int64) error
	LatestForSubject(ctx context.Context, subjectType, subjectKey string, types ...model.TaskType) (*model.Task, error)
	LatestForSubjects(ctx context.Context, subjectType string, subjectKeys []string, types ...model.TaskType) (map[string]model.Task, error)
	ListCurrentFailedForSubject(ctx context.Context, subjectType, subjectKey string, beforeID int64, limit int, types ...model.TaskType) (TaskPage, error)
	ListHistory(ctx context.Context, anchorID, beforeID int64, limit int) (TaskPage, error)
	AppendEvent(ctx context.Context, taskID int64, eventType string, details json.RawMessage) error
	ListEvents(ctx context.Context, taskID, beforeID int64, limit int) ([]model.TaskEvent, error)
	ObserveOperation(ctx context.Context, id, generation int64, key string) (time.Time, error)
	AdmitEffect(ctx context.Context, id, generation int64, key string, checkpoint json.RawMessage) error
	ResolveOperation(ctx context.Context, id, generation int64, key string) error
	GetByIdentity(ctx context.Context, taskType model.TaskType, subjectType, subjectKey string, generation int64) (*model.Task, error)
	PreviousStoreCheckpoints(ctx context.Context, copyID, taskID int64) ([]model.Task, error)
	ClaimNext(ctx context.Context, leaseDuration time.Duration, filter TaskClaimFilter) (*model.Task, error)
	RenewLease(ctx context.Context, id, generation int64, leaseDuration time.Duration) (time.Time, error)
	WriteCheckpoint(ctx context.Context, id, generation int64, checkpoint json.RawMessage) error
	ValidateClaim(ctx context.Context, id, generation int64) error
	MarkWorkStarted(ctx context.Context, id, generation int64, startedAt time.Time) error
	Settle(ctx context.Context, id, generation int64, transition TaskTransition) error
	ShortenLease(ctx context.Context, id, generation int64, duration time.Duration) error
	WakePending(ctx context.Context, ids []int64) (int, error)
	WakePendingOfTypes(ctx context.Context, ids []int64, types []model.TaskType, skipWaitReasons []string) (int, error)
	AcknowledgeFailed(ctx context.Context, id int64) error
	AcknowledgeFailedForSubject(ctx context.Context, subjectType, subjectKey string) (int, error)
	// AcknowledgeFailedMatching acknowledges every unacknowledged failure the filter
	// covers and reports how many it acknowledged.
	AcknowledgeFailedMatching(ctx context.Context, filter TaskAcknowledgeFilter) (int, error)
	// CountFailedMatching reports how many failures the same filter covers, so a
	// bulk confirmation can be previewed before it is confirmed.
	CountFailedMatching(ctx context.Context, filter TaskAcknowledgeFilter) (int, error)
	List(ctx context.Context, filter TaskListFilter) (TaskPage, error)
	CountByScope(ctx context.Context, scope TaskScope) ([]TaskStatusCount, error)
	CountUnacknowledgedFailed(ctx context.Context) (int64, error)
	CountOverviewActivePipeline(ctx context.Context) ([]TaskPipelineCount, error)
}

TaskRepository defines persistence operations for Task entities.

type TaskScheduleRepository

type TaskScheduleRepository interface {
	Ensure(ctx context.Context, key string, nextRunAt time.Time) error
	GetForUpdate(ctx context.Context, key string) (*model.TaskSchedule, error)
	GetByTaskID(ctx context.Context, taskID int64) (*model.TaskSchedule, error)
	ListDue(ctx context.Context, now time.Time) ([]model.TaskSchedule, error)
	SetHead(ctx context.Context, key string, expectedGeneration, generation int64, expectedTaskID, taskID *int64, nextRunAt time.Time) error
	ScheduleNext(ctx context.Context, key string, taskID int64, nextRunAt time.Time) error
}

type TaskScope

type TaskScope string
const (
	TaskScopeWork    TaskScope = "work"
	TaskScopeHistory TaskScope = "history"
)

func (TaskScope) Valid

func (s TaskScope) Valid() bool

type TaskStatusCount

type TaskStatusCount struct {
	Type   string `bun:"type"`
	Status string `bun:"status"`
	Count  int64  `bun:"count"`
}

TaskStatusCount holds a task count grouped by type and status.

type TaskTransition

type TaskTransition struct {
	Observation        *TaskObservationPatch
	WorkStartedAt      *time.Time
	ClearWorkStartedAt bool
	Status             model.TaskStatus
	ResumeMode         model.TaskResumeMode
	AvailableAt        time.Time
	WaitReason         *string
	FailureReason      *string
	LastError          *string
	StatusMessage      *string
	IncrementRetry     bool
}

type UpdateBucketCopyPolicyInput

type UpdateBucketCopyPolicyInput struct {
	Name                    string
	SetDefaultCopies        bool
	DefaultCopies           *int
	SetMinimumDurableCopies bool
	MinimumDurableCopies    *int
}

UpdateBucketCopyPolicyInput distinguishes omitted fields from explicit nulls.

type UploadCopyBindingInput

type UploadCopyBindingInput struct {
	StorageDataSetID int64
	CopyIndex        int
	TransferMethod   model.StorageCopyTransferMethod
	ProviderID       types.OnChainID
}

type WalletOperationRepository

type WalletOperationRepository interface {
	GetOperationSubject(ctx context.Context, id int64) (*model.WalletOperation, error)
	CreateOrGet(ctx context.Context, input CreateWalletOperationInput) (*model.WalletOperation, bool, error)
	GetByID(ctx context.Context, id int64) (*model.WalletOperation, error)
	BindTask(ctx context.Context, id, taskID int64) error
	TransferTaskOwner(ctx context.Context, id, oldTaskID, newTaskID int64) error
	ReopenUnsentForRetry(ctx context.Context, id, oldTaskID, newTaskID int64) error
	MarkBroadcastAttempted(ctx context.Context, id, taskID int64) error
	MarkSubmitted(ctx context.Context, id, taskID int64, txHash string) error
	RecordSubmission(ctx context.Context, id, taskID int64, txHash string, signedTransaction []byte, lastError string) error
	RecordConfirmationError(ctx context.Context, id, taskID int64, lastError string) error
	MarkConfirmed(ctx context.Context, id, taskID int64, txHash string) error
	MarkConfirmedWithoutTransaction(ctx context.Context, id, taskID int64) error
	MarkFailed(ctx context.Context, id, taskID int64, lastError string) error
	MarkUnknown(ctx context.Context, id, taskID int64, lastError string) error
	MarkSubmissionUnknown(ctx context.Context, id, taskID int64, lastError string) error
	ListRecent(ctx context.Context, limit int) ([]model.WalletOperation, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL