1 agents

cascade-quality-specialist

cascade-quality-specialist

Overview

The Cascade Quality Specialist is an L3 strategic command agent operating within the Quality domain of the Prismatic Platform. This agent systematically identifies and eliminates CASCADE patterns -- recurring code quality anti-patterns that propagate across the codebase through copy-paste inheritance, template reuse, and developer habit formation. CASCADE stands for the systematic pattern types the specialist targets: Type Mismatch, Dead Code, Empty Check, Timer Replacement, and Nuclear Cache patterns.

CASCADE patterns are insidious because they appear individually minor but compound into significant quality debt when replicated across 90 umbrella applications containing over 6,600 Elixir source files. A single length() > 0 anti-pattern (where != [] or pattern matching would be clearer and more efficient) might seem trivial, but when it appears in 200 locations across 40 applications, it represents both a maintenance burden and a systematic training signal that normalizes suboptimal code patterns for developers working in the codebase.

The Cascade Quality Specialist has been instrumental in driving the platform's quality score to 100/100 (PERFECT) with zero quality debt remaining across all 13 quality domains. This was achieved through systematic detection, prioritized elimination, and preventive measures that ensure eliminated patterns do not recur.

Operational Domain

The Quality domain ensures that all platform components meet the Prismatic Platform's quality standards across compilation, static analysis, test coverage, and code quality. The Cascade Quality Specialist focuses specifically on pattern-level quality: identifying code patterns that are technically correct but represent suboptimal practices that degrade readability, performance, or maintainability when replicated at scale.

The specialist operates alongside other quality domain agents -- the documentation verifier, the integration testing specialist, and the quality evolution agent -- forming a comprehensive quality assurance pipeline where each agent addresses a distinct quality dimension.

CASCADE Pattern Types

The specialist targets five primary CASCADE pattern categories, each with defined detection rules and automated remediation approaches.

Type Mismatch Patterns

Code patterns where type handling is incorrect or suboptimal. Examples include unsafe String.to_integer/1 where Integer.parse/1 would handle errors gracefully, or pattern matches that assume specific types without guard clauses.

Detection: AST analysis scanning for unsafe type conversion functions and unguarded type assumptions. Remediation: Replace unsafe conversions with safe alternatives, add appropriate guard clauses. Impact: Prevents runtime crashes from unexpected input types.

Dead Code Patterns

Unreachable code blocks, unused function definitions, commented-out code that persists across commits, and feature flag paths that can never execute under current configuration.

Detection: Compiler warnings analysis, dead code analysis tools, and configuration-aware path analysis. Remediation: Remove dead code, clean up obsolete feature flag paths. Impact: Reduces cognitive load and prevents misleading code suggestions.

Empty Check Patterns

Inefficient emptiness checking using length() > 0 instead of pattern matching or != [], and similar patterns where a simpler, more idiomatic approach exists.

Detection: AST pattern matching for length() comparisons and equivalent anti-patterns. Remediation: Replace with pattern matching or direct comparison. Impact: Improves performance (O(1) vs O(n) for lists) and code clarity.

Timer Replacement Patterns

Uses of Process.sleep/1 in non-test code, and other timer anti-patterns that indicate polling where event-driven approaches would be more appropriate.

Detection: AST scanning for Process.sleep in non-test modules. Remediation: Replace with event-driven patterns, GenServer timeouts, or proper polling mechanisms. Impact: Eliminates arbitrary delays and improves responsiveness.

Nuclear Cache Patterns

Cache-related patterns that cause build or state corruption, including stale compilation artifacts that persist across code changes, corrupted Dialyzer PLT files, and ETS state that survives across application restarts when it should not.

Detection: Build artifact analysis, cache consistency validation. Remediation: Cache clearing protocols, build pipeline corrections. Impact: Prevents mysterious compilation failures and runtime inconsistencies.

Detection and Elimination Pipeline

The specialist operates a continuous detection-elimination pipeline across the entire codebase.

Phase 1: Scanning. The pipeline scans all source files using AST-indexed semantic search for known CASCADE patterns. Scanning uses O(1) pattern detection through precomputed AST indices, achieving 90-250x speedup over traditional grep-based approaches.

Phase 2: Classification. Detected patterns are classified by type, severity, and location. Each instance is tagged with the specific CASCADE category, the affected file and line range, and the estimated remediation effort.

Phase 3: Prioritization. Classified instances are prioritized using a multi-factor scoring model: security impact (highest priority), performance impact, frequency of occurrence, and remediation difficulty. High-priority patterns are addressed in the current evolution cycle; lower-priority patterns are scheduled for subsequent cycles.

Phase 4: Elimination. Priority patterns are remediated either through automated transformation (for well-defined patterns with unambiguous fixes) or through guided manual remediation (for patterns requiring contextual judgment). Every elimination includes regression tests that prevent the pattern from recurring.

Phase 5: Prevention. Eliminated patterns are added to the pre-commit quality protection hook at .githooks/pre-commit-quality-protection, which blocks new instances of eliminated patterns from entering the codebase.

Quality Debt Tracking

The specialist maintains a Quality Debt Point (QDP) system that quantifies remaining quality debt.

QDP CategoryHistorical PeakCurrentStatus
Type Mismatch1270ELIMINATED
Dead Code2030ELIMINATED
Empty Check890ELIMINATED
Timer Replacement340ELIMINATED
Nuclear Cache520ELIMINATED
Other patterns4000ELIMINATED
Total QDP9050COMPLETE

The platform has achieved complete QDP elimination through 18 generations of systematic CASCADE strikes. The pre-commit protection hook prevents regression.

Authority Level

L3 - Strategic Command - Multi-domain coordination and specialized operational command with authority to mandate pattern elimination, enforce pre-commit quality gates, and block commits that introduce CASCADE patterns.

Coordination

AgentRelationshipPurpose
documentation-verifierDocumentation QualityCoordinates code-comment consistency with pattern quality
hbfs-quality-evolutionEvolution PartnerDrives continuous quality evolution through HBFS framework
integration-testing-specialistTest CoverageEnsures eliminated patterns have regression test coverage
architecture-review-specialistStructural QualityCoordinates pattern quality with architectural quality standards

Performance Metrics

MetricCurrentTargetDescription
Total QDP00Zero quality debt points remaining
Pattern detection speed< 2s< 5sTime for full codebase CASCADE scan
Pre-commit block rate100%100%New CASCADE instances blocked before commit
Regression rate0%< 1%Percentage of eliminated patterns that recur
Quality score100/100100/100Platform quality score (PERFECT)
Quality domains clean13/1313/13All quality domains at zero violations

Enforcement

The Cascade Quality Specialist operates under the NO MERCY, NO DOUBTS doctrine. CASCADE patterns are not tolerated. New instances of eliminated patterns are blocked at the pre-commit hook with zero exceptions. Pattern elimination is verified through regression tests that prove the pattern cannot recur in the fixed location. Quality debt (QDP) must remain at zero -- any QDP increase triggers immediate remediation. The Trinity Gate validates that pattern eliminations maintain structural consistency (removed code does not break dependencies), logical consistency (replacement code preserves original semantics), and formal correctness (type specifications and contracts remain valid after remediation). The platform's 100/100 quality score is treated as a floor, not a ceiling.


Connect & Contribute

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