Skip to main content

Module locks

Module locks 

Source
Expand description

File locking for concurrent agents.

When file_locking is enabled in config, agents lock files they work on to prevent concurrent writes. Locks are stored as JSON files in .mana/locks/.

Lock lifecycle:

  • Pre-emptive: mana run locks files listed in the unit’s paths field on spawn.
  • On-write: The pi extension locks files on first write (safety net).
  • Release: Locks are released when the agent finishes or is killed.

Structs§

ActiveLock
A lock with its file system path.
LockInfo
Information stored in each lock file.

Functions§

acquire
Acquire a lock on a file for a unit agent.
check_lock
Check if a file is currently locked.
clear_all
Force-clear all locks.
list_locks
List all active locks, cleaning stale ones (dead PIDs) along the way.
lock_dir
Return the locks directory, creating it if needed.
release_all_for_unit
Release all locks held by a specific unit.