/**
 * ContextBudgetOptimizer — priority-based context trimming with per-field token accounting.
 *
 * Key metric: evidence_pass_rate_per_token
 * Goal: maximize verification pass probability per token spent.
 *
 * Priority order (highest first):
 *   1. node goal
 *   2. explicit user constraints (system prompt)
 *   3. evidence requirements
 *   4. failing evidence from previous attempt
 *   5. directly changed files
 *   6. dependency node summaries
 *   7. relevant file slices
 *   8. graph memory facts
 *   9. broad project background
 */
import type { ContextCapsule, FileSlice, MemoryFact } from "./context-capsule.js";
export interface ContextBudgetReport {
    readonly nodeId: string;
    readonly attemptId: string;
    readonly totalTokensEstimated: number;
    readonly systemTokens: number;
    readonly taskTokens: number;
    readonly dependencyTokens: number;
    readonly fileTokens: number;
    readonly memoryTokens: number;
    readonly evidenceTokens: number;
    readonly toolResultTokens: number;
    readonly droppedItems: readonly DroppedContextItem[];
}
export interface DroppedContextItem {
    readonly kind: "file" | "memory" | "dependency" | "tool-result" | "log";
    readonly reason: "low-relevance" | "budget-limit" | "duplicate" | "too-large";
    readonly summary: string;
}
export interface ContextTokenBreakdown {
    readonly system: number;
    readonly task: number;
    readonly goal: number;
    readonly dependencies: number;
    readonly files: number;
    readonly memory: number;
    readonly evidence: number;
    readonly priorAttempts: number;
    readonly total: number;
}
export interface ContextBudgetOptimizationResult {
    readonly capsule: ContextCapsule;
    readonly report: ContextBudgetReport;
    readonly breakdown: ContextTokenBreakdown;
}
/** Per-item evidence stats for pass-rate-per-token tracking. */
export interface ContextItemEvidenceStats {
    readonly itemId: string;
    readonly kind: "file" | "memory" | "dependency" | "tool-result";
    readonly tokens: number;
    readonly evidencePassCount: number;
    readonly evidenceFailCount: number;
    readonly passRate: number;
}
export declare function estimateTokens(text: string): number;
export declare function estimateFileSliceTokens(slice: FileSlice): number;
export declare function estimateMemoryFactTokens(fact: MemoryFact): number;
export declare function breakdownCapsuleTokens(capsule: ContextCapsule): ContextTokenBreakdown;
export declare function optimizeContextBudget(capsule: ContextCapsule, attemptId: string): ContextBudgetOptimizationResult;
export declare function createContextBudgetOptimizer(): {
    optimize: typeof optimizeContextBudget;
    breakdown: typeof breakdownCapsuleTokens;
    estimateTokens: typeof estimateTokens;
    estimateFileSliceTokens: typeof estimateFileSliceTokens;
    estimateMemoryFactTokens: typeof estimateMemoryFactTokens;
};
