executionstore

package
v0.158.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 15 Imported by: 1 module, 0 packages

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

Overview

Package executionstore composes immutable repository-backed execution receipts with server-private SQLite snapshot bytes and lifecycle state.

Index

Constants

View Source
const (
	DirEnv           = "DATATUG_EVIDENCE_DIR"
	DefaultDir       = ".datatug/evidence"
	DefaultByteCap   = 2 << 20
	DefaultRetention = 30 * 24 * time.Hour
)

Variables

View Source
var (
	ErrSnapshotNotFound = errors.New("snapshot not found")
	ErrUnsafePrivateDir = errors.New("private evidence directory must be outside Git and evidence repositories")
)

Functions

func ResolvePrivateDir

func ResolvePrivateDir(explicit string) (string, error)

ResolvePrivateDir selects the explicitly configured directory, then the environment override, then ~/.datatug/evidence.

Types

type Manager

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

Manager opens one Store per routed evidence store and owns their handles.

func NewManager

func NewManager(roots incidentstore.RepositoryRoots, locations map[string]incidents.StoreLocation, options Options) (*Manager, error)

func (*Manager) Close

func (m *Manager) Close() error

func (*Manager) IncidentStoreByID added in v0.28.0

func (m *Manager) IncidentStoreByID(projectID, storeID string) (incidents.APIStore, error)

IncidentStoreByID exposes the canonical incident provider already owned by this routed evidence store. Incident and execution evidence therefore share one RepositoryStore, lock, and recovery boundary.

func (*Manager) ProjectStore

func (m *Manager) ProjectStore(projectID string) (*Store, error)

ProjectStore opens the primary project-repository evidence route.

func (*Manager) RegisterProject added in v0.133.0

func (m *Manager) RegisterProject(projectID, dir string) error

RegisterProject adds a newly created, operator-rooted project without closing existing evidence stores or changing their routes. HTTP never supplies dir.

func (*Manager) RoutedStore

func (m *Manager) RoutedStore(projectID string, incident *apicontract.IncidentRef) (*Store, error)

RoutedStore selects an incident-qualified route or the project's primary route when incident is absent.

func (*Manager) Store

func (m *Manager) Store(location incidents.StoreLocation) (*Store, error)

Store opens one configured project, dedicated, or application repository.

func (*Manager) StoreByID

func (m *Manager) StoreByID(projectID, storeID string) (*Store, error)

StoreByID resolves a qualified evidence store for reads where the execution reference itself carries the route.

type Options

type Options struct {
	PrivateDir string
	ByteCap    int
	Retention  time.Duration
	Now        func() time.Time
}

Options are trusted server configuration, never request-controlled.

type Store

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

Store owns one routed repository and its private snapshot sidecar.

func (*Store) Close

func (s *Store) Close() error

func (*Store) Execution

func (*Store) Executions

func (s *Store) Executions(ctx context.Context) ([]apicontract.ExecutionRecord, error)

func (*Store) ExecutionsBounded

func (s *Store) ExecutionsBounded(ctx context.Context, limit int) ([]apicontract.ExecutionRecord, bool, error)

func (*Store) ExpireDue

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

ExpireDue deletes retained bytes and advances available snapshots to the terminal expired state. Receipts and snapshotRef remain untouched.

func (*Store) PutExecution

func (s *Store) PutExecution(ctx context.Context, record apicontract.ExecutionRecord) error

func (*Store) PutSnapshot

func (s *Store) PutSnapshot(ctx context.Context, ref apicontract.ExecutionRef, recordset apicontract.Recordset, executedAt time.Time) (snapshotRef string, stored bool, err error)

PutSnapshot stores canonical typed-row JSON when it fits the configured cap. A refusal returns stored=false and writes no lifecycle row.

func (*Store) RequireIncident

func (s *Store) RequireIncident(ctx context.Context, ref incidents.IncidentRef) error

RequireIncident proves that a client-supplied incident association resolves in the same routed repository before immutable evidence is written.

func (*Store) RollbackSnapshot

func (s *Store) RollbackSnapshot(ctx context.Context, snapshotRef string) error

RollbackSnapshot removes unpublished bytes after receipt publication fails.

func (*Store) Snapshot

func (*Store) State

func (s *Store) State(ctx context.Context, snapshotRef string) (*apicontract.SnapshotState, error)

State returns the separately stored current lifecycle state.

Jump to

Keyboard shortcuts

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