transaction

package
v0.0.0-...-1f39044 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 20 Imported by: 2 modules, 1 package

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

Index

Constants

View Source
const (
	ReceiptPhaseStateCommitted = "state_committed"
	ReceiptPhaseCommitted      = "committed"
)

Variables

View Source
var ErrEnvironmentAuthority = errors.New("environment owner authority is invalid or missing")

Functions

func AuthorizeEnvironmentMutation

func AuthorizeEnvironmentMutation(state domain.StateFileV2, authority *domain.EnvironmentAuthority, action, installationID, bindingID, sourceKey string, allowCreate bool) error

AuthorizeEnvironmentMutation is the common ownership guard used by SDK and legacy CLI lifecycle paths before any managed effect. It never adopts an unmanaged binding and requires authority whenever the selected binding is environment-owned.

func ComparableStateDigest

func ComparableStateDigest(state domain.StateFileV2) (string, error)

ComparableStateDigest uses the persisted comparison used by durable state decisions without normalizing lifecycle values or receipt content.

func ComputeEnvironmentReceiptID

func ComputeEnvironmentReceiptID(environmentID, alias, clientID string) string

func DropEnvironmentReceipt

func DropEnvironmentReceipt(state *domain.StateFileV2, authority *domain.EnvironmentAuthority)

func UpsertEnvironmentReceipt

func UpsertEnvironmentReceipt(state *domain.StateFileV2, authority *domain.EnvironmentAuthority, installationID, bindingID, sourceKey, packageDigest string, profile *domain.ProfileAuthority, phase string) error

func ValidateEnvironmentRecoveryScope

func ValidateEnvironmentRecoveryScope(state domain.StateFileV2, authority *domain.EnvironmentAuthority) error

ValidateEnvironmentRecoveryScope refuses a mixed owned/foreign or indeterminate recovery before Kernel.Recover can change any journal, receipt or native intent. One typed owner must cover the complete pending scope.

Types

type DirectoryGroup

type DirectoryGroup struct {
	OperationGroupID string
	Mutations        []DirectoryMutation
	DesiredState     domain.StateFileV2
	// PostApplyVerify runs once every mutation in the group has been applied and
	// individually verified, and before the group's state commit decision. It
	// exists for verification that depends on the whole group's restored
	// filesystem state at once (for example, a native client registry that must
	// observe every reconstructed path together before any single one can be
	// confirmed). A returned error rolls back every applied mutation in the
	// group; no state or native side effect from this group is ever committed.
	PostApplyVerify func(context.Context) error
}

DirectoryGroup is one commit decision for a fully preflighted set of physical backends. Every directory is activated and verified before state is made authoritative. A failure before that decision rolls all activated directories back in reverse order.

type DirectoryMutation

type DirectoryMutation struct {
	PublicationParentAuthority *domain.ProfileAuthority
	// ExpectedPublication seals the original staged objects before releasing
	// a descendant handle for a fresh standalone publication. It is transient;
	// the directory journal retains the corresponding versioned proof.
	ExpectedPublication dirswap.PreparedPublication
	// Standalone retains an auxiliary directory receipt independently of the
	// package binding. Only fresh publication is allowed; it never replaces a
	// package or changes its materialization/native ownership.
	Standalone      bool
	OperationID     string
	InstallationID  string
	ClientBindingID string
	Sequence        int
	OwnedBase       string
	ActivePath      string
	StagingPath     string
	BeforeDigest    string
	AfterDigest     string
	NativeObjects   []domain.NativeObjectOwnership
	Activation      domain.ActivationState
	Authentication  domain.AuthenticationState
	Policy          domain.PolicyState
	Verification    domain.VerificationState
	// DesiredState is the fully validated state that becomes authoritative only
	// after the staged directory is active and verified. Keeping it in memory
	// closes the crash window that would otherwise persist "prepared" state
	// before a durable directory intent exists.
	DesiredState domain.StateFileV2
	Verify       func(context.Context, string) error
	// RequireAbsent rejects this mutation, before any journal write or
	// filesystem mutation, if ActivePath already exists. See dirswap.Input's
	// field of the same name.
	RequireAbsent bool
	// VerifyBefore proves caller ownership at the active and moved backup paths.
	VerifyBefore         func(context.Context, string) error
	EnvironmentAuthority *domain.EnvironmentAuthority
}

type DirectoryRemoval

type DirectoryRemoval struct {
	DataReceiptID    string
	ProfileOwners    []domain.PhysicalProfileOwner
	OperationGroupID string
	OperationID      string
	InstallationID   string
	ClientBindingID  string
	Sequence         int
	OwnedBase        string
	ActivePath       string
	BeforeDigest     string
	// Standalone records a removal receipt at state-file level. This is used
	// when the same commit decision removes the owning binding/installation.
	Standalone           bool
	Verify               func(context.Context, string) error
	EnvironmentAuthority *domain.EnvironmentAuthority
}

type DirectoryRemovalGroup

type DirectoryRemovalGroup struct {
	OperationGroupID string
	Removals         []DirectoryRemoval
	DesiredState     domain.StateFileV2
}

type GroupError

type GroupError struct {
	Phase GroupFailurePhase
	Err   error
}

GroupError carries the kernel's durable observation of a failed operation group. Callers must not infer rollback merely from an empty receipt slice: an empty slice can also mean that the first mutation never started.

func (*GroupError) Error

func (err *GroupError) Error() string

func (*GroupError) Unwrap

func (err *GroupError) Unwrap() error

type GroupFailurePhase

type GroupFailurePhase string
const (
	GroupFailureUnchanged  GroupFailurePhase = "managed_unchanged"
	GroupFailureRolledBack GroupFailurePhase = "managed_rolled_back"
	GroupFailureUnknown    GroupFailurePhase = "managed_commit_unknown"
	GroupFailureCommitted  GroupFailurePhase = "managed_committed"
)

func FailurePhase

func FailurePhase(err error) GroupFailurePhase

type Kernel

type Kernel struct {
	Namespace         string
	PhysicalAuthority ports.PhysicalProfileAuthority
	NativeRecovery    ports.NativeTransitionRecovery
	StateStore        StateStore
	Directory         dirswap.Manager
}

func (Kernel) ApplyDirectory

func (kernel Kernel) ApplyDirectory(ctx context.Context, mutation DirectoryMutation) (domain.MutationReceipt, error)

func (Kernel) ApplyDirectoryGroup

func (kernel Kernel) ApplyDirectoryGroup(ctx context.Context, group DirectoryGroup) ([]domain.MutationReceipt, error)

func (Kernel) Load

func (kernel Kernel) Load() (domain.StateFileV2, error)

Load implements the small state authority consumed by native recovery.

func (Kernel) PersistStateDecision

func (kernel Kernel) PersistStateDecision(before, desired domain.StateFileV2) error

PersistStateDecision gives lifecycle state writes the same visibility and durability handling as directory commit decisions.

func (Kernel) PersistStateDecisionWithDisposition

func (kernel Kernel) PersistStateDecisionWithDisposition(before, desired domain.StateFileV2) (domain.StateDecisionDisposition, error)

Only exact old visibility authorizes native restoration. Desired visibility with unresolved durability deliberately remains Unknown.

func (Kernel) PrevalidateRecovery

func (kernel Kernel) PrevalidateRecovery(ctx context.Context) error

PrevalidateRecovery is inert and covers the entire pending durability decision.

func (Kernel) Recover

func (kernel Kernel) Recover(ctx context.Context) error

func (Kernel) RemoveDirectory

func (kernel Kernel) RemoveDirectory(ctx context.Context, removal DirectoryRemoval) (domain.MutationReceipt, error)

func (Kernel) RemoveDirectoryGroup

func (kernel Kernel) RemoveDirectoryGroup(ctx context.Context, group DirectoryRemovalGroup) ([]domain.MutationReceipt, error)

type ProjectRootPublisher

type ProjectRootPublisher struct{ Kernel Kernel }

ProjectRootPublisher uses the installation's existing kernel and namespace. A committed standalone receipt owns the root after any one binding is removed. It grants no authority to replace or delete the runtime's mutable contents.

func (ProjectRootPublisher) PublishProjectRoot

func (publisher ProjectRootPublisher) PublishProjectRoot(ctx context.Context, request domain.ActivationRequest, spec ports.NativeProjectRoot) (resultErr error)

func (ProjectRootPublisher) VerifyProjectRoot

func (publisher ProjectRootPublisher) VerifyProjectRoot(ctx context.Context, root string, marker domain.NativeObjectOwnership) error

type StateStore

type StateStore interface {
	Load() (domain.StateFileV2, error)
	Save(domain.StateFileV2) error
}

Jump to

Keyboard shortcuts

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