Skip to content

test: make semantic-storage timestamp filters deterministic - #1849

Open
DivyamTalwar wants to merge 1 commit into
MemMachine:mainfrom
DivyamTalwar:fix/semantic-storage-test-clock-1509
Open

DivyamTalwar wants to merge 1 commit into
MemMachine:mainfrom
DivyamTalwar:fix/semantic-storage-test-clock-1509

Conversation

@DivyamTalwar

Copy link
Copy Markdown

Purpose of the change

Semantic-storage time-filter tests currently bracket the host clock with short sleeps, while PostgreSQL and Neo4j create timestamps using their own clocks. The intended ordering therefore depends on clock agreement. This makes the tested data deterministic without changing production timestamp generation or predicates.

Description

  • Supply fixed UTC registered_at values in both history-age tests. Preserve minimum-uningested, set identity, and ingestion-state assertions; add the exact inclusive cutoff boundary.
  • Deliberately reverse episode created_at relative to registration time to prove the filter uses the intended timestamp.
  • Set timestamps only on the exact feature IDs returned by add_feature: committed SQL updates, Neo4j elementId updates, or in-memory entries. Unsupported backends fail explicitly.
  • Preserve exact <, >=, range, set, and tag expectations in all three feature-filter families.
  • Keep a separate check that an actual default-created feature receives a non-null, timezone-aware timestamp.
  • Parametrize only this test module's clock with ±24-hour offsets. No OS, database, storage-module, or event-loop clock is altered.
  • Use deterministic history IDs, as neighboring history tests do, without creating unrelated episode-store rows.

Fixes/Closes

Fixes #1724.

Type of change

  • Project Maintenance (test reliability; no production changes)

How Has This Been Tested?

Controlled regression on Linux/Python 3.12:

  • Before the patch, the original three feature-filter tests failed at both module-local clock offsets: three failures for −24 hours and three for +24 hours.
  • Updated affected in-memory cases: 13 passed, zero skipped.
  • Broader in-memory subset without unrelated episode-store fixtures: 38 passed, two existing Neo4j-specific skips.
  • Repository-wide Ruff and formatting pass; changed-file ty and whitespace checks pass.

Real integration on macOS arm64/Python 3.12.12 with Docker:

  • 26 passed, zero skipped, across the PostgreSQL/pgvector and Neo4j variants.
  • Both clock directions, history equality, ingestion/count behavior, feature default timestamps, and exact range/tag/set selection are covered.
  • Four existing testcontainers deprecation warnings remain.

Integration command:

uv run --frozen pytest \
  packages/server/server_tests/memmachine_server/semantic_memory/storage/test_semantic_storage.py \
  -m integration -k 'older_than or created_at' -vv -rs

The initial Linux integration attempt skipped all 26 cases because Docker was unavailable there; those skips are not counted as validation. The subsequent Mac run above executed all 26. The full repository and OS/Python CI matrix were not run locally.

  • Unit Test
  • Integration Test

Checklist

  • I have signed the commit(s) within this pull request
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code
  • I have added unit tests that prove my fix is effective
  • New and existing tests pass locally with my changes (focused suites above)
  • I have checked my code and corrected any misspellings

Maintainer Checklist

  • Confirmed all checks passed
  • Contributor has signed the commit(s)
  • Reviewed the code
  • Run, Tested, and Verified the change(s) work as expected

Further comments

Implementation, code review, and validation were performed with OpenAI Codex under the contributor's authorization. Human self-review remains unchecked. The commit is signed off and has GitHub's verified signature. This patch changes one test file, with no production or dependency-lock changes.

Refs MemMachine#1724

Implemented and reviewed with OpenAI Codex.

Signed-off-by: Divyam Talwar <divyamtalwar0@gmail.com>

This branch has not been deployed

No deployments
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.

pgvector semantic storage tests compare a host-clock cutoff with database-stamped times 10 ms apart

1 participant