outputcap

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0 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 outputcap defines the native capabilities consumed by the incremental output runtime. Keeping these contracts below osfs lets platform implementations depend on capability semantics without depending on the state-machine package that orchestrates them.

Index

Constants

View Source
const (
	ExecutionModeResumable = ExecutionResumable
	ExecutionModeLiveOnly  = ExecutionLiveOnly
)
View Source
const (
	PublishCommitted     = PublishNoReplaceCommitted
	PublishCollision     = PublishNoReplaceCollision
	PublishIndeterminate = PublishNoReplaceIndeterminate
)
View Source
const (
	CallerProvidedContainer = checkpointmodel.CallerProvidedContainer
	AuthorityCreatedRoot    = checkpointmodel.AuthorityCreatedRoot
)
View Source
const (
	OutputRootBindingBytes         = sha256.Size
	DestinationBindingIDBytes      = sha256.Size
	MaxRootIdentityClaimBytes      = 256
	MaxNamespaceIdentityClaimBytes = 256
	DestinationBindingIDDomainV1   = "windshare/destination-authority-id/v1"
)
View Source
const (
	IdentitySchemeLinuxHandleV2     = checkpointmodel.IdentitySchemeLinuxHandleV2
	IdentitySchemeWindowsObjectIDV1 = checkpointmodel.IdentitySchemeWindowsObjectIDV1
	IdentitySchemeDarwinObjectIDV1  = checkpointmodel.IdentitySchemeDarwinObjectIDV1
	IdentitySchemePortableWitnessV1 = checkpointmodel.IdentitySchemePortableWitnessV1
)
View Source
const (
	// ControlDirectoryName is the private recovery and metadata directory created
	// directly inside a bound destination container.
	ControlDirectoryName = ".windshare-output"

	// RecoveryIdentityPrefix is the prefix of directory recovery witness files
	// created directly inside an authority-created result root.
	RecoveryIdentityPrefix = ".wsresume"
)

Variables

View Source
var (
	ErrInvalidDestinationCapabilities = errors.New("osfs: destination capabilities are invalid")
	ErrOrdinaryOutputUnsupported      = errors.New("osfs: ordinary output is unsupported by the destination")
	// ErrRecoverableOutputUnsupported reports that the native filesystem cannot
	// establish restart identity and checkpoint ordering.
	ErrRecoverableOutputUnsupported = errors.New("osfs: recoverable native output is unsupported")
	// ErrUnsafeNamespace reports that the output namespace cannot safely retain
	// resumable state or receive file content.
	ErrUnsafeNamespace = errors.New("osfs: recoverable output namespace is unsafe")
	// ErrNamespaceCollision reports that a no-replace namespace mutation found an
	// existing entry.
	ErrNamespaceCollision = errors.New("osfs: output namespace entry already exists")
	// ErrNameRejected is a pre-mutation refusal of one confined component, not
	// a permission, ownership, or storage failure.
	ErrNameRejected = errors.New("osfs: destination rejects the output name")
	// ErrNamespaceLockBusy reports that another operation owns the namespace lock.
	ErrNamespaceLockBusy = errors.New("osfs: output namespace lock is already held")
)
View Source
var (
	ErrInvalidRootBinding          = errors.New("osfs: output root binding is invalid")
	ErrInvalidDestinationBindingID = errors.New("osfs: destination binding identity is invalid")
)
View Source
var ErrFixedLinkSourceChanged = errors.New("osfs: fixed output link source changed")

ErrFixedLinkSourceChanged is emitted only before attempting a no-replace mutation. That cut lets recovery distinguish an invalidated source witness from an unknown final-publication outcome.

Functions

func ReservedNamespacePrefix added in v0.1.5

func ReservedNamespacePrefix(scope ReservedNamespaceScope) string

ReservedNamespacePrefix reports the private WindShare namespace prefix reserved for direct children of a root with scope.

func ReservedRootName added in v0.1.5

func ReservedRootName(scope ReservedNamespaceScope, name string) bool

ReservedRootName reports whether name, as a direct child of a root with scope, falls in WindShare's private namespace for that root.

Matching uses the catalog's Unicode 15 full-fold key so case-insensitive filesystems cannot alias a user entry onto a private marker or control directory. Both reserved prefixes begin with ASCII '.', and no other Unicode 15 scalar folds or canonically composes to '.', so ordinary non-dot names return without allocation.

Types

type CapabilityEvidence

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

CapabilityEvidence pairs a guarantee with the closed reason that explains a negative result. Supported facts intentionally carry no reason.

func SupportedCapability

func SupportedCapability() CapabilityEvidence

func UnsupportedCapability

func UnsupportedCapability(reason CapabilityReason) (CapabilityEvidence, error)

func (CapabilityEvidence) Fact

func (evidence CapabilityEvidence) Fact() CapabilityFact

func (CapabilityEvidence) Reason

func (evidence CapabilityEvidence) Reason() CapabilityReason

func (CapabilityEvidence) Supported

func (evidence CapabilityEvidence) Supported() bool

func (CapabilityEvidence) Valid

func (evidence CapabilityEvidence) Valid() bool

type CapabilityFact

type CapabilityFact uint8

CapabilityFact is deliberately binary. Platforms report one fact per semantic guarantee rather than smuggling partial support through an enum.

const (
	CapabilityUnsupported CapabilityFact = iota + 1
	CapabilitySupported
)

func (CapabilityFact) String

func (fact CapabilityFact) String() string

func (CapabilityFact) Supported

func (fact CapabilityFact) Supported() bool

func (CapabilityFact) Valid

func (fact CapabilityFact) Valid() bool

type CapabilityReason

type CapabilityReason uint8

CapabilityReason is closed because callers may expose it in typed diagnostics and must never infer behavior from platform error strings.

const (
	CapabilityReasonNone CapabilityReason = iota + 1
	CapabilityReasonUnsupportedFilesystem
	CapabilityReasonNetworkFilesystem
	CapabilityReasonUserspaceFilesystem
	CapabilityReasonCloudPlaceholder
	CapabilityReasonReparseOrNestedMount
	CapabilityReasonUnsafePublication
	CapabilityReasonUnverifiableOperationRecovery
	CapabilityReasonUnverifiableRangeRecovery
	CapabilityReasonUnverifiableCrashCleanup
	CapabilityReasonCleanupOwnershipUnknown
)

func (CapabilityReason) String

func (reason CapabilityReason) String() string

func (CapabilityReason) Valid

func (reason CapabilityReason) Valid() bool

type CompatibleNameReport added in v0.1.5

type CompatibleNameReport struct {
	RepairedCount uint64
	ReportName    string
	PageCount     uint64
}

CompatibleNameReport summarizes compatible-name repairs exported beside a destination when an operation settles or is discarded. Either all fields are zero or all fields describe an exported report.

func (CompatibleNameReport) Empty added in v0.1.5

func (report CompatibleNameReport) Empty() bool

func (CompatibleNameReport) Valid added in v0.1.5

func (report CompatibleNameReport) Valid() bool

type CreateAuthorityValidator

type CreateAuthorityValidator interface {
	ValidateCreateAuthority() error
}

CreateAuthorityValidator verifies that a live directory capability still carries the authority required to create a child.

type CurrentEntryReference

type CurrentEntryReference interface {
	Kind() EntryKind
	Close() error
}

CurrentEntryReference is a live-handle identity witness for one opened entry. It is suitable for same-object checks only while retained and is never a restart-stable locator.

type DestinationBindingID

type DestinationBindingID [DestinationBindingIDBytes]byte

DestinationBindingID identifies a retained destination binding. Recoverable bindings derive it from a durable namespace witness; process bindings derive it from a fresh nonce and cannot use it to reopen a previous operation.

func DestinationBindingIDFromBytes

func DestinationBindingIDFromBytes(raw []byte) (DestinationBindingID, error)

func NewDestinationBindingID

func NewDestinationBindingID(
	rootIdentity []byte,
	namespaceIdentity []byte,
) (DestinationBindingID, error)

func NewProcessDestinationBindingID

func NewProcessDestinationBindingID(nonce []byte) (DestinationBindingID, error)

NewProcessDestinationBindingID allocates an identity that cannot be recreated from a path or stale private files. The retained root handle remains authority.

func (DestinationBindingID) AuthorityRef

func (DestinationBindingID) Bytes

func (id DestinationBindingID) Bytes() []byte

func (DestinationBindingID) IsZero

func (id DestinationBindingID) IsZero() bool

func (DestinationBindingID) String

func (id DestinationBindingID) String() string

type DestinationCapabilities

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

DestinationCapabilities keeps independent proofs independent. In particular, failure to prove restart recovery cannot erase a proven no-replace publish.

func NewDestinationCapabilities

func NewDestinationCapabilities(
	safePublish CapabilityEvidence,
	operationRecovery CapabilityEvidence,
	rangeRecovery CapabilityEvidence,
	crashCleanup CapabilityEvidence,
) (DestinationCapabilities, error)

func (DestinationCapabilities) CrashCleanup

func (capabilities DestinationCapabilities) CrashCleanup() CapabilityEvidence

func (DestinationCapabilities) OperationRecovery

func (capabilities DestinationCapabilities) OperationRecovery() CapabilityEvidence

func (DestinationCapabilities) RangeRecovery

func (capabilities DestinationCapabilities) RangeRecovery() CapabilityEvidence

func (DestinationCapabilities) SafePublish

func (capabilities DestinationCapabilities) SafePublish() CapabilityEvidence

func (DestinationCapabilities) Valid

func (capabilities DestinationCapabilities) Valid() bool

type Directory

type Directory interface {
	Close() error
	Duplicate() (Directory, error)
	Sync() error
	// Names requires a complete enumeration within the limit. ReadNameBatch
	// permits a larger namespace while bounding the returned work.
	Names(limit int) ([]string, error)
	ReadNameBatch(limit int) (DirectoryNameBatch, error)
	ObserveEntry(name string) (EntryKind, error)
	ClassifyExactEntry(name string) (EntryKind, bool, error)
	OpenEntry(name string) (CurrentEntryReference, error)
	EntryMatches(name string, expected CurrentEntryReference) (bool, error)
	OpenPinnedDirectory(expected CurrentEntryReference, private bool) (Directory, error)
	RemoveEntry(name string, expected CurrentEntryReference) error
	SameDirectory(Directory) (bool, error)
	SetModifiedTime(catalog.ModifiedTime) error

	OpenDirectory(name string, private bool) (Directory, error)
	CreateDirectory(name string, private bool) (Directory, error)
	InstallDirectoryNoReplace(candidate Directory, name string) (Directory, error)
	RemoveDirectory(name string, expected Directory) error

	// CreateFile exclusively creates and initializes an exact-sized file.
	// Providers own rollback until success. If rollback cannot be completed,
	// a nil file does not prove that the name is absent; callers must not infer
	// cleanup authority by reopening it or dismantle dependent recovery state.
	CreateFile(name string, private bool, size int64) (MutableFile, error)
	OpenObservedFile(name string, private bool) (ObservedFile, error)
	OpenRecoveryDurabilityFile(name string, private bool) (RecoveryDurabilityFile, error)
	OpenMutableFile(name string, private bool) (MutableFile, error)
	LinkFileNoReplace(source FileIdentity, name string) (ObservedFile, error)
	ReplacePrivateFile(source FileIdentity, name string) error
	RemoveFile(name string, expected FileIdentity) error
	AcquireLock(name string, existingOnly bool) (Lock, bool, error)
}

Directory is a live, fixed-handle directory capability. Restart-stable ownership is bound at platform identityScheme boundaries rather than exposed as a second, path-like authority on each directory handle.

type DirectoryNameBatch

type DirectoryNameBatch struct {
	Names   []string
	HasMore bool
}

