Documentation
¶
Overview ¶
Package lockfile implements both Delivery locks from PRD §14: the run-spanning Delivery lock and the process-scoped mutation serializer. The run lock is the existence of .orchestrator/delivery.lock, created with O_EXCL so acquisition is atomic on every supported OS.
The run lock deliberately outlives the acquiring process: a Delivery run spans many short-lived orch invocations plus a host agent session, so the recorded PID is advisory and its death is never treated as staleness. There is no automatic takeover; recovery is always the explicit human action `orch abort` (PRD §15). A lock file that exists but cannot be read still denies acquisition (fail closed).
Index ¶
Constants ¶
const Path = ".orchestrator/delivery.lock"
Path is the repo-relative location of the Delivery lock file.
const SchemaVersion = 1
SchemaVersion is the lock-file schema this build reads and writes.
Variables ¶
var ErrHeld = errors.New("delivery lock is already held")
ErrHeld reports that the Delivery lock is already held. Callers test for it with errors.Is.
Functions ¶
func Acquire ¶
Acquire atomically creates the lock file recording o. If the lock already exists — even unreadable — it returns an error wrapping ErrHeld and changes nothing.
Types ¶
type Mutation ¶ added in v0.11.0
type Mutation struct {
// contains filtered or unexported fields
}
Mutation holds the process-scoped lock that serializes mutating Delivery commands. Release must be deferred immediately after a successful AcquireMutation and called from the acquiring goroutine. On Windows that goroutine stays pinned to the owning OS thread until Release.
func AcquireMutation ¶ added in v0.11.0
AcquireMutation blocks until no other process is running a mutating Delivery command for repoRoot and no other same-process acquisition is held. The operating system owns the underlying repository-scoped lock, so process exit releases it without staleness detection or takeover.
type Owner ¶
type Owner struct {
SchemaVersion int `json:"schema_version"`
RunID string `json:"run_id"`
Host string `json:"host"` // "claude", "codex", or "opencode"
Hostname string `json:"hostname"`
PID int `json:"pid"`
AcquiredAt time.Time `json:"acquired_at"`
}
Owner identifies who acquired the lock. Hostname and PID exist for audit and diagnostics only: the acquiring process is expected to exit while its Delivery run legitimately continues.