Skip to main content

Module quality_gates

Module quality_gates 

Expand description

Quality-gates: parse .codelore-thresholds.toml at the repo root and evaluate a fact store against the declared gates. Used by codelore check to power CI quality-gate enforcement.

§Config schema

[gates]
cognitive_max = 30        # any file exceeding fails
code_health_min = 60      # any file below fails (composite code-health score, 0..=100)
hotspot_score_max = 8.0   # any file above fails
disallow_clone_type_1 = true
max_dependency_cycles = 0 # no import-graph cycles allowed
max_propagation_cost = 0.15  # change-reach ceiling (0..1)
max_red_effort_pct = 30.0    # red-band churn ceiling (%, [0, 100])

[diff]
delta_code_health_min = -5  # health may drop at most 5 pts in a PR
new_hotspot_max = 0         # zero new hotspots allowed
no_new_cycles = true        # a PR may not introduce a dependency cycle
delta_code_health_min_per_file = 0.0  # gate-only: no changed file may lower its own health
new_file_health_min = 50.0  # gate-only: added files must clear this floor

[calibration]
defect_artifact = "defects.calib.json"  # repo-declared --defect-calibration default

§Why thresholds-in-repo vs CLI flags

Thresholds live with the codebase, not the invocation. That means the gate is the same whether a contributor’s pre-push hook, GitHub Actions, an IDE plugin, or a release pipeline runs the check. Per the feedback_modernize_dont_migrate memory: thresholds files predate CodeLore (CodeMaat reads CSV rules); ours integrates with --group-file, --mailmap, and the existing convention-naming pattern — same data, deeper DX.

Re-exports§

pub use config::CalibrationConfig;
pub use config::DiffGates;
pub use config::Gates;
pub use config::NewCodeGates;
pub use config::THRESHOLDS_FILENAME;
pub use config::Thresholds;
pub use config::resolve_defect_calibration;
pub use evaluators::ArchMeasured;
pub use evaluators::GateViolation;
pub use evaluators::change_set_gate_verdict;
pub use evaluators::diff_gate_verdict;
pub use evaluators::evaluate_architecture_gate;
pub use evaluators::evaluate_architecture_gate_measured;
pub use evaluators::evaluate_clone_gate;
pub use evaluators::evaluate_code_health_gate;
pub use evaluators::evaluate_corpus_percentile_rows;
pub use evaluators::evaluate_diff_gate;
pub use evaluators::evaluate_effort_exposure_gate;
pub use evaluators::evaluate_effort_exposure_rows;
pub use evaluators::evaluate_effort_exposure_rows_exempt;
pub use evaluators::evaluate_familiarity_gate;
pub use evaluators::evaluate_familiarity_rows;
pub use evaluators::evaluate_finding_overlap_rows;
pub use evaluators::evaluate_full_tree;
pub use evaluators::evaluate_gate_thresholds;
pub use evaluators::evaluate_hotspot_anchored_rows;
pub use evaluators::evaluate_new_code_rows;
pub use evaluators::head_has_scorable_source;
pub use evaluators::verdict_from;

Modules§

config
Threshold configuration: parse, discover, and validate .codelore-thresholds.toml.
evaluators
Gate evaluators: pure comparisons of analysis result sets (or a fact store) against the configured Thresholds, each returning the list of GateViolations it found.
evidence
Evidence chain for gate findings — the top-N commits that most recently and heavily touched a path, used to populate codeFlows and relatedLocations in SARIF output.
ledger
Gate-run ledger: append-only JSONL record of every evaluated gate.
ratchet
Betterer-style committed quality snapshot for codelore check --ratchet.