# O(1) Quality Gate Metric Thresholds for Realizar
# Spec: PMAT-802 - A+ Compliance (95%+ coverage, all files <2000 lines)
# Pattern: Toyota Way - Jidoka (MEAN mode: warnings = errors)

[thresholds]
# Hard limits (block commits) - based on Makefile tier targets
lint_max_ms = 60_000              # 60s (clippy on large codebase)
lint_full_max_ms = 120_000        # 2min (full clippy with all features)
test_tier1_max_ms = 30_000        # 30s (unit tests)
test_tier2_max_ms = 600_000       # 10min (full test suite with GPU)
coverage_max_ms = 1_800_000       # 30min (coverage on 6700+ tests)
bench_max_ms = 1_200_000          # 20min (Criterion benchmarks)
binary_max_bytes = 50_000_000     # 50MB (ML inference binary)

# Soft limits (warnings only)
build_release_max_ms = 300_000    # 5min (release build)
mutation_test_max_ms = 7_200_000  # 2hr (mutation testing on large codebase)

# GPU-specific thresholds
cuda_test_max_ms = 600_000        # 10min (CUDA tests)

[staleness]
# Metrics older than this trigger warnings
max_age_days = 7

[enforcement]
# Pre-commit behavior (MEAN mode = strict)
fail_on_stale_metrics = false     # Warn, don't block
fail_on_missing_metrics = false   # Allow commits if no cache
fail_on_threshold_violation = true # Block commits on violations

[trend_analysis]
# Track metrics for Kaizen (continuous improvement)
enabled = true
retention_days = 90
alert_on_regression = true
regression_threshold_pct = 10.0   # Alert if >10% slower

[quality_gates]
# PMAT-802 targets (A+ grade)
min_coverage_pct = 95.0           # Target: 95% line coverage (PMAT-802)
min_mutation_score_pct = 80.0     # Target: 80% mutation score
max_cyclomatic_complexity = 10    # Target: <=10 per function
min_tdg_grade = "A"               # Target: A or better (>=90)
max_unsafe_blocks = 300           # Current: ~240 (GPU/SIMD code)
max_unwrap_calls = 50             # Prefer error handling
max_file_lines = 2000             # PMAT-802: No files >2000 lines
max_function_lines = 100          # Keep functions focused

[file_health]
# PMAT-802: File modularity targets
max_lines_per_file = 2000         # Hard limit
warn_lines_per_file = 1000        # Soft warning
target_health_pct = 95.0          # Target: 95% file health

[performance]
# Inference targets (llama.cpp parity)
min_toks_per_sec_q4 = 100.0       # Target: 100+ tok/s Q4_K
min_toks_per_sec_f32 = 0.1        # F32 is memory-bound
max_latency_p50_ms = 100          # p50 < 100ms
max_latency_p99_ms = 500          # p99 < 500ms
