/**
 * Practice Store (Phase 4)
 *
 * Best-practice "cards" learned from past deliveries and injected into future
 * prompts for similar tasks. A card records guidance distilled from a
 * *successful* run — the winning strategy seed and how many turns it took —
 * keyed by task keywords.
 *
 * Provenance matters: cards are derived from the harness's own strategy seeds
 * and gate outcomes, never from raw model output. This keeps the long-term
 * store free of model-authored text (a stored-prompt-injection vector).
 */
export interface PracticeCard {
    id: string;
    /** Winning strategy seed id (provenance anchor — never model text) */
    strategy: string;
    /** Lowercased keywords that gate retrieval relevance */
    keywords: string[];
    /** Guidance injected into prompts — always regenerated from strategy+bestTurns */
    guidance: string;
    /** Times this practice has been reinforced by a successful delivery */
    successCount: number;
    /** Fewest turns a delivery using this practice took (lower = stronger) */
    bestTurns: number;
}
/** Input to record a successful delivery as a practice. */
export interface PracticeInput {
    strategy: string;
    keywords: string[];
    turns: number;
}
export interface PracticeStore {
    /** Retrieve the most relevant cards for a task instruction (keyword overlap) */
    retrieve(instruction: string, limit?: number): PracticeCard[];
    /** All stored cards (used by semantic retrieval to rank the full set) */
    all(): PracticeCard[];
    /** Reinforce or create a card from a successful delivery */
    record(input: PracticeInput): void;
}
/**
 * Minimal embedding interface — satisfied by the project's EmbeddingService
 * (nomic-768 via llama.cpp, with its own provider fallback chain down to
 * TF-IDF). Injected rather than imported so the practice module stays
 * dependency-light and unit-testable without the memory subsystem.
 */
export interface SemanticRetriever {
    embed(text: string): Promise<number[]>;
    cosineSimilarity(a: number[], b: number[]): number;
}
/** Extract lowercased keyword tokens from a task instruction. */
export declare function extractKeywords(text: string, max?: number): string[];
export interface SemanticRetrieveOptions {
    limit?: number;
    minSimilarity?: number;
}
/**
 * Retrieve practices by semantic similarity to the instruction, ranked by
 * cosine distance then reinforcement (success count, fewest turns). This
 * catches near-misses that keyword overlap drops — "parse a duration" vs
 * "parse durations into seconds".
 *
 * Fail-soft and degenerate-safe: if the embedding provider is unavailable,
 * throws, or yields no match above the similarity floor, it falls back to the
 * synchronous keyword retrieval so practices are never silently disabled.
 */
export declare function retrievePracticesSemantic(store: PracticeStore, instruction: string, retriever: SemanticRetriever, options?: SemanticRetrieveOptions): Promise<PracticeCard[]>;
/** In-memory store — the base implementation; the file store persists it. */
export declare class InMemoryPracticeStore implements PracticeStore {
    protected cards: PracticeCard[];
    constructor(cards?: PracticeCard[]);
    retrieve(instruction: string, limit?: number): PracticeCard[];
    record(input: PracticeInput): void;
    /** Smallest unused pN id — robust to merges and dropped (corrupt) cards. */
    private nextId;
    all(): PracticeCard[];
}
/** File-backed practice store (JSON). Self-heals on missing/corrupt files. */
export declare class FilePracticeStore extends InMemoryPracticeStore {
    private readonly path;
    constructor(path: string);
    /**
     * Load cards from disk, validating every field. The on-disk file is NOT
     * trusted to supply guidance text — guidance is regenerated from the
     * validated strategy + bestTurns via distillPractice, so a tampered file
     * cannot inject prompt text (the read path enforces the same provenance
     * the write path guarantees). Structurally-invalid cards are dropped.
     */
    private static load;
    record(input: PracticeInput): void;
    private persist;
}
/** Default on-disk location for a project's learned practices. */
export declare function defaultPracticePath(projectRoot: string): string;
/**
 * Distill a one-line practice from a successful delivery. Provenance-safe:
 * built only from the winning strategy and turn count, not model output.
 */
export declare function distillPractice(winningStrategy: string | undefined, turns: number): string;
//# sourceMappingURL=practice.d.ts.map