"""Data infrastructure, extraction, and processing constants."""

# --- EWC / continual learning ---
EWC_PERTURBATION_SCALE = 0.01
EWC_LEARNING_RATE = 1.0
CONTINUAL_EWC_LAMBDA = 1000.0
CONTINUAL_FORGETTING_THRESHOLD = 0.9
CONTINUAL_CONVERGENCE_WINDOW = 10
CONTINUAL_REPLAY_INTERVAL = 5
CONTINUAL_SHARED_UPDATE_RATE = 0.1

# --- Transport RL ---
RL_NUM_EPISODES = 10
RL_EPSILON = 0.1
RL_BASELINE = 0.5
RL_DISCOUNT = 1.0
RL_BATCH_LIMIT = 100

# --- Weight modification ---
WM_TOLERANCE = 0.01
WM_MAX_INTERFERENCE = 0.3

# --- Extraction strategy ---
EXTRACTION_WEIGHTED_DECAY = 0.5
EXTRACTION_DB_BATCH_SIZE = 50
EXTRACTION_DEFAULT_PAIR_LIMIT = 500
EXTRACTION_SINGLE_PAIR_LIMIT = 200
EXTRACTOR_DEFAULT_LIMIT = 500
EXTRACTOR_MIN_TEXT_LENGTH = 500

# --- Contrastive pairs diagnostics ---
PAIRS_MAX_DUPLICATE_FRACTION = 0.05
PAIRS_MIN_UNIQUE_PROMPT_RATIO = 0.75
PAIRS_MIN_AVERAGE_LENGTH = 15
PAIRS_SIMILARITY_THRESHOLD = 0.8
PAIR_MIN_TEXT_LENGTH = 10

# --- Database loading limits ---
DATABASE_PAIR_LOADING_LIMIT = 1000
DATABASE_ACTIVATION_LOADING_LIMIT = 500
BENCHMARK_PAIR_LOADING_LIMIT = 60

# --- Data generation bounds ---
GENERATE_PAIRS_MIN_TOKENS = 2048
GENERATE_OVERSAMPLING_FACTOR = 1.5
PAIR_GENERATORS_DEFAULT_N = 50

# --- SimHash deduplication ---
DEDUP_WORD_NGRAM = 3
DEDUP_CHAR_NGRAM = 4
SIMHASH_DEFAULT_THRESHOLD_BITS = 3
SIMHASH_RELAXED_THRESHOLD_BITS = 10
SIMHASH_DEFAULT_NUM_BANDS = 8
SIMHASH_THRESHOLD_AGGRESSIVE = 10
SIMHASH_THRESHOLD_CONSERVATIVE = 3
DEDUP_ITEM_THRESHOLD = 1000

# --- PaCMAP optimization phases ---
PACMAP_INITIAL_SCALE = 0.01
PACMAP_W_NEAR = 1.0
PACMAP_W_MID = 0.5
PACMAP_W_FAR = 0.1
PACMAP_PHASE_1_END = 0.1
PACMAP_PHASE_2_END = 0.35
PACMAP_P1_NEAR = 2.0
PACMAP_P1_MID = 0.5
PACMAP_P1_FAR = 0.01
PACMAP_P2_NEAR = 3.0
PACMAP_P2_MID = 1.0
PACMAP_P2_FAR = 0.1
PACMAP_P3_NEAR = 1.0
PACMAP_P3_MID = 0.5
PACMAP_P3_FAR = 1.0
PACMAP_FAR_REPULSE_EPS = 0.01

# --- PaCMAP adaptive neighbors ---
PACMAP_NEIGHBORS_MIN = 5
PACMAP_NEIGHBORS_MAX = 15
PACMAP_NEIGHBORS_DIVISOR = 4
PACMAP_N_COMPONENTS_DEFAULT = 10
PACMAP_MN_RATIO_DEFAULT = 0.5
PACMAP_FP_RATIO_DEFAULT = 2.0
PACMAP_NUM_ITERS_DEFAULT = 50
PACMAP_ALT_NUM_ITERS = 100
PACMAP_LEARNING_RATE_DEFAULT = 1.0
PACMAP_N_MID_PAIRS = 5
PACMAP_N_FAR_PAIRS = 2

# --- Adaptive cross-validation ---
ADAPTIVE_CV_MIN_FOLDS = 2
ADAPTIVE_CV_MAX_FOLDS = 5
ADAPTIVE_CV_SAMPLES_PER_FOLD = 10

# --- Adaptive MLP probe ---
ADAPTIVE_MLP_HIDDEN_MIN = 16
ADAPTIVE_MLP_HIDDEN_MAX = 256

# --- Adaptive manifold ---
ADAPTIVE_MANIFOLD_MAX_COMPONENTS = 15

# --- Adaptive permutation ---
ADAPTIVE_PERMUTATIONS_MIN = 50
ADAPTIVE_PERMUTATIONS_MAX = 200
ADAPTIVE_PERMUTATIONS_DIVISOR = 5000

