Expand description
Envelope-aware wrapper around the
socket_patch_core::patch::apply_lock advisory lock.
Mutating subcommands (apply, rollback, repair, remove) all
need the same shape: acquire the lock at the top of run, on
contention emit a JSON envelope with errorCode: "lock_held" (or
stderr in human mode) and exit 1. This module centralises that
emission so the four call sites stay one line each.
The lock itself is in socket-patch-core (cross-crate, also used
by tests). This module is the CLI-side glue that knows how to
render the failure through the shared crate::json_envelope.
Structs§
- Lock
Acquired - Outcome of a successful lock acquisition. Callers attach a
lock_brokenevent to their own envelope whenbroke_lockis true, so the audit trail follows the same conventions as the rest of the command’s output.
Constants§
- LOCK_
BROKEN_ CODE - Stable
errorCodetag emitted as aSkippedwarning event when--break-lockactually deletes a pre-existing lock file. Exposed for downstream consumers and integration tests that pattern-match on it.
Functions§
- acquire_
or_ emit - Try to acquire
<socket_dir>/apply.lockand return the guard, or emit a failure envelope and a non-zero exit code. - lock_
broken_ event - Build the warning event that callers attach to their envelope
when
LockAcquired::broke_lockis true. Artifact-level (no PURL) since the action targets the.socket/directory itself, not a specific package. - record_
lock_ broken - Convenience: record the
lock_brokenwarning event on an envelope. Mirrors the inline pattern at each call site so we don’t drift on the action / errorCode pair.