-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
edge-caseEdge case scenarios and testingEdge case scenarios and testingeffort-mediumMedium effort: 2-4 hoursMedium effort: 2-4 hoursenhancementNew feature or requestNew feature or requestimpact-highHigh impact on users or systemHigh impact on users or systempost-mvpPost-MVP feature, not needed for initial releasePost-MVP feature, not needed for initial release
Description
Summary
Current implementation uses "last write wins" for concurrent access. Two CLI instances can corrupt session state when modifying the same session file simultaneously.
Current Behavior
- No file locking
- Race conditions possible
- Last write wins (may lose data)
Proposed Enhancement
Add file locking using standard libraries:
- Node.js:
proper-lockfile(npm package) - Python:
filelock(pip package)
Usage (Internal)
TypeScript:
import lockfile from 'proper-lockfile';
async saveSessionState(state: SessionState) {
const release = await lockfile.lock(targetPath);
try {
// Write file...
} finally {
await release();
}
}Python:
from filelock import FileLock
def save_session_state(state: dict) -> str:
lock = FileLock(f"{target_path}.lock")
with lock:
# Write file...Implementation
Files:
cli/src/utils/session-state-manager.tsanalyzer/src/utils/session_state_manager.py
Dependencies:
- Add
proper-lockfileto package.json - Add
filelockto requirements.txt
Trade-offs
- Adds dependencies
- Slightly slower (lock acquisition overhead)
- Benefits: Safe concurrent access, prevents corruption
Effort
~4 hours
Related
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
edge-caseEdge case scenarios and testingEdge case scenarios and testingeffort-mediumMedium effort: 2-4 hoursMedium effort: 2-4 hoursenhancementNew feature or requestNew feature or requestimpact-highHigh impact on users or systemHigh impact on users or systempost-mvpPost-MVP feature, not needed for initial releasePost-MVP feature, not needed for initial release