Skip to content

Commit f482b40

Browse files
committed
chore: Update gitignore
1 parent e3d686b commit f482b40

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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/

server/indexer/cleanup.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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)

0 commit comments

Comments
 (0)