fix: keep embedded session controls visible and handle empty memory
Publish documentation / publish (push) Successful in 34s
Publish documentation / publish (push) Successful in 34s
Cap the embedded shell at its portal container height so steering and stop controls remain accessible. Skip vector retrieval for an empty authoritative Memory archive and compute SQL-rule embeddings lazily. Validated with 54 Memory tests, 90 frontend tests, five browser scenarios, frontend and Docker builds, and a read-only comparison against the real empty Memory archive.
This commit is contained in:
@@ -157,7 +157,7 @@ def test_recall_cli_reconstructs_applied_and_rejected_memory_from_persisted_f2_s
|
||||
cards = {r.id: Card(id=r.id, family="domain_clarification", subject=r.subject,
|
||||
detail=r.detail, scope="psd-clinical", workspace_id="psd-clinical", origin="workflow",
|
||||
created_at=r.ts, updated_at=r.ts, revision="r", indexed=True) for r in records}
|
||||
archive = SimpleNamespace(list=lambda query: {}, get=lambda identity: cards[identity],
|
||||
archive = SimpleNamespace(list=lambda query: {"total": len(cards)}, get=lambda identity: cards[identity],
|
||||
close=lambda: None)
|
||||
archive.operation = lambda: nullcontext(archive)
|
||||
service = MemoryService(archive, PrincipalContext(issuer="local", subject="reviewer"),
|
||||
@@ -179,3 +179,43 @@ def test_recall_cli_reconstructs_applied_and_rejected_memory_from_persisted_f2_s
|
||||
assert current_phase(repository.get(session_id)) == 2
|
||||
assert embedder.questions == ["active patients"]
|
||||
assert searcher.calls == [([0.1, 0.2], 20, ["memory"])]
|
||||
|
||||
|
||||
def test_empty_archive_recall_does_not_require_vector_projection(tmp_path, monkeypatch):
|
||||
"""A fresh installation can have an empty dense-only Memory collection."""
|
||||
from tht.ports.vector import VectorStoreError
|
||||
|
||||
class UnavailableSearcher:
|
||||
def search(self, *args, **kwargs):
|
||||
raise VectorStoreError("BM25 collection configuration mismatch")
|
||||
|
||||
archive = SimpleNamespace(list=lambda query: {"items": [], "total": 0}, close=lambda: None)
|
||||
service = MemoryService(archive, PrincipalContext(issuer="local", subject="reviewer"),
|
||||
store_factory=lambda: None, embedder_factory=Embedder)
|
||||
embedder = Embedder()
|
||||
monkeypatch.setattr("tht.cli.memory_cmd.memory_service", lambda cfg: service)
|
||||
monkeypatch.setattr("tht.cli.vector_cmd.open_searcher", lambda cfg: UnavailableSearcher())
|
||||
monkeypatch.setattr("tht.cli.vector_cmd.make_embedder", lambda cfg: embedder)
|
||||
for command in ("search", "solved-search"):
|
||||
response = CliRunner().invoke(app, ["memory", command, "active patients", "--json",
|
||||
"-c", str(_workspace_config(tmp_path))])
|
||||
assert response.exit_code == 0, response.output
|
||||
assert json.loads(response.stdout) == []
|
||||
assert embedder.questions == []
|
||||
|
||||
|
||||
def test_recall_does_not_hide_an_unavailable_authoritative_archive():
|
||||
import pytest
|
||||
|
||||
from tht.memory.models import MemoryUnavailable
|
||||
|
||||
def unavailable(query):
|
||||
raise MemoryUnavailable("Memory archive is unavailable")
|
||||
|
||||
archive = SimpleNamespace(list=unavailable)
|
||||
service = MemoryService(archive, PrincipalContext(issuer="local", subject="reviewer"),
|
||||
store_factory=lambda: None, embedder_factory=Embedder)
|
||||
embedder = Embedder()
|
||||
with pytest.raises(MemoryUnavailable):
|
||||
service.recall("active patients", searcher=Searcher([]), embedder=embedder)
|
||||
assert embedder.questions == []
|
||||
|
||||
Reference in New Issue
Block a user