import type { Finding } from '../agent/types';
import type { AnalysisPatternEntry, NegativePatternEntry, FailedApproach, PatternStatus, PatternProvenance } from './types';
import { type KnowledgeScope } from '../services/scopedKnowledgeStore';
/**
 * Test-only: disable the live supersede store. Both handles snap to
 * `null` so neither path will attempt an adapter open. This is the
 * primitive existing fs-mocked tests use to keep production sqlite
 * out of the test process.
 *
 * Use `resetSupersedeHandlesForTesting()` instead when a test needs
 * to observe which adapter factory the production code calls.
 */
export declare function setSupersedeStoreForTesting(handle: null): void;
/**
 * Test-only: clear both handles back to `undefined` so the next read
 * or write attempt triggers a fresh adapter factory call. Used by
 * tests that spy on `openSupersedeStore*` to verify which factory the
 * recall path goes through.
 */
export declare function resetSupersedeHandlesForTesting(): void;
/**
 * Optional metadata that callers (claudeRuntime, review agent, feedback path)
 * attach to new pattern entries. Every field is optional so existing
 * positional-argument callers keep working unchanged.
 */
export interface PatternSaveExtras {
    /** Defaults to 'provisional' on save. */
    status?: PatternStatus;
    failureModeHash?: string;
    provenance?: PatternProvenance;
    bucketKey?: string;
    /** Enterprise tenant/workspace scope for learned pattern isolation. */
    knowledgeScope?: KnowledgeScope;
}
/**
 * Extract trace feature fingerprint from analysis context.
 * Used for similarity matching across sessions.
 */
export declare function extractTraceFeatures(context: {
    architectureType?: string;
    sceneType?: string;
    packageName?: string;
    findingTitles?: string[];
    findingCategories?: string[];
}): string[];
/**
 * Extract key insights from analysis findings and conclusion.
 * These are the patterns worth remembering across sessions.
 */
export declare function extractKeyInsights(findings: Finding[], conclusion: string): string[];
/**
 * Save an analysis pattern to persistent storage.
 * Call after a successful analysis to build long-term memory.
 */
export declare function saveAnalysisPattern(features: string[], insights: string[], sceneType: string, architectureType?: string, confidence?: number, extras?: PatternSaveExtras): Promise<void>;
/**
 * Save a negative pattern — records what strategies FAILED for similar traces.
 * Call after watchdog triggers, verification failures, or persistent tool errors.
 */
export declare function saveNegativePattern(features: string[], failedApproaches: FailedApproach[], sceneType: string, architectureType?: string, extras?: PatternSaveExtras): Promise<void>;
/**
 * Find patterns similar to the current trace features.
 * Returns matched patterns sorted by effective score (similarity × decay).
 */
export declare function matchPatterns(features: string[], scope?: KnowledgeScope): Array<AnalysisPatternEntry & {
    score: number;
}>;
/**
 * Find negative patterns similar to the current trace features.
 * Negative patterns persist longer (90 days) and use the same weighted matching.
 */
export declare function matchNegativePatterns(features: string[], scope?: KnowledgeScope): Array<NegativePatternEntry & {
    score: number;
}>;
/**
 * Recurrence detection: when a new negative pattern arrives whose
 * failureModeHash already has an `active_canary` supersede marker, that's
 * the signal that the alleged fix didn't work — flip the marker to `failed`
 * so subsequent injections restore full weight.
 */
export declare function checkAndRecordRecurrence(failureModeHash: string | undefined): void;
/**
 * Save a pattern derived from a quick-path analysis. Quick-path conclusions
 * are weaker (10-turn budget, no verifier) so they go into a separate bucket
 * with a 7-day TTL and only surface as fallbacks (×0.3 weight) when no
 * full-path pattern matches the same features.
 */
export declare function saveQuickPathPattern(features: string[], insights: string[], sceneType: string, architectureType?: string, extras?: PatternSaveExtras): Promise<void>;
/**
 * Match quick-path patterns as a fallback. Only used when `matchPatterns()`
 * came back empty for the current features — surfaces with ×0.3 weight on
 * top of the usual scoring chain so a stronger long-term match always wins.
 */
export declare function matchQuickPatternsAsBackup(features: string[], scope?: KnowledgeScope): Array<AnalysisPatternEntry & {
    score: number;
}>;
/**
 * Promote a quick-path pattern to long-term memory once a full-path run
 * verifies the same features with the same scene/arch/domain and at least
 * one matching insight category. Returns true on promotion.
 *
 * Implements the six-criterion judgement from §6 of the design doc:
 *   1. same sceneType + archType + domain
 *   2. weighted Jaccard similarity ≥ 0.65
 *   3. full-path verifier passed (caller's responsibility — pass `true`)
 *   4. at least one matching insight or finding category
 *   5. quick pattern has no rejected/disputed status
 *   6. (caller may also gate on full packageName equality as bonus)
 */
export declare function promoteQuickPatternIfMatching(input: {
    fullPathFeatures: string[];
    fullPathInsights: string[];
    sceneType: string;
    architectureType?: string;
    verifierPassed: boolean;
    knowledgeScope?: KnowledgeScope;
}): Promise<boolean>;
export type FeedbackRating = 'positive' | 'negative';
/**
 * Apply a feedback rating to the pattern matching `patternId` (across both
 * positive and quick buckets). Implements the time-window rules from §4.3:
 *   <10s reverse: last-write-wins (audit only)
 *   10s–24h reverse: → disputed
 *   >24h reverse: → disputed_late
 * Same-direction feedback simply refreshes lastFeedbackAt.
 *
 * Returns the resulting status, or `null` when the pattern was not found.
 */
export declare function applyFeedbackToPattern(patternId: string, rating: FeedbackRating, now?: number): Promise<PatternStatus | null>;
/**
 * Sweep each on-disk bucket and promote any provisional entries past the
 * auto-confirm window. Run lazily from the system prompt builder so the
 * cost is amortized across normal traffic.
 */
export declare function sweepAutoConfirm(now?: number): Promise<void>;
/**
 * Build a system prompt section from matched patterns.
 * Provides cross-session context to Claude.
 */
export declare function buildPatternContextSection(features: string[], scope?: KnowledgeScope): string | undefined;
/**
 * Build a system prompt section from matched negative patterns.
 * Warns Claude about strategies that previously FAILED for similar traces.
 */
export declare function buildNegativePatternSection(features: string[], scope?: KnowledgeScope): string | undefined;
//# sourceMappingURL=analysisPatternMemory.d.ts.map