# Infrastructure Validation Configuration
# This file defines validation rules, their execution order, and settings

[validation_settings]
# Global validation settings
default_severity_filter = "warning"
default_report_format = "md"
max_concurrent_rules = 4
progress_reporting = true
auto_fix_enabled = true

# Rule execution settings
[execution]
# Rules execution order and grouping
rule_groups = [
    "syntax",      # Critical syntax validation first
    "compilation", # Compilation checks
    "schema",      # Schema validation
    "security",    # Security checks
    "best_practices", # Best practices
    "compatibility"   # Compatibility checks
]

# Timeout settings (in seconds)
rule_timeout = 30
file_timeout = 10
total_timeout = 300

# Parallel processing
parallel_files = true
max_file_workers = 8

# Core validation rules
[[rules]]
id = "VAL001"
name = "YAML Syntax Validation"
description = "Validate YAML files have correct syntax and can be parsed"
category = "syntax"
severity = "critical"
enabled = true
auto_fix = true
files_pattern = '.*\.ya?ml$'
validator_function = "validate_yaml_syntax"
fix_function = "fix_yaml_syntax"
execution_order = 1
tags = ["syntax", "yaml", "critical"]

[[rules]]
id = "VAL002"
name = "KCL Compilation Check"
description = "Validate KCL files compile successfully"
category = "compilation"
severity = "critical"
enabled = true
auto_fix = false
files_pattern = '.*\.k$'
validator_function = "validate_kcl_compilation"
fix_function = null
execution_order = 2
tags = ["kcl", "compilation", "critical"]
dependencies = ["kcl"]  # Required system dependencies

[[rules]]
id = "VAL003"
name = "Unquoted Variable References"
description = "Check for unquoted variable references in YAML that cause parsing errors"
category = "syntax"
severity = "error"
enabled = true
auto_fix = true
files_pattern = '.*\.ya?ml$'
validator_function = "validate_quoted_variables"
fix_function = "fix_unquoted_variables"
execution_order = 3
tags = ["yaml", "variables", "syntax"]

[[rules]]
id = "VAL004"
name = "Required Fields Validation"
description = "Validate that all required fields are present in configuration files"
category = "schema"
severity = "error"
enabled = true
auto_fix = false
files_pattern = '.*\.(k|ya?ml)$'
validator_function = "validate_required_fields"
fix_function = null
execution_order = 10
tags = ["schema", "required", "fields"]

[[rules]]
id = "VAL005"
name = "Resource Naming Conventions"
description = "Validate resource names follow established conventions"
category = "best_practices"
severity = "warning"
enabled = true
auto_fix = true
files_pattern = '.*\.(k|ya?ml)$'
validator_function = "validate_naming_conventions"
fix_function = "fix_naming_conventions"
execution_order = 20
tags = ["naming", "conventions", "best_practices"]

[[rules]]
id = "VAL006"
name = "Basic Security Checks"
description = "Validate basic security configurations like SSH keys, exposed ports"
category = "security"
severity = "error"
enabled = true
auto_fix = false
files_pattern = '.*\.(k|ya?ml)$'
validator_function = "validate_security_basics"
fix_function = null
execution_order = 15
tags = ["security", "ssh", "ports"]

[[rules]]
id = "VAL007"
name = "Version Compatibility Check"
description = "Check for deprecated versions and compatibility issues"
category = "compatibility"
severity = "warning"
enabled = true
auto_fix = false
files_pattern = '.*\.(k|ya?ml|toml)$'
validator_function = "validate_version_compatibility"
fix_function = null
execution_order = 25
tags = ["versions", "compatibility", "deprecation"]

[[rules]]
id = "VAL008"
name = "Network Configuration Validation"
description = "Validate network configurations, CIDR blocks, and IP assignments"
category = "networking"
severity = "error"
enabled = true
auto_fix = false
files_pattern = '.*\.(k|ya?ml)$'
validator_function = "validate_network_config"
fix_function = null
execution_order = 18
tags = ["networking", "cidr", "ip"]

# Extension points for custom rules
[extensions]
# Paths to search for custom validation rules
rule_paths = [
    "./custom_rules",
    "./providers/*/validation_rules",
    "./taskservs/*/validation_rules",
    "../validation_extensions"
]

# Custom rule file patterns
rule_file_patterns = [
    "*_validation_rules.toml",
    "validation_*.toml",
    "rules.toml"
]

# Hook system for extending validation
[hooks]
# Pre-validation hooks
pre_validation = []

# Post-validation hooks
post_validation = []

# Per-rule hooks
pre_rule = []
post_rule = []

# Report generation hooks
pre_report = []
post_report = []

# CI/CD integration settings
[ci_cd]
# Exit code mapping
exit_codes = { passed = 0, critical = 1, error = 2, warning = 3, system_error = 4 }

# CI-specific settings
minimal_output = true
no_colors = true
structured_output = true

# Report formats for CI
ci_report_formats = ["yaml", "json"]

# Performance settings
[performance]
# File size limits (in MB)
max_file_size = 10
max_total_size = 100

# Memory limits
max_memory_usage = "512MB"

# Caching settings
enable_caching = true
cache_duration = 3600  # seconds

# Provider-specific rule configurations
[providers.upcloud]
enabled_rules = ["VAL001", "VAL002", "VAL003", "VAL004", "VAL006", "VAL008"]
custom_rules = ["UPCLOUD001", "UPCLOUD002"]

[providers.aws]
enabled_rules = ["VAL001", "VAL002", "VAL003", "VAL004", "VAL006", "VAL007", "VAL008"]
custom_rules = ["AWS001", "AWS002", "AWS003"]

[providers.local]
enabled_rules = ["VAL001", "VAL002", "VAL003", "VAL004", "VAL005"]
custom_rules = []

# Taskserv-specific configurations
[taskservs.kubernetes]
enabled_rules = ["VAL001", "VAL002", "VAL004", "VAL006", "VAL008"]
custom_rules = ["K8S001", "K8S002"]

[taskservs.containerd]
enabled_rules = ["VAL001", "VAL004", "VAL006"]
custom_rules = ["CONTAINERD001"]