/quality-gates

Quality BLOCKING Production high usage

/quality-gates

Overview

/quality-gates is a production command in the Quality category of the Prismatic Platform. It enforces a comprehensive set of quality gate checkpoints that every code change must pass before being accepted into the codebase. The gates cover compilation warnings, Credo static analysis, Dialyzer type checking, test execution, typespec coverage, memory safety patterns, and 13 total quality domains. The command operates at BLOCKING authority level, meaning it can halt commits, merge requests, and deployments when quality standards are not met.

This command is executed by the quality-gate-enforcer agent and represents the primary enforcement mechanism of the platform's quality infrastructure. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The BLOCKING authority level is the highest enforcement authority in the quality system, giving this command absolute veto power over any code change that fails to meet standards.

The quality gate system evolved from early compilation checks into a comprehensive 13-domain quality enforcement framework. Each domain has specific metrics, thresholds, and detection rules. The platform currently maintains a 100/100 quality score with zero violations across all domains, a state achieved through systematic application of quality gates over hundreds of evolution cycles.

Architecture

The quality gate system operates as a multi-stage checkpoint pipeline where each stage must pass before the next begins.

Gate Pipeline Architecture

              /quality-gates
                    |
           Gate Configuration
                    |
    +-------+-------+-------+-------+
    |       |       |       |       |
  Stage 1  Stage 2  Stage 3  Stage 4
  Compile  Static   Dynamic  Meta
    |       |       |       |
  Warnings Credo   Tests   Quality
  Dialyzer Pattern  Cover   Score
  Types    Safety   Perf    DNA
    |       |       |       |
    +-------+-------+-------+
                    |
           Gate Verdict
           (PASS/FAIL)
                    |
         +----+----+----+
         |    |         |
       Allow  Block   Report

Quality Domains (13 Total)

DomainGate StageCheck TypeCurrent Status
CompilationStage 1Zero warnings (--warnings-as-errors)0 violations
DialyzerStage 1Type consistency analysis0 violations
CredoStage 2Static code analysis (--strict)0 violations
Guard FunctionsStage 2Guard clause presence on public functions0 violations
Memory SafetyStage 2Unsafe map access, nil handling0 violations
Typespec CoverageStage 2@spec annotation completeness0 violations
@impl CoverageStage 2Callback implementation annotations0 violations (709 total)
DateTime PrecisionStage 2Microsecond precision enforcement0 violations
Timing PatternsStage 2Process.sleep and timer anti-patterns0 violations
TODO ManagementStage 2TODO/FIXME tracking and lifecycle0 violations
PerformanceStage 3Page load (<250ms), render (<100ms)0 violations
Regression PreventionStage 325 custom Credo checks0 violations
Quality ScoreStage 4Composite 100-point score100/100

Usage

# Run all quality gates (standard mode)
/quality-gates

# Run quick gates only (compilation + critical checks)
/quality-gates --quick

# Run full gates including performance benchmarks
/quality-gates --full

# Run gates for specific application
/quality-gates --app prismatic_web

# Run specific gate stage only
/quality-gates --stage 2

# Run gates with detailed output
/quality-gates --verbose

# Run gates in CI mode (optimized for pipelines)
/quality-gates --ci

# Pre-commit gate check (fastest)
/quality-gates --pre-commit

# Show gate configuration without running
/quality-gates --show-config

# Run gates and export report
/quality-gates --report ./gate-report.json

Practical Examples

# Pre-commit quick validation
/quality-gates --pre-commit --app prismatic_perimeter

# Full validation before merge request
/quality-gates --full --verbose --report ./mr-quality.json

# CI/CD pipeline gate (exits non-zero on failure)
/quality-gates --ci --exit-code

# Check specific quality domain
/quality-gates --domain dialyzer --verbose

# Validate after refactoring
/quality-gates --full --app prismatic_api --verbose

Options

OptionTypeDefaultDescription
--quickflagfalseRun only Stage 1 gates (fastest)
--fullflagfalseRun all stages including performance
--pre-commitflagfalseOptimized for pre-commit hook usage
--ciflagfalseCI/CD pipeline optimized mode
--appstringallSpecific application to gate
--stageintegerallRun specific gate stage (1-4)
--domainstringallCheck specific quality domain
--verboseflagfalseDetailed output per check
--exit-codeflagtrueReturn non-zero on failure
--reportpathnoneExport gate report to file
--show-configflagfalseDisplay gate configuration
--fixflagfalseAuto-fix violations where possible
--parallelflagtrueRun independent checks in parallel
--timeoutduration300sMaximum total execution time

Execution Flow

Stage 1: Compilation Gates

The first stage verifies that the codebase compiles cleanly:

  1. Zero-Warning Compilation -- mix compile --warnings-as-errors --force must produce zero warnings
  2. Dialyzer Analysis -- Type specifications are verified against actual function implementations
  3. Dependency Check -- All dependencies are present and compatible

