Skip to content

fix(response_analyzer): progress detection in non-git multi-repo workspaces - #342

Open
DrumRobot wants to merge 1 commit into
frankbria:mainfrom
DrumRobot:fix/issue-340-nongit-progress
Open

fix(response_analyzer): progress detection in non-git multi-repo workspaces#342
DrumRobot wants to merge 1 commit into
frankbria:mainfrom
DrumRobot:fix/issue-340-nongit-progress

Conversation

@DrumRobot

@DrumRobot DrumRobot commented Jul 16, 2026

Copy link
Copy Markdown

Summary

Fixes #340 — in a multi-repo workspace whose root folder is not a git repository, analyze_response could never see progress: the git rev-parse --git-dir gate failed every loop, file-change detection was skipped entirely, and the Claude CLI result JSON carries no files_modified field. Every loop counted as no-progress and the circuit breaker opened unconditionally after the threshold.

This PR adds three complementary signal paths (any one of them ends the false-positive class):

  1. $RALPH_DIR repo fallback — new _resolve_git_progress_dir() helper prefers the CWD repository and falls back to the tracker directory's own repository. Tracker updates (fix_plan.md) become the progress proxy. The .loop_start_sha commit-range comparison stays CWD-repo-only, since the recorded SHA belongs to the CWD repository; fallback mode counts uncommitted changes only.
  2. RALPH_STATUS self-reportparse_json_response() now extracts FILES_MODIFIED: <N> and PROGRESS: true from the RALPH_STATUS block embedded in the .result text, with the same explicit-intent semantics and the same start-of-line anchoring as the existing EXIT_SIGNAL extraction (prose mentions do not trigger). Structured metadata stays authoritative — the self-report fills the gap, never lowers the count.
  3. JSON-path has_progress from files_modified — a structured or self-reported positive files_modified sets has_progress directly, instead of relying exclusively on git detection.

Scope note: the self-report extraction is implemented for the JSON path (.result field) only, matching the Claude CLI output format where the bug was observed. Text-mode outputs already benefit from path 1.

Test plan

  • 5 new regression tests in tests/unit/test_exit_detection.bats (issue Circuit breaker false positive: progress detection is blind when the loop CWD is not a git repository (multi-repo workspace) #340 section):
    • tracker-repo fallback detects a modified fix_plan.md when the CWD is not a repo (fails on main, passes here)
    • no repo anywhere → completes cleanly with has_progress=false (no crash, no fabricated progress)
    • FILES_MODIFIED: 3 self-report → files_modified=3, has_progress=true (fails on main)
    • PROGRESS: true without a file count → has_progress=true, files_modified=0 (fails on main)
    • explicit FILES_MODIFIED: 0has_progress stays false
  • Full test_exit_detection.bats suite: 72/72 pass
  • test_json_parsing.bats: no failures (RALPH_STATUS anchoring tests unaffected)
  • test_circuit_breaker_recovery.bats: no failures

…spaces (frankbria#340)

When the loop CWD is not a git repository (multi-repo workspace root),
the git rev-parse gate skipped file-change detection entirely, so
has_progress stayed false on every loop regardless of real work, and the
circuit breaker opened unconditionally after the no-progress threshold.

Three complementary signal paths fix the class of false positives:

1. RALPH_DIR repo fallback: _resolve_git_progress_dir() prefers the CWD
   repository and falls back to $RALPH_DIR's own repository — tracker
   updates (fix_plan.md) become the progress proxy. The .loop_start_sha
   commit-range comparison only applies in CWD-repo mode since the
   recorded SHA belongs to the CWD repository.

2. RALPH_STATUS self-report: parse_json_response() extracts
   FILES_MODIFIED: <N> and PROGRESS: true from the RALPH_STATUS block in
   the .result text, with the same explicit-intent semantics (and the
   same start-of-line anchoring) as the existing EXIT_SIGNAL extraction.
   Structured metadata stays authoritative; the self-report never lowers
   the count.

3. JSON-path has_progress from files_modified: a structured or
   self-reported positive files_modified now sets has_progress directly
   instead of relying exclusively on git detection.

5 regression tests: tracker-repo fallback detects a modified fix_plan.md;
no-repo-anywhere still completes with has_progress=false; FILES_MODIFIED
self-report sets count + progress; PROGRESS: true works without a file
count; explicit FILES_MODIFIED: 0 does not fabricate progress.

Fixes frankbria#340

Contributed by @daegunjhy

Signed-off-by: Hayoung Jeong <drumrobot43@gmail.com>
@DrumRobot
DrumRobot marked this pull request as ready for review July 16, 2026 14:24
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.

Circuit breaker false positive: progress detection is blind when the loop CWD is not a git repository (multi-repo workspace)

1 participant