configrestore

package
v0.0.0-...-89d81dd Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package configrestore turns one successful generation staging result into a deterministic set of concrete target actions, verified pre-mutation snapshots, and durable transaction records. It does not mutate targets.

Index

Constants

View Source
const (
	RegistryTypeSZ       uint32 = 1
	RegistryTypeExpandSZ uint32 = 2
	RegistryTypeDWORD    uint32 = 4
)

Registry value type numbers match the Windows registry API. Keeping the raw type and bytes allows rollback to reproduce values without lossy string conversion and keeps the read interface portable for tests.

Variables

View Source
var ErrPublicationAmbiguous = errors.New("journal publication outcome is ambiguous")

ErrPublicationAmbiguous marks a fail-stop result: publication returned an error and the destination could not subsequently be proven absent or equal to the intended immutable record. Callers must not infer that rollback is safe from this error.

View Source
var ErrRecoveryRequired = errors.New("config restore recovery required")

ErrRecoveryRequired marks a durable pending transaction that could not be proven restored. Callers must not begin new config mutation after this error.

View Source
var ErrStoreMemberReverted = errors.New("config restore store member already reverted")

ErrStoreMemberReverted reports that a generation member has already been durably consumed and must not mutate its targets again.

Functions

func PreflightAppClosure

func PreflightAppClosure(
	ctx context.Context,
	required bool,
	patterns []string,
	observer ProcessObserver,
) error

PreflightAppClosure observes process basenames and rejects a declared match. It never starts, stops, signals, or otherwise mutates a process.

Types

type Action

type Action struct {
	Kind     ActionKind
	Strategy string
	Source   string
	Target   string

	SourceMode        os.FileMode
	SourceIsDirectory bool
	Exclude           []string
	DesiredContent    []byte
	RegistryValue     *RegistryValue
	SnapshotRequired  bool
	// contains filtered or unexported fields
}

Action is one exact target operation. SnapshotRequired is unconditional for every action; legacy RestoreDef.Backup is intentionally ignored.

type ActionKind

type ActionKind string

ActionKind is a concrete operation understood by the later transaction layer. Declarative merge/append/glob strategies no longer remain here.

const (
	ActionCopy        ActionKind = "copy"
	ActionWriteFile   ActionKind = "write-file"
	ActionDeleteFile  ActionKind = "delete-file"
	ActionRegistrySet ActionKind = "registry-set"
)

type Code

type Code string

Code is a stable machine-readable materialization or preflight failure.

const (
	CodeInvalidRequest          Code = "invalid_request"
	CodeUnsupportedRestore      Code = "unsupported_restore"
	CodeUnsafePath              Code = "unsafe_path"
	CodeSourceMissing           Code = "source_missing"
	CodeUnsupportedFileType     Code = "unsupported_file_type"
	CodeTargetOverlap           Code = "target_overlap"
	CodeValidationMapping       Code = "validation_mapping"
	CodeInvalidRegistryTarget   Code = "invalid_registry_target"
	CodeInvalidRegistryValue    Code = "invalid_registry_value"
	CodeMalformedJSON           Code = "malformed_json"
	CodeMaterialization         Code = "materialization_failed"
	CodeAppClosureConfig        Code = "app_closure_config"
	CodeProcessObservation      Code = "process_observation_failed"
	CodeAppRunning              Code = "app_running"
	CodeBackupFailed            Code = "backup_failed"
	CodeJournalIntentFailed     Code = "journal_intent_failed"
	CodeJournalCompletionFailed Code = "journal_completion_failed"
)

func CodeOf

func CodeOf(err error) Code

CodeOf extracts a configrestore Code from err.

type Error

type Error struct {
	Code            Code
	ActionIndex     int
	ValidationIndex int
	MappingCount    int
	Target          string
	ProcessBasename string
	ProcessPattern  string
	Err             error
}

