lockfile

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 8 Imported by: 0 modules, 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 lockfile implements the exclusive cross-host Delivery lock (PRD §14): one active Delivery coordinator per repository across both hosts. The lock is the existence of .orchestrator/delivery.lock, created with O_EXCL so acquisition is atomic on every supported OS.

The 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

View Source
const Path = ".orchestrator/delivery.lock"

Path is the repo-relative location of the Delivery lock file.

View Source
const SchemaVersion = 1

SchemaVersion is the lock-file schema this build reads and writes.

Variables

View Source
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

func Acquire(repoRoot string, o Owner) error

Acquire atomically creates the lock file recording o. If the lock already exists — even unreadable — it returns an error wrapping ErrHeld and changes nothing.

func PIDAlive

func PIDAlive(pid int) bool

PIDAlive reports whether a process with the given PID currently exists. EPERM counts as alive: the process exists but belongs to another user. Advisory only — PIDs are reused, and the acquiring orch process is expected to exit during a healthy Delivery run.

func Release

func Release(repoRoot string) error

Release removes the lock file. A missing lock is not an error, so Release is idempotent.

Types

type Owner

type Owner struct {
	SchemaVersion int       `json:"schema_version"`
	RunID         string    `json:"run_id"`
	Host          string    `json:"host"` // "claude" or "codex"
	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.

func Inspect

func Inspect(repoRoot string) (*Owner, error)

Inspect returns the current owner, (nil, nil) when no lock exists, or an error when the lock exists but cannot be trusted. Callers must treat an error as "cannot verify, deny" (fail closed).

Jump to

Keyboard shortcuts

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