projectmutation

package
v0.46.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package projectmutation owns the shared mechanics of one focused project mutation. Operation packages retain validation, write order, rollback, recovery, outcome, and presentation policy.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProjectLeaseCoverage identifies a missing tracked-and-resident lease.
	ErrProjectLeaseCoverage = errors.New("project mutation requires a covering project lease")
	// ErrTrackedLeaseCoverage identifies a missing selected-checkout lease.
	ErrTrackedLeaseCoverage = errors.New("project mutation requires a covering tracked lease")
	// ErrSynchronizationAttempted identifies a second publication attempt.
	ErrSynchronizationAttempted = errors.New("project mutation synchronization already attempted")
)

Functions

func Finish

func Finish[T any](outcome T, operationErr, releaseErr error, committed func(T) bool, makePartial func(T, error, Phase) error) error

Finish joins a release result after the focused operation has classified its own failure. Committed outcomes become typed partials, while an existing partial retains both causes.

func Promote

func Promote[T any](outcome T, err error, phase Phase, committed func(T) bool, makePartial func(T, error, Phase) error) error

Promote converts a plain post-commit failure into the focused operation's typed partial result. Existing partial results remain authoritative.

Types

type Failure

type Failure struct {
	Phase Phase
	Cause error
}

Failure preserves a cause while making its retry boundary explicit.

func (*Failure) Error

func (e *Failure) Error() string

func (*Failure) Unwrap

func (e *Failure) Unwrap() error

type LeaseAcquirer

type LeaseAcquirer func(context.Context, string) (*filesystem.Lease, func() error, error)

LeaseAcquirer is the narrow injection seam for acquisition and release faults. A nil acquirer selects the scope's production acquisition.

type Partial

type Partial[T any] struct {
	Outcome  T
	Cause    error
	Recovery []string
}

Partial retains an operation-owned outcome, cause, and ordered recovery guidance without taking ownership of their policy.

func NewPartial

func NewPartial[T any](outcome T, cause error, recovery []string) Partial[T]

NewPartial constructs shared typed partial-effect plumbing for a focused operation's outcome and recovery policy.

func (*Partial[T]) Error

func (e *Partial[T]) Error() string

func (*Partial[T]) JoinCause

func (e *Partial[T]) JoinCause(err error)

JoinCause retains a later cleanup or release failure in the same typed partial result.

func (*Partial[T]) Unwrap

func (e *Partial[T]) Unwrap() error

type Phase

type Phase string

Phase identifies the mechanical boundary at which an operation stopped.

const (
	PhaseLease       Phase = "lease"
	PhaseAuthority   Phase = "authority"
	PhaseReload      Phase = "reload"
	PhasePublication Phase = "publication"
	PhaseCleanup     Phase = "cleanup"
	PhaseRelease     Phase = "release"
)

func FailurePhase

func FailurePhase(err error) (Phase, bool)

FailurePhase returns the mechanical boundary retained by err.

type Scope

type Scope uint8

Scope is the physical-root coverage selected by a focused operation.

const (
	// TrackedScope covers only the selected checkout.
	TrackedScope Scope = iota + 1
	// ProjectScope covers the selected checkout and shared resident root.
	ProjectScope
)

type Transaction

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

Transaction holds one operation-selected lease and its project loader. Callers explicitly decide when authority is loaded, mutated, reloaded, and synchronized.

func AcquireProject

func AcquireProject(ctx context.Context, root string, loader *project.Loader, acquire LeaseAcquirer) (*Transaction, error)

AcquireProject acquires the complete tracked-and-resident transaction.

func UseProject

func UseProject(ctx context.Context, root string, loader *project.Loader, lease *filesystem.Lease) (*Transaction, error)

UseProject binds an already-held complete project lease after caller-owned setup such as compatibility gating and loader construction.

func UseTracked

func UseTracked(ctx context.Context, root string, loader *project.Loader, lease *filesystem.Lease) (*Transaction, error)

UseTracked binds an already-held selected-checkout lease after caller-owned setup such as compatibility gating and loader construction.

func (*Transaction) LoadAuthority

func (t *Transaction) LoadAuthority() (*project.Session, error)

LoadAuthority opens the currently committed project authority while the operation-selected lease is held.

func (*Transaction) LoadForMutation

func (t *Transaction) LoadForMutation(files *filesystem.Handle) (*project.Session, *filesystem.ExpectedIdentity, error)

LoadForMutation selects config authority through files and retains its exact replacement identity.

func (*Transaction) Open

func (t *Transaction) Open() (*filesystem.Handle, error)

Open returns a root-confined filesystem handle for the selected project.

func (*Transaction) Release

func (t *Transaction) Release() error

Release ends the operation-selected lease and types a release fault.

func (*Transaction) Root

func (t *Transaction) Root() string

Root reports the operation-selected project root.

func (*Transaction) Scope

func (t *Transaction) Scope() Scope

Scope reports the physical-root coverage selected by the operation.

func (*Transaction) Synchronize

func (t *Transaction) Synchronize() (publisher.Result, error)

Synchronize reloads committed authority and then performs one Publisher operation under the transaction's existing complete project lease.

Jump to

Keyboard shortcuts

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