Frank Bria
aca3670cc7
fix(loop): respect Claude's EXIT_SIGNAL when checking completion indicators ( #90 )
...
* fix(loop): respect Claude's EXIT_SIGNAL when checking completion indicators
The should_exit_gracefully() function was exiting prematurely based solely
on completion_indicators heuristics, ignoring Claude's explicit EXIT_SIGNAL
in the RALPH_STATUS block. This caused premature exits during productive
iterations when Claude reported work in progress.
Changes:
- ralph_loop.sh: Added dual-condition check requiring BOTH completion
indicators >= 2 AND exit_signal == true before exiting
- response_analyzer.sh: Added explicit_exit_signal_found flag to prevent
natural language heuristics from overriding Claude's explicit intent
- Added 14 new tests (10 unit + 4 integration) covering EXIT_SIGNAL behavior
Decision matrix:
| indicators >= 2 | EXIT_SIGNAL | Result |
|-----------------|-------------|--------|
| true | true | Exit |
| true | false | Continue |
| true | missing | Continue (defaults to false) |
| false | true | Continue (threshold not met) |
Fixes premature exit bug during productive development iterations.
* Update lib/response_analyzer.sh
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
* test(exit): add STATUS=COMPLETE vs EXIT_SIGNAL=false conflict test
docs(exit): update CLAUDE.md with EXIT_SIGNAL gate documentation
- Added test for STATUS=COMPLETE with EXIT_SIGNAL=false conflict
(EXIT_SIGNAL takes precedence, allowing phase completion without loop exit)
- Updated "Intelligent Exit Detection" section with dual-condition explanation
- Added "Completion Indicators with EXIT_SIGNAL Gate" section with decision table
- Documented conflict resolution behavior and implementation details
---------
Co-authored-by: Test User <test@example.com>
Co-authored-by: macroscopeapp[bot] <170038800+macroscopeapp[bot]@users.noreply.github.com>
2026-01-12 22:07:24 -07:00
Test User
4b1ca9bcc7
feat(import): modernize ralph_import.sh with JSON output parsing
...
- Add --output-format json flag for structured Claude CLI responses
- Implement detect_response_format() for JSON vs text detection
- Implement parse_conversion_response() for extracting JSON fields
- Add check_claude_version() for modern CLI feature detection
- Enhance error handling with structured JSON error messages
- Improve file verification with JSON-derived status information
- Maintain backward compatibility with automatic text fallback
- Add 11 new TDD tests for modern CLI features (tests 23-33)
- Update README.md with Modern CLI Features section
- Update CLAUDE.md with v0.9.8 release notes
Test count: 276 (up from 265)
2026-01-10 11:12:13 -07:00
Test User
b06d979b0b
test(import): add 22 comprehensive tests for ralph_import.sh
...
Add integration tests for PRD to Ralph format conversion:
- File format support tests (.md, .txt, .json)
- Output file creation tests (PROMPT.md, @fix_plan.md, specs/requirements.md)
- Project naming tests (custom names, auto-detection from filename)
- Error handling tests (missing files, dependencies, conversion failures)
- Help and usage tests
- Full workflow integration tests
- Edge case handling (hyphens, uppercase, subdirectory paths)
Test infrastructure:
- Mock ralph-setup command using PATH manipulation
- Mock Claude Code CLI for isolated conversion testing
- Added create_sample_prd_txt() fixture helper
Test count: 223 (up from 201)
2026-01-09 16:13:23 -07:00
Test User
a6587aa189
fix(test): improve test reliability and remove tautologies
...
- Remove unused 'load mocks' (mocks.bash not needed)
- Use GIT_AUTHOR_*/GIT_COMMITTER_* env vars instead of git config --global
- Prefix git commands with 'command' to bypass shell function overrides
- Fix tautological assertions in edge case tests:
- Rename test to "succeeds when run in existing directory (idempotent)"
- Assert success ($status -eq 0) instead of always-true condition
2026-01-09 15:47:41 -07:00
Test User
c68e484f7d
test(setup): add 36 comprehensive tests for setup.sh
...
Add integration tests validating project initialization:
- Directory creation (project dir, subdirectories)
- Template copying (PROMPT.md, @fix_plan.md, @AGENT.md, specs)
- Git initialization (repo, commit, message)
- README creation and content
- Custom/default project names
- Working directory behavior
- Error handling (missing templates)
- Output message validation
Test count: 201 (up from 165)
2026-01-09 15:01:53 -07:00
frankbria
3503b9b27b
fix: address code review feedback
...
README.md:
- Update version badge to v0.9.3
- Update test count to 165 in all locations
- Update test coverage breakdown (111 unit + 54 integration)
test_installation.bats:
- Add missing mock setup.sh in setup() function
- Fix dependency test to mock all three deps (jq, git, node/npx)
- Remove unused source_install_functions helper function
2026-01-09 14:20:58 -07:00
frankbria
6688c27681
test(install): add 14 comprehensive installation tests
...
- Add test_installation.bats with full coverage of install.sh
- Tests cover directory creation, command installation, permissions
- Template and lib file copying verification
- Dependency detection with mocked failures (jq, git, node)
- PATH detection and warning system tests
- Uninstallation cleanup verification
- Idempotency testing (run twice without errors)
- End-to-end installation workflow validation
- All tests use isolated temp directories for safety
- Update CLAUDE.md with new test count (165 total)
- Fix npm test script to run tests recursively
- Version bump to v0.9.3
2026-01-09 14:05:46 -07:00
frankbria
3ae67f66ac
Phase 2: Requirements, testing, and documentation enhancements
...
Implements all Phase 2 high-priority recommendations from expert panel:
**1. Requirements Improvement** (Karl Wiegers, Gojko Adzic)
- Enhanced templates/PROMPT.md with 6 concrete Given/When/Then scenarios
- Specification by Example format for all exit conditions
- Clear expectations for each scenario type:
* Successful completion
* Test-only loops
* Stuck on errors
* No work remaining
* Making progress
* Blocked on dependencies
**2. Use Case Documentation** (Alistair Cockburn)
- Created comprehensive USE_CASES.md (600+ lines)
- Defined 6 primary use cases with full Cockburn format:
* UC-1: Execute Development Loop
* UC-2: Detect Project Completion
* UC-3: Prevent Resource Waste
* UC-4: Handle API Rate Limits
* UC-5: Provide Loop Monitoring
* UC-6: Reset Circuit Breaker
- Includes actors, goals, success scenarios, extensions, edge cases
- Clear goal hierarchy and success metrics
**3. Enhanced Test Coverage** (Lisa Crispin, Janet Gregory)
- Added tests/integration/test_edge_cases.bats (20 new tests)
- Edge cases: empty files, large files, corrupted JSON, unicode
- Boundary conditions: exact thresholds, overflow scenarios
- Error conditions: missing git, malformed data, rapid transitions
- All 40 integration tests passing (100% success rate)
**4. Circuit Breaker Robustness**
- Enhanced init_circuit_breaker() with corruption detection
- Auto-recovery from corrupted state/history files
- Validates JSON before use, recreates if invalid
**5. Specification Workshop Guide**
- Created SPECIFICATION_WORKSHOP.md
- Three Amigos methodology with templates
- Includes complete example workshop
- Best practices and red flags
- Quick 15-minute template for small features
**Test Results**: 40/40 integration tests passing
**Documentation Added**: 1,200+ lines (USE_CASES.md, SPECIFICATION_WORKSHOP.md)
**Coverage Improvement**: Edge cases and error conditions fully tested
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 21:34:54 -07:00
frankbria
2cf06b0de2
Implement Phase 1 critical fixes: Response analyzer & circuit breaker
...
Implements all Phase 1 recommendations from expert panel review:
1. **Response Analysis Pipeline** (Martin Fowler recommendation)
- New lib/response_analyzer.sh component
- Parses Claude Code output for completion signals
- Detects test-only loops and stagnation
- Updates .exit_signals file with structured data
- Tracks confidence scores and progress indicators
2. **Circuit Breaker Pattern** (Michael Nygard recommendation)
- New lib/circuit_breaker.sh component
- Three-state pattern: CLOSED → HALF_OPEN → OPEN
- Prevents runaway token consumption
- Detects: no progress (3 loops), same errors (5 loops)
- Automatic halt with clear user guidance
- Manual reset capability
3. **Structured Output Contract** (Sam Newman recommendation)
- Updated PROMPT.md template with RALPH_STATUS format
- Defines clear JSON-parseable exit signals
- SMART criteria for completion detection
- Concrete examples for all scenarios
4. **Integration & Testing**
- ralph_loop.sh integration of both components
- 20 comprehensive BATS integration tests (all passing)
- Tests cover: signal detection, circuit states, full loop flows
- Validates Phase 1 implementation correctness
**Impact**: Solves infinite loop problem, enables reliable exit detection,
prevents token waste through systematic stagnation detection.
**Test Results**: 20/20 integration tests passing
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-01 21:11:18 -07:00