Skip to content

fix: Recognize STATUS: COMPLETE as progress in circuit breaker#140

Merged
frankbria merged 2 commits into
frankbria:mainfrom
gwicho38:fix/circuit-breaker-completion-signal
Jan 30, 2026
Merged

fix: Recognize STATUS: COMPLETE as progress in circuit breaker#140
frankbria merged 2 commits into
frankbria:mainfrom
gwicho38:fix/circuit-breaker-completion-signal

Conversation

@gwicho38
Copy link
Copy Markdown
Contributor

@gwicho38 gwicho38 commented Jan 29, 2026

Summary

  • Fix circuit breaker false positive when Claude completes work and commits it immediately
  • Add multiple progress detection sources beyond just git diff

Problem

The circuit breaker was only detecting progress through git diff changes. When Claude completed work and committed it, subsequent loops showed 0 uncommitted changes, causing the circuit breaker to trip after 3 loops with "No progress detected."

This was happening in projects like mcli where Claude would:

  1. Complete a task (e.g., "Add Pydantic validation models")
  2. Commit the changes immediately
  3. Report STATUS: COMPLETE with FILES_MODIFIED: 6
  4. On next loop, git diff shows 0 changes
  5. Circuit breaker sees "no progress" → trips after 3 loops

Solution

Add multiple progress detection sources in record_loop_result():

  1. Git diff changes (existing) - uncommitted file changes
  2. has_completion_signal from .response_analysis - Claude's STATUS: COMPLETE
  3. files_modified from RALPH_STATUS block - Claude's reported file count

If any of these indicate progress, reset the consecutive_no_progress counter.

Test plan

  • Run existing bats tests
  • Test with a project that commits work immediately
  • Verify circuit breaker doesn't trip when STATUS: COMPLETE is reported

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved progress detection to treat external completion signals and reported file modifications as valid progress in addition to git changes, reducing false no-progress states and improving completion reliability.

✏️ Tip: You can customize this high-level summary in your review settings.

The circuit breaker was only detecting progress through git diff changes.
When Claude completed work and committed it, subsequent loops showed 0
uncommitted changes, causing the circuit breaker to trip after 3 loops.

This fix adds multiple progress detection sources:
1. Git diff changes (existing)
2. has_completion_signal from response analysis (STATUS: COMPLETE)
3. files_modified reported by Claude in RALPH_STATUS block

This ensures that completed work is recognized as progress even when
all changes have been committed to git.

Fixes issue where circuit breaker would repeatedly trip on projects
where Claude finishes tasks and commits them immediately.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 29, 2026

Walkthrough

Expands progress detection in record_loop_result to include completion signals and Claude-reported file modifications parsed from a new $RALPH_DIR/.response_analysis JSON file, in addition to existing git-change detection.

Changes

Cohort / File(s) Summary
Multi-source Progress Detection
lib/circuit_breaker.sh
Adds parsing of $RALPH_DIR/.response_analysis to extract analysis.has_completion_signal, exit_signal, and files_modified (exposed as ralph_files_modified). Introduces local has_completion_signal and ralph_files_modified variables and updates progress determination: treat git changes, completion signals, or ralph_files_modified > 0 as progress. Integrates these sources with existing consecutive_no_progress, last_progress_loop, same-error counting, and state transitions.

Sequence Diagram(s)

(Skipped — changes are contained within a single script and modify internal progress-detection logic without introducing a broader multi-component protocol that requires visualization.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 A rabbit's nibble on the log:
New signals whisper from a hidden file,
Git and Claude now walk the same mile,
Loops detect progress from many tracks,
I hop, I cheer—no more looking back! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: recognizing STATUS: COMPLETE as a progress signal in the circuit breaker to prevent false trips.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented Jan 29, 2026

Recognize completion signals in lib/circuit_breaker.sh:record_loop_result to count progress when STATUS: COMPLETE, exit_signal, or $RALPH_DIR/.response_analysis reports files_modified > 0

Add parsing of $RALPH_DIR/.response_analysis via jq to set progress when analysis.has_completion_signal, analysis.exit_signal, or analysis.files_modified > 0, resetting consecutive_no_progress and updating last_progress_loop in circuit_breaker.sh.

📍Where to Start

Start with the record_loop_result function in circuit_breaker.sh.


Macroscope summarized 085208e.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@lib/circuit_breaker.sh`:
- Around line 108-131: The combined declaration+assignment for exit_signal masks
jq failures; instead declare exit_signal first (e.g., local exit_signal), then
assign it from jq with a separate command substitution and fallback
(exit_signal=$(jq -r '.analysis.exit_signal // false' "$response_analysis_file"
2>/dev/null || echo "false")), and preserve the subsequent conditional that sets
has_completion_signal when exit_signal == "true"; update the same pattern if
there are any other local+assignment uses (see exit_signal,
response_analysis_file, has_completion_signal).

Comment thread lib/circuit_breaker.sh
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@frankbria
Copy link
Copy Markdown
Owner

@claude Review the PR

@claude
Copy link
Copy Markdown

claude Bot commented Jan 30, 2026

Claude encountered an error —— View job

Command failed: git fetch origin --depth=20 fix/circuit-breaker-completion-signal

I'll analyze this and get back to you.

@frankbria frankbria merged commit 5cad271 into frankbria:main Jan 30, 2026
4 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants