Coverage for /home/admin/Documents/AI/applications/lexigram-dev/lexigram/experimental/ai/lexigram-ai-memory/src/lexigram/ai/memory/pruning/types.py: 100%
15 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
« prev ^ index » next coverage.py v7.15.4, created at 2026-08-25 07:19 +0800
1"""Pruning types and enums for context pruning."""
3from __future__ import annotations
5from dataclasses import dataclass, field
6from enum import StrEnum
9class PruningStrategy(StrEnum):
10 """Enum of pruning scoring strategies.
12 Attributes:
13 RECENCY: Keep most recent entries by timestamp.
14 RELEVANCE: Keep highest-relevance entries (placeholder for future embedding-based scoring).
15 HYBRID: Weighted blend of recency and relevance (content length as proxy).
16 """
18 RECENCY = "recency"
19 RELEVANCE = "relevance"
20 HYBRID = "hybrid"
23@dataclass(frozen=True)
24class PruningResult:
25 """Result of a context pruning operation.
27 Attributes:
28 kept: List of MemoryEntry items kept (score-ordered, highest first).
29 pruned_count: Number of entries that were removed.
30 original_count: Number of entries that came in.
31 token_budget: The token budget that was applied.
32 strategy: The pruning strategy used.
33 metadata: Optional metadata dictionary with additional pruning details.
34 """
36 kept: list
37 pruned_count: int
38 original_count: int
39 token_budget: int
40 strategy: PruningStrategy
41 metadata: dict = field(default_factory=dict)