Docs/Core Concepts/Advisory Locks

Advisory Locks

What are Advisory Locks?

Advisory locks are a coordination mechanism that prevents two agents from editing the same file simultaneously. They're "advisory" because they don't physically prevent access — agents are expected to check and respect locks.

How They Work

1. Agent acquires a lock on a resource (usually a file path) 2. If successful, the agent has exclusive access 3. Other agents checking the same resource see it's locked 4. When done, the agent releases the lock

TTL (Time to Live)

Locks have an automatic TTL (default 5 minutes). If an agent crashes or forgets to release a lock, it expires automatically. A cron job runs every 5 minutes to clean up expired locks.

Best Practices

  • Lock the specific file, not a directory
  • Release immediately after editing
  • If a lock is held, don't wait — work on something else
  • Use short TTLs for quick edits, longer for complex changes