[PR #158] [CLOSED] fix(loop): remove dead code and improve diagnostics for #157 #172

Closed
opened 2026-02-27 10:22:31 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mikeyobrien/ralph-orchestrator/pull/158
Author: @mikeyobrien
Created: 2/5/2026
Status: Closed

Base: mainHead: fix/157-dead-code-and-diagnostics


📝 Commits (10+)

  • 92dd44b refactor: global rename ralph -> hats
  • 61c91cb feat: add backward-compatible config fallback for ralph migration
  • 6062bad docs: update backlog with completed items and issue triage
  • 5a48168 fix: relax bench_get_for_topic_baseline threshold for debug/ARM builds
  • a362023 chore: gitignore .ralph/ runtime artifacts from pre-rename runs
  • b131a4b docs: add ralph-to-hats migration guide
  • 24d45e1 docs: update BACKLOG with completed P1 communication items
  • 0c605ef feat: add BDD preset and proof artifact infrastructure
  • 7bb9e8c feat: wire proof generation into loop completion handler
  • d2fcff0 docs: update BACKLOG with BDD/proof infrastructure progress

📊 Changes

781 files changed (+10655 additions, -44994 deletions)

View changed files

📝 .claude/agents/code-assist.md (+1 -1)
📝 .claude/agents/ralph-e2e-verifier.md (+18 -18)
📝 .claude/agents/ralph-loop-runner.md (+12 -12)
📝 .claude/skills/code-task-generator/SKILL.md (+5 -5)
📝 .claude/skills/create-hat-collection/SKILL.md (+7 -7)
📝 .claude/skills/evaluate-presets/SKILL.md (+6 -6)
📝 .claude/skills/find-code-tasks/SKILL.md (+4 -4)
📝 .claude/skills/pdd/SKILL.md (+8 -8)
📝 .claude/skills/playwriter/SKILL.md (+1 -1)
📝 .claude/skills/ralph-operations/SKILL.md (+52 -52)
📝 .claude/skills/release-bump/SKILL.md (+9 -9)
📝 .claude/skills/test-driven-development/SKILL.md (+3 -3)
📝 .claude/skills/tmux-terminal/SKILL.md (+13 -13)
📝 .claude/skills/tui-validate/SKILL.md (+27 -27)
📝 .github/ISSUE_TEMPLATE/bug_report.yml (+6 -6)
📝 .github/ISSUE_TEMPLATE/config.yml (+2 -2)
📝 .github/ISSUE_TEMPLATE/feature_request.yml (+3 -3)
📝 .github/ISSUE_TEMPLATE/question.yml (+6 -6)
📝 .github/workflows/ci.yml (+6 -6)
📝 .github/workflows/release.yml (+10 -10)

...and 80 more files

📄 Description

Summary

Follow-up to fa8cd62 which fixed the core infinite loop bug in #157. This PR addresses cleanup and diagnostics identified in the root cause analysis.

Changes

1. Remove dead code: check_default_publishes and record_event_count

These methods in EventLoop were never called from loop_runner.rs. They only had callers in unit tests testing their own behavior. This is misleading dead code -- a contributor could reasonably assume default_publishes was wired into the loop when it wasn't.

  • Removed both methods from event_loop/mod.rs
  • Removed 3 associated tests from event_loop/tests.rs
  • default_publishes remains a valid config field; a future PR can wire it back in properly if desired

2. Improve fallback exhaustion error message

Before:

Fallback recovery exhausted after 3 attempts, terminating

After:

Fallback recovery exhausted after 3 attempts, terminating.
The agent did not emit any events via \`hats emit\`.
Ensure your backend model supports tool use.

This directly addresses the #157 reporter's confusion -- they were using a free-tier model (kimi-k2.5-free) that likely can't invoke hats emit.

3. Add no-progress detection warning

New counter consecutive_no_progress tracks iterations where the agent produces no JSONL events. At 5 consecutive empty iterations, logs a warning:

Agent has not emitted events for 5 consecutive iterations.
The loop may not be making progress.

Fires once per streak (uses == not >=) to avoid log spam. Resets when real events arrive.

Testing

  • cargo build -- clean
  • cargo test -p hats-core -p hats-cli -- all pass (1 pre-existing flaky test on Termux unrelated)
  • cargo clippy -- no new warnings

Refs


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mikeyobrien/ralph-orchestrator/pull/158 **Author:** [@mikeyobrien](https://github.com/mikeyobrien) **Created:** 2/5/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/157-dead-code-and-diagnostics` --- ### 📝 Commits (10+) - [`92dd44b`](https://github.com/mikeyobrien/ralph-orchestrator/commit/92dd44be8b8b631a395fe70e0bc259e916b7ae07) refactor: global rename ralph -> hats - [`61c91cb`](https://github.com/mikeyobrien/ralph-orchestrator/commit/61c91cb1599f0f41ff2e85367cd182946e5cffbd) feat: add backward-compatible config fallback for ralph migration - [`6062bad`](https://github.com/mikeyobrien/ralph-orchestrator/commit/6062bad80c3a94a7247a02d876e66e04e0204635) docs: update backlog with completed items and issue triage - [`5a48168`](https://github.com/mikeyobrien/ralph-orchestrator/commit/5a481681b0d21a782640b601a9c75d3c14fefb93) fix: relax bench_get_for_topic_baseline threshold for debug/ARM builds - [`a362023`](https://github.com/mikeyobrien/ralph-orchestrator/commit/a362023f840d4a9b2673f62e065ab40aa5ae9071) chore: gitignore .ralph/ runtime artifacts from pre-rename runs - [`b131a4b`](https://github.com/mikeyobrien/ralph-orchestrator/commit/b131a4b4934b15e4b1e23fdf0a5f12217a8b5fc0) docs: add ralph-to-hats migration guide - [`24d45e1`](https://github.com/mikeyobrien/ralph-orchestrator/commit/24d45e15a8acfee7ed52d6743782e125f1f51184) docs: update BACKLOG with completed P1 communication items - [`0c605ef`](https://github.com/mikeyobrien/ralph-orchestrator/commit/0c605ef00e3e58732bf2bd1569eb0abafd00e33b) feat: add BDD preset and proof artifact infrastructure - [`7bb9e8c`](https://github.com/mikeyobrien/ralph-orchestrator/commit/7bb9e8cb94a60089368c3a87b42dc0c9626e1993) feat: wire proof generation into loop completion handler - [`d2fcff0`](https://github.com/mikeyobrien/ralph-orchestrator/commit/d2fcff0499d76c0e6733c538ba11835d41f59707) docs: update BACKLOG with BDD/proof infrastructure progress ### 📊 Changes **781 files changed** (+10655 additions, -44994 deletions) <details> <summary>View changed files</summary> 📝 `.claude/agents/code-assist.md` (+1 -1) 📝 `.claude/agents/ralph-e2e-verifier.md` (+18 -18) 📝 `.claude/agents/ralph-loop-runner.md` (+12 -12) 📝 `.claude/skills/code-task-generator/SKILL.md` (+5 -5) 📝 `.claude/skills/create-hat-collection/SKILL.md` (+7 -7) 📝 `.claude/skills/evaluate-presets/SKILL.md` (+6 -6) 📝 `.claude/skills/find-code-tasks/SKILL.md` (+4 -4) 📝 `.claude/skills/pdd/SKILL.md` (+8 -8) 📝 `.claude/skills/playwriter/SKILL.md` (+1 -1) 📝 `.claude/skills/ralph-operations/SKILL.md` (+52 -52) 📝 `.claude/skills/release-bump/SKILL.md` (+9 -9) 📝 `.claude/skills/test-driven-development/SKILL.md` (+3 -3) 📝 `.claude/skills/tmux-terminal/SKILL.md` (+13 -13) 📝 `.claude/skills/tui-validate/SKILL.md` (+27 -27) 📝 `.github/ISSUE_TEMPLATE/bug_report.yml` (+6 -6) 📝 `.github/ISSUE_TEMPLATE/config.yml` (+2 -2) 📝 `.github/ISSUE_TEMPLATE/feature_request.yml` (+3 -3) 📝 `.github/ISSUE_TEMPLATE/question.yml` (+6 -6) 📝 `.github/workflows/ci.yml` (+6 -6) 📝 `.github/workflows/release.yml` (+10 -10) _...and 80 more files_ </details> ### 📄 Description ## Summary Follow-up to fa8cd62 which fixed the core infinite loop bug in #157. This PR addresses cleanup and diagnostics identified in the [root cause analysis](https://github.com/mikeyobrien/ralph-orchestrator/issues/157). ## Changes ### 1. Remove dead code: `check_default_publishes` and `record_event_count` These methods in `EventLoop` were **never called** from `loop_runner.rs`. They only had callers in unit tests testing their own behavior. This is misleading dead code -- a contributor could reasonably assume `default_publishes` was wired into the loop when it wasn't. - Removed both methods from `event_loop/mod.rs` - Removed 3 associated tests from `event_loop/tests.rs` - `default_publishes` remains a valid config field; a future PR can wire it back in properly if desired ### 2. Improve fallback exhaustion error message Before: ``` Fallback recovery exhausted after 3 attempts, terminating ``` After: ``` Fallback recovery exhausted after 3 attempts, terminating. The agent did not emit any events via \`hats emit\`. Ensure your backend model supports tool use. ``` This directly addresses the #157 reporter's confusion -- they were using a free-tier model (kimi-k2.5-free) that likely can't invoke `hats emit`. ### 3. Add no-progress detection warning New counter `consecutive_no_progress` tracks iterations where the agent produces no JSONL events. At 5 consecutive empty iterations, logs a warning: ``` Agent has not emitted events for 5 consecutive iterations. The loop may not be making progress. ``` Fires once per streak (uses `==` not `>=`) to avoid log spam. Resets when real events arrive. ## Testing - `cargo build` -- clean - `cargo test -p hats-core -p hats-cli` -- all pass (1 pre-existing flaky test on Termux unrelated) - `cargo clippy` -- no new warnings ## Refs - Fixes cleanup items from #157 - Builds on fa8cd62 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 10:22:31 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ralph-orchestrator#172
No description provided.