MarketAlly.AIPlugin.Extensions/MarketAlly.AIPlugin.Learning/Configuration/LearningConfiguration.cs

214 lines
6.8 KiB
C#
Executable File

using System.ComponentModel.DataAnnotations;
namespace MarketAlly.AIPlugin.Learning.Configuration
{
/// <summary>
/// Main configuration class for learning operations
/// </summary>
public class LearningConfiguration
{
public const string SectionName = "Learning";
[Required]
public GitConfiguration Git { get; set; } = new();
public LearningModeConfiguration LearningModes { get; set; } = new();
public SecurityConfiguration Security { get; set; } = new();
public PerformanceConfiguration Performance { get; set; } = new();
public LoggingConfiguration Logging { get; set; } = new();
public AIConfiguration AI { get; set; } = new();
}
/// <summary>
/// Git-related configuration
/// </summary>
public class GitConfiguration
{
[Required]
public string BranchPrefix { get; set; } = "ai-refactoring";
[Required]
public string FailedBranchPrefix { get; set; } = "failed-attempts";
public bool AutoMerge { get; set; } = false;
public bool RequireCleanWorkingDirectory { get; set; } = true;
[Range(1, 90)]
public int MaxBranchRetentionDays { get; set; } = 30;
public bool AutoCleanup { get; set; } = true;
[Required]
public string CommitterName { get; set; } = "AI Learning System";
[Required]
[EmailAddress]
public string CommitterEmail { get; set; } = "ai@learning.system";
}
/// <summary>
/// Learning mode configurations
/// </summary>
public class LearningModeConfiguration
{
public LearningModeSettings Conservative { get; set; } = new()
{
Name = "Conservative",
MaxIterations = 10,
MaxAttemptsPerFile = 2,
TimeoutMinutes = 30,
AllowedApproaches = new[] { "RenameVariable", "AddDocumentation", "FormatCode" },
RiskThreshold = 0.1
};
public LearningModeSettings Moderate { get; set; } = new()
{
Name = "Moderate",
MaxIterations = 20,
MaxAttemptsPerFile = 3,
TimeoutMinutes = 60,
AllowedApproaches = new[] { "RenameVariable", "ExtractMethod", "AddDocumentation", "SimplifyExpression", "FormatCode" },
RiskThreshold = 0.3
};
public LearningModeSettings Aggressive { get; set; } = new()
{
Name = "Aggressive",
MaxIterations = 50,
MaxAttemptsPerFile = 5,
TimeoutMinutes = 120,
AllowedApproaches = new[] { "ExtractMethod", "RenameVariable", "ReduceCoupling", "AddDocumentation", "SimplifyExpression", "FormatCode", "ExtractInterface" },
RiskThreshold = 0.5
};
}
/// <summary>
/// Individual learning mode settings
/// </summary>
public class LearningModeSettings
{
[Required]
public string Name { get; set; } = string.Empty;
[Range(1, 1000)]
public int MaxIterations { get; set; } = 20;
[Range(1, 10)]
public int MaxAttemptsPerFile { get; set; } = 3;
[Range(1, 480)]
public int TimeoutMinutes { get; set; } = 60;
[Required]
public string[] AllowedApproaches { get; set; } = Array.Empty<string>();
[Range(0.0, 1.0)]
public double RiskThreshold { get; set; } = 0.3;
[Range(0.0, 1.0)]
public double MinConfidenceScore { get; set; } = 0.5;
}
/// <summary>
/// Security-related configuration
/// </summary>
public class SecurityConfiguration
{
[Required]
public string[] AllowedFileExtensions { get; set; } = new[] { ".cs", ".csproj", ".sln", ".config", ".json" };
[Required]
public string[] ForbiddenDirectories { get; set; } = new[] { "bin", "obj", ".vs", ".git", "packages", "node_modules" };
public bool EnablePathValidation { get; set; } = true;
public bool EnableInputSanitization { get; set; } = true;
[Range(1024, long.MaxValue)] // Minimum 1KB
public long MaxFileSizeBytes { get; set; } = 10 * 1024 * 1024; // 10MB
[Range(1, 10000)]
public int MaxFilesPerSession { get; set; } = 1000;
}
/// <summary>
/// Performance-related configuration
/// </summary>
public class PerformanceConfiguration
{
[Range(1, 32)]
public int MaxConcurrentOperations { get; set; } = Environment.ProcessorCount;
[Range(1, 100)]
public int BatchSize { get; set; } = 10;
public bool EnableCaching { get; set; } = true;
[Range(1, 1440)]
public int CacheExpirationMinutes { get; set; } = 60;
[Range(1, 10)]
public int RetryAttempts { get; set; } = 3;
[Range(100, 10000)]
public int RetryDelayMilliseconds { get; set; } = 1000;
public bool EnableProgressReporting { get; set; } = true;
[Range(1, 60)]
public int ProgressReportingIntervalSeconds { get; set; } = 5;
}
/// <summary>
/// Logging configuration
/// </summary>
public class LoggingConfiguration
{
public bool EnableStructuredLogging { get; set; } = true;
public bool EnableCorrelationIds { get; set; } = true;
public string LogLevel { get; set; } = "Information";
public bool LogToFile { get; set; } = true;
public string LogDirectory { get; set; } = "Logs";
public int MaxLogFiles { get; set; } = 30;
public long MaxLogFileSizeBytes { get; set; } = 100 * 1024 * 1024; // 100MB
public bool EnableMetrics { get; set; } = true;
public bool EnableTracing { get; set; } = false;
}
/// <summary>
/// AI-related configuration
/// </summary>
public class AIConfiguration
{
public bool EnableSemanticSearch { get; set; } = true;
public bool EnableEmbeddings { get; set; } = true;
[Range(1, 100)]
public int MaxSearchResults { get; set; } = 10;
[Range(0.0, 1.0)]
public double MinSimilarityScore { get; set; } = 0.7;
public int MaxContextTokens { get; set; } = 8000;
public bool EnableContextPreparation { get; set; } = true;
public bool EnableDependencyTracking { get; set; } = true;
public bool EnableChangeImpactAnalysis { get; set; } = true;
[Range(1, 10)]
public int MaxContextDepth { get; set; } = 3;
public string[] PreferredPatterns { get; set; } = Array.Empty<string>();
}
}