Skip to content

[Bug]: Knowledge-base watcher stores sync time instead of source mtime #649

Description

@BunnyTeddy

Problem

The automatic MemorySyncManager path for files under knowledge_base/ calls LongTermMemoryStore.index_file() without the file's source mtime. index_file() therefore defaults the database files.mtime value to the current sync time. The direct memory ingest path already passes the document mtime, so watcher-indexed documents behave inconsistently.

This makes file freshness metadata inaccurate and can distort retrieval recency scoring for older documents.

Reproduction

  1. Create knowledge_base/old.md and set its filesystem mtime to a timestamp well in the past.
  2. Start MemorySyncManager (or wait for its watcher to index the file).
  3. Read the stored mtime with LongTermMemoryStore.get_file_mtimes(["knowledge_base/old.md"]).
  4. Observe that it is close to the sync time rather than the source file's mtime.

Expected behavior

Automatic knowledge-base synchronization passes the source file mtime to index_file(), matching ingest_document(), so the persisted metadata reflects the document on disk.

Acceptance criteria

  • Initial and watcher-driven knowledge-base indexing pass the file's filesystem mtime to index_file().
  • A regression test proves the captured mtime equals the source file mtime.
  • Existing memory-file sync, public APIs, persistence schema, and migrations remain unchanged.
  • No network or provider dependency is required by the test.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: memoryDurable memory, embeddings, retrieval, and storagepriority: p3Low priority: minor issue, polish, or backlog workstatus: needs reviewImplementation exists and needs maintainer reviewtype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions