MarketAlly.AIPlugin.Extensions/MarketAlly.AIPlugin.Context/Configuration/ContextConfiguration.cs

246 lines
6.2 KiB
C#
Executable File

using System.ComponentModel.DataAnnotations;
namespace MarketAlly.AIPlugin.Context.Configuration
{
/// <summary>
/// Configuration settings for the context management system
/// </summary>
public class ContextConfiguration
{
/// <summary>
/// Storage path for context files
/// </summary>
[Required]
public string StoragePath { get; set; } = ".context";
/// <summary>
/// Maximum context size in characters
/// </summary>
[Range(1000, 1000000)]
public int MaxContextSize { get; set; } = 50000;
/// <summary>
/// Enable compression for older files
/// </summary>
public bool EnableCompression { get; set; } = true;
/// <summary>
/// Retention policy settings
/// </summary>
public RetentionPolicy Retention { get; set; } = new();
/// <summary>
/// Search configuration settings
/// </summary>
public SearchConfiguration Search { get; set; } = new();
/// <summary>
/// Performance configuration settings
/// </summary>
public PerformanceConfiguration Performance { get; set; } = new();
/// <summary>
/// Security configuration settings
/// </summary>
public SecurityConfiguration Security { get; set; } = new();
/// <summary>
/// Monitoring and observability settings
/// </summary>
public MonitoringConfiguration Monitoring { get; set; } = new();
}
/// <summary>
/// Retention policy configuration
/// </summary>
public class RetentionPolicy
{
/// <summary>
/// Maximum number of entries per file
/// </summary>
[Range(100, 10000)]
public int MaxEntriesPerFile { get; set; } = 1000;
/// <summary>
/// Retention period in days
/// </summary>
[Range(1, 3650)]
public int RetentionDays { get; set; } = 90;
/// <summary>
/// Maximum file size in bytes
/// </summary>
[Range(1024, 100 * 1024 * 1024)]
public long MaxFileSizeBytes { get; set; } = 10 * 1024 * 1024; // 10MB
/// <summary>
/// Age in days after which files should be compressed
/// </summary>
[Range(1, 365)]
public int CompressionAgeInDays { get; set; } = 30;
/// <summary>
/// Enable automatic cleanup of expired entries
/// </summary>
public bool EnableAutoCleanup { get; set; } = true;
}
/// <summary>
/// Search configuration settings
/// </summary>
public class SearchConfiguration
{
/// <summary>
/// Enable semantic search capabilities
/// </summary>
public bool EnableSemanticSearch { get; set; } = false;
/// <summary>
/// Enable fuzzy matching for searches
/// </summary>
public bool EnableFuzzyMatching { get; set; } = true;
/// <summary>
/// Fuzzy matching threshold (0.0 to 1.0)
/// </summary>
[Range(0.0, 1.0)]
public double FuzzyMatchingThreshold { get; set; } = 0.7;
/// <summary>
/// Maximum number of search results to return
/// </summary>
[Range(1, 1000)]
public int MaxSearchResults { get; set; } = 50;
/// <summary>
/// Enable search result caching
/// </summary>
public bool EnableCaching { get; set; } = true;
/// <summary>
/// Cache expiration time in minutes
/// </summary>
[Range(1, 1440)]
public int CacheExpirationMinutes { get; set; } = 30;
/// <summary>
/// OpenAI API key for semantic search (if enabled)
/// </summary>
public string? OpenAIApiKey { get; set; }
/// <summary>
/// OpenAI model to use for embeddings
/// </summary>
public string OpenAIEmbeddingModel { get; set; } = "text-embedding-3-small";
}
/// <summary>
/// Performance configuration settings
/// </summary>
public class PerformanceConfiguration
{
/// <summary>
/// Enable streaming JSON processing for large files
/// </summary>
public bool EnableStreamingJson { get; set; } = true;
/// <summary>
/// Maximum number of entries to process concurrently
/// </summary>
[Range(1, 100)]
public int MaxConcurrentOperations { get; set; } = 10;
/// <summary>
/// Cache size limit for search results
/// </summary>
[Range(100, 10000)]
public int CacheSizeLimit { get; set; } = 1000;
/// <summary>
/// Cache compaction percentage when limit is reached
/// </summary>
[Range(0.1, 0.9)]
public double CacheCompactionPercentage { get; set; } = 0.25;
/// <summary>
/// Enable parallel processing for search operations
/// </summary>
public bool EnableParallelProcessing { get; set; } = true;
}
/// <summary>
/// Security configuration settings
/// </summary>
public class SecurityConfiguration
{
/// <summary>
/// Enable encryption for sensitive content
/// </summary>
public bool EnableEncryption { get; set; } = true;
/// <summary>
/// Encryption key for data protection
/// </summary>
public string? EncryptionKey { get; set; }
/// <summary>
/// Enable sensitive data detection
/// </summary>
public bool EnableSensitiveDataDetection { get; set; } = true;
/// <summary>
/// Automatically encrypt detected sensitive data
/// </summary>
public bool AutoEncryptSensitiveData { get; set; } = true;
/// <summary>
/// Regular expressions for detecting sensitive data patterns
/// </summary>
public List<string> SensitiveDataPatterns { get; set; } = new()
{
@"\b[A-Za-z0-9+/]{40,}\b", // API keys
@"\b[\w\.-]+@[\w\.-]+\.\w+\b", // Email addresses
@"\b\d{3}-\d{2}-\d{4}\b", // SSN patterns
@"\b(?:\d{4}[-\s]?){3}\d{4}\b", // Credit card numbers
@"\bbearer\s+[A-Za-z0-9\-\._~\+\/]+=*\b", // Bearer tokens
@"\bpassword[:=]\s*[^\s]+\b" // Password patterns
};
}
/// <summary>
/// Monitoring and observability configuration
/// </summary>
public class MonitoringConfiguration
{
/// <summary>
/// Enable detailed logging
/// </summary>
public bool EnableDetailedLogging { get; set; } = true;
/// <summary>
/// Enable performance metrics collection
/// </summary>
public bool EnableMetrics { get; set; } = true;
/// <summary>
/// Enable distributed tracing
/// </summary>
public bool EnableTracing { get; set; } = false;
/// <summary>
/// Log level for context operations
/// </summary>
public string LogLevel { get; set; } = "Information";
/// <summary>
/// Enable health checks for context storage
/// </summary>
public bool EnableHealthChecks { get; set; } = true;
/// <summary>
/// Health check interval in seconds
/// </summary>
[Range(10, 3600)]
public int HealthCheckIntervalSeconds { get; set; } = 60;
}
}