catalog

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package catalog models an incrementally materialized hierarchy of share nodes.

Catalog metadata deliberately excludes sender-private source locators and file version candidates. A CatalogStore keeps those values beside public entries so callers cannot accidentally serialize filesystem authority into a receiver-facing page.

Index

Constants

View Source
const (
	DefaultSessionActiveScans = 4
	DefaultShareActiveScans   = 16
	DefaultProcessActiveScans = 64

	DefaultSessionScanWork = 1_048_576
	DefaultShareScanWork   = 4_194_304
	DefaultProcessScanWork = 16_777_216

	DefaultShareCommittedEntries   = 4_194_304
	DefaultProcessCommittedEntries = 16_777_216

	DefaultSessionCatalogMemory = uint64(16) << 20
	DefaultShareCatalogMemory   = uint64(64) << 20
	DefaultProcessCatalogMemory = uint64(512) << 20

	DefaultShareCatalogSpill   = uint64(2) << 30
	DefaultProcessCatalogSpill = uint64(16) << 30
)
View Source
const (
	MinChunkSize     = 1 << 10
	DefaultChunkSize = 1 << 20
	MaxChunkSize     = 4 << 20
	MaxSafeInteger   = 1<<53 - 1
	MaxFileSize      = MaxSafeInteger
)
View Source
const (
	WireVersionV2            = 2
	SuiteV2                  = 2
	SenderPublicKeySize      = 32
	MaxDescriptorObjectBytes = 16 << 10
)
View Source
const (
	MaxSourceIdentityBytes   = 4 << 10
	MaxVersionCandidateBytes = 4 << 10
)
View Source
const (
	MaxSelectedRoots          = 4_096
	MaxSelectedRootNamesBytes = 1 << 20
)
View Source
const (
	// This is a metadata budget, not a filesystem component limit. It leaves
	// room for UTF-16 native names and NFC expansion without unbounded records.
	MaxNameBytes = 4 << 10
	MaxPathBytes = 32 * 1024
	MaxPathDepth = 256
)
View Source
const (
	MinScanRetryCooldown     = 250 * time.Millisecond
	DefaultScanRetryCooldown = time.Second
	MaxScanRetryCooldown     = 30 * time.Second
)
View Source
const (
	MaxCatalogPageEntries  = 256
	MaxCatalogPayloadBytes = 60 << 10
	MaxDirectoryEntries    = 1_048_576
	PageCommitmentBytes    = 32
	// These charges deliberately exceed the current Go struct headers so a
	// receiver budget bounds decoded catalog state, not merely compact wire bytes.
	CatalogPageMemoryOverhead       = 192
	CatalogEntryMemoryOverhead      = 128
	CatalogNameMemoryOverhead       = 16
	DirectorySnapshotMemoryOverhead = 128
)
View Source
const CatalogNodeMemoryOverhead = uint64(256)
View Source
const (
	DefaultSortRunMemoryBytes = uint64(1) << 20
)
View Source
const IdentityBytes = 16
View Source
const (
	// MaxSourceOmissionSamples bounds local feedback without traversing omitted subtrees.
	MaxSourceOmissionSamples = 16
)
View Source
const MaxSourceReferenceBytes = 64 << 10
View Source
const PagePayloadSchema = 1
View Source
const PathPolicy = "windshare/path/v3-unicode-" + unicode15.Version
View Source
const ScanAttemptLedgerBytes = 96

ScanAttemptLedgerBytes conservatively accounts for both attempt and generation replay guards retained for the share lifetime.

View Source
const ScanProgressEntryInterval = uint64(MaxCatalogPageEntries)

ScanProgressEntryInterval matches one maximum catalog page. The first child is reported immediately; later milestones are coalesced so a slow receiver cannot turn waiting feedback into scan-wide backpressure.

Variables

View Source
var (
	ErrCatalogClosed      = errors.New("catalog store is closed")
	ErrGenerationConflict = errors.New("catalog directory generation conflicts with committed state")
)
View Source
var (
	ErrInvalidPagePayload      = errors.New("invalid catalog page payload")
	ErrNonCanonicalPagePayload = errors.New("non-canonical catalog page payload")
)
View Source
var (
	ErrInvalidName = errors.New("invalid catalog name")
	ErrInvalidPath = errors.New("invalid catalog path")
	ErrPathTooDeep = errors.New("catalog path exceeds maximum depth")
)
View Source
var (
	ErrPageLimit        = errors.New("catalog page exceeds its entry limit")
	ErrPageSequence     = errors.New("catalog page sequence is invalid")
	ErrSiblingCollision = errors.New("catalog siblings collide under portable name matching")
)
View Source
var (
	ErrCommittedRootUnavailable = errors.New("catalog committed-root capability is unavailable")
	ErrCommittedRootMismatch    = errors.New("catalog committed-root capability does not match the descriptor")
)
View Source
var ErrBudgetExceeded = errors.New("catalog resource budget exceeded")
View Source
var ErrCorruptCatalogStorage = errors.New("catalog durable storage is corrupt")
View Source
var ErrDirectoryStale = errors.New("catalog directory identity became stale")
View Source
var ErrIdentityLength = errors.New("catalog identity must be exactly 16 bytes")
View Source
var ErrScanSinkClosed = errors.New("catalog scan child sink is closed")

Functions

func CanonicalName

func CanonicalName(name string) (string, error)

CanonicalName normalizes Unicode before validation so equality and ordering are stable across filesystems that expose different normalization forms. Destination naming restrictions belong to materialization; rejecting a readable source name here would also prevent lossless archives and compatible-name repair.

func CanonicalPath

func CanonicalPath(path string) (string, error)

func NewCatalogPage

func NewCatalogPage(spec CatalogPageSpec) (CatalogPage, PagePayload, error)

func NewPermanentScanError

func NewPermanentScanError(cause error) error

