File Locking prevents multiple agents from editing the same file simultaneously. When an agent locks a file, other agents are blocked from modifying it until the lock is released. Locks are tied to tasks and auto-release after inactivity.
Before editing any file, an agent must acquire a lock via the acs_lock_file tool. The lock is registered in ETS for fast lookups and tied to the agent's current task. When the task is released, all associated locks are released automatically.
1. Agent → acs_lock_file(agent_id, task_id, "lib/foo.ex")
→ Lock acquired — safe to edit
2. Agent edits lib/foo.ex
→ No other agent can lock this file
3. Agent → acs_release_work(agent_id, task_id)
→ All task locks released automatically| Tool | Description |
|---|---|
acs_lock_file | Acquire an exclusive lock on a file path |
acs_unlock_file | Release a file lock (single or all for a task) |
acs_get_locked_files | View all currently locked files |