Error identifies the exact declarative item that failed. Indices are zero-based and remain -1 when a failure is not tied to one declaration.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type GenerationRevertAction

type GenerationRevertAction struct {
	Index      int
	Kind       ActionKind
	Target     string
	BackupUsed bool
}

GenerationRevertAction reports one concrete action restored to its prior state. Actions are ordered exactly as the reverse execution occurred.

type GenerationRevertResult

type GenerationRevertResult struct {
	ActionCount int
	Actions     []GenerationRevertAction
}

GenerationRevertResult reports the concrete actions restored for one member.

type Guard

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

Guard is the live config-mutation capability. It retains the process-wide store lock from pending recovery through journal completion.

func BeginLive

func BeginLive(ctx context.Context, stateDir, runID string, registry RegistryMutator) (*Guard, error)

BeginLive acquires the global config-mutation lock for stateDir, recovers every pending generation transaction, and returns while retaining the lock.

func BeginLiveWithBoundary

func BeginLiveWithBoundary(
	ctx context.Context,
	stateDir, runID string,
	registry RegistryMutator,
	boundary HostBoundary,
) (*Guard, error)

BeginLiveWithBoundary retains an optional host authority across pending recovery, live transaction creation, and later generation revert.

func (*Guard) ActiveStoreRuns

func (g *Guard) ActiveStoreRuns(ctx context.Context) ([]*StoreRun, error)

ActiveStoreRuns returns newest-first runs whose members have not been reverted. Members within each run are ordered by ascending mutation ordinal.

func (*Guard) Close

func (g *Guard) Close() error

Close releases the process-wide mutation lock. It is idempotent.

func (*Guard) CreateTransactionRoot

func (g *Guard) CreateTransactionRoot(captureID string) (string, error)

CreateTransactionRoot creates one immutable store descriptor and returns the safe root consumed by snapshot and journal preparation.

func (*Guard) DiscardTransactionRoot

func (g *Guard) DiscardTransactionRoot(root string) error

DiscardTransactionRoot removes a preallocated transaction only while it has no durable journal intent. Once intent exists, recovery/history owns it.

func (*Guard) LegacyJournalConsumed

func (g *Guard) LegacyJournalConsumed(ctx context.Context, path string) (bool, error)

LegacyJournalConsumed reports whether the exact current bytes at path are already bound to a durably consumed legacy member. It never registers new history and is used to exclude completed standalone journals from ordering.

func (*Guard) LegacyMemberRevertRoot

func (g *Guard) LegacyMemberRevertRoot(ctx context.Context, member *StoreMember) (string, error)

LegacyMemberRevertRoot returns the stable engine-owned work directory for a registered legacy journal. Repeated calls return the same directory; a consumed member returns ErrStoreMemberReverted and cannot be replayed.

func (*Guard) MarkLegacyMemberReverted

func (g *Guard) MarkLegacyMemberReverted(ctx context.Context, member *StoreMember) error

MarkLegacyMemberReverted durably consumes a registered legacy member after the command layer has successfully reverted its verified journal.

func (*Guard) PrepareLegacyMemberRevert

func (g *Guard) PrepareLegacyMemberRevert(ctx context.Context, member *StoreMember) (string, []byte, error)

PrepareLegacyMemberRevert returns a stable engine-owned work directory and the exact registered journal bytes whose digest was verified under the live restore lease. Callers execute only these pinned bytes, never an earlier or later read of the mutable journal path.

func (*Guard) RegisterLegacyJournal

func (g *Guard) RegisterLegacyJournal(path string) (*StoreMember, error)

RegisterLegacyJournal binds an existing legacy journal to the current restore run at the next mutation ordinal.

func (*Guard) RevertGenerationMember

func (g *Guard) RevertGenerationMember(ctx context.Context, member *StoreMember) (*GenerationRevertResult, error)

RevertGenerationMember restores one committed generation transaction to its exact prior state and only then publishes its immutable consumption record.

type HostBoundary

