Coverage for src / harnessutils / memory.py: 100%

3 statements  

« prev     ^ index     » next       coverage.py v7.13.2, created at 2026-03-10 19:23 -0600

1"""SemanticMemoryBackend protocol for harness-utils. 

2 

3Consumers implement this protocol to provide semantic memory capabilities. 

4harness-utils only holds a reference — it does not call the backend internally. 

5""" 

6 

7from typing import Any, Protocol, runtime_checkable 

8 

9 

10@runtime_checkable 

11class SemanticMemoryBackend(Protocol): 

12 async def add_artifact( 

13 self, 

14 content: str, 

15 kind: str, 

16 *, 

17 namespace: str = "default", 

18 metadata: dict[str, Any] | None = None, 

19 ) -> Any: ... 

20 

21 async def search_artifacts( 

22 self, 

23 query: str, 

24 *, 

25 top_k: int = 10, 

26 kind: str | None = None, 

27 namespace: str | None = None, 

28 min_similarity: float = 0.0, 

29 ) -> list[Any]: ... 

30 

31 async def get_artifact(self, artifact_id: int) -> Any | None: ... 

32 

33 async def update_artifact( 

34 self, 

35 artifact_id: int, 

36 *, 

37 metadata: dict[str, Any] | None = None, 

38 content: str | None = None, 

39 ) -> Any: ... 

40 

41 async def delete_artifact(self, artifact_id: int) -> None: ...