fix: address PR review feedback from CodeRabbit

- Move history file init before auto-recovery logic to prevent
  log_circuit_transition from writing to nonexistent history file
- Fix BSD date -j timezone handling: normalize tz (Z→+0000, ±HH:MM→±HHMM)
  and parse with %z format so UTC timestamps aren't misinterpreted as local
- Update stale test counts in CLAUDE.md (420→484) and README.md (465→484)
  across badge, header, and inline comments
This commit is contained in:
Test User 2026-02-07 01:45:53 -07:00
parent b4b9db6b76
commit c10efb99f9
4 changed files with 21 additions and 21 deletions

View file

@ -169,7 +169,7 @@ tmux attach -t <session-name>
### Running Tests
```bash
# Run all tests (420 tests)
# Run all tests (484 tests)
npm test
# Run specific test suites

View file

@ -3,7 +3,7 @@
[![CI](https://github.com/frankbria/ralph-claude-code/actions/workflows/test.yml/badge.svg)](https://github.com/frankbria/ralph-claude-code/actions/workflows/test.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
![Version](https://img.shields.io/badge/version-0.11.4-blue)
![Tests](https://img.shields.io/badge/tests-465%20passing-green)
![Tests](https://img.shields.io/badge/tests-484%20passing-green)
[![GitHub Issues](https://img.shields.io/github/issues/frankbria/ralph-claude-code)](https://github.com/frankbria/ralph-claude-code/issues)
[![Mentioned in Awesome Claude Code](https://awesome.re/mentioned-badge.svg)](https://github.com/hesreallyhim/awesome-claude-code)
[![Follow on X](https://img.shields.io/twitter/follow/FrankBria18044?style=social)](https://x.com/FrankBria18044)
@ -18,7 +18,7 @@ Ralph is an implementation of the Geoffrey Huntley's technique for Claude Code t
**Version**: v0.11.4 - Active Development
**Core Features**: Working and tested
**Test Coverage**: 465 tests, 100% pass rate
**Test Coverage**: 484 tests, 100% pass rate
### What's Working Now
- Autonomous development loops with intelligent exit detection
@ -624,7 +624,7 @@ If you want to run the test suite:
# Install BATS testing framework
npm install -g bats bats-support bats-assert
# Run all tests (465 tests)
# Run all tests (484 tests)
npm test
# Run specific test suites
@ -756,7 +756,7 @@ cd ralph-claude-code
# Install dependencies and run tests
npm install
npm test # All 465 tests must pass
npm test # All 484 tests must pass
```
### Priority Contribution Areas

View file

@ -57,6 +57,18 @@ init_circuit_breaker() {
EOF
fi
# Ensure history file exists before any transition logging
if [[ -f "$CB_HISTORY_FILE" ]]; then
if ! jq '.' "$CB_HISTORY_FILE" > /dev/null 2>&1; then
# Corrupted, recreate
rm -f "$CB_HISTORY_FILE"
fi
fi
if [[ ! -f "$CB_HISTORY_FILE" ]]; then
echo '[]' > "$CB_HISTORY_FILE"
fi
# Auto-recovery: check if OPEN state should transition (Issue #160)
local current_state
current_state=$(jq -r '.state' "$CB_STATE_FILE" 2>/dev/null || echo "$CB_STATE_CLOSED")
@ -111,18 +123,6 @@ EOF
fi
fi
fi
# Check if history file exists and is valid JSON
if [[ -f "$CB_HISTORY_FILE" ]]; then
if ! jq '.' "$CB_HISTORY_FILE" > /dev/null 2>&1; then
# Corrupted, recreate
rm -f "$CB_HISTORY_FILE"
fi
fi
if [[ ! -f "$CB_HISTORY_FILE" ]]; then
echo '[]' > "$CB_HISTORY_FILE"
fi
}
# Get current circuit breaker state

View file

@ -66,10 +66,10 @@ parse_iso_to_epoch() {
fi
# Try BSD date -j (native macOS)
# Strip timezone suffix for BSD compatibility
local stripped="${iso_timestamp%%+*}"
stripped="${stripped%%Z*}"
if result=$(date -j -f "%Y-%m-%dT%H:%M:%S" "$stripped" +%s 2>/dev/null) && [[ "$result" =~ ^[0-9]+$ ]]; then
# Normalize timezone for BSD parsing (Z → +0000, ±HH:MM → ±HHMM)
local tz_fixed
tz_fixed=$(echo "$iso_timestamp" | sed -E 's/Z$/+0000/; s/([+-][0-9]{2}):([0-9]{2})$/\1\2/')
if result=$(date -j -f "%Y-%m-%dT%H:%M:%S%z" "$tz_fixed" +%s 2>/dev/null) && [[ "$result" =~ ^[0-9]+$ ]]; then
echo "$result"
return
fi