datalifecycle

package
v0.10.257 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package datalifecycle manages cr's durable local data retention.

Index

Constants

View Source
const (
	// LiveRetention is the default retention window for live review runs.
	LiveRetention = 90 * 24 * time.Hour
	// DryRunRetention is the default retention window for dry-run review runs.
	DryRunRetention = 7 * 24 * time.Hour
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Layout    statepaths.Layout
	Store     Store
	Now       func() time.Time
	RemoveAll RemoveAllFunc
	Progress  ProgressReporter
}

Options contains lifecycle operation dependencies.

type OrphanItem

type OrphanItem struct {
	Path  string
	Bytes int64
}

OrphanItem describes one unreferenced artifact directory.

type ProgressReporter added in v0.9.177

type ProgressReporter interface {
	Start(op, target string) ProgressSpan
}

ProgressReporter records lifecycle sub-steps without depending on a specific CLI surface.

type ProgressSpan added in v0.9.177

type ProgressSpan interface {
	End(error)
}

ProgressSpan completes one lifecycle progress event.

type PruneOptions

type PruneOptions struct {
	OlderThan time.Duration
	KeepLast  *int
	DryRun    bool
	Retention RetentionPolicy
}

PruneOptions selects runs to prune.

type PruneResult

type PruneResult struct {
	DryRun         bool
	SelectedRuns   []RunItem
	DeletedRuns    []RunItem
	OrphansRemoved []OrphanItem
	Warnings       []string
}

PruneResult summarizes one prune operation.

func Prune

func Prune(ctx context.Context, opts Options, prune PruneOptions) (PruneResult, error)

Prune deletes selected ledger rows first, then best-effort artifact dirs.

type PurgeResult

type PurgeResult struct {
	DataRoot string
	DryRun   bool
	Removed  bool
}

PurgeResult summarizes a whole data-root purge.

func Purge

func Purge(layout statepaths.Layout, dryRun bool, yes bool, removeAll RemoveAllFunc) (PurgeResult, error)

Purge removes the whole data root without opening the ledger database.

type RemoveAllFunc

type RemoveAllFunc func(string) error

RemoveAllFunc removes a path recursively.

type RetentionPolicy added in v0.1.36

type RetentionPolicy struct {
	LiveMaxAge  time.Duration
	LiveForever bool
	// DryRunMaxAge is an internal policy override for callers that own dry-run
	// lifecycle separately from profile config. The zero value uses DryRunRetention.
	DryRunMaxAge time.Duration
}

RetentionPolicy controls the built-in no-selector retention windows.

type RunItem

type RunItem struct {
	RunID        string
	PostMode     ledger.PostMode
	StartedAt    time.Time
	ArtifactPath string
}

RunItem describes one selected or deleted ledger run.

type Stats

type Stats struct {
	DataRoot      string
	LedgerPath    string
	RunsRoot      string
	RunCount      int
	LiveRuns      int
	DryRunRuns    int
	OutcomeCounts map[ledger.Outcome]int
	OldestStarted *time.Time
	NewestStarted *time.Time
	ArtifactBytes int64
	OrphanCount   int
	OrphanBytes   int64
}

Stats summarizes local durable data.

func Show

func Show(ctx context.Context, opts Options) (Stats, error)

Show returns current data lifecycle stats.

type Store

type Store interface {
	ListRuns(context.Context) ([]ledger.Run, error)
	DeleteRun(context.Context, string) error
}

Store is the ledger behavior required by data lifecycle operations.

Jump to

Keyboard shortcuts

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