func NewTransientScanError

func NewTransientScanError(cause error, cooldown time.Duration) error

func SiblingNameKey

func SiblingNameKey(name string) string

SiblingNameKey returns the key under which sibling names collide: two names cannot coexist in one directory listing when their keys are equal, because receivers may compare them case- or form-insensitively. Computing it once per name lets callers detect collisions with a map instead of pairwise folds.

func ValidChunkSize

func ValidChunkSize(size uint32) bool

ValidChunkSize reports whether size is a suite-02 block size: a power of two from MinChunkSize to MaxChunkSize inclusive.

Types

type BackendPreparation

type BackendPreparation struct {
	Directory CommittedDirectory
	Usage     ResourceUsage
	Existing  bool
}

type BackendTransaction

type BackendTransaction interface {
	PutDirectory(NodeRecord) error
	PutChild(NodeRecord) error
	PutPage(CatalogPage, PagePayload) error
	Prepare(context.Context) (BackendPreparation, error)
	Publish(context.Context) (CommittedDirectory, error)
	Abort() error
}

type BudgetAccount

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

func NewBudgetAccount

func NewBudgetAccount(name string, limits BudgetLimits) (*BudgetAccount, error)

func (*BudgetAccount) Name

func (a *BudgetAccount) Name() string

func (*BudgetAccount) Snapshot

func (a *BudgetAccount) Snapshot() BudgetSnapshot

type BudgetHierarchy

type BudgetHierarchy struct {
	Process *BudgetAccount
	Share   *BudgetAccount
	Session *BudgetAccount
}

type BudgetLimits

type BudgetLimits ResourceUsage

func DefaultProcessBudgetLimits

func DefaultProcessBudgetLimits() BudgetLimits

func DefaultSessionBudgetLimits

func DefaultSessionBudgetLimits() BudgetLimits

func DefaultShareBudgetLimits

func DefaultShareBudgetLimits() BudgetLimits

type BudgetReservation

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

func ReserveHierarchy

func ReserveHierarchy(hierarchy BudgetHierarchy, usage ResourceUsage) (*BudgetReservation, error)

func (*BudgetReservation) Grow

func (r *BudgetReservation) Grow(usage ResourceUsage) error

Grow adds a cumulative charge to one logical reservation. Scan work is commonly metered one entry at a time; aggregating it here avoids allocating a reservation object per directory entry outside the memory budget it enforces.

func (*BudgetReservation) Release

func (r *BudgetReservation) Release()

func (*BudgetReservation) Shrink

func (r *BudgetReservation) Shrink(usage ResourceUsage) error

Shrink releases a known subset while keeping the logical reservation live. External merge passes use it when an input run is deleted, so the spill budget measures peak bytes on disk instead of cumulative I/O.

type BudgetSnapshot

type BudgetSnapshot struct {
	Name   string
	Limits BudgetLimits
	Used   ResourceUsage
}

type Capability

type Capability uint64
const (
	CapabilityCatalog Capability = 1 << iota
	CapabilityRanges
	CapabilityAuthenticatedModifiedTime
	CapabilityShareInstanceRefreshReserved
	CapabilityOfflineObjectReserved
	CapabilityMultiRelayDeliveryReserved
)

type CatalogPage

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

func DecodeCatalogPage added in v0.1.4

func DecodeCatalogPage(encoded []byte) (CatalogPage, error)

DecodeCatalogPage admits a canonical page from authenticated wire bytes.

func (CatalogPage) Address added in v0.1.4

func (p CatalogPage) Address() PageAddress

func (CatalogPage) Commitment

func (p CatalogPage) Commitment() PageCommitment

func (CatalogPage) DirectoryID

func (p CatalogPage) DirectoryID() DirectoryID

func (CatalogPage) Entries

func (p CatalogPage) Entries() []Entry

func (CatalogPage) Entry

func (p CatalogPage) Entry(index uint32) (Entry, bool)

func (CatalogPage) EntryCount

func (p CatalogPage) EntryCount() int

func (CatalogPage) EstimatedMemoryBytes

func (p CatalogPage) EstimatedMemoryBytes() uint64

func (CatalogPage) Generation

func (p CatalogPage) Generation() DirectoryGeneration

func (CatalogPage) OmittedCount

func (p CatalogPage) OmittedCount() uint64

func (CatalogPage) PageIndex

func (p CatalogPage) PageIndex() uint32

func (CatalogPage) Previous

func (p CatalogPage) Previous() PageCommitment

func (CatalogPage) ShareInstance

func (p CatalogPage) ShareInstance() ShareInstance

func (CatalogPage) Terminal

func (p CatalogPage) Terminal() bool

type CatalogPageSpec

type CatalogPageSpec struct {
	ShareInstance ShareInstance
	DirectoryID   DirectoryID
	Generation    DirectoryGeneration
	PageIndex     uint32
	Previous      PageCommitment
	Entries       []Entry
	Terminal      bool
	OmittedCount  uint64
}

type CatalogStore

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

func NewCatalogStore

func NewCatalogStore(config StoreConfig) (result *CatalogStore, resultErr error)

func (*CatalogStore) Close

func (s *CatalogStore) Close() error

func (*CatalogStore) CommitDirectory

func (s *CatalogStore) CommitDirectory(ctx context.Context, commit DirectoryCommit, sessionBudget *BudgetAccount) (CommittedDirectory, error)

func (*CatalogStore) CommitSyntheticRoot

func (s *CatalogStore) CommitSyntheticRoot(ctx context.Context, commit DirectoryCommit, startupBudget *BudgetAccount) (CommittedRoot, error)

func (*CatalogStore) Directory

func (s *CatalogStore) Directory(ctx context.Context, directory DirectoryID) (CommittedDirectory, bool, error)

func (*CatalogStore) FailurePayload added in v0.1.4

func (s *CatalogStore) FailurePayload(
	ctx context.Context,
	directory DirectoryID,
	attempt ScanAttemptID,
) (FailurePayload, bool, error)

func (*CatalogStore) ListChildren

func (s *CatalogStore) ListChildren(ctx context.Context, directory DirectoryID, sessionBudget *BudgetAccount, options ScanOptions, scanner DirectoryScanner) (CommittedDirectory, error)

func (*CatalogStore) Node

func (s *CatalogStore) Node(ctx context.Context, id NodeID) (NodeRecord, bool, error)

func (*CatalogStore) Page

func (s *CatalogStore) Page(ctx context.Context, directory DirectoryID, generation DirectoryGeneration, index uint32) (CatalogPage, bool, error)

func (*CatalogStore) PagePayload added in v0.1.4

func (s *CatalogStore) PagePayload(ctx context.Context, directory DirectoryID, generation DirectoryGeneration, index uint32) (PagePayload, bool, error)

type Clock

type Clock interface {
	Now() time.Time
}

type CommittedDirectory

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

CommittedDirectory is the small, durable identity of one immutable generation. Pages remain backend-addressed so directory width never dictates the amount of live Go memory needed to browse or replay it.

func (CommittedDirectory) DirectoryID

func (d CommittedDirectory) DirectoryID() DirectoryID

func (CommittedDirectory) EntryCount

func (d CommittedDirectory) EntryCount() uint64

func (CommittedDirectory) Equal

func (CommittedDirectory) Generation

func (d CommittedDirectory) Generation() DirectoryGeneration

func (CommittedDirectory) IsZero

func (d CommittedDirectory) IsZero() bool

func (CommittedDirectory) OmittedCount

func (d CommittedDirectory) OmittedCount() uint64

func (CommittedDirectory) PageCount

func (d CommittedDirectory) PageCount() uint32

func (CommittedDirectory) ShareInstance

func (d CommittedDirectory) ShareInstance() ShareInstance

func (CommittedDirectory) TerminalCommitment

func (d CommittedDirectory) TerminalCommitment() PageCommitment

type CommittedRoot

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

CommittedRoot is the local capability proving that the synthetic root, private NodeRecords, and their retained budget were atomically published. It deliberately has no public constructor: startup and registration code cannot manufacture readiness before CatalogStore commits it.

func (CommittedRoot) AuthorizeRegistration

func (root CommittedRoot) AuthorizeRegistration(descriptor ShareDescriptor) error

AuthorizeRegistration must be called by the v2 registration boundary immediately before it emits REGISTER. ShareDescriptor is transport-neutral, so the local commit capability remains separate and cannot be serialized or replayed as if it were sender-authenticated wire data.

func (CommittedRoot) IsZero

func (root CommittedRoot) IsZero() bool

type DescriptorSpec

type DescriptorSpec struct {
	WireVersion      uint32
	Suite            uint32
	ShareInstance    ShareInstance
	SyntheticRoot    DirectoryID
	RootCommit       CommittedRoot
	ChunkSize        uint32
	Capabilities     Capability
	SenderPublicKey  []byte
	CreatedAtSeconds uint64
	PathPolicy       string
}

type DirectoryCommit

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

func NewSyntheticRootCommit

func NewSyntheticRootCommit(spec SyntheticRootCommitSpec) (DirectoryCommit, error)

NewSyntheticRootCommit builds the only catalog generation required before registration. It consumes already-opened selected-root records and therefore cannot accidentally turn share readiness into descendant traversal.

func (DirectoryCommit) Directory

func (c DirectoryCommit) Directory() NodeRecord

func (DirectoryCommit) EntryCount

func (c DirectoryCommit) EntryCount() uint64

func (DirectoryCommit) Generation

func (c DirectoryCommit) Generation() DirectoryGeneration

func (DirectoryCommit) OmittedCount

func (c DirectoryCommit) OmittedCount() uint64

type DirectoryFailure

type DirectoryFailure struct {
	DirectoryID DirectoryID
	AttemptID   ScanAttemptID
	Kind        FailureKind
	Transient   bool
	RetryAfter  time.Duration
	// contains filtered or unexported fields
}

func (*DirectoryFailure) Error

func (e *DirectoryFailure) Error() string

func (*DirectoryFailure) Unwrap

func (e *DirectoryFailure) Unwrap() error

type DirectoryFailureRecord

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

func (DirectoryFailureRecord) AttemptID

func (r DirectoryFailureRecord) AttemptID() ScanAttemptID

func (DirectoryFailureRecord) DirectoryID

func (r DirectoryFailureRecord) DirectoryID() DirectoryID

func (DirectoryFailureRecord) Generation

func (DirectoryFailureRecord) Kind

func (DirectoryFailureRecord) PreviousAttemptID

func (r DirectoryFailureRecord) PreviousAttemptID() ScanAttemptID

func (DirectoryFailureRecord) RetryAfter

func (r DirectoryFailureRecord) RetryAfter() time.Duration

func (DirectoryFailureRecord) Retryable

func (r DirectoryFailureRecord) Retryable() bool

func (DirectoryFailureRecord) ShareInstance

func (r DirectoryFailureRecord) ShareInstance() ShareInstance

type DirectoryGeneration

type DirectoryGeneration [IdentityBytes]byte

func DirectoryGenerationFromBytes

func DirectoryGenerationFromBytes(raw []byte) (DirectoryGeneration, error)

func (DirectoryGeneration) Bytes

func (id DirectoryGeneration) Bytes() []byte

func (DirectoryGeneration) Equal

func (DirectoryGeneration) IsZero

func (id DirectoryGeneration) IsZero() bool

type DirectoryGenerationGenerator

type DirectoryGenerationGenerator interface {
	NewDirectoryGeneration() (DirectoryGeneration, error)
}

type DirectoryGenerationGeneratorFunc

type DirectoryGenerationGeneratorFunc func() (DirectoryGeneration, error)

func (DirectoryGenerationGeneratorFunc) NewDirectoryGeneration

func (f DirectoryGenerationGeneratorFunc) NewDirectoryGeneration() (DirectoryGeneration, error)

type DirectoryGenerationValidator

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

DirectoryGenerationValidator incrementally authenticates the namespace invariants that span page boundaries. Its retained collision state is bounded by MaxDirectoryEntries, so callers do not need to materialize the generation.

func (*DirectoryGenerationValidator) AcceptPage

func (validator *DirectoryGenerationValidator) AcceptPage(page CatalogPage) error

func (*DirectoryGenerationValidator) Finish

func (validator *DirectoryGenerationValidator) Finish() (CommittedDirectory, error)

type DirectoryID

type DirectoryID [IdentityBytes]byte

func DirectoryIDFromBytes

func DirectoryIDFromBytes(raw []byte) (DirectoryID, error)

func (DirectoryID) Bytes

func (id DirectoryID) Bytes() []byte

func (DirectoryID) Equal

func (id DirectoryID) Equal(other DirectoryID) bool

func (DirectoryID) IsZero

func (id DirectoryID) IsZero() bool

func (DirectoryID) NodeID

func (id DirectoryID) NodeID() NodeID

type DirectoryPageCursor

type DirectoryPageCursor interface {
	Next(context.Context) (CatalogPage, bool, error)
	Close() error
}

DirectoryPageCursor owns one forward-only authenticated generation walk. Keeping the cursor contract in catalog lets transports stream pages without forcing consumers to retain a DirectorySnapshot or depend on a wire adapter.

type DirectoryScanner

type DirectoryScanner interface {
	// ScanDirectory must validate the directory identity before enumeration and
	// again before returning nil. Children remain provisional until this method
	// returns, so stale, cancellation, and reparse failures cannot publish pages.
	ScanDirectory(context.Context, ScanRequest) (ScanResult, error)
}

type DirectoryScannerFunc

type DirectoryScannerFunc func(context.Context, ScanRequest) (ScanResult, error)

func (DirectoryScannerFunc) ScanDirectory

func (f DirectoryScannerFunc) ScanDirectory(ctx context.Context, request ScanRequest) (ScanResult, error)

type DirectorySnapshot

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

func NewDirectorySnapshot

func NewDirectorySnapshot(pages []CatalogPage) (DirectorySnapshot, error)

func (DirectorySnapshot) DirectoryID

func (s DirectorySnapshot) DirectoryID() DirectoryID

func (DirectorySnapshot) EntryCount

func (s DirectorySnapshot) EntryCount() uint64

func (DirectorySnapshot) Equal

func (s DirectorySnapshot) Equal(other DirectorySnapshot) bool

func (DirectorySnapshot) EstimatedMemoryBytes

func (s DirectorySnapshot) EstimatedMemoryBytes() uint64

func (DirectorySnapshot) Generation

func (s DirectorySnapshot) Generation() DirectoryGeneration

func (DirectorySnapshot) OmittedCount

func (s DirectorySnapshot) OmittedCount() uint64

func (DirectorySnapshot) Page

func (s DirectorySnapshot) Page(index uint32) (CatalogPage, bool)

func (DirectorySnapshot) PageCount

func (s DirectorySnapshot) PageCount() int

func (DirectorySnapshot) Pages

func (s DirectorySnapshot) Pages() []CatalogPage

func (DirectorySnapshot) ShareInstance

func (s DirectorySnapshot) ShareInstance() ShareInstance

func (DirectorySnapshot) TerminalCommitment

func (s DirectorySnapshot) TerminalCommitment() PageCommitment

type Entry

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

func NewDirectoryEntry

func NewDirectoryEntry(id DirectoryID, name string, modified ModifiedTime) (Entry, error)

func NewFileEntry

func NewFileEntry(id FileID, name string, expectedSize uint64, modified ModifiedTime) (Entry, error)

func (Entry) DirectoryID

func (e Entry) DirectoryID() (DirectoryID, bool)

func (Entry) ExpectedSize

func (e Entry) ExpectedSize() uint64

func (Entry) FileID

func (e Entry) FileID() (FileID, bool)

func (Entry) Kind

func (e Entry) Kind() NodeKind

func (Entry) ModifiedTime

func (e Entry) ModifiedTime() ModifiedTime

func (Entry) Name

func (e Entry) Name() string

func (Entry) NodeID

func (e Entry) NodeID() NodeID

type FailureEncoder added in v0.1.4

type FailureEncoder interface {
	EncodeFailure(DirectoryFailureRecord) (FailurePayload, error)
}

type FailureEncoderFunc added in v0.1.4

type FailureEncoderFunc func(DirectoryFailureRecord) (FailurePayload, error)

func (FailureEncoderFunc) EncodeFailure added in v0.1.4

func (function FailureEncoderFunc) EncodeFailure(record DirectoryFailureRecord) (FailurePayload, error)

type FailureKind

type FailureKind uint8
const (
	FailureKindUnknown FailureKind = iota
	FailureKindStale
	FailureKindPermission
	FailureKindCollision
	FailureKindTooWide
	FailureKindBudget
	FailureKindPermanentIO
	FailureKindTransientIO
)

type FailurePayload added in v0.1.4

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

FailurePayload carries the bytes committed with a directory scan failure. Its digest lets the backend check payload integrity on replay.

func NewFailurePayload added in v0.1.4

func NewFailurePayload(encoded []byte) (FailurePayload, error)

func (FailurePayload) Bytes added in v0.1.4

func (o FailurePayload) Bytes() []byte

func (FailurePayload) IsZero added in v0.1.4

func (o FailurePayload) IsZero() bool

type FailurePreparation

type FailurePreparation struct {
	Record   DirectoryFailureRecord
	Usage    ResourceUsage
	Existing bool
}

type FileBackendFaultPoint

type FileBackendFaultPoint string
const (
	FileFaultStageDirectory      FileBackendFaultPoint = "stage-directory"
	FileFaultStageChild          FileBackendFaultPoint = "stage-child"
	FileFaultStagePage           FileBackendFaultPoint = "stage-page"
	FileFaultStagePageCommitment FileBackendFaultPoint = "stage-page-commitment"
	FileFaultStageNodeIndex      FileBackendFaultPoint = "stage-node-index"
	FileFaultPrepare             FileBackendFaultPoint = "prepare"
	FileFaultPublish             FileBackendFaultPoint = "publish"
	FileFaultStageFailure        FileBackendFaultPoint = "stage-failure"
	FileFaultPublishFailure      FileBackendFaultPoint = "publish-failure"
)

type FileBackendFaults

type FileBackendFaults interface {
	Fail(FileBackendFaultPoint) error
}

type FileCatalogBackend

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

func NewFileCatalogBackend

func NewFileCatalogBackend(config FileCatalogBackendConfig) (*FileCatalogBackend, error)

func (*FileCatalogBackend) BeginDirectory

func (b *FileCatalogBackend) BeginDirectory(ctx context.Context, directory DirectoryID, generation DirectoryGeneration, meter ResourceMeter) (BackendTransaction, error)

func (*FileCatalogBackend) CatalogSpillRoot

func (b *FileCatalogBackend) CatalogSpillRoot() string

CatalogSpillRoot keeps committed pages and their transient sort runs under the same lifecycle-owned storage authority without exposing backend internals.

func (*FileCatalogBackend) Close

func (b *FileCatalogBackend) Close() error

func (*FileCatalogBackend) CommitFailure

func (b *FileCatalogBackend) CommitFailure(
	ctx context.Context,
	record DirectoryFailureRecord,
	payload FailurePayload,
	meter ResourceMeter,
	prepare func(ResourceUsage) error,
) (FailurePreparation, error)

func (*FileCatalogBackend) Destroy

func (b *FileCatalogBackend) Destroy() error

func (*FileCatalogBackend) LoadDirectory

func (b *FileCatalogBackend) LoadDirectory(ctx context.Context, directory DirectoryID) (CommittedDirectory, bool, error)

func (*FileCatalogBackend) LoadFailurePayload added in v0.1.4

func (b *FileCatalogBackend) LoadFailurePayload(
	ctx context.Context,
	directory DirectoryID,
	attempt ScanAttemptID,
) (FailurePayload, bool, error)

func (*FileCatalogBackend) LoadNode

func (b *FileCatalogBackend) LoadNode(ctx context.Context, id NodeID) (NodeRecord, bool, error)

func (*FileCatalogBackend) LoadPagePayload added in v0.1.4

func (b *FileCatalogBackend) LoadPagePayload(ctx context.Context, directory DirectoryID, generation DirectoryGeneration, index uint32) (PagePayload, bool, error)

func (*FileCatalogBackend) Recover

func (*FileCatalogBackend) ReplayFailures

func (b *FileCatalogBackend) ReplayFailures(ctx context.Context, yield func(DirectoryFailureRecord, bool) error) error

type FileCatalogBackendConfig

type FileCatalogBackendConfig struct {
	Root          string
	ShareInstance ShareInstance
	Faults        FileBackendFaults
}

type FileID

type FileID [IdentityBytes]byte

func FileIDFromBytes

func FileIDFromBytes(raw []byte) (FileID, error)

func (FileID) Bytes

func (id FileID) Bytes() []byte

func (FileID) Equal

func (id FileID) Equal(other FileID) bool

func (FileID) IsZero

func (id FileID) IsZero() bool

func (FileID) NodeID

func (id FileID) NodeID() NodeID

type FileSpillFactory

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

func NewFileSpillFactory

func NewFileSpillFactory(root string) *FileSpillFactory

func (*FileSpillFactory) Destroy

func (f *FileSpillFactory) Destroy(share ShareInstance) error

func (*FileSpillFactory) NewWorkspace

func (f *FileSpillFactory) NewWorkspace(ctx context.Context, request SpillRequest) (SpillWorkspace, error)

func (*FileSpillFactory) Recover

func (f *FileSpillFactory) Recover(ctx context.Context, share ShareInstance) error

type MemoryCatalogBackend

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

func NewMemoryCatalogBackend

func NewMemoryCatalogBackend() *MemoryCatalogBackend

func (*MemoryCatalogBackend) BeginDirectory

func (b *MemoryCatalogBackend) BeginDirectory(ctx context.Context, directory DirectoryID, generation DirectoryGeneration, meter ResourceMeter) (BackendTransaction, error)

func (*MemoryCatalogBackend) Close

func (b *MemoryCatalogBackend) Close() error

func (*MemoryCatalogBackend) CommitFailure

func (b *MemoryCatalogBackend) CommitFailure(
	ctx context.Context,
	record DirectoryFailureRecord,
	payload FailurePayload,
	meter ResourceMeter,
	prepare func(ResourceUsage) error,
) (FailurePreparation, error)

func (*MemoryCatalogBackend) LoadDirectory

func (b *MemoryCatalogBackend) LoadDirectory(ctx context.Context, directory DirectoryID) (CommittedDirectory, bool, error)

func (*MemoryCatalogBackend) LoadFailurePayload added in v0.1.4

func (b *MemoryCatalogBackend) LoadFailurePayload(
	ctx context.Context,
	directory DirectoryID,
	attempt ScanAttemptID,
) (FailurePayload, bool, error)

func (*MemoryCatalogBackend) LoadNode

func (b *MemoryCatalogBackend) LoadNode(ctx context.Context, id NodeID) (NodeRecord, bool, error)

func (*MemoryCatalogBackend) LoadPagePayload added in v0.1.4

func (b *MemoryCatalogBackend) LoadPagePayload(ctx context.Context, directory DirectoryID, generation DirectoryGeneration, index uint32) (PagePayload, bool, error)

func (*MemoryCatalogBackend) Recover

func (*MemoryCatalogBackend) ReplayFailures

func (b *MemoryCatalogBackend) ReplayFailures(ctx context.Context, yield func(DirectoryFailureRecord, bool) error) error

type ModifiedTime

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

func NewModifiedTime

func NewModifiedTime(seconds int64, nanoseconds uint32, precision TimePrecision) (ModifiedTime, error)

func (ModifiedTime) Nanoseconds

func (m ModifiedTime) Nanoseconds() uint32

func (ModifiedTime) Precision

func (m ModifiedTime) Precision() TimePrecision

func (ModifiedTime) Present

func (m ModifiedTime) Present() bool

func (ModifiedTime) Seconds

func (m ModifiedTime) Seconds() int64

type NodeID

type NodeID [IdentityBytes]byte

func NodeIDFromBytes

func NodeIDFromBytes(raw []byte) (NodeID, error)

func (NodeID) Bytes

func (id NodeID) Bytes() []byte

func (NodeID) Equal

func (id NodeID) Equal(other NodeID) bool

func (NodeID) IsZero

func (id NodeID) IsZero() bool

type NodeKind

type NodeKind uint8
const (
	NodeKindUnknown NodeKind = iota
	NodeKindDirectory
	NodeKindFile
)

type NodeRecord

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

func NewDirectoryNodeRecord

func NewDirectoryNodeRecord(id DirectoryID, parent DirectoryID, name string, reference SourceReference, sourceIdentity SourceIdentity, modified ModifiedTime) (NodeRecord, error)

func NewFileNodeRecord

func NewFileNodeRecord(id FileID, parent DirectoryID, name string, reference SourceReference, sourceIdentity SourceIdentity, candidate VersionCandidate, expectedSize uint64, modified ModifiedTime) (NodeRecord, error)

func NewSyntheticRootNodeRecord

func NewSyntheticRootNodeRecord(id DirectoryID) (NodeRecord, error)

func (NodeRecord) DirectoryID

func (n NodeRecord) DirectoryID() (DirectoryID, bool)

func (NodeRecord) Entry

func (n NodeRecord) Entry() Entry

func (NodeRecord) EstimatedMemoryBytes

func (n NodeRecord) EstimatedMemoryBytes() uint64

func (NodeRecord) FileID

func (n NodeRecord) FileID() (FileID, bool)

func (NodeRecord) IsSyntheticRoot

func (n NodeRecord) IsSyntheticRoot() bool

func (NodeRecord) Kind

func (n NodeRecord) Kind() NodeKind

func (NodeRecord) MatchesEntry

func (n NodeRecord) MatchesEntry(entry Entry) bool

func (NodeRecord) NodeID

func (n NodeRecord) NodeID() NodeID

func (NodeRecord) Parent

func (n NodeRecord) Parent() DirectoryID

func (NodeRecord) SourceIdentity

func (n NodeRecord) SourceIdentity() SourceIdentity

func (NodeRecord) SourceReference

func (n NodeRecord) SourceReference() SourceReference

func (NodeRecord) VersionCandidate

func (n NodeRecord) VersionCandidate() VersionCandidate

type NodeRecordIterator

type NodeRecordIterator interface {
	Next(context.Context) (NodeRecord, bool, error)
	Close() error
}

type PageAddress added in v0.1.4

type PageAddress struct {
	ShareInstance ShareInstance
	DirectoryID   DirectoryID
	Generation    DirectoryGeneration
	PageIndex     uint32
}

type PageCommitment

type PageCommitment [PageCommitmentBytes]byte

func NewPageCommitment

func NewPageCommitment(raw []byte) (PageCommitment, error)

func (PageCommitment) Bytes

func (c PageCommitment) Bytes() []byte

func (PageCommitment) IsZero

func (c PageCommitment) IsZero() bool

type PagePayload added in v0.1.4

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

PagePayload binds owned canonical bytes to the address and commitment established by page construction or an addressed storage read.

func (PagePayload) Address added in v0.1.4

func (p PagePayload) Address() PageAddress

func (PagePayload) Bytes added in v0.1.4

func (p PagePayload) Bytes() []byte

func (PagePayload) Commitment added in v0.1.4

func (p PagePayload) Commitment() PageCommitment

func (PagePayload) IsZero added in v0.1.4

func (p PagePayload) IsZero() bool

type ReceivedDescriptorSpec

type ReceivedDescriptorSpec struct {
	WireVersion      uint32
	Suite            uint32
	ShareInstance    ShareInstance
	SyntheticRoot    DirectoryID
	ChunkSize        uint32
	Capabilities     Capability
	SenderPublicKey  []byte
	CreatedAtSeconds uint64
	PathPolicy       string
}

type ResourceMeter

type ResourceMeter interface {
	Consume(ResourceUsage) error
	Release(ResourceUsage) error
}

type ResourceUsage

type ResourceUsage struct {
	ActiveScans uint64
	ScanWork    uint64
	Entries     uint64
	MemoryBytes uint64
	SpillBytes  uint64
}

type ScanAttemptID

type ScanAttemptID [IdentityBytes]byte

func ScanAttemptIDFromBytes

func ScanAttemptIDFromBytes(raw []byte) (ScanAttemptID, error)

func (ScanAttemptID) Bytes

func (id ScanAttemptID) Bytes() []byte

func (ScanAttemptID) Equal

func (id ScanAttemptID) Equal(other ScanAttemptID) bool

func (ScanAttemptID) IsZero