type HostBoundary interface {
	ResolveHostPath(authored string, instance modules.ConfigInstance) (string, error)
	ResolveFilesystemIdentity(identity string) (string, error)
	ProjectFilesystemIdentity(absolute string) (string, error)
	ValidateFilesystemTarget(absolute string) error
}

HostBoundary is the optional operating-system authority used by validation runs. The core config-restore package deliberately knows nothing about the validation-mode implementation that supplies it.

type JournalAction

type JournalAction struct {
	Index             int                `json:"index"`
	Kind              ActionKind         `json:"kind"`
	Strategy          string             `json:"strategy"`
	Target            string             `json:"target"`
	RegistryKey       string             `json:"registryKey"`
	RegistryValueName string             `json:"registryValueName"`
	MissingParents    []string           `json:"missingParents"`
	Prior             JournalActionState `json:"prior"`
	Desired           JournalActionState `json:"desired"`
	SourceDigest      string             `json:"sourceDigest"`
}

JournalAction is one ordered concrete transaction action without staged bytes or a mutable source path.

type JournalActionState

type JournalActionState struct {
	Kind       StateKind                `json:"kind"`
	Digest     string                   `json:"digest"`
	Mode       uint32                   `json:"mode"`
	BackupPath string                   `json:"backupPath"`
	Entries    []JournalFilesystemEntry `json:"entries"`
}

JournalActionState is the canonical prior or desired state recorded for an action. Mode contains portable permission bits as an unsigned integer.

type JournalFilesystemEntry

type JournalFilesystemEntry struct {
	Path        string    `json:"path"`
	Kind        StateKind `json:"kind"`
	Mode        uint32    `json:"mode"`
	Size        int64     `json:"size"`
	ContentHash string    `json:"contentHash"`
}

JournalFilesystemEntry is a stable, per-entry filesystem identity used by recovery to distinguish prior, desired, and partially applied tree states.

type JournalIntent

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

JournalIntent is an immutable, verified view of a pending intent. The transaction root is private so terminal writers cannot be redirected.

func PersistJournalIntent

func PersistJournalIntent(ctx context.Context, request JournalIntentRequest) (*JournalIntent, error)

PersistJournalIntent durably publishes one immutable pending intent before any target mutation. An identical existing intent is returned idempotently.

func ReadJournalIntent

func ReadJournalIntent(ctx context.Context, transactionRoot string) (*JournalIntent, error)

ReadJournalIntent reads and verifies the canonical pending intent beneath a safe transaction root.

func ReadJournalIntentWithBoundary

func ReadJournalIntentWithBoundary(ctx context.Context, transactionRoot string, boundary HostBoundary) (*JournalIntent, error)

ReadJournalIntentWithBoundary verifies semantic durable identities against the current optional host authority before reading snapshot artifacts.

func (*JournalIntent) Actions

func (i *JournalIntent) Actions() []JournalAction

func (*JournalIntent) Digest

func (i *JournalIntent) Digest() string

func (*JournalIntent) Lineage

func (i *JournalIntent) Lineage() JournalLineage

func (*JournalIntent) Path

func (i *JournalIntent) Path() string

func (*JournalIntent) State

func (i *JournalIntent) State() JournalState

func (*JournalIntent) Validations

func (i *JournalIntent) Validations() []JournalValidation

type JournalIntentRequest

type JournalIntentRequest struct {
	Prepared        *PreparedSet
	TransactionRoot string
	Lineage         JournalLineage
}

JournalIntentRequest persists one already-verified PreparedSet beneath the same caller-owned transaction root used for its snapshots.

type JournalLineage

