Files
ratatoskr/tests/test_provider_serve_memory.py
T
vh cd12951aca feat(provider): memory plane — SQLite+sqlite-vec store + dev shell
The second plane of ratatoskr's Tier-3 Bifrost consumer: a durable memory
store Worldtree writes agent memory chunks into (upsert_many) and recalls
by vector similarity (search), with point reads + deletes. Implements
bifrost's own MemoryDataStore Protocol; conformance is #195 parity vs
InMemoryMemoryStore through the real dispatch_memory_call.

Store (memory_store.py): open_memory_store, describe_store, upsert_many
(replay/conflict idempotency, optimistic locking, injection rule, atomic
batch), search (cosine over sqlite-vec vec0, scope isolation INV-005,
over-fetch-then-filter so top_k counts in-scope), get/get_many,
delete_many, build_memory_provider_app. Dev shell (serve_memory.py):
ratatoskr-memory-provider entrypoint, port 8391.

TDD + heid-code-review (panel Groa/Hulda/Regin, zero true drift). Adopted
fixups: scope_filter dict guard, top_k<=0 -> [], stronger scope-isolation
+ delete-hit-search + handshake-POST tests. Partial-map optimistic-lock
semantics pinned against the reference via a new expected_revisions
parity test.

26 memory + 4 serve tests; #195 parity (upsert/search/expected_revisions)
green; ruff clean. Deps: +sqlite-vec.
2026-06-15 21:39:42 -07:00

49 lines
1.5 KiB
Python

"""Tests for the memory-provider serve entrypoint (ratatoskr.provider.serve_memory).
Only the env -> app seam is unit-tested; uvicorn.run is the untestable shell.
"""
from __future__ import annotations
import pytest
from ratatoskr.provider.serve_memory import build_memory_app_from_env
def test_build_memory_app_from_env_requires_heimdall_key():
with pytest.raises(RuntimeError):
build_memory_app_from_env(
{"RATATOSKR_MEMORY_DB": ":memory:", "RATATOSKR_MEMORY_EMBEDDING_DIM": "8"}
)
def test_build_memory_app_from_env_requires_embedding_dim():
# A wrong/missing dim silently breaks vector search -> require it explicitly.
with pytest.raises(RuntimeError):
build_memory_app_from_env(
{"RATATOSKR_HEIMDALL_KEY": "k", "RATATOSKR_MEMORY_DB": ":memory:"}
)
def test_build_memory_app_from_env_rejects_non_positive_dim():
with pytest.raises(RuntimeError):
build_memory_app_from_env(
{
"RATATOSKR_HEIMDALL_KEY": "k",
"RATATOSKR_MEMORY_DB": ":memory:",
"RATATOSKR_MEMORY_EMBEDDING_DIM": "0",
}
)
def test_build_memory_app_from_env_builds_app_with_routes():
app = build_memory_app_from_env(
{
"RATATOSKR_HEIMDALL_KEY": "shared-secret",
"RATATOSKR_MEMORY_DB": ":memory:",
"RATATOSKR_MEMORY_EMBEDDING_DIM": "8",
}
)
paths = {getattr(r, "path", None) for r in app.routes}
assert "/bifrost/handshake" in paths
assert "/bifrost/memory-call" in paths