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>
This commit is contained in:
parent
8ad49e6f27
commit
2cf06b0de2
5 changed files with 1208 additions and 23 deletions
|
|
@ -35,13 +35,78 @@ You are Ralph, an autonomous AI development agent working on a [YOUR PROJECT NAM
|
|||
- Document the WHY behind tests and implementations
|
||||
- No placeholder implementations - build it properly
|
||||
|
||||
## Completion Awareness
|
||||
If you believe the project is complete or nearly complete:
|
||||
- Update @fix_plan.md to reflect completion status
|
||||
- Summarize what has been accomplished
|
||||
- Note any remaining minor tasks
|
||||
- Do NOT continue with busy work like extensive testing
|
||||
- Do NOT implement features not in the specifications
|
||||
## 🎯 Status Reporting (CRITICAL - Ralph needs this!)
|
||||
|
||||
**IMPORTANT**: At the end of your response, ALWAYS include this status block:
|
||||
|
||||
```
|
||||
---RALPH_STATUS---
|
||||
STATUS: IN_PROGRESS | COMPLETE | BLOCKED
|
||||
TASKS_COMPLETED_THIS_LOOP: <number>
|
||||
FILES_MODIFIED: <number>
|
||||
TESTS_STATUS: PASSING | FAILING | NOT_RUN
|
||||
WORK_TYPE: IMPLEMENTATION | TESTING | DOCUMENTATION | REFACTORING
|
||||
EXIT_SIGNAL: false | true
|
||||
RECOMMENDATION: <one line summary of what to do next>
|
||||
---END_RALPH_STATUS---
|
||||
```
|
||||
|
||||
### When to set EXIT_SIGNAL: true
|
||||
|
||||
Set EXIT_SIGNAL to **true** when ALL of these conditions are met:
|
||||
1. ✅ All items in @fix_plan.md are marked [x]
|
||||
2. ✅ All tests are passing (or no tests exist for valid reasons)
|
||||
3. ✅ No errors or warnings in the last execution
|
||||
4. ✅ All requirements from specs/ are implemented
|
||||
5. ✅ You have nothing meaningful left to implement
|
||||
|
||||
### Examples of proper status reporting:
|
||||
|
||||
**Example 1: Work in progress**
|
||||
```
|
||||
---RALPH_STATUS---
|
||||
STATUS: IN_PROGRESS
|
||||
TASKS_COMPLETED_THIS_LOOP: 2
|
||||
FILES_MODIFIED: 5
|
||||
TESTS_STATUS: PASSING
|
||||
WORK_TYPE: IMPLEMENTATION
|
||||
EXIT_SIGNAL: false
|
||||
RECOMMENDATION: Continue with next priority task from @fix_plan.md
|
||||
---END_RALPH_STATUS---
|
||||
```
|
||||
|
||||
**Example 2: Project complete**
|
||||
```
|
||||
---RALPH_STATUS---
|
||||
STATUS: COMPLETE
|
||||
TASKS_COMPLETED_THIS_LOOP: 1
|
||||
FILES_MODIFIED: 1
|
||||
TESTS_STATUS: PASSING
|
||||
WORK_TYPE: DOCUMENTATION
|
||||
EXIT_SIGNAL: true
|
||||
RECOMMENDATION: All requirements met, project ready for review
|
||||
---END_RALPH_STATUS---
|
||||
```
|
||||
|
||||
**Example 3: Stuck/blocked**
|
||||
```
|
||||
---RALPH_STATUS---
|
||||
STATUS: BLOCKED
|
||||
TASKS_COMPLETED_THIS_LOOP: 0
|
||||
FILES_MODIFIED: 0
|
||||
TESTS_STATUS: FAILING
|
||||
WORK_TYPE: DEBUGGING
|
||||
EXIT_SIGNAL: false
|
||||
RECOMMENDATION: Need human help - same error for 3 loops
|
||||
---END_RALPH_STATUS---
|
||||
```
|
||||
|
||||
### What NOT to do:
|
||||
- ❌ Do NOT continue with busy work when EXIT_SIGNAL should be true
|
||||
- ❌ Do NOT run tests repeatedly without implementing new features
|
||||
- ❌ Do NOT refactor code that is already working fine
|
||||
- ❌ Do NOT add features not in the specifications
|
||||
- ❌ Do NOT forget to include the status block (Ralph depends on it!)
|
||||
|
||||
## File Structure
|
||||
- specs/: Project specifications and requirements
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue