feat: stuck detection — alerts when same files repeat 3x

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-04 14:34:52 +02:00
parent 8fdbd81a05
commit bf911b2117
2 changed files with 87 additions and 0 deletions
+55
View File
@@ -0,0 +1,55 @@
import sys
sys.path.insert(0, 'bin')
from stuck_check import is_stuck
def test_not_stuck_with_different_files():
entries = [
{'project': 'x', 'files_changed': ['a.go']},
{'project': 'x', 'files_changed': ['b.go']},
{'project': 'x', 'files_changed': ['c.go']},
]
assert is_stuck('x', entries) is False
def test_stuck_when_same_files_3_times():
entries = [
{'project': 'x', 'files_changed': ['a.go', 'b.go']},
{'project': 'x', 'files_changed': ['a.go', 'b.go']},
{'project': 'x', 'files_changed': ['a.go', 'b.go']},
]
assert is_stuck('x', entries) is True
def test_not_stuck_with_fewer_than_3_entries():
entries = [
{'project': 'x', 'files_changed': ['a.go']},
{'project': 'x', 'files_changed': ['a.go']},
]
assert is_stuck('x', entries) is False
def test_only_checks_matching_project():
entries = [
{'project': 'y', 'files_changed': ['a.go']},
{'project': 'y', 'files_changed': ['a.go']},
{'project': 'y', 'files_changed': ['a.go']},
{'project': 'x', 'files_changed': ['a.go']},
{'project': 'x', 'files_changed': ['a.go']},
]
assert is_stuck('x', entries) is False # only 2 entries for x
def test_not_stuck_when_files_empty():
"""Empty file sets don't count as stuck — agent may not have changed anything."""
entries = [
{'project': 'x', 'files_changed': []},
{'project': 'x', 'files_changed': []},
{'project': 'x', 'files_changed': []},
]
assert is_stuck('x', entries) is False
def test_order_matters_only_last_3():
"""Only the last 3 entries matter."""
entries = [
{'project': 'x', 'files_changed': ['a.go']},
{'project': 'x', 'files_changed': ['a.go']},
{'project': 'x', 'files_changed': ['a.go']},
{'project': 'x', 'files_changed': ['b.go']}, # most recent: different
]
assert is_stuck('x', entries) is False