func (id ScanAttemptID) IsZero() bool

type ScanAttemptIDGenerator

type ScanAttemptIDGenerator interface {
	NewScanAttemptID() (ScanAttemptID, error)
}

type ScanAttemptIDGeneratorFunc

type ScanAttemptIDGeneratorFunc func() (ScanAttemptID, error)

func (ScanAttemptIDGeneratorFunc) NewScanAttemptID

func (f ScanAttemptIDGeneratorFunc) NewScanAttemptID() (ScanAttemptID, error)

type ScanChildSink

type ScanChildSink interface {
	Add(context.Context, ScannedChild) error
}

type ScanError

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

func (*ScanError) Error

func (e *ScanError) Error() string

func (*ScanError) Unwrap

func (e *ScanError) Unwrap() error

type ScanOmissionReporter

type ScanOmissionReporter interface {
	ReportScanOmissions(additionalCount uint64, additionalSamples []SourceOmission)
}

ScanOmissionReporter publishes the complete omission summary for one directory scan once catalog-level admission and commit succeed. Keeping publication on the source preserves native paths and diagnostic correlation without exposing host filesystem layout to catalog storage.

type ScanOmissionReporterFunc

type ScanOmissionReporterFunc func(additionalCount uint64, additionalSamples []SourceOmission)

func (ScanOmissionReporterFunc) ReportScanOmissions

func (report ScanOmissionReporterFunc) ReportScanOmissions(additionalCount uint64, additionalSamples []SourceOmission)

type ScanOptions

type ScanOptions struct {
	Retry    bool
	Progress ScanProgressObserver
}

type ScanProgress

type ScanProgress struct {
	AttemptID         ScanAttemptID
	DiscoveredEntries uint64
}

type ScanProgressObserver

type ScanProgressObserver interface {
	ObserveScanProgress(context.Context, ScanProgress) error
}

type ScanProgressObserverFunc

type ScanProgressObserverFunc func(context.Context, ScanProgress) error

func (ScanProgressObserverFunc) ObserveScanProgress

func (observe ScanProgressObserverFunc) ObserveScanProgress(
	ctx context.Context,
	progress ScanProgress,
) error

type ScanRequest

type ScanRequest struct {
	AttemptID  ScanAttemptID
	Generation DirectoryGeneration
	Directory  NodeRecord
	Work       ScanWork
	Children   ScanChildSink
}

type ScanResult

type ScanResult struct {
	// OmittedCount counts immediate children the source could not include in a
	// fully enumerated, stable directory before catalog-level admission. An
	// omitted directory counts once for its entire subtree. Failures that prevent
	// complete enumeration or directory identity validation must return an error.
	OmittedCount uint64
	// Omissions publishes local omission feedback and diagnostics once the caller
	// commits the scanned directory generation.
	Omissions ScanOmissionReporter
}

func (ScanResult) PublishOmissions

func (r ScanResult) PublishOmissions(additionalCount uint64, additionalSamples []SourceOmission)

type ScanWork

type ScanWork interface {
	Consume(uint64) error
}

type ScannedChild

type ScannedChild struct {
	DirectoryID      DirectoryID
	FileID           FileID
	Name             string
	SourceReference  SourceReference
	SourceIdentity   SourceIdentity
	VersionCandidate VersionCandidate
	ExpectedSize     uint64
	ModifiedTime     ModifiedTime
}

type SelectionError

type SelectionError struct {
	Label string
	Cause error
}

SelectionError identifies the caller's selected item when acquisition fails. Label is display-only: providers retain all authority to resolve the selection.

func (*SelectionError) Error

func (err *SelectionError) Error() string

func (*SelectionError) Unwrap

func (err *SelectionError) Unwrap() error

type SelectionNameCollisionError

type SelectionNameCollisionError struct {
	FirstLabel  string
	SecondLabel string
}

SelectionNameCollisionError identifies selections that cannot coexist under the synthetic root. Labels are display facts, not filesystem authority; this error is distinct from catalog integrity failures such as duplicate node IDs.

func (*SelectionNameCollisionError) Error

func (err *SelectionNameCollisionError) Error() string

type ShareDescriptor

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

func NewReceivedShareDescriptor

func NewReceivedShareDescriptor(spec ReceivedDescriptorSpec) (ShareDescriptor, error)

NewReceivedShareDescriptor validates an authenticated descriptor without manufacturing the sender-local CommittedRoot capability required to register.

func NewShareDescriptor

func NewShareDescriptor(spec DescriptorSpec) (ShareDescriptor, error)

func (ShareDescriptor) BlockCountFieldPresent

func (d ShareDescriptor) BlockCountFieldPresent() bool

func (ShareDescriptor) Capabilities

func (d ShareDescriptor) Capabilities() Capability

func (ShareDescriptor) ChunkSize

func (d ShareDescriptor) ChunkSize() uint32

func (ShareDescriptor) CreatedAtSeconds

func (d ShareDescriptor) CreatedAtSeconds() uint64

func (ShareDescriptor) PathPolicy

func (d ShareDescriptor) PathPolicy() string

func (ShareDescriptor) SenderPublicKey

func (d ShareDescriptor) SenderPublicKey() []byte

func (ShareDescriptor) ShareInstance

func (d ShareDescriptor) ShareInstance() ShareInstance

func (ShareDescriptor) Suite

func (d ShareDescriptor) Suite() uint32

func (ShareDescriptor) SyntheticRoot

func (d ShareDescriptor) SyntheticRoot() DirectoryID

func (ShareDescriptor) WireVersion

func (d ShareDescriptor) WireVersion() uint32

type ShareInstance

type ShareInstance [IdentityBytes]byte

func ShareInstanceFromBytes

func ShareInstanceFromBytes(raw []byte) (ShareInstance, error)

func (ShareInstance) Bytes

