-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or requestfeature:phase2-governancePhase 2 Governance featuresPhase 2 Governance featuresphase:P2.1Core GovernanceCore Governance
Description
Task: Implement priority-based rule sorting
Phase: 2.1 - Core Governance
Estimated: 0.5 day
File: cch_cli/src/hooks/processor.rs
Depends on: P2.1-T03
Description
Sort rules by priority before matching, with higher numbers running first.
Acceptance Criteria
- Create function
sort_rules_by_priority(rules: &mut Vec<Rule>) - Sort by priority descending (higher first)
- Stable sort to preserve file order for same priority
- Default priority = 0 for rules without explicit priority
- Call sorting before rule matching in hook processor
- Add unit tests for sorting behavior
Code Reference
pub fn sort_rules_by_priority(rules: &mut [Rule]) {
rules.sort_by(|a, b| {
let priority_a = a.priority.unwrap_or(0);
let priority_b = b.priority.unwrap_or(0);
priority_b.cmp(&priority_a) // Descending order
});
}Tests Required
- Higher priority rules run first
- Same priority preserves file order (stable sort)
- Default priority (0) sorts after explicit priorities
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfeature:phase2-governancePhase 2 Governance featuresPhase 2 Governance featuresphase:P2.1Core GovernanceCore Governance