feat(maintenance): per-tick stuck-issue sweep (#129)#137
Merged
Conversation
Adds forge_loop.stuck_sweep — a health-check that runs each tick after the iteration loop and before the next dispatch. It reads the tail of events.jsonl, counts worker_iterations_exhausted events per issue (resetting on a recovery event), and demotes any issue that crosses settings.maintenance.stuck_threshold_attempts (default 2) AND still carries loop:ready. This closes the gap CTO surfaced dogfooding the brainstormer epic: when the iteration loop's escalation didn't fully land (label-API hiccup, transient bug, or pre-#128 dropped removal), the dispatcher kept re-picking the same broken issue on every tick. The sweep is the belt to escalate_to_human's braces. Behaviour: - Counts exhausted attempts since the last success-shaped event per issue, so a recovered issue is never demoted on stale history. - Idempotent: skips issues that have already shed loop:ready since the last tick (no double-comment, no fight with escalate_to_human). - Best-effort: gh API failures are caught and logged as stuck_sweep_demoted{ok=false,reason=...} so the tick never crashes. - Emits the new typed StuckSweepDemotedEvent for every action. Wired into runner/tick._tick before the dispatch fetch. Config plumbed through settings.maintenance.stuck_threshold_attempts + settings.maintenance.stuck_tail_events. Tests cover the full matrix from the issue: ≥threshold exhausted → demoted; success-after-exhausted → not demoted; zero exhausted → no action; gh failure caught; idempotent skip; tail-window respect; malformed JSON tolerated; multi-issue ordering. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner
Author
|
Source issue #129 was closed mid-flight (state: closed). Loop refusing auto-merge. Reopen the issue OR merge manually. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
forge_loop.stuck_sweep— per-tick health-check that scans the events.jsonl tail, countsworker_iterations_exhaustedper issue (resetting on recovery), and demotes any issue pastsettings.maintenance.stuck_threshold_attemptsthat still carriesloop:ready.runner/tick._tickso it runs after the iteration loop and before the next dispatch batch.StuckSweepDemotedEvent+ newMaintenanceSettingsgroup withstuck_threshold_attempts(default 2) andstuck_tail_events(default 100).loop:readywhenescalate_to_humandidn't fully land (CTO-flagged during the brainstormer epic dogfood).Test plan
pytest tests/test_stuck_sweep.py— 13 tests covering the full matrix from feat(maintenance): stuck-issue sweep — demote loop:ready issues with N exhausted iteration attempts #129loop:ready→ silent skip, no double-demotionFixes #129
🤖 Generated with Claude Code