state

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 11 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 HydrationFile added in v0.2.1

type HydrationFile struct {
	SidecarBlob string `json:"sidecar_blob,omitempty"`
	SHA256      string `json:"sha256"`
	Size        int64  `json:"size"`
}

HydrationFile records the sidecar blob and content digest for one hydrated file.

type HydrationJournal added in v0.2.1

type HydrationJournal struct {
	Version      int                           `json:"version"`
	SourceBranch string                        `json:"source_branch"`
	Namespaces   map[string]HydrationNamespace `json:"namespaces"`
	UpdatedAt    time.Time                     `json:"updated_at"`
}

HydrationJournal records the sidecar blobs last materialized into the main worktree.

type HydrationNamespace added in v0.2.1

type HydrationNamespace struct {
	LockCommit string                   `json:"lock_commit"`
	Files      map[string]HydrationFile `json:"files"`
}

HydrationNamespace records one namespace's last hydrated lock commit.

type RescueCandidate added in v0.2.1

type RescueCandidate struct {
	Path  string
	Class string
}

RescueCandidate describes a file that should be moved into rescue.

type RescueFile added in v0.2.1

type RescueFile struct {
	OriginalPath string `json:"original_path"`
	RescuePath   string `json:"rescue_path"`
	SHA256       string `json:"sha256"`
	Bytes        int64  `json:"bytes"`
	Class        string `json:"class,omitempty"`
}

RescueFile records one rescued file.

type RescueManifest added in v0.2.1

type RescueManifest struct {
	ID        string       `json:"id"`
	CreatedAt time.Time    `json:"created_at"`
	Operation string       `json:"operation"`
	Root      string       `json:"root"`
	Files     []RescueFile `json:"files"`
}

RescueManifest records files moved aside before prune or overwrite operations.

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) CreateRescue added in v0.2.1

func (s *Store) CreateRescue(
	ctx context.Context,
	root string,
	operation string,
	candidates []RescueCandidate,
) (RescueManifest, error)

CreateRescue moves candidates from root into a new rescue directory.

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) ListRescues added in v0.2.1

func (s *Store) ListRescues(ctx context.Context) ([]RescueManifest, error)

ListRescues returns every rescue manifest, newest first.

func (*Store) LoadHydration added in v0.2.1

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

LoadHydration returns the current hydration journal if it 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.

func (*Store) RestoreRescue added in v0.2.1

func (s *Store) RestoreRescue(
	ctx context.Context,
	root string,
	id string,
	paths []string,
	overwrite bool,
) (RescueManifest, error)

RestoreRescue restores paths from one rescue manifest.

func (*Store) WriteHydration added in v0.2.1

func (s *Store) WriteHydration(ctx context.Context, journal HydrationJournal) error

WriteHydration replaces the local hydration journal atomically.

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