Skip to main content

Module lock

Module lock 

Source
Expand description

File-based lock to prevent concurrent devflow advance invocations for the same phase.

Creates .devflow/lock-{phase:02} with the PID of the lock holder. Uses O_EXCL for atomic acquisition — if the file already exists, the lock is contended.

The lock is scoped per-phase (not per-project): advance() holds it across a gate’s multi-day blocking wait, and every phase run ends at a mandatory Ship gate, so a project-wide lock would starve devflow parallel’s sibling phases with no retry (CR-03, 13-REVIEW.md).

Structs§

LockGuard
Guard that releases the lock file on drop.

Enums§

LockError
Errors produced by lock operations.

Functions§

acquire
Acquire an exclusive lock for the given project root and phase.
acquire_project
Acquire the short-held, project-wide lock that serializes mutations of the primary checkout (version-bump commits/tags, docs commits, branch integration/cleanup) across concurrently finishing phases (13-DEFERRED-CR-03 fix shape #3).
acquire_project_blocking
Blocking variant of acquire_project: waits out a sibling phase’s short critical section, polling with backoff up to timeout. Returns the last Contended error if the sibling still holds the lock at the deadline — after timeout of waiting the holder is more likely wedged than slow, and failing loudly beats mutating the checkout concurrently.
holder
Check whether a lock is currently held for this project/phase, returning the PID of the holder if the file exists.
remove_stale_locks
Remove this project’s per-phase lock files, skipping any whose recorded holder PID is still alive — deleting a live holder’s lock would let a duplicate advance acquire it, after which the original holder’s LockGuard::Drop deletes the NEW holder’s file.