/**
 * Context Assembler
 *
 * Mathematical context-token optimization engine.
 * Replaces heuristic file selection with a quality-scored greedy knapsack.
 *
 * Quality = w1 * relevance + w2 * recency + w3 * connectivity + w4 * novelty
 * Maximize Σ(quality_i) subject to Σ(tokens_i) ≤ budget
 *
 * Phase: 8B (depends on 8A Session DNA)
 */
import { type SemanticScoreBreakdown } from './semantic-ranking.js';
export interface ContextChunk {
    source: string;
    content: string;
    tokens: number;
    quality: number;
    label: string;
    startLine: number;
    endLine: number;
    scoreBreakdown?: ContextChunkScoreBreakdown;
    /** Memory entropy (0=fresh, 1=noise) — used to penalize noisy memory chunks */
    entropy?: number;
    /** Memory trust (0-1) — used to boost high-trust memory chunks */
    trust?: number;
    /** Pre-computed mtime so scoreRecency does not statSync per chunk in the hot loop. */
    mtimeMs?: number;
}
export interface QualityWeights {
    relevance: number;
    recency: number;
    connectivity: number;
    novelty: number;
}
export interface AssemblyResult {
    selected: ContextChunk[];
    totalQuality: number;
    totalTokens: number;
    budget: number;
    efficiency: number;
    rejectedCount: number;
}
export interface BudgetConfig {
    base: number;
    taskMultiplier: number;
    effectiveBudget: number;
    reason: string;
}
export interface ContextChunkScoreBreakdown {
    relevance: SemanticScoreBreakdown;
    recency: number;
    connectivity: number;
    novelty: number;
    final: number;
}
export declare class ContextAssembler {
    private weights;
    private seenChunks;
    private readonly embedder;
    private readonly vectorCache;
    constructor(weights?: Partial<QualityWeights>);
    /**
     * Maximize Σ(quality_i) subject to Σ(tokens_i) ≤ budget
     * Solved via greedy knapsack: sort by quality/token ratio descending.
     */
    assemble(task: string, candidates: ContextChunk[], budget: number): AssemblyResult;
    /**
     * Compute quality score for a chunk:
     * quality = w1*relevance + w2*recency + w3*connectivity + w4*novelty
     */
    scoreChunk(chunk: ContextChunk, task: string): number;
    scoreChunkBreakdown(chunk: ContextChunk, task: string): ContextChunkScoreBreakdown;
    /** Map quality score to token tier: L0, L1, or L2 */
    tierForQuality(quality: number): 'L0' | 'L1' | 'L2';
    /** Relevance: keyword overlap between chunk content and task */
    private scoreRelevance;
    /** Recency: how recently the file was modified (exponential decay) */
    private scoreRecency;
    /** Novelty: chunks not yet seen in this session score higher */
    private scoreNovelty;
    /**
     * Compute adaptive budget: simple tasks -25%, complex tasks +50%
     */
    computeBudget(task: string, baseBudget: number): BudgetConfig;
    /**
     * Split a file into semantic chunks at function/class boundaries.
     * Falls back to line-based chunking if parsing fails.
     */
    chunkFile(filepath: string): Promise<ContextChunk[]>;
    /** Chunk TypeScript/JavaScript by function and class boundaries */
    private chunkByBoundaries;
    /** Chunk by fixed-size window (for non-JS/TS files) */
    private chunkByWindow;
    /** Simple tokenizer: lowercase, split on non-alphanum, filter stopwords */
    private tokenize;
    /** Unique key for a chunk (path + line range) */
    private chunkKey;
    private vectorFor;
    /** Reset session state (seen chunks) */
    reset(): void;
    /** Format assembly result for MCP response */
    static format(result: AssemblyResult, config: BudgetConfig): string;
}
