t1045: Fix SonarCloud regression detection + auto-remediation#1418
t1045: Fix SonarCloud regression detection + auto-remediation#1418marcusquinn merged 3 commits intomainfrom
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
WalkthroughThree shell scripts are modified to refine audit automation and boundary matching. Code-audit-helper receives a duplicate case arm for check-regression; issue-sync simplifies boundary pattern construction; pulse.sh reduces field consumption and introduces auto-remediation for audit findings via task creation. Changes
Sequence Diagram(s)sequenceDiagram
participant Pulse as pulse.sh (Phase 10c)
participant Helper as audit-task-creator<br/>-helper.sh
participant TaskSys as Task System
participant Log as Logging
Pulse->>Pulse: Detect audit regression
Pulse->>Helper: Check if helper exists
alt Helper exists
Pulse->>Helper: Invoke to auto-create task
Helper->>TaskSys: Create task from findings
TaskSys-->>Helper: Task created
Helper-->>Pulse: Success
Pulse->>Log: Log success message
else Helper missing
Pulse->>Log: Log warning (graceful fallback)
end
Pulse->>Log: Continue with standard logging
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 14 00:30:22 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 14 00:31:25 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 14 00:39:49 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sat Feb 14 00:43:33 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
…t1045) - Add cmd_check_regression() to detect >20% increase in findings - Compare latest vs previous audit run - Return exit 1 on regression, 0 otherwise - Update help text and main dispatcher - Fixes 189 false warnings in supervisor.log
- When regressions detected, auto-create tasks via audit-task-creator-helper.sh - Filter for high severity findings and auto-dispatch - Fixes pattern (2): regression detection now creates actionable tasks - Update Phase 10c comment to reflect auto-remediation capability
- Remove unused escaped_task_regex in issue-sync.sh - Replace unused read variables with _ placeholder in pulse.sh (3 occurrences) - All modified .sh files now pass shellcheck -x -S warning
2efaf23 to
6435ef0
Compare
🔍 Code Quality Report�[0;35m[MONITOR]�[0m Code Review Monitoring Report �[0;34m[INFO]�[0m Latest Quality Status: �[0;34m[INFO]�[0m Recent monitoring activity: 📈 Current Quality Metrics
Generated on: Sun Feb 15 00:51:57 UTC 2026 Generated by AI DevOps Framework Code Review Monitoring |
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
.agents/scripts/code-audit-helper.sh (2)
1385-1400:⚠️ Potential issue | 🟡 MinorDuplicate
check-regressioncase arm — the second one (Line 1392) is unreachable dead code.Bash
casematches the first arm and never reaches the duplicate at Line 1392. This should be removed to avoid confusion and maintain Zero Technical Debt standards.🧹 Remove duplicate case arm
case "$command" in audit) cmd_audit "$@" ;; report) cmd_report "$@" ;; summary) cmd_summary "$@" ;; check-regression) cmd_check_regression "$@" ;; status) cmd_status "$@" ;; reset) cmd_reset "$@" ;; - check-regression) cmd_check_regression "$@" ;; help | --help | -h) show_help ;; *)
1242-1256:⚠️ Potential issue | 🟠 MajorValidate that API-derived values are numeric before SQL interpolation and arithmetic.
Variables
$total,$critical,$high,$medium,$loware parsed from an external API response and interpolated directly into a SQLINSERT(Line 1256) and bash arithmetic (Lines 1267–1282). Ifjqreturns an empty string or non-numeric value (e.g., malformed API response), this causes either SQL syntax errors or bash arithmetic failures underset -e.🛡️ Add numeric validation after parsing
total=$(echo "$response" | jq -r '.total // 0' 2>/dev/null) || total=0 critical=$(echo "$response" | jq -r '[.facets[]? | select(.property=="severities") | .values[]? | select(.val=="BLOCKER" or .val=="CRITICAL") | .count] | add // 0' 2>/dev/null) || critical=0 high=$(echo "$response" | jq -r '[.facets[]? | select(.property=="severities") | .values[]? | select(.val=="MAJOR") | .count] | add // 0' 2>/dev/null) || high=0 medium=$(echo "$response" | jq -r '[.facets[]? | select(.property=="severities") | .values[]? | select(.val=="MINOR") | .count] | add // 0' 2>/dev/null) || medium=0 low=$(echo "$response" | jq -r '[.facets[]? | select(.property=="severities") | .values[]? | select(.val=="INFO") | .count] | add // 0' 2>/dev/null) || low=0 + + # Sanitise: ensure all counts are integers (guards against malformed API responses) + [[ "$total" =~ ^[0-9]+$ ]] || total=0 + [[ "$critical" =~ ^[0-9]+$ ]] || critical=0 + [[ "$high" =~ ^[0-9]+$ ]] || high=0 + [[ "$medium" =~ ^[0-9]+$ ]] || medium=0 + [[ "$low" =~ ^[0-9]+$ ]] || low=0As per coding guidelines,
.agents/scripts/*.sh: "Reliability and robustness" and "Error recovery mechanisms".
🧹 Nitpick comments (2)
.agents/scripts/code-audit-helper.sh (1)
1249-1253: Three separate DB queries for the same row — consider consolidating.Lines 1251–1253 each query
regression_snapshotsfor the same latest row. A single query returning all three columns would be cleaner and slightly more efficient.♻️ Consolidate into one query
- prev_total=$(db "$AUDIT_DB" "SELECT total FROM regression_snapshots WHERE source='sonarcloud' ORDER BY id DESC LIMIT 1;" 2>/dev/null) || prev_total="" - prev_critical=$(db "$AUDIT_DB" "SELECT critical FROM regression_snapshots WHERE source='sonarcloud' ORDER BY id DESC LIMIT 1;" 2>/dev/null) || prev_critical="" - prev_high=$(db "$AUDIT_DB" "SELECT high FROM regression_snapshots WHERE source='sonarcloud' ORDER BY id DESC LIMIT 1;" 2>/dev/null) || prev_high="" + local prev_snapshot + prev_snapshot=$(db "$AUDIT_DB" -separator '|' "SELECT total, critical, high FROM regression_snapshots WHERE source='sonarcloud' ORDER BY id DESC LIMIT 1;" 2>/dev/null) || prev_snapshot="" + local prev_total prev_critical prev_high + IFS='|' read -r prev_total prev_critical prev_high <<<"$prev_snapshot".agents/scripts/supervisor/pulse.sh (1)
1479-1508: Phase 10c auto-remediation logic is solid with valid DRY improvement opportunity.The regression detection → auto-task-creation flow is well-structured: proper cooldown, guarded execution, graceful failure handling, and correct flag usage for
audit-task-creator-helper.sh(which supports both--severity highand--dispatch).However,
task_creatorat line 1484 duplicates the path already assigned tounified_task_creatorat line 1318 in the same function scope. Consider reusing the existing variable to reduce duplication and avoid drift if the path changes.♻️ Reuse existing variable
- local task_creator="${SCRIPT_DIR}/audit-task-creator-helper.sh" if [[ -x "$audit_helper" ]]; then ... if ! bash "$audit_helper" check-regression 2>>"$SUPERVISOR_LOG"; then log_warn " Phase 10c: Audit regressions detected — review SonarCloud dashboard" # Auto-create tasks for new findings (t1045) - if [[ -x "$task_creator" ]]; then + if [[ -x "$unified_task_creator" ]]; then log_info " Phase 10c: Auto-creating tasks for new findings" - if bash "$task_creator" create --severity high --dispatch 2>>"$SUPERVISOR_LOG"; then + if bash "$unified_task_creator" create --severity high --dispatch 2>>"$SUPERVISOR_LOG"; then



Summary
Verification (t1008 verify worker)
All three deliverables confirmed complete and functional:
Files Changed (11)
Summary by CodeRabbit
New Features
Refactor