/**
 * Schema Recommendation Service
 *
 * Analyzes raw_fragments to identify fields that should be promoted to schema fields.
 * Supports auto-enhancement for high-confidence fields and manual recommendations.
 */
export interface FieldRecommendation {
    field_name: string;
    field_type: "string" | "number" | "date" | "boolean" | "array" | "object";
    required?: boolean;
    frequency: number;
    sample_values: unknown[];
    confidence: number;
    type_consistency: number;
    source_diversity?: number;
    naming_pattern_match?: boolean;
    format_consistency?: number;
}
export interface SchemaRecommendation {
    entity_type: string;
    fields: FieldRecommendation[];
    source: "raw_fragments" | "agent" | "inference";
    confidence_score: number;
    reasoning?: string;
    affected_entities_count?: number;
}
export interface AutoEnhancementConfig {
    enabled: boolean;
    threshold: 1 | 2 | 3 | "pattern";
    min_confidence: number;
    auto_enhance_high_confidence: boolean;
    user_specific_aggressive: boolean;
    global_conservative: boolean;
    trusted_source_relaxation: boolean;
}
export declare const DEFAULT_AUTO_ENHANCEMENT_CONFIG: AutoEnhancementConfig;
export declare class SchemaRecommendationService {
    private schemaRegistry;
    constructor();
    /** Active registry row, or code-defined ENTITY_SCHEMAS baseline when none. */
    private loadSchemaForAutoEnhance;
    /**
     * Check if a field is eligible for auto-enhancement based on confidence criteria
     */
    checkAutoEnhancementEligibility(options: {
        entity_type: string;
        fragment_key: string;
        user_id?: string;
        config?: AutoEnhancementConfig;
        observation_source?: string;
    }): Promise<{
        eligible: boolean;
        confidence: number;
        inferred_type?: "string" | "number" | "date" | "boolean" | "array" | "object";
        reasoning?: string;
        converter_suggestion?: {
            from: "number" | "string" | "boolean" | "array" | "object";
            to: "string" | "number" | "date" | "boolean" | "array" | "object";
            function: string;
            deterministic: boolean;
        };
    }>;
    /**
     * Automatically enhance schema for high-confidence fields
     * Includes race condition handling for concurrent enhancements
     */
    autoEnhanceSchema(options: {
        entity_type: string;
        field_name: string;
        field_type: "string" | "number" | "date" | "boolean" | "array" | "object";
        user_id?: string;
        user_specific?: boolean;
        converter_suggestion?: {
            from: "number" | "string" | "boolean" | "array" | "object";
            to: "string" | "number" | "date" | "boolean" | "array" | "object";
            function: string;
            deterministic: boolean;
        };
    }): Promise<any>;
    /**
     * Calculate confidence score for a field based on samples
     * Enhanced with robust type inference logic
     */
    calculateFieldConfidence(options: {
        fragment_key: string;
        entity_type: string;
        user_id?: string;
    }): Promise<{
        confidence: number;
        type_consistency: number;
        naming_pattern_match: boolean;
        format_consistency: number;
        inferred_type?: "string" | "number" | "date" | "boolean" | "array" | "object";
    }>;
    /**
     * Analyze raw_fragments to identify fields that should be promoted
     */
    analyzeRawFragments(options: {
        entity_type?: string;
        user_id?: string;
        min_frequency?: number;
        min_confidence?: number;
    }): Promise<SchemaRecommendation[]>;
    /**
     * Generate LLM-based recommendations (opt-in, non-deterministic)
     */
    generateInferenceRecommendations(options: {
        entity_type: string;
        user_id?: string;
        raw_fragments_sample: Array<{
            fragment_key: string;
            fragment_value: unknown;
            frequency_count: number;
        }>;
    }): Promise<SchemaRecommendation>;
    /**
     * Store recommendation from agent or inference
     */
    storeRecommendation(recommendation: {
        entity_type: string;
        user_id?: string;
        source: "agent" | "inference";
        fields: FieldRecommendation[];
        confidence_score: number;
        reasoning?: string;
    }): Promise<string>;
    /**
     * Get pending recommendations for an entity type
     */
    getRecommendations(options: {
        entity_type?: string;
        user_id?: string;
        source?: "raw_fragments" | "agent" | "inference";
        status?: "pending" | "approved" | "rejected";
    }): Promise<Array<SchemaRecommendation & {
        id: string;
        status: string;
    }>>;
    /**
     * Queue auto-enhancement check for deferred processing
     */
    queueAutoEnhancementCheck(options: {
        entity_type: string;
        fragment_key: string;
        user_id?: string;
        frequency_count?: number;
    }): Promise<void>;
    /**
     * Look up the most common observation_source for a given entity_type + user_id.
     * Used to determine if the majority of observations come from trusted sources.
     */
    private lookupDominantObservationSource;
    /**
     * Detect if a converter is needed for an existing field with type mismatch
     * Analyzes raw_fragments data to determine appropriate converter based on data patterns
     */
    private detectConverterNeeded;
    /**
     * Check if field matches blacklist patterns
     */
    private checkBlacklist;
    /**
     * Check if field name matches a wildcard pattern
     */
    private matchesPattern;
    /**
     * Validate field name
     */
    private isValidFieldName;
    /**
     * Analyze types across samples (multi-pass type detection)
     * Null values are excluded from consistency calculation since they're expected for optional fields
     */
    private analyzeTypes;
    /**
     * Infer type from a single value (multi-pass detection)
     */
    private inferType;
    /**
     * Check if string is ISO 8601 date
     */
    private isISODate;
    /**
     * Check if string is email
     */
    private isEmail;
    /**
     * Check if string is UUID
     */
    private isUUID;
    /**
     * Check if string is numeric
     */
    private isNumericString;
    /**
     * Check if string is boolean
     */
    private isBooleanString;
    /**
     * Check if field name matches common naming patterns
     */
    private checkNamingPattern;
    /**
     * Check format consistency for specific types
     * Null values are excluded from format consistency calculation since they're expected for optional fields
     */
    private checkFormatConsistency;
    /**
     * Calculate overall confidence score
     */
    private calculateOverallConfidence;
}
export declare const schemaRecommendationService: SchemaRecommendationService;
//# sourceMappingURL=schema_recommendation.d.ts.map