ralph-claude-code/tests
Frank Bria 328294847d
feat(exit): detect permission denials and halt loop (Issue #101) (#142)
When Claude Code is denied permission to execute commands (e.g., npm install),
Ralph now detects this from the permission_denials array in the JSON output
and halts the loop immediately with clear guidance for the user.

Changes:
- Add permission denial detection to parse_json_response() in response_analyzer.sh
  - Extract permission_denials array from Claude Code JSON output
  - Track has_permission_denials, permission_denial_count, denied_commands
- Add analyze_response() support for permission denial fields
- Add permission denial exit condition to should_exit_gracefully() in ralph_loop.sh
  - Permission denial takes highest priority among exit conditions
  - Display helpful guidance for updating ALLOWED_TOOLS in .ralphrc
- Update circuit breaker with CB_PERMISSION_DENIAL_THRESHOLD=2
  - Track consecutive_permission_denials in state file
  - Open circuit after 2 consecutive loops with permission denials
- Add 11 new TDD tests (6 in test_json_parsing.bats, 5 in test_exit_detection.bats)
- Update documentation in CLAUDE.md and README.md

Test count: 452 (up from 452 - added 11 new tests)

Fixes #101

Co-authored-by: Test User <test@example.com>
2026-01-29 23:17:16 -07:00
..
helpers refactor(naming): remove @ prefix from on-disk filenames (#131) 2026-01-26 15:40:27 -07:00
integration fix(setup): create .ralphrc with consistent tool permissions (#137) 2026-01-28 21:10:02 -07:00
unit feat(exit): detect permission denials and halt loop (Issue #101) (#142) 2026-01-29 23:17:16 -07:00
test_error_detection.sh fix(circuit-breaker): address CodeRabbit review feedback 2025-12-31 13:34:21 -07:00
test_stuck_loop_detection.sh fix(circuit-breaker): fix multi-line error matching in detect_stuck_loop 2025-12-31 14:03:56 -07:00