Stage 1 failures block all subsequent stages. Compilation must be clean before any further analysis.

Stage 2: Static Analysis Gates

The second stage performs comprehensive static analysis:

  1. Credo Strict -- mix credo --strict checks code style, readability, and complexity
  2. Pattern Verification -- 25 custom Credo checks prevent regression of 700+ previously eliminated violations
  3. Memory Safety -- Detects unsafe map access (map.key without guard), nil propagation risks
  4. Typespec Coverage -- Ensures public functions have @spec annotations
  5. Guard Functions -- Verifies guard clauses on public function heads
  6. @impl Annotations -- Confirms callback implementations are annotated
  7. DateTime Precision -- Enforces microsecond precision in all timestamp operations
  8. Timing Patterns -- Detects Process.sleep usage and timer anti-patterns
  9. TODO Management -- Tracks and enforces TODO lifecycle rules

Stage 3: Dynamic Analysis Gates

The third stage runs tests and performance benchmarks:

  1. Test Suite -- mix test with full coverage reporting
  2. Performance Checks -- Page load times, render times, health check response times
  3. Regression Tests -- Dedicated regression test suite for previously fixed bugs

Stage 4: Meta-Quality Gates

The fourth stage evaluates overall quality health:

  1. Quality Score -- Composite score across all 13 domains must be >= 100
  2. Quality DNA -- Cross-session quality continuity verification
  3. Quality Floor -- Guardian checks that quality has not regressed below floor

Integration Points

ComponentIntegration TypeDescription
/quality-unifiedPeerUnified quality interface delegates to gates
/quality-evolveConsumerEvolution validated through gates
/quality-hbfsPeerHBFS prioritization informs gate focus
/quality-enforcePeerEnforcement policies drive gate thresholds
/regression-checkComponentRegression checks are a gate stage 2 component
Pre-commit HookCallerGit pre-commit invokes --pre-commit mode
CI/CD PipelineCallerGitLab CI invokes --ci mode
TelemetryMonitoringGate execution metrics and trends

Best Practices

Gate Mode Selection

Choose the appropriate gate mode for your context:

ContextRecommended ModeTypical Duration
Every file save--pre-commit --quick10-30s
Before commit--pre-commit30-60s
Before merge request--full2-5 min
CI/CD pipeline--ci --full3-8 min
After major refactor--full --verbose5-10 min

Handling Gate Failures

When gates fail, the output identifies the specific domain, violation location, and suggested fix. Address violations in priority order:

  1. Stage 1 failures (compilation) -- Must fix first; blocks everything
  2. Stage 2 critical (memory safety, regression) -- High risk if ignored
  3. Stage 2 standard (Credo, typespecs) -- Code quality
  4. Stage 3 (tests, performance) -- Runtime behavior
  5. Stage 4 (meta-quality) -- Systemic health

Continuous Gate Compliance

Maintain continuous gate compliance rather than batch-fixing before merges. Running --pre-commit --quick after every significant change catches violations early when they are cheapest to fix.

Error Handling

Error CodeDescriptionResolution
GATE_BLOCKEDOne or more gates failed, code change blockedFix violations shown in output
COMPILATION_WARNINGZero-warning policy violatedFix or suppress the specific warning
DIALYZER_MISMATCHType specification inconsistencyCorrect @spec to match implementation
CREDO_VIOLATIONStatic analysis rule violatedFollow Credo suggestion in output
TEST_FAILUREOne or more tests failedFix failing tests before proceeding
PERFORMANCE_VIOLATIONPage load or render time exceeded limitOptimize slow paths; see profiling data
QUALITY_REGRESSIONQuality score decreased from baselineInvestigate which domain regressed
TIMEOUTGate execution exceeded time limitIncrease --timeout or narrow scope with --app

Advanced Usage

Custom Gate Profiles

Create named gate profiles for different scenarios:

# Use a custom profile for experimental branches
/quality-gates --profile experimental  # Relaxed thresholds
/quality-gates --profile production    # Strictest thresholds

Selective Domain Override

Temporarily exempt specific domains (with documented justification):

# Skip Dialyzer for rapid prototyping (requires L3+ authority)
/quality-gates --skip-domain dialyzer --reason "prototyping phase, will add types before merge"

Gate Trend Analysis

Analyze quality gate results over time:

/quality-gates --history 30d --format json --report ./gate-trends.json

Doctrine Compliance

All commands operate under the NO MERCY, NO DOUBTS doctrine:

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. Gate failures are absolute: no code passes through a failed gate.
  • NO DOUBTS: Full investigation before action, evidence-based results. Every gate verdict includes specific evidence for the pass/fail decision.

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL