Skip to content

SWF(bug): keep conversation item ids unique after an item is deleted - #9

Merged
maplepaladin73 merged 1 commit into
mainfrom
devin/1794943731-conversation-item-id-seq
Nov 17, 2026
Merged

maplepaladin73 merged 1 commit into
mainfrom
devin/1794943731-conversation-item-id-seq

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

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_items minted ids as item_<conv>_<items.len() + i>. After remove_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, and remove_item(_1) deletes both B and C.

Fix: Conversation gets a private next_item_seq field. create sets it to the number of initial items, add_items mints ids from it and advances it, and removal never changes it, so a minted id is never handed out twice. Client-supplied ids are still preserved by stamp_id, and LRU/TTL behaviour is unchanged.

Test plan

New regression test add_items_after_removal_keeps_ids_unique reproduces the scenario above.

Before the fix (test commit applied to unfixed code):

---- conversation_store::tests::add_items_after_removal_keeps_ids_unique stdout ----
panicked at crates/spark-server/src/conversation_store.rs:348:9:
assertion `left != right` failed
  left: String("item_cd7702fa-18f5-4b6b-85b2-63089bb73dfc_1")
 right: "item_cd7702fa-18f5-4b6b-85b2-63089bb73dfc_1"

test result: FAILED. 6 passed; 1 failed; 0 ignored; 0 measured; 3154 filtered out

After the fix:

test conversation_store::tests::add_items_after_removal_keeps_ids_unique ... ok
test conversation_store::tests::ttl_evicts ... ok

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 3154 filtered out

Try it (on a GPU-less host, run bash scripts/ci_gpu_stubs.sh once first so the test binary links):

ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server conversation_store
  • cargo fmt --all -- --check
  • ATLAS_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)
  • typos
  • Added a regression test
  • Real model / hardware: not run. This is an in-memory store change with no GPU path.

Notes 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.


Software Factory opened this PR for Robert
Implemented in session Fix duplicate conversation item IDs after delete
Review with Devin · Open in Devin Desktop


Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@maplepaladin73
maplepaladin73 merged commit 499d328 into main Nov 17, 2026
1 check passed
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