fault

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 5 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 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

Constants

This section is empty.

Variables

View Source
var ErrInvalidFault = errors.New("transfer fault is invalid")

Functions

func BoundaryCancellation

func BoundaryCancellation(err error) error

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

func CauseOf(err error) error

CauseOf returns the diagnostic cause of a direct *BoundaryError, or err itself.

func Compare

func Compare(left, right Fault) int

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

func IsCancellation(ctx context.Context, err error) bool

IsCancellation reports whether caller context or an immediate collaborator result represents cancellation rather than a classified fault.

func IsSessionTerminal added in v0.1.6

func IsSessionTerminal(err error) bool

IsSessionTerminal reports whether err represents terminal protocol-session teardown.

func JoinErrors added in v0.1.6

func JoinErrors(candidates ...error) error

JoinErrors reduces candidates and returns a typed-nil-safe error.

func ReduceBoundaryErrorSet

func ReduceBoundaryErrorSet(candidates ...error) error

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

func ReduceBoundaryErrors(ctx context.Context, candidates ...error) error

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.

func Wrap

func Wrap(value Fault, cause error) error

Wrap wraps cause with a validated transfer fault for collaborator boundaries.

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

func Normalize(ctx context.Context, err error, classify func(error) (Fault, bool)) *BoundaryError

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 (
	CatalogUnavailable CatalogCode = iota + 1
	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 Domain

type Domain uint8

Domain identifies the collaborator whose contract produced a fault.

const (
	DomainSource Domain = iota + 1
	DomainCatalog
	DomainSession
	DomainOutput
	DomainCheckpoint
)

func (Domain) String

func (domain Domain) 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

func ClassifyContent(err error) (Fault, bool)

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

func FaultOf(err error) Fault

FaultOf returns the Fault carried by a direct *BoundaryError, or zero.

func Join

func Join(faults ...Fault) Fault

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 NewOutput

func NewOutput(scope Scope, code OutputCode) (Fault, error)

func NewSession

func NewSession(scope Scope, code SessionCode) (Fault, error)

func NewSource

func NewSource(scope Scope, code SourceCode) (Fault, error)

func (Fault) CatalogCode

func (fault Fault) CatalogCode() (CatalogCode, bool)

func (Fault) CheckpointCode

func (fault Fault) CheckpointCode() (CheckpointCode, bool)

func (Fault) Code

func (fault Fault) Code() uint16

func (Fault) Domain

func (fault Fault) Domain() Domain

func (Fault) IsZero

func (fault Fault) IsZero() bool

func (Fault) OutputCode

func (fault Fault) OutputCode() (OutputCode, bool)

func (Fault) Scope

func (fault Fault) Scope() Scope

func (Fault) SessionCode

func (fault Fault) SessionCode() (SessionCode, bool)

func (Fault) SourceCode

func (fault Fault) SourceCode() (SourceCode, bool)

func (Fault) String

func (fault Fault) String() string

func (Fault) Valid

func (fault Fault) Valid() 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.

const (
	ScopeFileLocal Scope = iota + 1
	ScopeDirectoryLocal
	ScopeOutputPause
	ScopeSessionTerminal
)

func (Scope) String

func (scope Scope) String() string

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 (
	SourceUnavailable SourceCode = iota + 1
	SourceRevisionChanged
	SourceRevisionInvalidated
	SourcePermanent
)

func (SourceCode) String

func (code SourceCode) String() string

Jump to

Keyboard shortcuts

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