Skip to content

fix(storage): Skip locked conversations during sanitization#567

Merged
JeanMertz merged 1 commit intomainfrom
prr133
Apr 16, 2026
Merged

fix(storage): Skip locked conversations during sanitization#567
JeanMertz merged 1 commit intomainfrom
prr133

Conversation

@JeanMertz
Copy link
Copy Markdown
Collaborator

During workspace sanitization, invalid conversation directories are normally trashed. However, this creates a race condition when two processes are running concurrently: process A creates a conversation directory (e.g. for QUERY_MESSAGE.md while the editor is open) but hasn't persisted metadata.json yet, and process B's sanitization deletes it because it looks invalid.

To fix this, a new is_conversation_locked method is added to Storage, which returns true if a live (non-orphaned) lock file exists for a given conversation ID. During sanitization, any invalid conversation directory that is currently locked is skipped with a debug-level log entry instead of being trashed.

During workspace sanitization, invalid conversation directories are
normally trashed. However, this creates a race condition when two
processes are running concurrently: process A creates a conversation
directory (e.g. for `QUERY_MESSAGE.md` while the editor is open) but
hasn't persisted `metadata.json` yet, and process B's sanitization
deletes it because it looks invalid.

To fix this, a new `is_conversation_locked` method is added to
`Storage`, which returns `true` if a live (non-orphaned) lock file
exists for a given conversation ID. During sanitization, any invalid
conversation directory that is currently locked is skipped with a
`debug`-level log entry instead of being trashed.

Signed-off-by: Jean Mertz <git@jeanmertz.com>
@JeanMertz JeanMertz merged commit d8f9ebc into main Apr 16, 2026
13 checks passed
@JeanMertz JeanMertz deleted the prr133 branch April 16, 2026 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant