lifecycle

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package lifecycle contains durable primitives for repo and workspace lifecycle operations.

Index

Constants

View Source
const (
	// SchemaVersion is the lifecycle operation journal schema version.
	SchemaVersion = 1
	// PhaseConsumed marks an operation that should no longer appear as pending.
	PhaseConsumed = "consumed"
)

Variables

This section is empty.

Functions

func CheckCWDOutsideAffectedTree

func CheckCWDOutsideAffectedTree(req CWDSafetyRequest) error

CheckCWDOutsideAffectedTree fails closed if cwd is lexically or physically inside a tree that will be moved or deleted.

func ConsumeOperation

func ConsumeOperation(repoRoot, operationID string) error

ConsumeOperation removes a completed lifecycle journal record from the pending list.

func MoveSameFilesystemNoOverwrite

func MoveSameFilesystemNoOverwrite(sourcePath, destinationPath string) error

MoveSameFilesystemNoOverwrite moves sourcePath to destinationPath using the platform no-overwrite atomic rename primitive. Cross-filesystem moves fail closed so callers do not accidentally fall back to copy+delete semantics.

func OperationPath

func OperationPath(repoRoot, operationID string) (string, error)

OperationPath returns the journal path for a lifecycle operation ID.

func OperationsDir

func OperationsDir(repoRoot string) string

OperationsDir returns the lifecycle journal directory for repoRoot.

func SameFilesystem

func SameFilesystem(sourcePath, destinationParent string) (bool, error)

SameFilesystem reports whether sourcePath and destinationParent are on the same filesystem device.

func WriteOperation

func WriteOperation(repoRoot string, record OperationRecord) error

WriteOperation validates and atomically writes a lifecycle journal record.

Types

type CWDSafetyRequest

type CWDSafetyRequest struct {
	CWD             string
	AffectedRoot    string
	SafeNextCommand string
}

CWDSafetyRequest describes a mutation that would move or delete AffectedRoot.

type OperationRecord

type OperationRecord struct {
	SchemaVersion          int            `json:"schema_version"`
	OperationID            string         `json:"operation_id"`
	OperationType          string         `json:"operation_type"`
	RepoID                 string         `json:"repo_id"`
	Phase                  string         `json:"phase"`
	RecommendedNextCommand string         `json:"recommended_next_command"`
	CreatedAt              time.Time      `json:"created_at"`
	UpdatedAt              time.Time      `json:"updated_at"`
	LastError              string         `json:"last_error,omitempty"`
	Metadata               map[string]any `json:"metadata,omitempty"`
}

OperationRecord is the durable lifecycle journal record stored as JSON under .jvs/lifecycle/operations/<operation-id>.json.

func ListPendingOperations

func ListPendingOperations(repoRoot string) ([]OperationRecord, error)

ListPendingOperations returns all non-consumed lifecycle journal records in a stable creation-time order.

func ReadOperation

func ReadOperation(repoRoot, operationID string) (OperationRecord, error)

ReadOperation reads one lifecycle journal record by operation ID.

type UnsafeCWDError

type UnsafeCWDError struct {
	CWD             string
	AffectedRoot    string
	SafeNextCommand string
	Cause           error
}

UnsafeCWDError carries the user-facing safe command while remaining comparable with errclass.ErrLifecycleUnsafeCWD.

func (*UnsafeCWDError) As

func (e *UnsafeCWDError) As(target any) bool

func (*UnsafeCWDError) Error

func (e *UnsafeCWDError) Error() string

func (*UnsafeCWDError) Is

func (e *UnsafeCWDError) Is(target error) bool

Jump to

Keyboard shortcuts

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