personal memory agent
0

Configure Feed

Select the types of activity you want to include in your feed.

solstone / tests / test_entity_describe_pre_hook.py
2.7 kB 93 lines
1# SPDX-License-Identifier: AGPL-3.0-only 2# Copyright (c) 2026 sol pbc 3 4import importlib.util 5from pathlib import Path 6 7 8def _load_entity_describe_module(): 9 path = ( 10 Path(__file__).resolve().parents[1] 11 / "solstone" 12 / "apps" 13 / "entities" 14 / "talent" 15 / "entity_describe.py" 16 ) 17 spec = importlib.util.spec_from_file_location("test_entity_describe_hook", path) 18 assert spec is not None 19 assert spec.loader is not None 20 module = importlib.util.module_from_spec(spec) 21 spec.loader.exec_module(module) 22 return module 23 24 25def _prompt(current: str = "Existing description") -> str: 26 return "\n".join( 27 [ 28 "Entity Type: Person", 29 "Entity Name: Alice Example", 30 "Facet: work", 31 f"Current Description: {current}", 32 ] 33 ) 34 35 36def test_entity_describe_pre_hook_renders_found_evidence(monkeypatch): 37 module = _load_entity_describe_module() 38 39 monkeypatch.setattr( 40 module, 41 "search_journal", 42 lambda query, limit, facet: ( 43 1, 44 [ 45 { 46 "id": "20260422/work/090000_300/talents/sense.md:0", 47 "text": "Alice Example led the rollout planning.", 48 "metadata": { 49 "day": "20260422", 50 "facet": "work", 51 }, 52 } 53 ], 54 ), 55 ) 56 57 vars_ = module.pre_process({"prompt": _prompt()})["template_vars"] 58 59 assert vars_["entity_type"] == "Person" 60 assert vars_["entity_name"] == "Alice Example" 61 assert vars_["facet"] == "work" 62 assert vars_["current_description"] == "Existing description" 63 assert "Alice Example led the rollout planning." in vars_["evidence"] 64 65 66def test_entity_describe_pre_hook_empty_evidence_preserves_generic_inputs( 67 monkeypatch, 68): 69 module = _load_entity_describe_module() 70 monkeypatch.setattr(module, "search_journal", lambda query, limit, facet: (0, [])) 71 72 vars_ = module.pre_process({"prompt": _prompt("(none)")})["template_vars"] 73 74 assert vars_["entity_type"] == "Person" 75 assert vars_["entity_name"] == "Alice Example" 76 assert vars_["facet"] == "work" 77 assert vars_["current_description"] == "(none)" 78 assert vars_["evidence"] == "No journal evidence found for this entity." 79 80 81def test_entity_describe_ad_hoc_generate_has_no_output_path(): 82 from solstone.think.talents import prepare_config 83 84 config = prepare_config( 85 { 86 "name": "entities:entity_describe", 87 "prompt": _prompt(), 88 } 89 ) 90 91 assert config["type"] == "generate" 92 assert config["output"] == "md" 93 assert "output_path" not in config