fix(circuit-breaker): address CodeRabbit review feedback
Aligns error detection patterns across all implementations and improves test coverage based on CodeRabbit's critical and major findings. Changes: 1. CRITICAL: Align lib/response_analyzer.sh pattern with ralph_loop.sh - Changed Stage 1 filter from '"[^"]*\(error\|failed\)"[^"]*":' to '"[^"]*error[^"]*":' - Removed bare 'cannot' and 'unable to' from Stage 2 (prevent false positives in prose) - Both files now use identical patterns for consistency 2. MAJOR: Improved test coverage - Renamed test 10 from "Cannot/unable in error context" to "Error prefix with descriptive message" - Added test 10a to validate bare "cannot/unable" DON'T trigger false positives - Now testing 13 scenarios (was 12) 3. MINOR: Added comprehensive test strategy documentation - Header comments explain two-stage filtering approach - Documents pattern consistency requirement - Lists all 13 test scenarios and their purpose Test results: ✓ All 13 tests passing ✓ Pattern consistency validated across ralph_loop.sh and lib/response_analyzer.sh ✓ False positive scenarios properly excluded Addresses CodeRabbit review comments: - r2655862688 (Critical pattern inconsistency) - r2655862689 (Major test coverage gap) - r2655862690 (Minor misleading test name)
This commit is contained in:
parent
8fc53755bf
commit
90fb5587a1
2 changed files with 41 additions and 7 deletions
|
|
@ -90,10 +90,11 @@ analyze_response() {
|
|||
|
||||
# 4. Detect stuck/error loops
|
||||
# Use two-stage filtering to avoid counting JSON field names as errors
|
||||
# Stage 1: Filter out JSON field patterns
|
||||
# Stage 2: Count actual error messages (avoid type annotations like "error: Error")
|
||||
error_count=$(grep -v '"[^"]*\(error\|failed\)"[^"]*":' "$output_file" 2>/dev/null | \
|
||||
grep -cE '(^Error:|^ERROR:|^error:|\]: error|Link: error|Error occurred|failed with error|[Ee]xception|Fatal|FATAL|cannot|unable to)' \
|
||||
# Stage 1: Filter out JSON field patterns like "is_error": false
|
||||
# Stage 2: Count actual error messages in specific contexts
|
||||
# Pattern aligned with ralph_loop.sh to ensure consistent behavior
|
||||
error_count=$(grep -v '"[^"]*error[^"]*":' "$output_file" 2>/dev/null | \
|
||||
grep -cE '(^Error:|^ERROR:|^error:|\]: error|Link: error|Error occurred|failed with error|[Ee]xception|Fatal|FATAL)' \
|
||||
2>/dev/null || echo "0")
|
||||
error_count=$(echo "$error_count" | tr -d '[:space:]')
|
||||
error_count=${error_count:-0}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue