/quality-enforce

Quality P0 ABSOLUTE Production high usage

/quality-enforce

Overview

/quality-enforce is a production command in the Quality category of the Prismatic Platform that implements mandatory progressive quality debt elimination with AIAD enforcement. This is the platform's highest-authority quality command, operating at P0 ABSOLUTE -- a non-bypassable enforcement level that ensures every session, every commit, and every deployment contributes to maintaining the platform's quality score at 100/100 across all 13 quality domains.

The command scans the codebase for quality violations across all monitored domains, classifies them by severity and remediation cost, generates fix plans, and optionally auto-fixes violations that have safe, deterministic corrections. It operates on the fundamental platform principle that quality debt compounds exponentially -- a single tolerated violation creates precedent for more, eventually undermining the entire quality infrastructure. The platform's journey from an initial quality score to the current perfect 100/100 was driven primarily by this command's relentless enforcement.

This command operates under the P0 ABSOLUTE authority level and is executed by the quality-enforcement-commander agent. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The P0 ABSOLUTE authority means this command can block commits, reject deployments, and escalate violations to the highest platform authority levels without exception.

Quality enforcement is not a one-time activity -- it is woven into every phase of the development lifecycle. The command integrates with pre-commit hooks, CI/CD pipelines, session lifecycle events, and the autonomous evolution system to ensure that quality never regresses, even as the codebase grows. The current platform state of zero quality debt across 6,600+ Elixir source files is maintained through continuous enforcement by this command.

Architecture

The quality enforcement system operates through a layered architecture of scanners, classifiers, and enforcers.

Quality Enforcement Command
         |
         v
+-------------------+
| Domain Scanner    |
| (13 domains)      |
+-------------------+
         |
         v
+-------------------+
| Violation         |
| Classifier        |
+-------------------+
         |
    +----+----+
    |         |
    v         v
+--------+ +--------+
| Auto   | | Manual |
| Fixer  | | Report |
+--------+ +--------+
    |         |
    v         v
+-------------------+
| Enforcement Gate  |
| (BLOCKING)        |
+-------------------+

Quality Domains (13 Monitored)

DomainScannerCurrent Status
DialyzerStatic type analysis0 violations
CredoCode style and consistency0 violations
CompilationZero-warning compilation0 violations
DateTime PrecisionTimestamp handling correctness0 violations
Guard FunctionsProper guard clause usage0 violations
@impl CoverageCallback implementation annotations0 violations (709 annotations)
Memory SafetyUnsafe memory access patterns0 violations
PerformanceAnti-pattern detection0 violations
Regression PreventionKnown-bad pattern detection0 violations
Timing PatternsProcess.sleep and timing anti-patterns0 violations
TODO ManagementStale TODO/FIXME tracking0 violations
Typespec Coverage@spec annotation completeness0 violations
Unsafe Map Accessmap.field vs Map.get/2 patterns0 violations

Usage

Comprehensive Enforcement

# Run full quality enforcement across all domains
/quality-enforce

# Run with auto-fix for safe violations
/quality-enforce --fix

# Run specific domain only
/quality-enforce --domain dialyzer

# Run for specific application
/quality-enforce --app prismatic_perimeter

Progressive Elimination

# Show violations ordered by remediation cost (easiest first)
/quality-enforce --progressive

# Fix the N easiest violations
/quality-enforce --fix --limit 10

# Show the quality debt reduction plan
/quality-enforce --plan

# Execute the next planned elimination step
/quality-enforce --step

CI/CD Integration

# Blocking check with exit code (0 = pass, 1 = fail)
/quality-enforce --check --exit-code

# JSON output for CI reporting
/quality-enforce --check --format json

# Check only changed files (fast)
/quality-enforce --changed-only

# Pre-commit mode (minimal, fast)
/quality-enforce --pre-commit

Reporting

# Generate quality report
/quality-enforce --report

# Show quality trend over time
/quality-enforce --trend --window 30d

# Export violation details for tracking
/quality-enforce --export violations.json

# Show per-app quality scores
/quality-enforce --scores

Options & Parameters

OptionTypeDefaultDescription
--fixbooleanfalseAuto-fix safe violations
--domainstringallSpecific quality domain to check
--appstringallSpecific umbrella application to check
--progressivebooleanfalseOrder violations by remediation cost
--limitintegernilMaximum violations to fix in one run
--planbooleanfalseShow the quality debt elimination plan
--stepbooleanfalseExecute the next planned elimination step
--checkbooleanfalseCheck-only mode (no modifications)
--exit-codebooleanfalseSet exit code based on result
--changed-onlybooleanfalseCheck only files changed since last commit
--pre-commitbooleanfalseFast pre-commit mode
--reportbooleanfalseGenerate quality report
--trendbooleanfalseShow quality trend over time
--windowstring7dTime window for trend analysis
--formatjson | text | tabletextOutput format
--scoresbooleanfalseShow per-app quality scores
--verbosebooleanfalseDetailed violation descriptions

Execution Flow

  1. Domain Initialization -- All 13 quality domain scanners are initialized. Each scanner loads its configuration, including patterns to detect, severity levels, and auto-fix capabilities.

  2. File Discovery -- The target file set is determined based on scope options (--app, --changed-only, --domain). Git tree optimization is used for fast file enumeration.

  3. Parallel Scanning -- Domain scanners execute in parallel across the file set. Each scanner produces a list of violations with location, severity, description, and (where available) an auto-fix transformation.

  4. Violation Classification -- Violations are classified by severity (critical, warning, info) and remediation cost (trivial, easy, moderate, complex). Critical violations from BLOCKING domains halt the pipeline.

  5. Auto-Fix Application -- If --fix is enabled, violations with safe auto-fixes are applied. Each fix is validated by recompiling and running affected tests. Fixes that cause regressions are rolled back.

  6. Report Generation -- A summary report is generated showing violations found, violations fixed, remaining violations, and quality score impact.

  7. Gate Enforcement -- If violations remain and the command is running in --check or --pre-commit mode, the enforcement gate blocks the operation with a non-zero exit code.

Integration Points

SystemIntegrationPurpose
Quality GatesDirect quality gate enforcementGate authority
Pre-commit HooksPre-commit quality validationCommit blocking
CI/CD PipelineQuality check in deployment pipelineDeployment blocking
Quality DNAQuality state persistence across sessionsState tracking
Quality Floor GuardianAutonomous quality monitoringMonitoring
SEADFQuality evolution trackingEvolution
TelemetryEnforcement metrics and eventsObservability
CredoCode style domain scannerDomain input
DialyzerType analysis domain scannerDomain input

Best Practices

  1. Run before every commit -- The pre-commit hook should invoke /quality-enforce --pre-commit automatically. This catches violations before they enter the repository.

  2. Fix progressively -- When inheriting a codebase with quality debt, use --progressive --fix --limit 10 to fix the easiest violations first, building momentum before tackling complex ones.

  3. Never bypass -- The P0 ABSOLUTE authority means there is no legitimate reason to bypass quality enforcement. If a violation cannot be fixed, the approach needs to change, not the enforcement.

  4. Monitor trends -- Use --trend weekly to ensure quality scores remain stable or improving. Any downward trend indicates enforcement gaps.

  5. Per-app focus -- Use --app to focus enforcement on applications being actively developed. This provides faster feedback during development cycles.

Error Handling

ErrorCauseResolution
{:error, :compilation_required}Codebase needs compilation before scanningRun mix compile first
{:error, :fix_regression}Auto-fix caused test failureFix is rolled back; manual intervention needed
{:error, :domain_scanner_failed, domain}A domain scanner crashedCheck scanner configuration and dependencies
{:error, :quality_gate_failed}Violations remain after enforcementFix remaining violations before proceeding

Advanced Usage

CASCADE Pattern Detection

The enforcer detects CASCADE patterns -- categories of violations that tend to appear together and can be eliminated as a group:

# Detect and fix CASCADE patterns
/quality-enforce --cascade

# Known CASCADE patterns:
# - Type Mismatch (Dialyzer + Typespec)
# - Dead Code (Compilation warnings + Credo)
# - Empty Check (Guard Functions + Unsafe Map Access)
# - Timer Replacement (Timing Patterns + Performance)
# - Nuclear Cache (corrupted build artifacts)

Quality DNA Integration

# Check quality DNA state for an application
{:ok, dna} = QualityDNA.load("prismatic_perimeter")
# => %{score: 60, domains: %{dialyzer: 0, credo: 0, ...}}

Custom Domain Registration

# Register a custom quality domain
QualityEnforcement.register_domain(:custom_check, %{
  scanner: MyApp.CustomScanner,
  severity: :warning,
  auto_fixable: true,
  blocking: false
})

Doctrine Compliance

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

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. This command IS the NO MERCY doctrine in action. Every violation is detected, classified, and either fixed or blocked. No exceptions, no bypass, no deferred fixes.
  • NO DOUBTS: Full investigation before action, evidence-based results. Every violation is reported with its exact location, root cause, and remediation path. Auto-fixes are validated by compilation and tests before acceptance.

The command enforces NABLA axioms through its multi-domain scanning approach (Signal Plurality), its refusal to suppress any violation category (Contradiction Preservation), and its traceability of every fix to its originating violation (Provenance Mandatory).

  • /quality-gates - Enforce quality gate checkpoints with zero-warning compilation validation
  • /quality-unified - Unified quality command with quick, full, pre-commit and CI modes
  • /quality-hbfs - Hottest-bug-first search for quality assessment prioritization
  • /regression-check - Execute 25 custom Credo regression checks preventing 700+ violations
  • /benchmark - Comprehensive performance benchmarking with P95/P99 analysis
  • /fix - Bug fix implementation with mandatory regression tests

Connect & Contribute

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