feat(kugetsu): add lock mechanism for worktree coordination #96

Merged
shoko merged 1 commits from feat/issue-71-lock-mechanism-v2 into main 2026-04-02 04:52:45 +02:00
Owner

Summary

Fix for #71 - Lock mechanism for worktree coordination.

Changes

Add lock mechanism to prevent concurrent access to worktrees:

  • Add LOCKS_DIR constant (~/.kugetsu/locks)
  • Add acquire_lock() - acquires lock file with PID, session_id, timestamp
  • Add release_lock() - releases lock if held by current process
  • Add release_all_locks() - releases all locks for a session
  • Add check_lock() - check if issue is locked
  • Modify cmd_start to acquire lock before creating worktree
  • Modify cmd_destroy to release lock when destroying session
  • Add trap for cleanup on EXIT/INT/TERM

Lock files named after issue ref. Stale lock detection: if PID no longer exists, lock is considered stale.

Fixes #71

## Summary Fix for #71 - Lock mechanism for worktree coordination. ## Changes Add lock mechanism to prevent concurrent access to worktrees: - Add LOCKS_DIR constant (~/.kugetsu/locks) - Add acquire_lock() - acquires lock file with PID, session_id, timestamp - Add release_lock() - releases lock if held by current process - Add release_all_locks() - releases all locks for a session - Add check_lock() - check if issue is locked - Modify cmd_start to acquire lock before creating worktree - Modify cmd_destroy to release lock when destroying session - Add trap for cleanup on EXIT/INT/TERM Lock files named after issue ref. Stale lock detection: if PID no longer exists, lock is considered stale. Fixes #71
shoko added 1 commit 2026-04-02 04:20:38 +02:00
Add lock mechanism to prevent concurrent access to worktrees:
- Add LOCKS_DIR constant (~/.kugetsu/locks)
- Add acquire_lock() - acquires lock file with PID, session_id, timestamp
- Add release_lock() - releases lock if held by current process
- Add release_all_locks() - releases all locks for a session
- Add check_lock() - check if issue is locked
- Modify cmd_start to acquire lock before creating worktree
- Modify cmd_destroy to release lock when destroying session
- Add trap for cleanup on EXIT/INT/TERM

Lock files named after issue ref. Stale lock detection: if PID
no longer exists, lock is considered stale.

Fixes #71
shoko force-pushed feat/issue-71-lock-mechanism-v2 from 59061a9c03 to 990bc46477 2026-04-02 04:52:26 +02:00 Compare
shoko merged commit 8a72509452 into main 2026-04-02 04:52:45 +02:00
Sign in to join this conversation.