func (id ShareInstance) Bytes() []byte

func (ShareInstance) Equal

func (id ShareInstance) Equal(other ShareInstance) bool

func (ShareInstance) IsZero

func (id ShareInstance) IsZero() bool

type SourceError

type SourceError struct {
	Operation string
	Reference SourceReference
	Failure   SourceFailure
	Cause     error
}

func (*SourceError) Error

func (err *SourceError) Error() string

func (*SourceError) Unwrap

func (err *SourceError) Unwrap() error

type SourceFailure

type SourceFailure uint8

SourceFailure distinguishes adapter failures without requiring native error types or leaking the provider's lookup interpretation into its consumers.

const (
	SourceFailureUnavailable SourceFailure = iota + 1
	SourceFailureMissing
	SourceFailureAccessDenied
	SourceFailureUnsupported
	SourceFailureStale
)

type SourceIdentity

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

func NewSourceIdentity

func NewSourceIdentity(raw []byte) (SourceIdentity, error)

func (SourceIdentity) Bytes

func (v SourceIdentity) Bytes() []byte

func (SourceIdentity) IsZero

func (v SourceIdentity) IsZero() bool

type SourceOmission

type SourceOmission struct {
	Name   string
	Reason SourceOmissionReason
	// Detail explains the rejected spelling or colliding partner, including code points when visually identical.
	Detail string
}

func NewSiblingCollisionOmission

func NewSiblingCollisionOmission(name, other string) SourceOmission

type SourceOmissionObserver

type SourceOmissionObserver interface {
	ObserveSourceOmissions(SourceOmissions)
}

Observers must return promptly; presentation must not backpressure discovery.

type SourceOmissionObserverFunc

type SourceOmissionObserverFunc func(SourceOmissions)

func (SourceOmissionObserverFunc) ObserveSourceOmissions

func (observe SourceOmissionObserverFunc) ObserveSourceOmissions(value SourceOmissions)

type SourceOmissionReason

type SourceOmissionReason string
const (
	SourceOmissionNone         SourceOmissionReason = ""
	SourceOmissionSymbolicLink SourceOmissionReason = "symbolic_link"
	SourceOmissionReparsePoint SourceOmissionReason = "reparse_point"
	SourceOmissionSpecialFile  SourceOmissionReason = "special_file"
	SourceOmissionName         SourceOmissionReason = "unrepresentable_name"
	// SourceOmissionNameCollision marks every member of a sibling group whose names
	// match under portable name matching; none can be preferred without guessing.
	SourceOmissionNameCollision SourceOmissionReason = "name_collision"
	SourceOmissionAccessDenied  SourceOmissionReason = "access_denied"
)

func (SourceOmissionReason) RequiresDetail

func (reason SourceOmissionReason) RequiresDetail() bool

func (SourceOmissionReason) Valid

func (reason SourceOmissionReason) Valid() bool

type SourceOmissions

type SourceOmissions struct {
	Directory     DirectoryID
	Generation    DirectoryGeneration
	Attempt       ScanAttemptID
	DirectoryPath string
	Count         uint64
	Samples       []SourceOmission
}

SourceOmissions is local source feedback after a stable directory scan. Native names and paths stay out of catalog wire metadata because some omitted names cannot be represented by the catalog grammar. Count measures immediate children; an omitted directory excludes its subtree without traversing it.

type SourceReference

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

SourceReference is meaningful only to the file source that produced it. It is private catalog data, never a receiver path or a protocol object identity.

func NewSourceReference

func NewSourceReference(raw []byte) (SourceReference, error)

func (SourceReference) Bytes

func (v SourceReference) Bytes() []byte

func (SourceReference) IsZero

func (v SourceReference) IsZero() bool

type SpillFactory

type SpillFactory interface {
	NewWorkspace(context.Context, SpillRequest) (SpillWorkspace, error)
}

SpillFactory is injected because temporary storage is an admission-controlled resource, not an implementation detail that scanners may create ad hoc.

type SpillLifecycle

type SpillLifecycle interface {
	Recover(context.Context, ShareInstance) error
	Destroy(ShareInstance) error
}

type SpillObject

type SpillObject interface {
	Open(context.Context) (io.ReadCloser, error)
	Size() uint64
	Remove() error
}

type SpillRequest

type SpillRequest struct {
	ShareInstance ShareInstance
	AttemptID     ScanAttemptID
}

type SpillWorkspace

type SpillWorkspace interface {
	Create(context.Context) (SpillWriter, error)
	Close() error
}

type SpillWriter

type SpillWriter interface {
	io.Writer
	Commit() (SpillObject, error)
	Abort() error
}

type StoreConfig

type StoreConfig struct {
	ShareInstance  ShareInstance
	Backend        CatalogBackend
	ProcessBudget  *BudgetAccount
	ShareBudget    *BudgetAccount
	FailureEncoder FailureEncoder
	SpillFactory   SpillFactory
	SortRunBytes   uint64
	Clock          Clock
	AttemptIDs     ScanAttemptIDGenerator
	Generations    DirectoryGenerationGenerator
}

type SyntheticRootCommitSpec

type SyntheticRootCommitSpec struct {
	ShareInstance ShareInstance
	SyntheticRoot DirectoryID
	Generation    DirectoryGeneration
	SelectedRoots []NodeRecord
}

type TimePrecision

type TimePrecision uint8
const (
	TimePrecisionUnknown TimePrecision = iota
	TimePrecisionSeconds
	TimePrecisionMilliseconds
	TimePrecisionNanoseconds
)

type VersionCandidate

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

func NewVersionCandidate

func NewVersionCandidate(raw []byte) (VersionCandidate, error)

func (VersionCandidate) Bytes

func (v VersionCandidate) Bytes() []byte

func (VersionCandidate) IsZero

func (v VersionCandidate) IsZero() bool

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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