DirectoryNameBatch starts at the beginning of a fresh handle-relative scan. Removing returned entries advances subsequent batches without persisting a filesystem cursor. Names are locators; each mutation still requires ownership.

type EntryKind

type EntryKind uint8

EntryKind separates safe presence from object authority. Callers use it to settle a pre-state final-path collision without opening or following a directory, reparse point, or other non-regular object.

const (
	// EntryAbsent means the named directory entry does not exist.
	EntryAbsent EntryKind = iota
	// EntryRegularFile means the named entry is a regular file.
	EntryRegularFile
	// EntryDirectory means the named entry is a directory.
	EntryDirectory
	// EntryOther means the named entry exists but is neither a regular file nor a directory.
	EntryOther
)

type ExecutionMode

type ExecutionMode uint8
const (
	ExecutionResumable ExecutionMode = iota + 1
	ExecutionLiveOnly
)

func SelectExecutionMode

func SelectExecutionMode(capabilities DestinationCapabilities) (ExecutionMode, error)

SelectExecutionMode keeps safe current-process publication independent from restart authority. Missing restart evidence selects a lifecycle that retains live handles and never treats abandoned private names as recovery authority.

func (ExecutionMode) String

func (mode ExecutionMode) String() string

func (ExecutionMode) Valid

func (mode ExecutionMode) Valid() bool

type FileIdentity

type FileIdentity interface {
	Close() error
	Size() (uint64, error)
	SameFile(FileIdentity) (bool, error)
}

FileIdentity is the common authority required to prove that two concurrently open handles still name the same regular file. It intentionally carries no content, durability, or metadata-mutation operation.

type IdentitySchemeID

type IdentitySchemeID = checkpointmodel.IdentitySchemeID

func NewIdentitySchemeID

func NewIdentitySchemeID(value string) (IdentitySchemeID, error)

type Lock

type Lock interface {
	File() MutableFile
	Close() error
}

Lock retains both the namespace lock and the fixed file capability that carries its data.

type MetadataAuthorityValidator

type MetadataAuthorityValidator interface {
	ValidateMetadataAuthority() error
}

MetadataAuthorityValidator verifies that a live directory capability still carries the authority required to change metadata.

type MutableFile

type MutableFile interface {
	ObservedFile
	io.WriterAt
	Sync() error
	SetModifiedTime(catalog.ModifiedTime) error
}

MutableFile is the active transfer authority. Observation is included because transfer settlement must verify the metadata installed by this same handle.

type NativeErrorCarrier

type NativeErrorCarrier interface {
	NativeErrorClass() NativeErrorClass
}

type NativeErrorClass

type NativeErrorClass uint8

NativeErrorClass is a bounded provider diagnosis. Raw operating-system errors remain available to the provider, while higher layers can freeze this class before redacting diagnostic detail.

const (
	NativeErrorAccessDenied NativeErrorClass = iota + 1
	NativeErrorSharingViolation
	NativeErrorNotFound
	NativeErrorInvalidHandle
	NativeErrorUnsupported
	NativeErrorIO
	NativeErrorUnknown
)

func ClassifyNativeError

func ClassifyNativeError(err error) (NativeErrorClass, bool)

func (NativeErrorClass) String

func (class NativeErrorClass) String() string

func (NativeErrorClass) Valid

func (class NativeErrorClass) Valid() bool

type ObservedFile

type ObservedFile interface {
	FileIdentity
	io.ReaderAt
	MetadataMatches(uint64, catalog.ModifiedTime) (bool, error)
}

ObservedFile can inspect content and metadata without requesting any native right that can durably change the file.

type OutputRootBinding

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

OutputRootBinding commits to both the certified volume and the current root object. Keeping the opaque claims out of durable state prevents a copied native identifier from becoming filesystem authority after restart.

func NewOutputRootBinding

func NewOutputRootBinding(
	identityScheme IdentitySchemeID,
	volumeIdentity []byte,
	objectIdentity []byte,
) (OutputRootBinding, error)

func (OutputRootBinding) Bytes

func (binding OutputRootBinding) Bytes() []byte

