Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,36 @@ jobs:
# Temporary stores and copies of release-written ones, real
# writer/watcher/locks; no provider calls.
- run: SYNCMILL_TEST_MEMTOMEM_REAL=1 uv run pytest -q tests/test_memory_backend_memtomem_integration.py tests/test_memory_gc_process.py tests/test_frozen_memory_real.py tests/test_frozen_memory_schema1_real.py

# Mem0 and LangGraph stores written by released syncmill, read by HEAD's
# adapters with the real SDKs. The stores were embedded with exact FastEmbed
# model files: they are fetched once per models.json content, checked file by
# file, and read offline. The tests check the cache against models.json again
# before reading any store.
memory-backends-real:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 30
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
- uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6.8.0
with:
version: ${{ env.UV_VERSION }}
python-version: "3.12"
enable-cache: true
- run: uv sync --locked --group dev --extra mem0 --extra langgraph --managed-python
- id: models
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ runner.temp }}/fastembed
key: fastembed-${{ hashFiles('tests/fixtures/persisted/memory/backends/v*/models.json') }}
- if: steps.models.outputs.cache-hit != 'true'
run: uv run python tests/fixtures/persisted/memory/backends/fetch_models.py "${{ runner.temp }}/fastembed"
- run: uv run pytest -q tests/test_frozen_memory_backends_real.py -rxX
env:
SYNCMILL_TEST_MEMORY_BACKENDS_REAL: "1"
FASTEMBED_CACHE_PATH: ${{ runner.temp }}/fastembed
HF_HUB_OFFLINE: "1"
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ uv run syncmill memory migration plan --from memtomem --to mem0 # source-retai
SYNCMILL_TEST_MEMORY_MIGRATION_REAL=1 uv run pytest -q tests/test_memory_migration_integration.py # required before changing migration adapters
SYNCMILL_TEST_MEMTOMEM_REAL=1 uv run pytest -q tests/test_memory_backend_memtomem_integration.py tests/test_frozen_memory_real.py tests/test_frozen_memory_schema1_real.py # required before changing MemtomemBackend's replicated add flow or the memtomem pin (the last two read release-written stores)
SYNCMILL_TEST_LANGGRAPH_REAL=1 uv run pytest -q tests/test_memory_backend_langgraph_integration.py # required before changing LangGraph SDK pins/API calls
SYNCMILL_TEST_MEMORY_BACKENDS_REAL=1 FASTEMBED_CACHE_PATH=<cache> uv run --extra mem0 --extra langgraph pytest -q tests/test_frozen_memory_backends_real.py # release-written Mem0/LangGraph stores; required before changing either adapter, the mem0/LangGraph/FastEmbed pins, or SyncmillMemory's read paths (fill <cache> with tests/fixtures/persisted/memory/backends/fetch_models.py)
uv add <pkg> # add a dependency (edits pyproject.toml + uv.lock)
uv sync --group dev # install dev deps (pytest)
uv run pytest -q # run the hermetic test suite (tests/)
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ SYNCMILL_TEST_MEMORY_MIGRATION_REAL=1 uv run pytest -q \
tests/test_memory_migration_integration.py # migration adapters
SYNCMILL_TEST_LANGGRAPH_REAL=1 uv run pytest -q \
tests/test_memory_backend_langgraph_integration.py # LangGraph SDK pins
uv run --extra mem0 --extra langgraph python \
tests/fixtures/persisted/memory/backends/fetch_models.py ~/.cache/syncmill-fastembed
SYNCMILL_TEST_MEMORY_BACKENDS_REAL=1 FASTEMBED_CACHE_PATH=~/.cache/syncmill-fastembed \
uv run --extra mem0 --extra langgraph pytest -q \
tests/test_frozen_memory_backends_real.py # the Mem0 or LangGraph adapters
```

Running the agents for real needs the `claude`, `codex`, and `kimi` CLIs
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,11 @@ SYNCMILL_TEST_MEMTOMEM_REAL=1 uv run pytest -q \
tests/test_memory_gc_process.py \
tests/test_frozen_memory_real.py \
tests/test_frozen_memory_schema1_real.py
# release-written Mem0/LangGraph stores (fetch the FastEmbed models first)
uv run --extra mem0 --extra langgraph python \
tests/fixtures/persisted/memory/backends/fetch_models.py ~/.cache/syncmill-fastembed
SYNCMILL_TEST_MEMORY_BACKENDS_REAL=1 FASTEMBED_CACHE_PATH=~/.cache/syncmill-fastembed \
uv run --extra mem0 --extra langgraph pytest -q tests/test_frozen_memory_backends_real.py
```

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/persisted-contracts.md

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions tests/fixtures/persisted/memory/backends/fetch_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""Fetch the FastEmbed models the frozen Mem0 and LangGraph stores were embedded
with, at the exact revisions ``models.json`` records, into a FastEmbed cache.

python tests/fixtures/persisted/memory/backends/fetch_models.py <cache-dir>

Run with an interpreter that has ``huggingface_hub`` (a FastEmbed dependency),
e.g. ``uv run --extra mem0 --extra langgraph python ...``. Every release's
``models.json`` must name the same revision of each model. Only the files a
``models.json`` lists are fetched, and each is checked against its sha256. The
cache's ``refs/main`` is pointed at that revision, because FastEmbed resolves
``main`` when it loads a model offline (``HF_HUB_OFFLINE=1``), which is how the
tests read the stores.
"""

from __future__ import annotations

import hashlib
import json
import sys
from pathlib import Path

from huggingface_hub import hf_hub_download

HERE = Path(__file__).resolve().parent


def wanted() -> dict[str, dict]:
models: dict[str, dict] = {}
for manifest in sorted(HERE.glob("v*/models.json")):
for model, spec in json.loads(manifest.read_text(encoding="utf-8")).items():
if models.setdefault(model, spec) != spec:
sys.exit(f"{manifest}: {model} differs from another release's models.json")
if not models:
sys.exit("no models.json found")
return models


def main() -> None:
cache = Path(sys.argv[1]).resolve()
for model, spec in wanted().items():
if not model.startswith("models--"):
sys.exit(f"unexpected cache directory name {model}")
repo_id = model[len("models--"):].replace("--", "/", 1)
for entry in spec["files"]:
name, digest = entry["name"], entry["sha256"]
path = Path(hf_hub_download(
repo_id, name, revision=spec["revision"], cache_dir=str(cache)))
actual = hashlib.sha256(path.read_bytes()).hexdigest()
if actual != digest:
sys.exit(f"{repo_id}@{spec['revision']} {name}: sha256 {actual} != {digest}")
refs = cache / model / "refs"
refs.mkdir(parents=True, exist_ok=True)
(refs / "main").write_text(spec["revision"], encoding="utf-8")
print(f"{repo_id}@{spec['revision']}: {len(spec['files'])} files")


if __name__ == "__main__":
main()
Loading
Loading