"""Retention helpers for ADK stores.
Standalone functions to prune aged sessions, purge expired events, sweep scoped
memories, and prune aged artifact versions, decoupled from any framework worker
so retention can run from a cron job, a CLI, or a task queue.
Storage-level upkeep such as vacuuming, checkpointing, or refreshing optimizer
statistics is deliberately out of scope. Those are operator decisions that need
elevated privileges and their own scheduling, and several cannot run inside the
transaction a store session provides.
"""
import time
from datetime import datetime, timedelta, timezone
from typing import Any, Literal
from typing_extensions import TypedDict
from sqlspec.extensions.adk._config_utils import _adk_adapter_store_class
from sqlspec.utils.sync_tools import await_
__all__ = (
"PruneReport",
"prune_artifacts",
"prune_artifacts_sync",
"prune_events",
"prune_events_sync",
"prune_memory",
"prune_memory_sync",
"prune_sessions",
"prune_sessions_sync",
"prune_user_state",
"prune_user_state_sync",
)
class PruneReport(TypedDict):
"""Performance telemetry for a pruning operation."""
deleted_count: int
elapsed_ms: float
table: str