Quality Gates Framework
Relevant source files
The following files were used as context for generating this wiki page:
The Quality Gates Framework in flext-infra provides a structured, extensible system for enforcing code quality, documentation standards, and architectural constraints across a workspace. It utilizes a unified "check" and "fix" lifecycle, allowing tools to both detect violations and, where supported, automatically remediate them. This framework is a core component of the project's build automation and workspace management capabilities.
Sources: src/flext_infra/gates/base_gate.py, src/flext_infra/check/workspace_check.py:27-28, README.md
Framework Architecture
The framework is built on a template-based inheritance model. Every quality gate inherits from a common base class that defines the execution flow for timing, directory discovery, command building, and output parsing.
Base Gate Logic
The FlextInfraGate class serves as the abstract foundation. It implements the standard logic for executing check and fix operations via external CLI tools or internal validators.
The diagram above shows the standard template method flow for a gate execution.
Sources: src/flext_infra/gates/base_gate.py:38-66, src/flext_infra/gates/base_gate.py:127-160
Core Components
| Component | Description | Source |
|---|---|---|
FlextInfraGate | Abstract base class defining the check/fix lifecycle. | base_gate.py:21 |
FlextInfraWorkspaceChecker | Orchestrator that resolves project targets and runs gates. | workspace_check.py:27 |
GateExecution | Data structure containing the result, issues, and raw output. | _models/check.py:212 |
GateContext | Contextual settings including workspace root, reports dir, and fix flags. | _models/check.py:30 |
Gate Lifecycle Operations
Check Operation
The check operation is the primary diagnostic phase. It identifies files to be processed, builds a command (e.g., calling ruff or markdownlint), executes it, and parses the output into a structured Issue list.
- Discovery: Uses
discover_python_dirsto locate relevant targets. - Execution: Handles timeouts and environment variable injection.
- Warning Mode: Supports a "warn" mode where gates report issues but do not fail the overall pipeline.
Sources: src/flext_infra/gates/base_gate.py:38-66, src/flext_infra/gates/base_gate.py:257-287
Fix Operation
If a gate implements can_fix = True, it can automatically repair detected violations. The framework supports "check-only" fix previews where no files are written to disk.
Sequence diagram depicting the Fix lifecycle within the Quality Gates Framework.
Implementation Examples
Markdown Gate
The FlextInfraMarkdownGate utilizes markdownlint to enforce documentation standards. It resolves configuration by looking for .markdownlint.json in the workspace root or project directory.
Sources: src/flext_infra/gates/markdown.py:17-30
Namespace Gate
The FlextInfraNamespaceGate is a specialized gate that does not use an external CLI tool. Instead, it leverages a FlextInfraNamespaceValidator to enforce static namespace rules (NS-000..003) via rope.
Sources: src/flext_infra/gates/namespace.py:18-25
Codegen Quality Gate
The FlextInfraCodegenQualityGate performs workspace-wide checks specifically for constants migration. It compares "before" and "after" metrics, detects duplicate constant groups, and computes a final verdict based on namespace compliance and type safety.
Sources: src/flext_infra/codegen/constants_quality_gate.py:27-72
Data Models
The framework relies on Pydantic models to ensure strict typing and serializable reports.
| Model | Key Fields | Description |
|---|---|---|
Issue | file, line, column, code, message | Describes a specific violation. |
GateResult | gate, passed, errors, duration | Summary of a single gate's performance on a project. |
ProjectResult | gates, passed, total_errors | Aggregated results for an entire project across multiple gates. |
Sources: src/flext_infra/_models/check.py:178-208, src/flext_infra/_models/check.py:230-249
Reporting and Orchestration
The FlextInfraWorkspaceChecker manages the execution loop across multiple projects. It handles:
- Project Discovery: Resolving explicit project lists or discovering all workspace projects.
- Gate Resolution: Validating requested gate names against the
ALLOWED_GATESlist. - Artifact Generation: Writing JSON summaries and markdown reports (e.g.,
check-summary.json) to the specified reports directory.
Sources: src/flext_infra/check/workspace_check.py:64-98, src/flext_infra/check/workspace_check.py:151-182
The Quality Gates Framework ensures that all code and documentation changes meet the rigorous standards of the FLEXT infrastructure before being integrated, providing both automated enforcement and actionable feedback for developers.