type JournalLineage struct {
	RunID                       string   `json:"runId"`
	CaptureID                   string   `json:"captureId"`
	ModuleID                    string   `json:"moduleId"`
	ConfigSetID                 string   `json:"configSetId"`
	TargetInstanceID            string   `json:"targetInstanceId"`
	SourceGeneration            string   `json:"sourceGeneration"`
	TargetGeneration            string   `json:"targetGeneration"`
	MigrationPath               []string `json:"migrationPath"`
	SourceGenerationFingerprint string   `json:"sourceGenerationFingerprint"`
	CaptureModuleRevision       string   `json:"captureModuleRevision"`
	RestoreModuleRevision       string   `json:"restoreModuleRevision"`
}

JournalLineage binds one transaction to immutable capture and trusted restore-catalog identities.

type JournalMarker

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

JournalMarker is an immutable, verified terminal marker bound to its verified pending intent and private transaction root.

func PersistAbortedMarker

func PersistAbortedMarker(ctx context.Context, intent *JournalIntent) (*JournalMarker, error)

PersistAbortedMarker durably closes a pending intent when the engine proves that it performed no target mutation. The journal uses the rolled_back terminal state with rollbackOutcome=not_required; envelope status remains failed rather than rolled_back.

func PersistCommittedMarker

func PersistCommittedMarker(ctx context.Context, intent *JournalIntent) (*JournalMarker, error)

PersistCommittedMarker durably records a validated completed transaction.

func PersistRolledBackMarker

func PersistRolledBackMarker(
	ctx context.Context,
	intent *JournalIntent,
	validation ValidationStatus,
) (*JournalMarker, error)

PersistRolledBackMarker durably records a completely proven rollback. An incomplete rollback must not call this function and leaves the intent pending.

func (*JournalMarker) Actions

func (m *JournalMarker) Actions() []JournalAction

func (*JournalMarker) Digest

func (m *JournalMarker) Digest() string

func (*JournalMarker) IntentDigest

func (m *JournalMarker) IntentDigest() string

func (*JournalMarker) Lineage

func (m *JournalMarker) Lineage() JournalLineage

func (*JournalMarker) Path

func (m *JournalMarker) Path() string

func (*JournalMarker) RollbackOutcome

func (m *JournalMarker) RollbackOutcome() RollbackOutcome

func (*JournalMarker) State

func (m *JournalMarker) State() JournalState

func (*JournalMarker) ValidationStatus

func (m *JournalMarker) ValidationStatus() ValidationStatus

func (*JournalMarker) Validations

func (m *JournalMarker) Validations() []JournalValidation

type JournalState

type JournalState string

JournalState is the closed durable transaction-state vocabulary. An incomplete rollback leaves the state pending for recovery.

const (
	JournalPending    JournalState = "pending"
	JournalCommitted  JournalState = "committed"
	JournalRolledBack JournalState = "rolled_back"
)

type JournalValidation

type JournalValidation struct {
	Type     string `json:"type"`
	Path     string `json:"path"`
	JSONPath string `json:"jsonPath"`
	Section  string `json:"section"`
	Key      string `json:"key"`
	HostPath string `json:"hostPath"`
}

JournalValidation is one resolved final-target validation in declaration order. Empty primitive-specific fields remain explicit in canonical JSON.

type JournalWriter

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

JournalWriter owns private durability checkpoints used by failure tests.

func NewJournalWriter

func NewJournalWriter() *JournalWriter

func (*JournalWriter) PersistAborted

func (w *JournalWriter) PersistAborted(ctx context.Context, intent *JournalIntent) (*JournalMarker, error)

func (*JournalWriter) PersistCommitted

func (w *JournalWriter) PersistCommitted(ctx context.Context, intent *JournalIntent) (*JournalMarker, error)

func (*JournalWriter) PersistIntent

func (w *JournalWriter) PersistIntent(ctx context.Context, request JournalIntentRequest) (*JournalIntent, error)

PersistIntent is PersistJournalIntent with private failure checkpoints.

func (*JournalWriter) PersistRolledBack

func (w *JournalWriter) PersistRolledBack(
	ctx context.Context,
	intent *JournalIntent,
	validation ValidationStatus,
) (*JournalMarker, error)