func (OutputRootBinding) IdentityScheme

func (binding OutputRootBinding) IdentityScheme() IdentitySchemeID

func (OutputRootBinding) IsZero

func (binding OutputRootBinding) IsZero() bool

func (OutputRootBinding) String

func (binding OutputRootBinding) String() string

type Platform

type Platform interface {
	Root() Directory
	RootOpenDisposition() RootOpenDisposition
	AcquirePublicOperationGuard() (PublicOperationGuard, error)
	ValidateModifiedTime(catalog.ModifiedTime) error
	// Keys are pure admission indexes, not evidence about an external namespace.
	// Directory lookup and no-replace mutation remain authoritative for aliases
	// and names introduced by other operations.
	CanonicalLocatorKey(string) (string, error)
	CanonicalComponentKey(string) (string, error)
	Close() error
}

Platform is intentionally smaller than a general filesystem API. Requiring every mutation through fixed directory and file handles makes it difficult for the state machine to accidentally turn a persisted locator into authority.

type PublicEntryNamesValidator

type PublicEntryNamesValidator interface {
	ValidatePublicEntryNames(names []string) error
}

PublicEntryNamesValidator lets a native directory resolve a complete admission set in one scan. Windows needs this deeper batch boundary because DOS aliases are directory metadata; one full enumeration per selected leaf would make a large root and selection amplify each other quadratically.

type PublicOperationGuard

type PublicOperationGuard interface {
	Root() Directory
	Close() error
}

PublicOperationGuard retains native placement authority while one public namespace operation runs. Root is borrowed from the guard and remains valid only until Close; callers must not close it separately.

type PublishNoReplaceOutcome

type PublishNoReplaceOutcome uint8

PublishNoReplaceOutcome describes publication, independently of its error. A zero outcome with an error proves no namespace change succeeded. Once a name may be visible, failures must report Indeterminate and preserve recovery evidence instead of authorizing rollback.

const (
	PublishNoReplaceCommitted PublishNoReplaceOutcome = iota + 1
	PublishNoReplaceCollision
	PublishNoReplaceIndeterminate
)

func (PublishNoReplaceOutcome) String

func (outcome PublishNoReplaceOutcome) String() string

func (PublishNoReplaceOutcome) Valid

func (outcome PublishNoReplaceOutcome) Valid() bool

type RecoveryDurabilityFile

type RecoveryDurabilityFile interface {
	FileIdentity
	Sync() error
}

RecoveryDurabilityFile can make an already-authenticated file durable while withholding content read, content write, truncation, and metadata mutation.

type ReservedNamespaceScope added in v0.1.5

type ReservedNamespaceScope uint8

ReservedNamespaceScope identifies which private WindShare namespace shares direct children with a native execution root. It is orthogonal to RootOpenDisposition because a newly created destination container has AuthorityCreatedRoot ownership yet still guards the container control namespace rather than a result-root recovery witness prefix.

const (
	// ReservedNamespaceDestinationContainer guards WindShare's private control
	// directory directly inside a bound destination container.
	ReservedNamespaceDestinationContainer ReservedNamespaceScope = iota + 1

	// ReservedNamespaceResultRoot guards WindShare's private recovery witness
	// files directly inside an authority-created result root.
	ReservedNamespaceResultRoot
)

func ReservedNamespaceScopeForEntry added in v0.1.5

func ReservedNamespaceScopeForEntry(kind receivecontract.ContainerEntryKind) ReservedNamespaceScope

ReservedNamespaceScopeForEntry maps a top-level reservation entry kind to the private WindShare namespace that shares direct children with its execution root.

func (ReservedNamespaceScope) Valid added in v0.1.5

func (scope ReservedNamespaceScope) Valid() bool

Valid reports whether scope names a defined reserved root namespace.

type RootOpenDisposition

type RootOpenDisposition = checkpointmodel.RootOpenDisposition

RootOpenDisposition aliases the durable ownership value so platform opens and ownership-marker recovery cannot assign different meanings to the same certified root fact.

Jump to

Keyboard shortcuts

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