/** * quality-score.ts * * Compaction quality scoring, evaluates the output of a compaction strategy * by combining compression ratio and semantic retention signals. * * Score range: 0.0 (worst) → 1.0 (best) * Auto-switch threshold: scores below LOW_QUALITY_THRESHOLD trigger a strategy * escalation to the next more-aggressive strategy. */ import type { StrategyInput, StrategyOutput, CompactionStrategy } from './types.js'; /** * Compaction runs scoring below this value are considered low-quality and * trigger an automatic strategy switch. */ export declare const LOW_QUALITY_THRESHOLD = 0.4; /** Letter grade derived from the composite quality score. */ export type CompactionQualityGrade = 'A' | 'B' | 'C' | 'D' | 'F'; /** Semantic retention signals evaluated during scoring. */ export interface SemanticRetentionSignals { /** At least one handoff/summary message is present in the output. */ hasHandoff: boolean; /** Output contains non-trivial content (not just a blank handoff note). */ hasNonTrivialContent: boolean; /** The output message count is a reasonable fraction of the input. */ messageCountSane: boolean; /** The output token count is positive. */ positiveTokenCount: boolean; } /** Full quality score breakdown for a compaction run. */ export interface CompactionQualityScore { /** Fraction of tokens removed: (tokensBefore - tokensAfter) / tokensBefore. */ compressionRatio: number; /** Normalised compression dimension score (0–1). */ compressionScore: number; /** Semantic retention dimension score (0–1). */ retentionScore: number; /** Composite quality score: weighted sum of compression + retention (0–1). */ score: number; /** Letter grade derived from score. */ grade: CompactionQualityGrade; /** Individual semantic retention signals. */ signals: SemanticRetentionSignals; /** True when score < LOW_QUALITY_THRESHOLD and strategy escalation should occur. */ isLowQuality: boolean; /** Human-readable description of the score for diagnostics. */ description: string; } /** * Produces a human-readable diagnostic description for a quality score. */ export declare function describeScore(score: CompactionQualityScore): string; /** * Computes the quality score with description filled in. * * Prefer this over `scoreCompactionOutput` for all public use. */ export declare function computeQualityScore(input: StrategyInput, output: StrategyOutput): CompactionQualityScore; /** * Returns the next more-aggressive strategy for escalation when quality is low. * * Escalation path: * microcompact → autocompact → collapse → collapse (ceiling) * reactive → reactive (already maximum) * * @param current - The strategy that produced the low-quality result. * @returns The escalated strategy to re-run with. */ export declare function escalateStrategy(current: CompactionStrategy): CompactionStrategy; //# sourceMappingURL=quality-score.d.ts.map