type MaterializedSet

type MaterializedSet struct {
	Actions     []Action
	Validations []configvalidate.ResolvedValidation
	// contains filtered or unexported fields
}

MaterializedSet is safe to pass to a future backup/journal/commit layer. Its actions are ordered deterministically and contain no unresolved glob or merge operation.

func Materialize

func Materialize(ctx context.Context, request Request) (*MaterializedSet, error)

Materialize performs read-only preflight and resolves every selected restore declaration into concrete actions. It creates no backups or journals and performs no target mutation.

type PreparedAction

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

PreparedAction is opaque so callers cannot mutate the action or state that the later journal and commit layers will consume.

func (PreparedAction) Action

func (a PreparedAction) Action() Action

func (PreparedAction) Desired

func (a PreparedAction) Desired() StateRecord

func (PreparedAction) MissingParents

func (a PreparedAction) MissingParents() []string

func (PreparedAction) Prior

func (a PreparedAction) Prior() StateRecord

func (PreparedAction) SourceDigest

func (a PreparedAction) SourceDigest() string

type PreparedSet

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

PreparedSet is the only output accepted by later transaction phases. Its accessors return copies so the verified plan cannot be changed in place.

func PrepareSnapshots

func PrepareSnapshots(ctx context.Context, request SnapshotRequest) (*PreparedSet, error)

PrepareSnapshots uses a default preparer. Tests that need deterministic failure checkpoints use SnapshotPreparer.Prepare directly.

func (*PreparedSet) Actions

func (s *PreparedSet) Actions() []PreparedAction

func (*PreparedSet) SnapshotRoot

func (s *PreparedSet) SnapshotRoot() string

func (*PreparedSet) Validations

func (s *PreparedSet) Validations() []configvalidate.ResolvedValidation

type ProcessObserver

type ProcessObserver interface {
	RunningProcessBasenames(context.Context) ([]string, error)
}

ProcessObserver provides a read-only point-in-time process snapshot. The interface deliberately exposes no stop or kill capability.

type ProcessObserverFunc

type ProcessObserverFunc func(context.Context) ([]string, error)

ProcessObserverFunc adapts a function to ProcessObserver.

func (ProcessObserverFunc) RunningProcessBasenames

func (f ProcessObserverFunc) RunningProcessBasenames(ctx context.Context) ([]string, error)

type RecoveryError

type RecoveryError struct {
	TransactionID string
	Err           error
}

RecoveryError identifies the transaction that remains pending.

func (*RecoveryError) Error

func (e *RecoveryError) Error() string

func (*RecoveryError) Unwrap

func (e *RecoveryError) Unwrap() []error

type RegistryMutator

type RegistryMutator interface {
	RegistryReader
	SetValue(context.Context, string, string, uint32, []byte) error
	DeleteValue(context.Context, string, string) error
}

RegistryMutator performs exact named-value mutations. SetValue and DeleteValue must complete the OS mutation before returning; the transaction engine immediately rereads and verifies the raw type and bytes.

type RegistryReadResult

type RegistryReadResult struct {
	Exists    bool
	ValueType uint32
	Data      []byte
}

RegistryReadResult is an exact read-only snapshot of one named value.

type RegistryReader

type RegistryReader interface {
	ReadValue(context.Context, string, string) (RegistryReadResult, error)
}

RegistryReader reads one HKCU named value. It intentionally exposes no registry mutation capability.

type RegistryReaderFunc

type RegistryReaderFunc func(context.Context, string, string) (RegistryReadResult, error)

RegistryReaderFunc adapts a function to RegistryReader.

func (RegistryReaderFunc) ReadValue

func (f RegistryReaderFunc) ReadValue(ctx context.Context, key, valueName string) (RegistryReadResult, error)

type RegistryValue

type RegistryValue struct {
	Key       string
	ValueName string
	ValueType string
	Data      string
}

RegistryValue is one normalized HKCU named-value desired state.

