Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions tools/caretaker-agent/cloudrun/triage-worker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ def main() -> None:

if quality in ["SPAM", "EMPTY", "FEATURE"]:
print(f"[WORKER] Quality: {quality}. Applying auto-close label.")
if quality == "FEATURE":
send_comment_action(
owner,
repo,
issue_number,
"Thank you for bringing this to our attention. Right now, our "
"engineering team is focusing all resources on critical system "
"maintenance and core stability. Because of this, we don't have "
"immediate plans to address this specific issue. If you believe "
"this issue was misclassified, feel free to reopen it.",
)

send_label_action(owner, repo, issue_number, ["auto-close"])
store.release_lock(
owner,
Expand Down
37 changes: 35 additions & 2 deletions tools/caretaker-agent/cloudrun/triage-worker/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,48 @@ def test_main_claim_action_early_exits_zero(self):
@patch("main.process_issue_triage")
@patch("main.send_label_action")
def test_main_auto_close_quality_flow(self, mock_send_label, mock_triage):
"""SPAM/EMPTY/FEATURE issues dispatch auto-close label."""
"""SPAM and EMPTY issues dispatch auto-close label."""
for quality in ["SPAM", "EMPTY"]:
self.mock_store.acquire_lock.reset_mock()
self.mock_store.release_lock.reset_mock()
mock_send_label.reset_mock()
mock_triage.reset_mock()

self.mock_store.acquire_lock.return_value = ClaimAction.PROCEED
output = json.dumps({"triage_metadata": {"quality": quality}})
mock_triage.return_value = (True, output)

with self.assertRaises(SystemExit) as ctx:
main()

self.assertEqual(ctx.exception.code, 0)
mock_send_label.assert_called_once_with(
"owner", "repo", 42, ["auto-close"]
)
self.mock_store.release_lock.assert_called_once_with(
"owner", "repo", 42, "exec-123", success=True, status="AUTO_CLOSE"
)

@patch("main.process_issue_triage")
@patch("main.send_comment_action")
@patch("main.send_label_action")
def test_main_feature_quality_flow(
self, mock_send_label, mock_send_comment, mock_triage
):
"""FEATURE issues post comment and dispatch auto-close label."""
self.mock_store.acquire_lock.return_value = ClaimAction.PROCEED
output = json.dumps({"triage_metadata": {"quality": "SPAM"}})
output = json.dumps({"triage_metadata": {"quality": "FEATURE"}})
mock_triage.return_value = (True, output)

with self.assertRaises(SystemExit) as ctx:
main()

self.assertEqual(ctx.exception.code, 0)
mock_send_comment.assert_called_once()
args, _ = mock_send_comment.call_args
self.assertEqual(args[:3], ("owner", "repo", 42))
# Verify non-empty comment body
self.assertTrue(len(args[3].strip()) > 0)
mock_send_label.assert_called_once_with(
"owner", "repo", 42, ["auto-close"]
)
Expand Down
Loading