File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44# AI
55.ai /
6+ .tokensave /
67
78# Python
89.venv /
@@ -31,4 +32,4 @@ config.yaml
3132# Claude Code local settings
3233.claude /settings.local.json
3334
34- memory /
35+ memory /
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ import logging
4+ from typing import Protocol
5+
6+ logger = logging .getLogger (__name__ )
7+
8+
9+ class PrunableStore (Protocol ):
10+ """A store that can list indexed service names and delete all data for one."""
11+
12+ async def get_indexed_services (self ) -> list [str ]: ...
13+
14+ async def delete_by_service (self , service : str ) -> None : ...
15+
16+
17+ async def prune_orphaned_services (
18+ store : PrunableStore ,
19+ configured_names : set [str ],
20+ label : str = "data" ,
21+ ) -> list [str ]:
22+ """Delete all stored data for services that exist in the store but not in
23+ the configured set. Returns the list of orphaned service names that were pruned."""
24+ indexed_names = await store .get_indexed_services ()
25+ orphaned = set (indexed_names ) - configured_names
26+
27+ for name in sorted (orphaned ):
28+ logger .warning ("Pruning orphaned service %r from %s" , name , label )
29+ await store .delete_by_service (name )
30+
31+ return list (orphaned )
You can’t perform that action at this time.
0 commit comments