type Request

type Request struct {
	Stage    *migration.StageResult
	Plan     planner.PlanSet
	Boundary HostBoundary

	ProcessPatterns []string
	ProcessObserver ProcessObserver
}

Request binds a successful disposable stage to the planner-pinned target generation. ProcessPatterns must come from the same trusted catalog snapshot as Plan; bundle data must never populate them.

type RollbackOutcome

type RollbackOutcome string

RollbackOutcome records whether rollback was needed and proven. Failed rollback has no terminal marker and therefore leaves the intent pending.

const (
	RollbackNotAttempted RollbackOutcome = "not_attempted"
	RollbackNotRequired  RollbackOutcome = "not_required"
	RollbackSucceeded    RollbackOutcome = "succeeded"
)

type SnapshotPreparer

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

SnapshotPreparer owns optional internal checkpoints used by failure tests.

func NewSnapshotPreparer

func NewSnapshotPreparer() *SnapshotPreparer

func (*SnapshotPreparer) Prepare

func (p *SnapshotPreparer) Prepare(ctx context.Context, request SnapshotRequest) (result *PreparedSet, resultErr error)

Prepare snapshots and verifies every prior/desired state before publishing one immutable PreparedSet. It never mutates a restore target.

type SnapshotRequest

type SnapshotRequest struct {
	Set             *MaterializedSet
	TransactionRoot string
	RegistryReader  RegistryReader
	Boundary        HostBoundary
}

SnapshotRequest identifies one materialized set and an existing, caller-owned transaction root beneath which snapshots are published.

type StateEntry

type StateEntry struct {
	Path        string
	Kind        StateKind
	Mode        os.FileMode
	Size        int64
	ContentHash string
}

StateEntry is one canonical filesystem manifest entry. Registry and absent states have an empty manifest.

type StateKind

type StateKind string

StateKind is the canonical kind represented by a prior or desired digest.

const (
	StateAbsent        StateKind = "absent"
	StateFile          StateKind = "file"
	StateDirectory     StateKind = "directory"
	StateRegistryValue StateKind = "registry-value"
)

type StateRecord

type StateRecord struct {
	Kind       StateKind
	Digest     string
	Mode       os.FileMode
	BackupPath string
	// contains filtered or unexported fields
}

StateRecord is an immutable-by-value summary of one prior or desired state. BackupPath is empty when the prior filesystem target was absent.

func (StateRecord) Entries

func (s StateRecord) Entries() []StateEntry

type StoreActionInspection

type StoreActionInspection struct {
	Index          int
	Kind           ActionKind
	Status         StoreActionStatus
	Strategy       string
	SourceIdentity string
	SourceDigest   string
	TargetIdentity string
	PriorDigest    string
	DesiredDigest  string
	PriorKind      StateKind
	DesiredKind    StateKind
	Backup         StoreBackupInspection
}

StoreActionInspection records only the durable facts available in a generation journal. Filesystem identities are opaque digests, never paths.

type StoreActionStatus

type StoreActionStatus string

StoreActionStatus is a closed legacy restore outcome vocabulary.

const (
	StoreActionStatusFailed               StoreActionStatus = "failed"
	StoreActionStatusInstalled            StoreActionStatus = "installed"
	StoreActionStatusRestored             StoreActionStatus = "restored"
	StoreActionStatusSkipped              StoreActionStatus = "skipped"
	StoreActionStatusSkippedMissingSource StoreActionStatus = "skipped_missing_source"
	StoreActionStatusSkippedUpToDate      StoreActionStatus = "skipped_up_to_date"
)

type StoreBackupInspection

type StoreBackupInspection struct {
	Exists   bool
	Identity string
	Digest   string
	Kind     StateKind
	Mode     uint32
}

type StoreInspection

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

StoreInspection is an immutable, value-only view of one closed config restore store. Callers must hold an exclusive writer lease for the whole inspection; the inspector never opens, creates, or acquires mutation.lock.

