/** * Deterministic Pruner — replaces the 2-pass LLM-based pruner with a * sorting algorithm that drops observations based on coverage, relevance, * and age. * * The algorithm mirrors the LLM pruner's strategy: * 1. Coverage-tagged observations (reinforced by reflections) drop first * 2. Within same coverage: low > medium > high relevance * 3. Within same relevance: oldest first (age-gradient rule) * 4. Protected observations NEVER drop (critical, user assertions, completions) * * This eliminates ~2 LLM calls per compaction while producing equivalent results. */ import type { MemoryReflection, ObservationRecord } from "./types.js"; export type CoverageTag = "reinforced" | "cited" | "uncited"; export interface TaggedObservation { observation: ObservationRecord; coverage: CoverageTag; /** Number of reflections that cite this observation */ citationCount: number; /** True if this observation should never be dropped */ protected: boolean; /** Reason for protection (for debugging) */ protectedReason?: string; } /** * Compute coverage tags for all observations based on reflection citations. * - reinforced: ≥4 reflections cite this observation * - cited: 1-3 reflections cite this observation * - uncited: no reflection cites this observation */ export declare function computeCoverageTags(observations: ObservationRecord[], reflections: MemoryReflection[]): Map; /** * Tag observations with protection status. */ export declare function tagProtectedObservations(observations: ObservationRecord[]): Map; export interface PrunerResult { /** Kept observations */ observations: ObservationRecord[]; /** IDs of dropped observations */ droppedIds: string[]; /** Whether any protected observations were at risk of being dropped */ fellBack: boolean; /** Tokens before pruning */ tokensBefore: number; /** Tokens after pruning */ tokensAfter: number; } /** * Deterministically prune an observation pool to fit within a token budget. * * Algorithm: * 1. Compute coverage tags from reflection citations * 2. Detect protected observations (critical, assertions, completions, errors, unique IDs) * 3. Sort by droppability (reinforced+low+oldest first) * 4. Drop from the sorted list until pool ≤ targetTokens * 5. Never drop protected observations * * Target is 80% of the budget to leave breathing room for the summary text. */ export declare function deterministicPrune(observations: ObservationRecord[], reflections: MemoryReflection[], budgetTokens: number): PrunerResult; //# sourceMappingURL=deterministic-pruner.d.ts.map