[claude] Fix cycle-metrics pipeline: seed issue= from queue so retro is never null (#1250) #1253

Merged
claude merged 1 commits from claude/issue-1250 into main 2026-03-23 23:42:25 +00:00
Collaborator

Fixes #1250

Root cause

loop_guard.py signals readiness (exit 0) when it finds work in queue.json, but never recorded which issue it selected. When claude-loop/gemini-loop dispatchers run without writing cycle_result.json themselves, cycle_retro.py had no source for the issue number → all cycles logged issue=nullsummary.json showed 0% meaningful success.

Fix

scripts/loop_guard.py — two additions:

  1. seed_cycle_result(item) — pre-seeds .loop/cycle_result.json with {"issue": N, "type": T} from the top ready queue item when loop_guard finds work, but only if the file does not already exist (agent-written results always win).
  2. --pick flag — prints the selected issue number to stdout so shell scripts can capture it (ISSUE=$(loop_guard.py --pick)).

tests/loop/test_loop_guard_seed.py — 9 new unit tests covering:

  • seed writes correct issue + type
  • no-overwrite invariant (existing file preserved)
  • missing/None issue/type fields handled gracefully
  • OSError during seed is logged as WARNING, never raised
  • main() seeds on ready queue; does not create file when queue empty
  • --pick prints issue; does not print anything on empty queue

All 435 tests pass (2 pre-existing failures in test_three_strike_routes.py are unrelated to this change).

Fixes #1250 ## Root cause `loop_guard.py` signals readiness (exit 0) when it finds work in `queue.json`, but never recorded *which* issue it selected. When `claude-loop`/`gemini-loop` dispatchers run without writing `cycle_result.json` themselves, `cycle_retro.py` had no source for the issue number → all cycles logged `issue=null` → `summary.json` showed 0% meaningful success. ## Fix **`scripts/loop_guard.py`** — two additions: 1. `seed_cycle_result(item)` — pre-seeds `.loop/cycle_result.json` with `{"issue": N, "type": T}` from the top ready queue item when `loop_guard` finds work, but only if the file does not already exist (agent-written results always win). 2. `--pick` flag — prints the selected issue number to stdout so shell scripts can capture it (`ISSUE=$(loop_guard.py --pick)`). **`tests/loop/test_loop_guard_seed.py`** — 9 new unit tests covering: - seed writes correct issue + type - no-overwrite invariant (existing file preserved) - missing/None issue/type fields handled gracefully - OSError during seed is logged as WARNING, never raised - `main()` seeds on ready queue; does not create file when queue empty - `--pick` prints issue; does not print anything on empty queue All 435 tests pass (2 pre-existing failures in `test_three_strike_routes.py` are unrelated to this change).
claude added 1 commit 2026-03-23 23:42:07 +00:00
fix: seed cycle_result.json from queue so issue= is never null in retro
Some checks failed
Tests / lint (pull_request) Failing after 21s
Tests / test (pull_request) Has been skipped
8e6dbfe948
loop_guard.py picks the top-priority ready item from queue.json but
previously only signalled readiness (exit 0) without recording which
issue it selected.  When claude-loop / gemini-loop dispatchers don't
write cycle_result.json themselves, cycle_retro.py had no source for
the issue number and logged issue=null for every cycle, causing the
0% meaningful-success rate in summary.json.

Fix: add seed_cycle_result() that pre-seeds cycle_result.json with the
top queue item (issue + type) when loop_guard finds work, but only if
the file doesn't already exist — so agent-written results always win.
Also add --pick flag: prints the selected issue number to stdout for
shell scripts that need to pass --issue N downstream.

Tests: 9 new unit tests in tests/loop/test_loop_guard_seed.py covering
seed behaviour, no-overwrite invariant, graceful OSError, and --pick
mode in both work-found and empty-queue cases.

Fixes #1250

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
claude merged commit 35d2547a0b into main 2026-03-23 23:42:25 +00:00
claude deleted branch claude/issue-1250 2026-03-23 23:42:26 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1253