Documentation
¶
Overview ¶
Package fault defines the transport-neutral failure values consumed by transfer settlement policy.
Fault intentionally excludes native errors and diagnostic context. Keeping those details at the boundary that observed them prevents wrapping topology from becoming lifecycle or retirement authority.
Index ¶
- Variables
- func BoundaryCancellation(err error) error
- func CauseOf(err error) error
- func Compare(left, right Fault) int
- func IsCancellation(ctx context.Context, err error) bool
- func IsSessionTerminal(err error) bool
- func JoinErrors(candidates ...error) error
- func ReduceBoundaryErrorSet(candidates ...error) error
- func ReduceBoundaryErrors(ctx context.Context, candidates ...error) error
- func Wrap(value Fault, cause error) error
- type BoundaryError
- func Admit(err error) (*BoundaryError, bool)
- func ContextCause(ctx context.Context) *BoundaryError
- func DependencyContract(cause error) *BoundaryError
- func FromCancellation(ctx context.Context, diagnostic error) *BoundaryError
- func Merge(current *BoundaryError, candidates ...error) *BoundaryError
- func New(value Fault, cause error) *BoundaryError
- func Normalize(ctx context.Context, err error, classify func(error) (Fault, bool)) *BoundaryError
- func Reduce(candidates ...error) *BoundaryError
- func Require(err error) *BoundaryError
- func (failure *BoundaryError) Canceled() bool
- func (failure *BoundaryError) Cancellation() error
- func (failure *BoundaryError) Cause() error
- func (failure *BoundaryError) Err() error
- func (failure *BoundaryError) Error() string
- func (failure *BoundaryError) Fault() Fault
- func (failure *BoundaryError) Project(diagnostic error) error
- func (failure *BoundaryError) Unwrap() error
- type BoundaryResult
- type BoundaryResultKind
- type CatalogCode
- type CheckpointCode
- type Domain
- type Fault
- func ClassifyContent(err error) (Fault, bool)
- func DependencyContractFault() Fault
- func FaultOf(err error) Fault
- func Join(faults ...Fault) Fault
- func NewCatalog(scope Scope, code CatalogCode) (Fault, error)
- func NewCheckpoint(scope Scope, code CheckpointCode) (Fault, error)
- func NewOutput(scope Scope, code OutputCode) (Fault, error)
- func NewSession(scope Scope, code SessionCode) (Fault, error)
- func NewSource(scope Scope, code SourceCode) (Fault, error)
- func (fault Fault) CatalogCode() (CatalogCode, bool)
- func (fault Fault) CheckpointCode() (CheckpointCode, bool)
- func (fault Fault) Code() uint16
- func (fault Fault) Domain() Domain
- func (fault Fault) IsZero() bool
- func (fault Fault) OutputCode() (OutputCode, bool)
- func (fault Fault) Scope() Scope
- func (fault Fault) SessionCode() (SessionCode, bool)
- func (fault Fault) SourceCode() (SourceCode, bool)
- func (fault Fault) String() string
- func (fault Fault) Valid() bool
- type OutputCode
- type Retirement
- type Scope
- type SessionCode
- type SourceCode
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidFault = errors.New("transfer fault is invalid")
Functions ¶
func BoundaryCancellation ¶
BoundaryCancellation returns a standard cancellation sentinel for an unclassified collaborator result or an explicitly canceled BoundaryError. A classified fault without explicit cancellation owns its outcome; cancellation inside its diagnostic cause cannot grant cancellation authority.
func CauseOf ¶ added in v0.1.6
CauseOf returns the diagnostic cause of a direct *BoundaryError, or err itself.
func Compare ¶
Compare establishes a total order for deterministic reduction. Domain and code break equal-severity ties only; their order does not grant extra policy authority to one collaborator.
func IsCancellation ¶ added in v0.1.6
IsCancellation reports whether caller context or an immediate collaborator result represents cancellation rather than a classified fault.
func IsSessionTerminal ¶ added in v0.1.6
IsSessionTerminal reports whether err represents terminal protocol-session teardown.
func JoinErrors ¶ added in v0.1.6
JoinErrors reduces candidates and returns a typed-nil-safe error.
func ReduceBoundaryErrorSet ¶
ReduceBoundaryErrorSet joins already-completed sibling results when no operation context exists. It preserves explicit cancellation outside the fault lattice and applies the same total Fault join as the context-aware form.
func ReduceBoundaryErrors ¶
ReduceBoundaryErrors combines immediate sibling collaborator results without deriving policy from their aggregate error topology. Each candidate is normalized once, Fault values use the total deterministic join, and any cancellation remains outside the fault lattice.
Types ¶
type BoundaryError ¶
type BoundaryError struct {
// contains filtered or unexported fields
}
BoundaryError is the single normalized error carrier shared across transfer boundaries, lane scheduling, and job lifecycle policy. Fault and cancellation stay independent so a sibling cancellation never erases the fault that caused the owning operation to stop.
func Admit ¶ added in v0.1.6
func Admit(err error) (*BoundaryError, bool)
Admit accepts only a direct *BoundaryError carrier, rejecting arbitrary external wrappers from acquiring closed policy authority.
func ContextCause ¶ added in v0.1.6
func ContextCause(ctx context.Context) *BoundaryError
ContextCause returns an owned *BoundaryError propagated via context.WithCancelCause.
func DependencyContract ¶ added in v0.1.6
func DependencyContract(cause error) *BoundaryError
DependencyContract returns the fail-closed dependency-contract BoundaryError.
func FromCancellation ¶ added in v0.1.6
func FromCancellation(ctx context.Context, diagnostic error) *BoundaryError
FromCancellation builds a canceled *BoundaryError from ctx or diagnostic, preserving any already-owned *BoundaryError intact.
func Merge ¶ added in v0.1.6
func Merge(current *BoundaryError, candidates ...error) *BoundaryError
Merge joins candidates into current, preserving singleton identity when one side is nil.
func New ¶ added in v0.1.6
func New(value Fault, cause error) *BoundaryError
New constructs a normalized BoundaryError, failing closed to DependencyContractFault if value is invalid.
func Normalize ¶ added in v0.1.6
Normalize admits one collaborator error at a boundary into *BoundaryError. Caller cancellation and propagated worker causes win before inspecting err.
func Reduce ¶ added in v0.1.6
func Reduce(candidates ...error) *BoundaryError
Reduce combines direct *BoundaryError carriers and bare cancellation sentinels without traversing arbitrary wrapper graphs. A singleton direct carrier is returned unchanged to preserve context.WithCancelCause identity.
func Require ¶ added in v0.1.6
func Require(err error) *BoundaryError
Require ensures any non-nil error is a direct *BoundaryError, failing closed to DependencyContract for unadmitted values.
func (*BoundaryError) Canceled ¶ added in v0.1.6
func (failure *BoundaryError) Canceled() bool
func (*BoundaryError) Cancellation ¶ added in v0.1.6
func (failure *BoundaryError) Cancellation() error
func (*BoundaryError) Cause ¶ added in v0.1.6
func (failure *BoundaryError) Cause() error
func (*BoundaryError) Err ¶ added in v0.1.6
func (failure *BoundaryError) Err() error
Err converts a possibly-nil *BoundaryError to an untyped error without producing a typed-nil interface value.
func (*BoundaryError) Error ¶
func (failure *BoundaryError) Error() string
func (*BoundaryError) Fault ¶
func (failure *BoundaryError) Fault() Fault
func (*BoundaryError) Project ¶ added in v0.1.6
func (failure *BoundaryError) Project(diagnostic error) error
Project returns an error suitable for returning across a collaborator port, preserving cancellation as the bare sentinel and faults as *BoundaryError.
func (*BoundaryError) Unwrap ¶
func (failure *BoundaryError) Unwrap() error
type BoundaryResult ¶
type BoundaryResult struct {
// contains filtered or unexported fields
}
BoundaryResult is a closed normalization result. It cannot carry the raw cause, so settlement code receives no error graph to reinterpret.
func NormalizeBoundary ¶
func NormalizeBoundary(ctx context.Context, err error) BoundaryResult
NormalizeBoundary checks caller cancellation before accepting a typed collaborator fault. An unknown error is a local dependency-contract breach and therefore pauses output authority rather than acquiring file isolation or retirement authority.
func NormalizeBoundaryError ¶
func NormalizeBoundaryError(err error) BoundaryResult
NormalizeBoundaryError is the context-free form for a completed collaborator result. Keeping it separate prevents locked invariant and trace paths from inventing a context while retaining unclassified collaborator cancellation.
func (BoundaryResult) Fault ¶
func (result BoundaryResult) Fault() (Fault, bool)
func (BoundaryResult) Kind ¶
func (result BoundaryResult) Kind() BoundaryResultKind
type BoundaryResultKind ¶
type BoundaryResultKind uint8
const ( BoundarySuccess BoundaryResultKind = iota BoundaryCanceled BoundaryFailed )
type CatalogCode ¶
type CatalogCode uint16
const ( CatalogDirectoryStale CatalogInvalidGeneration )
func (CatalogCode) String ¶
func (code CatalogCode) String() string
type CheckpointCode ¶
type CheckpointCode uint16
const ( CheckpointBusy CheckpointCode = iota + 1 CheckpointCorruptRecord CheckpointUnsafeInstall CheckpointOwnershipMismatch CheckpointStateIO )
func (CheckpointCode) String ¶
func (code CheckpointCode) String() string
type Fault ¶
type Fault struct {
// contains filtered or unexported fields
}
Fault is an immutable, comparable policy value. Scope is deliberately not inferred from Code: the stable-cut evidence at a boundary decides whether an otherwise identical failure is isolated or requires pausing wider authority.
func ClassifyContent ¶ added in v0.1.6
ClassifyContent maps authenticated content-layer errors to file-local source faults independently of transport teardown.
func DependencyContractFault ¶
func DependencyContractFault() Fault
func FaultOf ¶ added in v0.1.6
FaultOf returns the Fault carried by a direct *BoundaryError, or zero.
func Join ¶
Join returns the maximum normalized fault and treats the zero value as the identity. Constructors are the only way external packages can create a non-zero Fault, so invalid values cannot silently enter policy reduction.
func NewCatalog ¶
func NewCatalog(scope Scope, code CatalogCode) (Fault, error)
func NewCheckpoint ¶
func NewCheckpoint(scope Scope, code CheckpointCode) (Fault, error)
func NewSession ¶
func NewSession(scope Scope, code SessionCode) (Fault, error)
func (Fault) CatalogCode ¶
func (fault Fault) CatalogCode() (CatalogCode, bool)
func (Fault) CheckpointCode ¶
func (fault Fault) CheckpointCode() (CheckpointCode, bool)
func (Fault) OutputCode ¶
func (fault Fault) OutputCode() (OutputCode, bool)
func (Fault) SessionCode ¶
func (fault Fault) SessionCode() (SessionCode, bool)
func (Fault) SourceCode ¶
func (fault Fault) SourceCode() (SourceCode, bool)
type OutputCode ¶
type OutputCode uint16
const ( OutputStateIO OutputCode = iota + 1 OutputOwnership OutputNamespaceUnsafe OutputUnsupportedFilesystem OutputDirectoryBinding OutputDirectoryMetadata OutputFileAlreadyActive OutputResourceBudget OutputMutationAmbiguous OutputContract )
func (OutputCode) String ¶
func (code OutputCode) String() string
type Retirement ¶
type Retirement uint8
const ( RetirementPermanentSource Retirement = iota + 1 RetirementInvalidatedRevision )
func RetirementFor ¶
func RetirementFor(fault Fault) (Retirement, bool)
RetirementFor is an explicit allowlist. Severity alone never permits state deletion, and the file-local check prevents a wider source failure from being repurposed as authority over one file.
type Scope ¶
type Scope uint8
Scope is also the severity order used by Join. The numeric order is frozen so Go and browser runtimes reduce sibling failures identically.
type SessionCode ¶
type SessionCode uint16
const ( SessionTransport SessionCode = iota + 1 SessionProtocol SessionResourceBudget SessionDependencyContract )
func (SessionCode) String ¶
func (code SessionCode) String() string
type SourceCode ¶
type SourceCode uint16
const ( SourceRevisionChanged SourceRevisionInvalidated SourcePermanent )
func (SourceCode) String ¶
func (code SourceCode) String() string