import type { CallScores } from "./holds.js"; export declare const HOLDS_SCHEMA = "\n CREATE TABLE IF NOT EXISTS holds (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n timestamp INTEGER NOT NULL,\n project_root TEXT NOT NULL,\n tool TEXT NOT NULL,\n signature_hash TEXT NOT NULL,\n command_preview TEXT,\n task TEXT,\n plan TEXT,\n context_summary TEXT,\n preceding_actions TEXT,\n scores TEXT NOT NULL,\n level TEXT NOT NULL,\n held INTEGER NOT NULL,\n reasons TEXT,\n agent_reason TEXT,\n outcome TEXT,\n outcome_at INTEGER,\n confidence REAL\n );\n CREATE INDEX IF NOT EXISTS idx_holds_project_signature ON holds(project_root, signature_hash);\n CREATE INDEX IF NOT EXISTS idx_holds_outcome ON holds(outcome);\n CREATE INDEX IF NOT EXISTS idx_holds_timestamp ON holds(timestamp);\n"; export declare function initSchema(retentionDays?: number): Promise; export interface HoldScores { irreversible: number; /** Reason categories from the verdict, used for same-reason queries and destructive-pattern detection. */ reasons: string[]; } /** Enumerations for type safety over bare strings. */ export type HoldLevel = "allow" | "deny" | "confirm"; export type HoldOutcome = "approved" | "declined" | "replanned" | "accepted" | "regretted" | "pending"; /** Context fields gathered at hold time, passed to toHoldRecord. */ export interface HoldContext { task?: string | undefined; plan?: string | undefined; contextSummary?: string | undefined; precedingActions?: string | undefined; agentReason?: string | undefined; } export interface HoldRecord { timestamp: number; projectRoot: string; tool: string; commandPreview: string; task?: string; plan?: string; contextSummary?: string; precedingActions?: string; scores: HoldScores; level: HoldLevel; held: boolean; reasons: string[]; agentReason?: string; confidence?: number; } export interface SmartHistory { exact: Record[]; similar: Record[]; sameReason: Record[]; signatureHash: string; } export interface ConfidenceResult { confidence: number; reason: string; exactCount: number; similarCount: number; sameReasonCount: number; } export interface SkipResult { skip: boolean; confidence: number; reason: string; } /** Hash tool + scores to identify similar holds. */ export declare function signatureHash(tool: string, scores: HoldScores): string; /** Build HoldRecord from held call data. Centralizes the field mapping. */ export declare function toHoldRecord(item: { at: number; tool: string; level: string; reasons: string[]; scores?: CallScores | undefined; }, projectRoot: string, ctx?: HoldContext): HoldRecord; export declare function recordHold(hold: HoldRecord): Promise; export declare function recordOutcome(id: number, outcome: string): Promise; export declare function querySmartHistory(tool: string, scores: HoldScores, projectRoot: string): Promise; export declare function calculateSmartConfidence(history: SmartHistory): ConfidenceResult; export declare function shouldSkipHold(tool: string, scores: HoldScores, projectRoot: string): Promise; /** Learn from past outcomes to suggest threshold adjustments. */ export interface ThresholdAdjustment { guard: string; currentThreshold: number; suggestedThreshold: number; reason: string; confidence: number; } /** Analyze hold outcomes to suggest threshold adjustments. */ export declare function analyzeThresholds(projectRoot: string): Promise; /** Learn which patterns are most likely to be false positives. */ export interface PatternInsight { pattern: string; falsePositiveRate: number; sampleSize: number; suggestion: string; } export declare function analyzePatterns(projectRoot: string): Promise; export interface ContextRecommendation { type: 'threshold' | 'exempt' | 'pattern'; message: string; priority: 'high' | 'medium' | 'low'; } /** Generate recommendations based on learning data. */ export declare function generateRecommendations(projectRoot: string): Promise; /** Analyze which types of steers are most effective at changing agent behavior. */ export interface SteerEffectivenessReport { /** Overall effectiveness rate (0-1). */ overall: number; /** Effectiveness by steer type. */ byType: Record; /** Suggestions for improving steer effectiveness. */ suggestions: string[]; /** Top performing steer patterns. */ topPatterns: Array<{ pattern: string; effectiveness: number; sampleSize: number; }>; } /** Analyze steer effectiveness from hold outcomes. */ export declare function analyzeSteerEffectivenessReport(projectRoot: string): Promise;