Skip to content

fix(analyzer): detect progress from committed work and embedded RALPH_STATUS#181

Open
enlego wants to merge 1 commit intofrankbria:mainfrom
enlego:fix/progress-detection-committed-work
Open

fix(analyzer): detect progress from committed work and embedded RALPH_STATUS#181
enlego wants to merge 1 commit intofrankbria:mainfrom
enlego:fix/progress-detection-committed-work

Conversation

@enlego
Copy link

@enlego enlego commented Feb 17, 2026

Summary

  • Fix false-negative progress detection when Claude commits work atomically after each task
  • git diff only sees uncommitted changes; projects using atomic commits trigger the circuit breaker with no real issue
  • Also fixes inconsistency where EXIT_SIGNAL was parsed from the embedded RALPH_STATUS block but TASKS_COMPLETED_THIS_LOOP and FILES_MODIFIED were not

Root cause

In analyze_response (JSON path, lib/response_analyzer.sh), progress is detected only via git diff --name-only. When Claude commits after each loop (a common and encouraged pattern), git diff returns 0 → has_progress = false → circuit breaker opens after CB_NO_PROGRESS_THRESHOLD consecutive loops.

Additionally, the JSON path already extracts EXIT_SIGNAL from the embedded ---RALPH_STATUS--- block in the result field, but ignores TASKS_COMPLETED_THIS_LOOP and FILES_MODIFIED from the same block.

Changes

lib/response_analyzer.shanalyze_response, JSON path (~line 343):

  1. Recent-commit detection: After git diff, check git log --oneline -1 --since="20 minutes ago". If a recent commit exists, set has_progress=true and populate files_modified from git diff-tree or git diff HEAD~1.

  2. Embedded RALPH_STATUS parsing: Extract TASKS_COMPLETED_THIS_LOOP and FILES_MODIFIED from the result field's ---RALPH_STATUS--- block, consistent with the existing EXIT_SIGNAL extraction. Also normalizes literal \n escape sequences to real newlines before parsing so grep/cut work correctly in both production and test environments.

tests/unit/test_json_parsing.bats — 4 new tests (section PROGRESS DETECTION WITH COMMITTED WORK TESTS):

  1. Detects progress from TASKS_COMPLETED_THIS_LOOP in embedded RALPH_STATUS
  2. Detects progress via recent git commit when git diff is zero
  3. Extracts FILES_MODIFIED from RALPH_STATUS when git diff is zero
  4. Does not flag progress when TASKS_COMPLETED_THIS_LOOP is zero

Test plan

  • npm test passes 100% (456/456 tests)
  • New tests cover: RALPH_STATUS-based progress, recent-commit detection, FILES_MODIFIED extraction, zero-task no-progress case
  • No regression in existing json_parsing, exit_detection, or circuit_breaker tests

🤖 Generated with Claude Code

…_STATUS

When Claude commits work atomically after each task, git diff returns zero
uncommitted changes. Ralph incorrectly treats this as no progress and opens
the circuit breaker after CB_NO_PROGRESS_THRESHOLD loops.

Two complementary fixes in the JSON analysis path:
- Check git log --since for recent commits, not just git diff
- Parse TASKS_COMPLETED_THIS_LOOP and FILES_MODIFIED from the embedded
  RALPH_STATUS block in the result field (consistent with existing
  EXIT_SIGNAL extraction added in Bug frankbria#1 Fix)

Also fixes literal \\n handling: normalize escape sequences from the jq
result field before grep/cut so parsing works in both production (where
jq decodes JSON escapes to real newlines) and test environments.

All 456 tests pass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Feb 17, 2026

Detect progress in lib/response_analyzer.sh::analyze_response from recent commits within 20 minutes and from embedded RALPH_STATUS fields

Add progress detection that checks git log --oneline -1 --since="20 minutes ago" and parses TASKS_COMPLETED_THIS_LOOP and FILES_MODIFIED from an embedded RALPH_STATUS in JSON .result; populate files_modified from git diff HEAD~1 --name-only or the embedded value; add unit tests for these cases in tests/unit/test_json_parsing.bats.

📍Where to Start

Start in analyze_response within lib/response_analyzer.sh, focusing on the JSON-handling path that parses RALPH_STATUS and checks recent commits.


Macroscope summarized e82400e.

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.

1 participant

Comments