fix(state): wire PID lock into mutating commands - #157
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 8 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
- Improved acquireLock error message to be clearer: 'another sharekit process is running (PID <N>) — retry after it finishes, or delete ~/.sharekit/.lock if stale' - Wired lock acquisition/release into: install, update, rollback, uninstall - Lock is acquired at function entry (after initial checks) and released in finally block (guarantees release on error) - Read-only commands (preview, inspect, list, search, scan, init) remain unlocked per design - Added comprehensive lock tests: live-PID detection, stale-lock cleanup, successful release, directory creation - All gates pass: typecheck, test, format:check
Replace /proc/<pid> check (Linux-only, breaks on macOS) with process.kill(pid, 0) which works cross-platform: - EPERM: process is alive but not owned by us - ESRCH: process is dead - Other errors: treat as dead Also handle non-numeric PIDs as stale (corrupted lock files). Update test suite: - Live-PID test now unconditionally throws on all platforms - Added test for non-numeric/corrupted lock content - All tests pass on both macOS and Linux
0552577 to
e4c1e8d
Compare
Summary
This completes issue #148 by wiring the existing
acquireLock()/releaseLock()primitives into all state-mutating commands. Previously, these functions existed but had zero call sites, leaving concurrent install/update/rollback/uninstall operations vulnerable to read-modify-write races oninstalled.jsonand backup directories.Changes
another sharekit process is running (PID <N>) — retry after it finishes, or delete ~/.sharekit/.lock if staleinstall()— acquires lock at entry, releases in finally blockupdate()— same patternrollback()— same patternuninstall()— same patternTesting
Notes
~/.sharekit/.lock(constantLOCK_FILEin state.ts)/proc/<pid>on Linux; on macOS (no/proc), any lock is treated as stale and cleaned