-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Summary
Support session-isolated dirty-file tracking to prevent interference between concurrent Claude sessions editing the same project.
Problem
Currently, dirty files are tracked in a single shared file: .claude/auto-memory/dirty-files
When multiple Claude sessions run concurrently on the same project:
- Session A edits
file1.py-> appends to dirty-files - Session B edits
file2.py-> appends to dirty-files - Session A's stop hook triggers memory update for both files (including B's changes)
- Session B may see empty dirty-files (if A cleared it) or trigger duplicate processing
This causes:
- Sessions processing files they didn't edit
- Race conditions on file reads/writes
- Duplicate or missed memory updates
- Unpredictable behavior in multi-session workflows
Proposed Solution
Use session-specific dirty-file tracking:
.claude/auto-memory/
dirty-files-{session_id_1}
dirty-files-{session_id_2}
...
Implementation steps:
- Check if Claude provides a session identifier via environment variable (e.g.,
CLAUDE_SESSION_ID) - Modify
post-tool-use.pyto write to session-specific file - Modify
stop.pyto read only the current session's dirty file - Add cleanup for stale session files (sessions that terminated without cleanup)
Considerations
- Session ID availability: Need to verify Claude exposes a session identifier
- Stale file cleanup: Sessions may crash without clearing their dirty files
- Backwards compatibility: Handle upgrade path from single-file to session-aware format
Affected Files
scripts/post-tool-use.py- dirty file writesscripts/stop.py- dirty file readsagents/memory-updater.md- may need session context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels