Repository navigation
SWF(bug): keep conversation item ids unique after an item is deleted - #9
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
5 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Conversation items appended after a delete could reuse an existing item's id; ids now come from a per-conversation counter that only moves forward.
Root cause:
ConversationStore::add_itemsminted ids asitem_<conv>_<items.len() + i>. Afterremove_item,items.len()shrinks, so the next index is one that is already in use. Example: create A (_0) and B (_1), delete A, append C. C also gets_1. Then GET-by-id returns B, andremove_item(_1)deletes both B and C.Fix:
Conversationgets a privatenext_item_seqfield.createsets it to the number of initial items,add_itemsmints ids from it and advances it, and removal never changes it, so a minted id is never handed out twice. Client-suppliedids are still preserved bystamp_id, and LRU/TTL behaviour is unchanged.Test plan
New regression test
add_items_after_removal_keeps_ids_uniquereproduces the scenario above.Before the fix (test commit applied to unfixed code):
After the fix:
Try it (on a GPU-less host, run
bash scripts/ci_gpu_stubs.shonce first so the test binary links):ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server conversation_storecargo fmt --all -- --checkATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests(the deny-warnings level comes from[workspace.lints])bash scripts/check-license-headers.sh(4163 valid, 0 invalid)typosNotes for reviewers
The diff covers only this bug. Sibling PRs handle LRU refresh on writes and TTL on item delete in the same file. Not tested: the end-to-end HTTP Conversations API against a running server.
Implemented in session Fix duplicate conversation item IDs after delete
Review with Devin · Open in Devin Desktop