feat(tests): load-balanced reviewer selection and Jira reviewer sync

This commit is contained in:
kitos
2026-07-06 10:56:40 +02:00
parent c41876b62f
commit 22be620665
3 changed files with 456 additions and 12 deletions
+30
View File
@@ -307,7 +307,9 @@ _SEVERITY_TO_PRIORITY: dict[str, str] = {
_STATE_EMOJI: dict[str, str] = {
"draft": "📝 Draft",
"red_executing": "🔴 Red Team Executing",
"red_review": "🔎 Red Lead Review",
"blue_evaluating": "🔵 Blue Team Evaluating",
"blue_review": "🔎 Blue Lead Review",
"in_review": "📋 In Review",
"validated": "✅ Validated",
"rejected": "❌ Rejected",
@@ -370,6 +372,18 @@ def _build_state_comment(
"Red Team has started the attack execution.",
]
elif new_state == "red_review":
lines += [
"Red Team has submitted evidence and the test is awaiting Red Lead review "
"before it queues for Blue Team.",
]
elif new_state == "blue_review":
lines += [
"Blue Team has submitted evidence and the test is awaiting Blue Lead review "
"before cross-validation.",
]
elif new_state == "blue_evaluating":
lines += [
"Red Team has finished execution and submitted evidence for Blue Team evaluation.",
@@ -667,6 +681,7 @@ def push_test_event(
new_state: str,
*,
extra: dict | None = None,
assignee: User | None = None,
) -> None:
"""Post a lifecycle comment to the Jira issue linked to *test*.
@@ -720,6 +735,21 @@ def push_test_event(
link.jira_issue_key, jira_account_id, exc_a,
)
if new_state in ("red_review", "blue_review") and assignee:
jira_account_id = getattr(assignee, "jira_account_id", None)
if jira_account_id:
try:
jira.assign_issue(link.jira_issue_key, account_id=jira_account_id)
logger.info(
"Assigned Jira ticket %s to reviewer account %s",
link.jira_issue_key, jira_account_id,
)
except Exception as exc_a:
logger.warning(
"Could not assign %s to reviewer %s: %s",
link.jira_issue_key, jira_account_id, exc_a,
)
link.last_synced_at = datetime.utcnow()
db.flush()
logger.info(