func InspectStore

func InspectStore(root string, exclusiveLease bool) (*StoreInspection, error)

InspectStore validates the existing config-restore/v1 store without writing to it. exclusiveLease is an explicit caller precondition: a concurrent writer makes the evidence invalid, and passing false is always rejected.

func InspectStoreWithBoundary

func InspectStoreWithBoundary(root string, exclusiveLease bool, boundary HostBoundary) (*StoreInspection, error)

InspectStoreWithBoundary resolves projected legacy journal identities under the caller's already-authorized host boundary without acquiring any lock.

func (StoreInspection) MemberCount

func (s StoreInspection) MemberCount() int

func (StoreInspection) Runs

func (StoreInspection) TransactionCount

func (s StoreInspection) TransactionCount() int

type StoreLineageInspection

type StoreLineageInspection struct {
	RunID                       string
	CaptureID                   string
	ModuleID                    string
	ConfigSetID                 string
	TargetInstanceID            string
	SourceGeneration            string
	TargetGeneration            string
	SourceGenerationFingerprint string
	CaptureModuleRevision       string
	RestoreModuleRevision       string
	// contains filtered or unexported fields
}

StoreLineageInspection contains only schema-recorded identity facts.

func (StoreLineageInspection) MigrationPath

func (l StoreLineageInspection) MigrationPath() []string

type StoreMember

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

StoreMember is an opaque, read-only capability returned by ActiveStoreRuns.

func (*StoreMember) CaptureID

func (m *StoreMember) CaptureID() string

func (*StoreMember) Kind

func (m *StoreMember) Kind() StoreMemberKind

func (*StoreMember) LegacyJournalPath

func (m *StoreMember) LegacyJournalPath() string

func (*StoreMember) Ordinal

func (m *StoreMember) Ordinal() uint64

type StoreMemberInspection

type StoreMemberInspection struct {
	Kind                  StoreMemberKind
	ID                    string
	Ordinal               uint64
	CaptureID             string
	DescriptorDigest      string
	MemberDigest          string
	IntentDigest          string
	TerminalDigest        string
	TerminalState         JournalState
	ValidationStatus      ValidationStatus
	RollbackOutcome       RollbackOutcome
	Reverted              bool
	RevertDigest          string
	HasLineage            bool
	Lineage               StoreLineageInspection
	LegacyJournalIdentity string
	LegacyJournalDigest   string
	// contains filtered or unexported fields
}

StoreMemberInspection binds a stored generation transaction or a registered legacy journal to its closed state. Legacy members do not invent lineage that their schema did not record.

func (StoreMemberInspection) Actions

type StoreMemberKind

type StoreMemberKind string

StoreMemberKind distinguishes an engine-owned generation transaction from a registered legacy journal in one restore run.

const (
	StoreMemberGeneration StoreMemberKind = "generation"
	StoreMemberLegacy     StoreMemberKind = "legacy"
)

type StoreRun

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

StoreRun groups active members produced beneath one BeginLive restore run.

func (*StoreRun) ID

func (r *StoreRun) ID() string

func (*StoreRun) Members

func (r *StoreRun) Members() []*StoreMember

func (*StoreRun) RunID

func (r *StoreRun) RunID() string

func (*StoreRun) StartedAt

func (r *StoreRun) StartedAt() time.Time

type StoreRunInspection

type StoreRunInspection struct {
	ID           string
	RunID        string
	StartedAtUTC string
	// contains filtered or unexported fields
}

StoreRunInspection is one restore run reconstructed from immutable store records. It deliberately contains no store or host filesystem path.

func (StoreRunInspection) Members

type TransactionError

type TransactionError struct {
	Reason   TransactionReason
	Primary  error
	Rollback error
}

TransactionError retains the primary failure while making an incomplete rollback inspectable without replacing that primary cause.

func (*TransactionError) Error

func (e *TransactionError) Error() string

