catalogflow

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 14 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 catalogflow provides the progressive LIST_CHILDREN service and client above an authenticated protocol session. It never reads a FrameChannel and never interprets local paths; transport and sender-object authentication are injected at its two narrow boundaries.

Index

Constants

View Source
const (
	DefaultClientCacheBytes      = uint64(16) << 20
	DefaultClientDirectories     = 4_096
	MaxConcurrentDirectoryLoads  = 4
	DirectoryFailureMemoryBytes  = 128
	CatalogLeaseClaimMemoryBytes = 64
	// MaxClientLeaseClaims keeps 16,384 claims * 64 bytes within 1 MiB even
	// when the caller configures an effectively unbounded cache.
	MaxClientLeaseClaims = 16_384
	// MaxDirectoryLeaseClaims keeps 256 claims * 64 bytes within 16 KiB so a
	// hot directory cannot monopolize the global claim budget.
	MaxDirectoryLeaseClaims = 256
)
View Source
const (
	DefaultPageObjectCacheBytes = uint64(1) << 20
	DefaultFailureObjectBytes   = uint64(16) << 20
)
View Source
const (
	DirectoryCodeStale       uint16 = 0x2001
	DirectoryCodePermission  uint16 = 0x2002
	DirectoryCodeCollision   uint16 = 0x2003
	DirectoryCodeTooWide     uint16 = 0x2004
	DirectoryCodeBudget      uint16 = 0x2005
	DirectoryCodePermanentIO uint16 = 0x2006
	DirectoryCodeTransientIO uint16 = 0x2007
	DirectoryCodeCancelled   uint16 = 0x2008

	MinRetryAfter = 250 * time.Millisecond
	MaxRetryAfter = 30 * time.Second
)
View Source
const MaxListRequestBytes = 40

Variables

View Source
var (
	ErrCatalogObjectConflict          = errors.New("catalog sender object identity already has different content")
	ErrCatalogObjectMissing           = errors.New("catalog sender object is not committed")
	ErrSealedCatalogStoreDestroyed    = errors.New("sealed catalog store was destroyed")
	ErrCatalogObjectVerifierDestroyed = errors.New("catalog object verifier was destroyed")
)
View Source
var (
	ErrWireObject       = errors.New("catalog wire object is invalid")
	ErrNonCanonicalWire = errors.New("catalog wire object is not canonical CBOR")
)
View Source
var (
	ErrInvalidRequest     = errors.New("catalog list request is invalid")
	ErrObjectIdentity     = errors.New("verified catalog object changes request identity")
	ErrPageGap            = errors.New("catalog page sequence contains a gap")
	ErrPageConflict       = errors.New("catalog page replay conflicts with committed content")
	ErrPostTerminal       = errors.New("catalog object arrived after the terminal page")
	ErrClientBudget       = errors.New("catalog client memory budget exceeded")
	ErrGenerationMismatch = errors.New("catalog request generation is stale")
	ErrPageOutOfRange     = errors.New("catalog request page is outside the generation")
	ErrUnverifiedObject   = errors.New("catalog verifier returned no page or failure")
	ErrResponseIdentity   = errors.New("verified catalog object does not answer its authenticated request")
)
View Source
var ErrCatalogCodec = errors.New("catalog flow object is malformed")
View Source
var ErrClientClosed = errors.New("catalog client is closed")
View Source
var ErrPageCursorState = errors.New("catalog page cursor state is invalid")

Functions

func DecodeCatalogResult

func DecodeCatalogResult(encoded []byte) ([]byte, error)

func EncodeCatalogResult

func EncodeCatalogResult(object []byte) ([]byte, error)

func EncodeDirectoryFailure

func EncodeDirectoryFailure(failure DirectoryFailure) ([]byte, error)

func EncodeListRequest

func EncodeListRequest(request ListRequest) ([]byte, error)

func SealDescriptor

func SealDescriptor(descriptor catalog.ShareDescriptor, config DescriptorObjectConfig) ([]byte, error)

Types

type AcceptStatus

type AcceptStatus uint8
const (
	PageAccepted AcceptStatus = iota + 1
	PageReplay
	GenerationCommitted
)

type AddressedSenderService

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

func NewAddressedSenderService

func NewAddressedSenderService(
	share catalog.ShareInstance,
	source PageAddressedSource,
) (*AddressedSenderService, error)

func (*AddressedSenderService) Serve

func (service *AddressedSenderService) Serve(
	ctx context.Context,
	request ListRequest,
	progress catalog.ScanProgressObserver,
) ([]byte, error)

type Assembler

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

func NewAssembler

func NewAssembler(instance catalog.ShareInstance, directory catalog.DirectoryID, maxPages uint32) (*Assembler, error)

func (*Assembler) Accept

func (a *Assembler) Accept(object VerifiedObject) (AcceptStatus, error)

func (*Assembler) NextRequest

func (a *Assembler) NextRequest() (ListRequest, error)

func (*Assembler) PageCount

func (a *Assembler) PageCount() int

func (*Assembler) Snapshot

func (a *Assembler) Snapshot() (catalog.DirectorySnapshot, bool)

type CatalogObjectVerifier

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

CatalogObjectVerifier owns its catalog secret and shares immutable sender verification state. Teardown must not invalidate other receiver components.

func NewCatalogObjectVerifier

func NewCatalogObjectVerifier(config CatalogObjectVerifierConfig) (*CatalogObjectVerifier, error)

func (*CatalogObjectVerifier) Destroy

func (verifier *CatalogObjectVerifier) Destroy()

Destroy waits for admitted verification to finish before erasing keys, so concurrent authentication never observes partially cleared authority.

func (*CatalogObjectVerifier) Stop

func (verifier *CatalogObjectVerifier) Stop()

Stop closes verifier admission without waiting for already-authenticated objects to finish decoding.

func (*CatalogObjectVerifier) Verify

func (verifier *CatalogObjectVerifier) Verify(
	ctx context.Context,
	share catalog.ShareInstance,
	request ListRequest,
	object []byte,
) (VerifiedObject, error)

type CatalogObjectVerifierConfig

type CatalogObjectVerifierConfig struct {
	ShareInstance catalog.ShareInstance
	CatalogKey    []byte
	Sender        *senderauth.Verifier
}

type CatalogStoreSource

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

CatalogStoreSource preserves the page-addressed backend boundary. A later page never materializes its siblings, and only page zero without a generation may trigger the directory's share-scoped lazy scan.

func NewCatalogStoreSource

func NewCatalogStoreSource(config CatalogStoreSourceConfig) (*CatalogStoreSource, error)

func (*CatalogStoreSource) LoadPage

func (source *CatalogStoreSource) LoadPage(
	ctx context.Context,
	request ListRequest,
	progress catalog.ScanProgressObserver,
) (PageResult, error)

type CatalogStoreSourceConfig

type CatalogStoreSourceConfig struct {
	ShareInstance catalog.ShareInstance
	Store         *catalog.CatalogStore
	SessionBudget *catalog.BudgetAccount
	Scanner       catalog.DirectoryScanner
}

type Client

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

func NewClient

func NewClient(config ClientConfig) (*Client, error)

func (*Client) AcquireDirectory

func (c *Client) AcquireDirectory(
	ctx context.Context,
	directory catalog.DirectoryID,
) (catalog.DirectorySnapshot, func(), error)

AcquireDirectory pins the exact cached result delivered to this caller. The callback must be invoked even when err is a DirectoryFailure, and is safe to invoke more than once.

func (*Client) CachedBytes

func (c *Client) CachedBytes() uint64

func (*Client) Close

func (c *Client) Close()

Close is the owner-side join. Callbacks may invoke Stop, but must leave Close to their owner because joining from an owned callback would self-deadlock.

func (*Client) LoadDirectory

func (c *Client) LoadDirectory(ctx context.Context, directory catalog.DirectoryID) (catalog.DirectorySnapshot, error)

func (*Client) OpenDirectoryPages

func (c *Client) OpenDirectoryPages(
	ctx context.Context,
	directory catalog.DirectoryID,
) (catalog.DirectoryPageCursor, error)

OpenDirectoryPages creates a forward-only generation cursor. Unlike LoadDirectory, it verifies and releases each sender object before requesting the next page, so a protocol-wide directory never becomes one Go allocation.

func (*Client) ReleaseDirectory

func (c *Client) ReleaseDirectory(directory catalog.DirectoryID) bool

func (*Client) Snapshot

func (c *Client) Snapshot(directory catalog.DirectoryID) (catalog.DirectorySnapshot, bool)

func (*Client) Stop

func (c *Client) Stop()

Stop synchronously freezes admission and cancels every owned load without joining callbacks. This split lets a verifier or transport callback request shutdown without waiting for the goroutine that is currently invoking it.

type ClientConfig

type ClientConfig struct {
	ShareInstance           catalog.ShareInstance
	Transport               PageTransport
	Verifier                ObjectVerifier
	MaxPagesPerDirectory    uint32
	MaxObjectBytes          uint32
	MaxCacheBytes           uint64
	MaxDirectories          int
	MaxConcurrentLoads      int
	MaxLeaseClaims          int
	MaxDirectoryLeaseClaims int
	Now                     func() time.Time
}

type DescriptorObjectConfig

type DescriptorObjectConfig struct {
	PKHash           []byte
	ShareIDRaw       []byte
	DescriptorKey    []byte
	SenderPrivateKey ed25519.PrivateKey
	Nonce            []byte
}

type DirectoryFailure

type DirectoryFailure struct {
	ShareInstance catalog.ShareInstance
	DirectoryID   catalog.DirectoryID
	AttemptID     catalog.ScanAttemptID
	Code          uint16
	Retryable     bool
	RetryAfter    time.Duration
}

func DecodeDirectoryFailure

func DecodeDirectoryFailure(encoded []byte) (DirectoryFailure, error)

func NewDirectoryFailure

func NewDirectoryFailure(failure DirectoryFailure) (DirectoryFailure, error)

func (DirectoryFailure) DirectoryFailure

func (f DirectoryFailure) DirectoryFailure()