# --- KNN adaptive k ---
KNN_ADAPTIVE_K_MIN = 3
KNN_ADAPTIVE_K_DIVISOR = 4

# --- UMAP adaptive neighbors ---
UMAP_NEIGHBORS_MIN = 5
UMAP_NEIGHBORS_MAX = 15
UMAP_NEIGHBORS_DIVISOR = 20

# --- Clustering validation ---
CLUSTERING_MIN_SAMPLES = 20
CLUSTERING_STABILITY_THRESHOLD = 0.8
CLUSTERING_MAX_K_SEARCH = 6
CLUSTERING_BALANCE_THRESHOLD = 0.2
CLUSTERING_QUALITY_W_STABILITY = 0.4
CLUSTERING_QUALITY_W_K_CONF = 0.3
CLUSTERING_QUALITY_W_BALANCE = 0.3
CLUSTERING_DEFAULT_CONFIDENCE = 0.5
CLUSTERING_MAX_CLUSTERS_DIVISOR = 5
CLUSTERING_MEANINGFUL_THRESHOLD = 0.1

# --- Diversity processor ---
DIVERSITY_OPENER_PENALTY = -2.0
DIVERSITY_OPENER_CUTOFF_POS = 5
DIVERSITY_TRIE_PENALTY = -1.0
DIVERSITY_TRIE_MAX_DEPTH = 6
DIVERSITY_LEDGER_MAX_ITEMS = 200
DIVERSITY_SAMPLE_K = 5
DIVERSITY_MIN_CLAUSE_LENGTH = 12
DIVERSITY_MAX_CLAUSE_LENGTH = 80
DIVERSITY_WINDOW_SIZE = 6
DIVERSITY_MAX_SAMPLE_SIZE = 20

# --- Spectral clustering ---
SPECTRAL_N_NEIGHBORS_DEFAULT = 10

# --- K-Means ---
KMEANS_N_INIT_DEFAULT = 20
KMEANS_N_INIT_SMALL = 3
KMEANS_N_INIT_MEDIUM = 5
KMEANS_N_INIT_LARGE = 10
KMEANS_MAX_ITERATIONS_DEFAULT = 50

# --- HDBSCAN ---
HDBSCAN_MIN_CLUSTER_FLOOR = 5
HDBSCAN_ADAPTIVE_DIVISOR = 20
HDBSCAN_MIN_SAMPLES_DEFAULT = 3
ELBOW_CONSECUTIVE_DECREASES = 3
MAX_SILHOUETTE_CLUSTERS = 6

# --- Synthetic data quality ---
SYNTHETIC_DEDUP_SIMILARITY = 0.95
SYNTHETIC_QUALITY_THRESHOLD = 0.7
SYNTHETIC_MIN_QUALITY = 0.3

# --- Nonsense baseline generation ---
NONSENSE_PAIRS_MIN = 30
NONSENSE_PAIRS_MAX = 100
NONSENSE_MIN_TOKENS = 5
NONSENSE_TOKEN_OFFSET = 100
NONSENSE_DEFAULT_NUM_PAIRS = 10
NONSENSE_Z_SIGNIFICANCE = 2.0

# --- Pair count ablation ---
PAIR_COUNT_ABLATION_SERIES = (10, 25, 50, 100, 200)
PAIRS_ABLATION_DEFAULT_MIN = 50

# --- Retry/buffer multipliers ---
PAIR_GEN_RETRY_MULTIPLIER = 50
DATA_OVERSAMPLE_MULTIPLIER = 3
SAMPLE_LOADING_BUFFER = 50

# --- Token estimation ---
TOKENS_PER_PAIR_ESTIMATE = 150
TOKENS_BASE_OFFSET = 500
TOKEN_ESTIMATE_MIN = 2048
TOKEN_ESTIMATE_MAX = 8192

# --- Discover steering ---
DISCOVER_STEERING_TASK_LIMIT = 1000
DISCOVER_STEERING_TRAIN_LIMIT = 500

# --- Continual loop ---
CONTINUAL_LOOP_QUERY_LIMIT = 20

# --- Cluster benchmarks ---
CLUSTER_PROGRESS_INTERVAL = 20
CLUSTER_MIN_PAIRS = 10
CLUSTER_PROMPT_TRUNCATION = 500
CLUSTER_RESPONSE_TRUNCATION = 200

# --- Additive weight modification method ---
ADDITIVE_METHOD_MAX_ALPHA = 2.0
ADDITIVE_KERNEL_CENTER_DIVISOR = 2.0
ADDITIVE_KERNEL_SIGMA_DIVISOR = 2.0

# --- Trait pair generation ---
PARSER_DEFAULT_NUM_PAIRS_TRAIT = 10

# --- Fast diversity ---
FAST_DIVERSITY_SEED = 13
