Repository navigation
fix: memory dedup race and episode end time going backwards - #44
Merged
Merged
Conversation
Two concurrent process_evidence calls with identical content for the same agent both run the ilike lookup before either commits, both pass the `if not memory` check, and both insert a Memory row and enqueue separate Qdrant upserts; if the owner then forgets one copy, the duplicate stays stored and vector-indexed, so 'forgotten' content is still recallable. Found by the GLM relay (memorygate__services__api_p1__sec__0), confirmed by 3 votes and Corti. Regression test to add: Run two concurrent process_evidence calls with identical content for the same agent and assert exactly one Memory row and one enqueued Qdrant upsert are produced, so a later forget of that memory leaves nothing recallable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The reuse query only requires occurred_start >= evidence.occurred_at - 30min, so evidence dated up to 30 minutes before the episode's start sets occurred_end < occurred_start; and if evidence.occurred_at is None (the fallback at line 59), occurred_end is wiped to None, destroying a previously stored end time. Found by the GLM relay (memorygate__services__api_p1__bugs__2), confirmed by 3 votes and Corti. Regression test to add: Add a regression test that processes evidence with occurred_at earlier than an open episode's occurred_end (and separately with occurred_at None) and asserts the episode's occurred_end is unchanged rather than overwritten with an earlier or None timestamp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Lite In Postgres `^` is exponentiation, so `hashtext(a) ^ hashtext(b)` is a float and pg_advisory_xact_lock has no overload for it. Use the two-int form instead, key it on the lowercased text (the lookup is case-insensitive), and only run it on PostgreSQL: the SQLite test database has no advisory locks and the commit broke tests/test_like_literal.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Found by the GLM bug relay, confirmed by votes, reviewed by Claude.
episode.occurred_endcould be overwritten with an earlier time orNone; it now only moves forward.Local (services/api): 406 passed; file-size and package-boundary checks ok.
🤖 Generated with Claude Code