Skip to content

SWF(bug): refresh conversation LRU order on writes - #11

Merged
maplepaladin73 merged 2 commits into
mainfrom
devin/1794943739-conversation-lru-writes
Nov 17, 2026
Merged

maplepaladin73 merged 2 commits into
mainfrom
devin/1794943739-conversation-lru-writes

Conversation

@maplepaladin73

@maplepaladin73 maplepaladin73 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Summary

Writing to a conversation (update_metadata, add_items, remove_item) now refreshes its LRU position, so a full store evicts the least recently used conversation instead of the one just written.

Root cause: get() refreshes both last_access and the eviction queue (Inner::order), but the three write paths refreshed only last_access. Capacity eviction pops from order, not by timestamp, so a written conversation kept its stale queue position. With capacity 2: create A, create B, write A, create C → A was evicted, B survived. This breaks the store's documented read-and-write LRU contract.

Fix: the queue update get() already does is pulled into Inner::touch_lru() and called by get() and by each successful write. remove_item calls it only when an item was actually removed, matching where it already updates last_access. The diff touches only this bug; duplicate item IDs after delete and TTL on item delete are fixed in separate PRs.

Test plan

Regression test write_refreshes_lru!, one test per write (capacity 2: create A, create B, write A, create C; A must survive and B must be evicted).

Before the fix (test commit only):

test conversation_store::tests::remove_item_refreshes_lru ... FAILED
test conversation_store::tests::update_metadata_refreshes_lru ... FAILED
test conversation_store::tests::add_items_refreshes_lru ... FAILED
written conversation was evicted
test result: FAILED. 0 passed; 3 failed; 0 ignored; 0 measured; 3160 filtered out

After the fix:

test conversation_store::tests::remove_item_refreshes_lru ... ok
test conversation_store::tests::update_metadata_refreshes_lru ... ok
test conversation_store::tests::add_items_refreshes_lru ... ok
test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 3160 filtered out

Whole conversation store suite, no regressions: test result: ok. 9 passed; 0 failed.

Try it:

ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo test -p spark-server refreshes_lru

(The test binary links NCCL/cuBLAS. On a host without CUDA libraries, point LIBRARY_PATH/LD_LIBRARY_PATH at them first.)

  • cargo fmt --all -- --check
  • ATLAS_SKIP_BUILD=1 CUDARC_CUDA_VERSION=13000 cargo clippy --workspace --tests (the blueprint lint chain, ending with typos, exited 0)
  • bash scripts/check-license-headers.sh (4163 valid, 0 invalid)
  • Tested against a real model / hardware: not done. The change is CPU-only store bookkeeping, covered by unit tests.
  • Added or updated tests where applicable

Notes for reviewers

Not tested: a live server run on real hardware. conversation_store.rs is 408 lines, under the 500-line cap.

CLA


Software Factory opened this PR for Robert
Implemented in session Refresh conversation LRU order on writes
Review with Devin · Open in Devin Desktop


maplepaladin73 and others added 2 commits November 17, 2026 19:32
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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 705abee into main Nov 17, 2026
1 check passed
maplepaladin73 added a commit that referenced this pull request Nov 29, 2026
…-and-p3-guards

spark-model(hy4): add chunk-aligned prefix caching (P2 #7) and process guards (P3 #10, #11)
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