func (*TransactionError) Unwrap

func (e *TransactionError) Unwrap() error

type TransactionExecutor

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

func NewTransactionExecutor

func NewTransactionExecutor() *TransactionExecutor

func (*TransactionExecutor) Execute

type TransactionObservation

type TransactionObservation struct {
	Stage           TransactionStage
	Progress        TransactionProgress
	ActionIndex     int
	ValidationIndex int
	Target          string
	Reason          TransactionReason
	Err             error
}

TransactionObservation is one ordered execution observation. Unused indices are -1. Observer failures cannot alter transaction control flow.

type TransactionObserver

type TransactionObserver interface {
	Observe(TransactionObservation)
}

type TransactionObserverFunc

type TransactionObserverFunc func(TransactionObservation)

func (TransactionObserverFunc) Observe

func (f TransactionObserverFunc) Observe(observation TransactionObservation)

type TransactionProgress

type TransactionProgress string

TransactionProgress is the closed observer progress vocabulary.

const (
	TransactionProgressStarted   TransactionProgress = "started"
	TransactionProgressCompleted TransactionProgress = "completed"
	TransactionProgressFailed    TransactionProgress = "failed"
)

type TransactionReason

type TransactionReason string

TransactionReason retains the primary execution failure independently of rollback outcome.

const (
	ReasonCommitFailed            TransactionReason = "commit_failed"
	ReasonTargetValidationFailed  TransactionReason = "target_validation_failed"
	ReasonJournalCompletionFailed TransactionReason = "journal_completion_failed"
)

type TransactionRequest

type TransactionRequest struct {
	Prepared *PreparedSet
	Intent   *JournalIntent
	Registry RegistryMutator
	Observer TransactionObserver
	Boundary HostBoundary
}

TransactionRequest executes one already-prepared and durably journaled set.

type TransactionResult

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

TransactionResult is an immutable closed result. Failed and rolled-back transactions return their primary error as well; CanContinue distinguishes a safe per-set failure from a run-wide fail-stop.

func ExecuteConfigSetTransaction

func ExecuteConfigSetTransaction(ctx context.Context, request TransactionRequest) (*TransactionResult, error)

func (*TransactionResult) CanContinue

func (r *TransactionResult) CanContinue() bool

func (*TransactionResult) FailStop

func (r *TransactionResult) FailStop() bool

FailStop is true only when later config-set mutation in the run is unsafe.

func (*TransactionResult) Marker

func (r *TransactionResult) Marker() *JournalMarker

func (*TransactionResult) MutationBegan

func (r *TransactionResult) MutationBegan() bool

func (*TransactionResult) PrimaryError

func (r *TransactionResult) PrimaryError() error

func (*TransactionResult) Reason

func (*TransactionResult) RollbackError

func (r *TransactionResult) RollbackError() error

func (*TransactionResult) Status

type TransactionStage

type TransactionStage string

TransactionStage is the command-event-compatible execution stage.

const (
	TransactionStageCommit     TransactionStage = "commit"
	TransactionStageValidation TransactionStage = "validation"
	TransactionStageRollback   TransactionStage = "rollback"
)

type TransactionStatus

type TransactionStatus string

TransactionStatus is the closed single-config-set execution vocabulary.

const (
	TransactionRestored       TransactionStatus = "restored"
	TransactionFailed         TransactionStatus = "failed"
	TransactionRolledBack     TransactionStatus = "rolled_back"
	TransactionRollbackFailed TransactionStatus = "rollback_failed"
)

type ValidationStatus

type ValidationStatus string

ValidationStatus records the final-target validation position associated with an immutable journal record.

const (
	ValidationPending ValidationStatus = "pending"
	ValidationNotRun  ValidationStatus = "not_run"
	ValidationPassed  ValidationStatus = "passed"
	ValidationFailed  ValidationStatus = "failed"
)

Jump to

Keyboard shortcuts

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