Documentation
¶
Overview ¶
Package execution reserves a worktree for one executor before it mutates runtime state or resources. A retained ownership record requires explicit reconciliation even after the OS has released a crashed process's lock.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConflictError ¶
ConflictError reports an active owner or abandoned execution awaiting reconciliation. Owner can be nil during an owner's metadata publication.
func (*ConflictError) Code ¶
func (*ConflictError) Code() string
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
func (*ConflictError) Unwrap ¶
func (e *ConflictError) Unwrap() error
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
func Acquire ¶
Acquire immediately rejects a competing execution, including one in the same process. It never modifies the previous owner's marker on rejection.
func FromContext ¶
func (*Lease) Abandon ¶
Abandon unlocks the worktree while preserving the recovery record. It never grants another execution permission to proceed without reconciliation. Use RequireRecovery while the current owner still has finalization work to do.
func (*Lease) Release ¶
Release clears the ownership record and unlocks the worktree. The caller must have confirmed resource cleanup first, or called RequireRecovery to preserve the record. A Release after Abandon leaves its recovery marker intact.
func (*Lease) RequireRecovery ¶
func (l *Lease) RequireRecovery()
RequireRecovery marks cleanup incomplete without unlocking the worktree. Call this before writing final status or restoring an enclosing operation's temporary environment. It immediately prevents borrowing this lease for more execution; Release retains the recovery marker once finalization is complete.
type Option ¶
type Option func(*options)
func WithRecovery ¶
WithRecovery permits replacing a retained owner only after reconcile returns nil. The callback runs while holding the worktree lock and must establish that resources left by the previous execution no longer conflict. A dead PID alone cannot establish this: children and external resources can outlive it.
type Owner ¶
type Owner struct {
Token string `json:"token"`
PID int `json:"pid"`
Worktree string `json:"worktree"`
Target string `json:"target,omitempty"`
Mode string `json:"mode,omitempty"`
Kind string `json:"kind,omitempty"`
AcquiredAt time.Time `json:"acquiredAt"`
}
Owner identifies the execution responsible for a worktree. Acquire supplies Token, PID, Worktree and AcquiredAt; callers describe Target, Mode and Kind. This record deliberately contains no runtime environment or credentials.