state

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package state stores local-only skeeper operational state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bypass added in v0.2.0

type Bypass struct {
	Time    time.Time `json:"time"`
	Env     string    `json:"env"`
	MainSHA string    `json:"main_sha"`
	Reason  string    `json:"reason"`
}

Bypass records an audited strict-hook bypass.

type Store

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

Store manages local transaction and bypass journals under .git/skeeper.

func New

func New(dir string) *Store

New returns a Store rooted at dir.

func (*Store) Abort added in v0.2.0

func (s *Store) Abort(ctx context.Context, id string) error

Abort removes a transaction before main index mutation.

func (*Store) Begin added in v0.2.0

func (s *Store) Begin(ctx context.Context, tx Transaction) error

Begin stores a new active transaction and rejects concurrent transactions.

func (*Store) Bypass added in v0.2.0

func (s *Store) Bypass(ctx context.Context) (Bypass, bool, error)

Bypass returns the latest audited bypass if one exists.

func (*Store) ClearBypass added in v0.2.0

func (s *Store) ClearBypass(ctx context.Context) error

ClearBypass removes the bypass journal.

func (*Store) Complete added in v0.2.0

func (s *Store) Complete(ctx context.Context, id string) error

Complete removes a completed transaction.

func (*Store) Current added in v0.2.0

func (s *Store) Current(ctx context.Context) (Transaction, bool, error)

Current returns the active transaction if one exists.

func (*Store) MarkPhase added in v0.2.0

func (s *Store) MarkPhase(ctx context.Context, id string, phase TransactionPhase) error

MarkPhase advances an active transaction phase.

func (*Store) RecordBypass added in v0.2.0

func (s *Store) RecordBypass(ctx context.Context, bypass Bypass) error

RecordBypass writes the latest audited bypass.

type Transaction added in v0.2.0

type Transaction struct {
	ID               string           `json:"id"`
	Kind             string           `json:"kind"`
	Phase            TransactionPhase `json:"phase"`
	Root             string           `json:"root"`
	Targets          []string         `json:"targets,omitempty"`
	Namespaces       []string         `json:"namespaces,omitempty"`
	MainIndexMutated bool             `json:"main_index_mutated"`
	CreatedAt        time.Time        `json:"created_at"`
	UpdatedAt        time.Time        `json:"updated_at"`
}

Transaction records a resumable multi-step operation.

type TransactionPhase added in v0.2.0

type TransactionPhase string

TransactionPhase identifies a durable mutating operation phase.

const (
	// TransactionPhasePlanned records a plan before side effects.
	TransactionPhasePlanned TransactionPhase = "planned"
	// TransactionPhaseSidecarPushed records that sidecar content is durable remotely.
	TransactionPhaseSidecarPushed TransactionPhase = "sidecar_pushed"
	// TransactionPhaseMainIndexMutated records that the main Git index was mutated.
	TransactionPhaseMainIndexMutated TransactionPhase = "main_index_mutated"
	// TransactionPhaseLockStaged records that skeeper.lock was written and staged.
	TransactionPhaseLockStaged TransactionPhase = "lock_staged"
)

func (TransactionPhase) Valid added in v0.2.0

func (p TransactionPhase) Valid() bool

Valid reports whether phase is part of the transaction state machine.

type TransactionStore added in v0.2.0

type TransactionStore interface {
	Begin(ctx context.Context, tx Transaction) error
	Current(ctx context.Context) (Transaction, bool, error)
	MarkPhase(ctx context.Context, id string, phase TransactionPhase) error
	Complete(ctx context.Context, id string) error
	Abort(ctx context.Context, id string) error
}

TransactionStore persists active transaction state.

Jump to

Keyboard shortcuts

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