DirectoryFailure marks an authenticated, directory-scoped source failure. Consumers may skip only this subtree; unmarked verifier, identity, transport, and budget errors remain fatal to the consuming operation.

func (DirectoryFailure) Error

func (f DirectoryFailure) Error() string

type DirectoryResult

type DirectoryResult struct {
	Snapshot catalog.DirectorySnapshot
	Failure  *DirectoryFailure
}

func FailureResult

func FailureResult(failure DirectoryFailure) DirectoryResult

func SnapshotResult

func SnapshotResult(snapshot catalog.DirectorySnapshot) DirectoryResult

type DirectorySource

type DirectorySource interface {
	LoadDirectory(ctx context.Context, directory catalog.DirectoryID) (DirectoryResult, error)
}

type ListRequest

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

func DecodeListRequest

func DecodeListRequest(encoded []byte) (ListRequest, error)

func NewListRequest

func NewListRequest(directory catalog.DirectoryID, generation *catalog.DirectoryGeneration, pageIndex uint32) (ListRequest, error)

func (ListRequest) DirectoryID

func (r ListRequest) DirectoryID() catalog.DirectoryID

func (ListRequest) Generation

func (r ListRequest) Generation() (catalog.DirectoryGeneration, bool)

func (ListRequest) PageIndex

func (r ListRequest) PageIndex() uint32

type ObjectVerifier

type ObjectVerifier interface {
	Verify(context.Context, catalog.ShareInstance, ListRequest, []byte) (VerifiedObject, error)
}

type OpenedDescriptor

type OpenedDescriptor struct {
	Descriptor catalog.ShareDescriptor
	Sender     *senderauth.Verifier
}

OpenedDescriptor keeps the authenticated sender identity with the data it authenticated, so all receiver components can share its checked key.

func OpenDescriptor

func OpenDescriptor(object []byte, pkHash, shareIDRaw, descriptorKey []byte) (OpenedDescriptor, error)

type PageAddressedSource

type PageAddressedSource interface {
	LoadPage(context.Context, ListRequest, catalog.ScanProgressObserver) (PageResult, error)
}

type PageResult

type PageResult struct {
	Page         catalog.CatalogPage
	SealedObject []byte
	Failure      *DirectoryFailure
}

type PageTransport

type PageTransport interface {
	FetchPage(context.Context, ListRequest) ([]byte, error)
}

type SealedCatalogStore

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

SealedCatalogStore owns cloned catalog/signing keys and a bounded read-through cache; CatalogStore's backend remains the authority for committed page bytes. Keeping the roles separate prevents random-nonce objects from becoming RAM-only state and gives Destroy one precise secret owner.

func NewSealedCatalogStore

func NewSealedCatalogStore(config SealedCatalogStoreConfig) (*SealedCatalogStore, error)

func (*SealedCatalogStore) Destroy

func (store *SealedCatalogStore) Destroy()

Destroy is owner-only and must not run from NonceSource.Read because it waits for every operation admitted before Stop to release its cryptographic inputs.

func (*SealedCatalogStore) LoadSealedFailure

func (store *SealedCatalogStore) LoadSealedFailure(ctx context.Context, failure DirectoryFailure) ([]byte, error)

func (*SealedCatalogStore) LoadSealedPage

func (store *SealedCatalogStore) LoadSealedPage(ctx context.Context, page catalog.CatalogPage) ([]byte, error)

func (*SealedCatalogStore) Seal

func (*SealedCatalogStore) SealFailure

func (*SealedCatalogStore) Stop

func (store *SealedCatalogStore) Stop()

Stop is safe inside NonceSource.Read: it rejects new work without waiting for the operation that owns the callback.

type SealedCatalogStoreConfig

type SealedCatalogStoreConfig struct {
	ShareInstance     catalog.ShareInstance
	CatalogKey        []byte
	SenderPrivateKey  ed25519.PrivateKey
	NonceSource       io.Reader
	MaxPageCacheBytes uint64
	MaxFailureBytes   uint64
}

type SealedObjectStore

type SealedObjectStore interface {
	LoadSealedPage(context.Context, catalog.CatalogPage) ([]byte, error)
	LoadSealedFailure(context.Context, DirectoryFailure) ([]byte, error)
}

SealedObjectStore returns the exact bytes committed for an immutable page or scan attempt. Catalog chaining hashes complete sender-object bytes, so serving code must never reseal on demand with a new nonce.

type SenderService

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

func NewSenderService

func NewSenderService(instance catalog.ShareInstance, source DirectorySource, objects SealedObjectStore) (*SenderService, error)

func (*SenderService) Serve

func (s *SenderService) Serve(ctx context.Context, request ListRequest) ([]byte, error)

type VerifiedObject

type VerifiedObject struct {
	Page    catalog.CatalogPage
	Failure *DirectoryFailure
}

func VerifiedFailure

func VerifiedFailure(failure DirectoryFailure) VerifiedObject

func VerifiedPage

func VerifiedPage(page catalog.CatalogPage) VerifiedObject

Jump to

Keyboard shortcuts

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