personal memory agent
1# SPDX-License-Identifier: AGPL-3.0-only
2# Copyright (c) 2026 sol pbc
3
4from __future__ import annotations
5
6import importlib
7import sys
8
9import pytest
10
11from solstone.observe.model_assets import (
12 ModelsDistributionUnavailable,
13 resolve_wespeaker_model,
14)
15
16MISSING_MODELS_MESSAGE = (
17 "solstone-journal-models is not installed; it ships solstone's bundled "
18 "speaker/VAD model weights and is included with a journal-host install "
19 "(for example: pip install solstone-journal)."
20)
21
22
23class _BlockModelsDistribution:
24 def find_spec(self, fullname, path=None, target=None):
25 if fullname == "solstone_journal_models" or fullname.startswith(
26 "solstone_journal_models."
27 ):
28 raise ImportError("blocked solstone_journal_models")
29 return None
30
31
32def test_transcribe_imports_survive_missing_models_distribution(monkeypatch):
33 for name in list(sys.modules):
34 if name == "solstone_journal_models" or name.startswith(
35 "solstone_journal_models."
36 ):
37 monkeypatch.delitem(sys.modules, name, raising=False)
38 monkeypatch.setattr(sys, "meta_path", [_BlockModelsDistribution(), *sys.meta_path])
39
40 importlib.import_module("solstone.observe.transcribe.main")
41 importlib.import_module("solstone.observe._silero_vad")
42
43 with pytest.raises(ModelsDistributionUnavailable) as exc_info:
44 resolve_wespeaker_model()
45
46 assert str(exc_info.value) == MISSING_MODELS_MESSAGE