Context
Follow-up from PR #133 (Story #92) code review. The lock mechanism for preventing concurrent KB installations was marked as incomplete in the story DoD and was not implemented in the PR.
Problem
Multiple concurrent pair install or pair update commands could interfere with each other, potentially causing:
- Corrupted KB installation (partial writes)
- Race conditions in temp file cleanup
- Inconsistent registry state
Proposed Solution
Implement lock file mechanism at target location:
- Lock file:
.pair/.install-lock at target directory
- Acquire: Before starting install/update operations
- Release: After completion (success or failure)
- Timeout: Fail fast if lock held > 30s (stale lock detection)
- Error message: Clear message when operation blocked by concurrent process
Acceptance Criteria
Technical Notes
Location: apps/pair-cli/src/kb-manager/lock-manager.ts
Interface:
interface LockManager {
acquire(targetDir: string): Promise<LockHandle>
release(handle: LockHandle): Promise<void>
isLocked(targetDir: string): Promise<boolean>
}
Implementation approach:
- Use
fs.writeFile with exclusive flag for atomic lock creation
- Store PID in lock file for diagnostics
- Check lock file mtime for staleness detection
Priority
Low - Concurrent usage unlikely in MVP (single-user CLI tool), but good practice for robustness.
Related
Context
Follow-up from PR #133 (Story #92) code review. The lock mechanism for preventing concurrent KB installations was marked as incomplete in the story DoD and was not implemented in the PR.
Problem
Multiple concurrent
pair installorpair updatecommands could interfere with each other, potentially causing:Proposed Solution
Implement lock file mechanism at target location:
.pair/.install-lockat target directoryAcceptance Criteria
Technical Notes
Location:
apps/pair-cli/src/kb-manager/lock-manager.tsInterface:
Implementation approach:
fs.writeFilewith exclusive flag for atomic lock creationPriority
Low - Concurrent usage unlikely in MVP (single-user CLI tool), but good practice for robustness.
Related