Skip to content

Preserve updated Q after cache eviction - #17

Open
Frankie-Xu wants to merge 1 commit into
MemTensor:mainfrom
Frankie-Xu:fix/q-cache-eviction-metadata
Open

Frankie-Xu wants to merge 1 commit into
MemTensor:mainfrom
Frankie-Xu:fix/q-cache-eviction-metadata

Conversation

@Frankie-Xu

Copy link
Copy Markdown

MemoryService keeps both a fast _q_cache and a _mem_cache of memory objects. After a successful Q update, FIFO eviction can remove an ID from _q_cache; the next retrieval then falls back to that memory object's stale metadata.q_value and silently loses the learned value.

Synchronize the cached memory metadata after a successful non-None single or batch update. This keeps the existing in-process fallback consistent after Q-cache eviction without changing the Q-learning formula, FIFO policy, retrieval scoring, or cross-process behavior. Storage failures and unsuccessful updates do not mutate either cache.

Validation:

  • On main c1b322c, the new single and batch eviction regressions fail (-0.5/0.5 learned values fall back to 0.0); failure and snapshot tests pass.
  • With this patch, 4 unittest cases pass; the same 4 pass under pytest and from a clean git archive export.
  • Coverage includes single and batch updates, FIFO eviction, negative and zero Q values, persistence failure without cache pollution, and q-cache snapshot round-trip.
  • Tests execute the real MemoryService retrieval/update and QValueUpdater paths with only MemOS import types, in-memory persistence, and fixed embeddings substituted.
  • compileall and git diff --check pass.

No live MemOS integration, cross-process consistency, concurrency redesign, or benchmark run is claimed. This is independent of PR #14's finite-value validation and PR #16's single-update Q-cache publication.

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