Spaces:
Sleeping
Sleeping
File size: 21,993 Bytes
9c1645f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 | """
Ticket generation scenarios for SupportOps Arena.
Defines root causes and generates tickets for easy, medium, and hard difficulty levels.
"""
import random
from datetime import datetime, timedelta
from typing import Any
from env.actions import ActionType
from env.state import (
UserContext, LogEntry, NetworkStatus, VPNStatus,
AuthStatus, ServiceHealth, TaskLevel
)
# βββ Easy Task Root Causes βββββββββββββββββββββββββββββββββββ
TASK_EASY_ROOT_CAUSES = [
{
"id": "wifi_adapter_disabled",
"description": "Network adapter disabled by OS update",
"category": "hardware",
"correct_remediation": ActionType.RECONFIGURE_CLIENT,
"correct_remediation_alts": [],
"diagnostic_path": [ActionType.QUERY_DEVICE_STATUS, ActionType.INSPECT_NETWORK],
"severity": "low",
"affected_users": 1
},
{
"id": "wifi_wrong_credentials",
"description": "Incorrect saved credentials for SSID",
"category": "auth",
"correct_remediation": ActionType.RESET_CREDENTIALS,
"correct_remediation_alts": [],
"diagnostic_path": [ActionType.CHECK_AUTHENTICATION, ActionType.INSPECT_LOGS],
"severity": "low",
"affected_users": 1
},
{
"id": "wifi_dns_corruption",
"description": "Local DNS cache corruption",
"category": "dns",
"correct_remediation": ActionType.FLUSH_DNS,
"correct_remediation_alts": [ActionType.RECONFIGURE_CLIENT],
"diagnostic_path": [ActionType.INSPECT_NETWORK, ActionType.INSPECT_LOGS],
"severity": "low",
"affected_users": 1
},
{
"id": "wifi_airplane_mode",
"description": "Airplane mode enabled by accident",
"category": "hardware",
"correct_remediation": ActionType.RECONFIGURE_CLIENT,
"correct_remediation_alts": [],
"diagnostic_path": [ActionType.QUERY_DEVICE_STATUS],
"severity": "low",
"affected_users": 1
},
{
"id": "wifi_dhcp_exhausted",
"description": "DHCP lease pool exhausted",
"category": "network",
"correct_remediation": ActionType.RESTART_SERVICE,
"correct_remediation_alts": [ActionType.ESCALATE_TICKET],
"diagnostic_path": [ActionType.INSPECT_NETWORK, ActionType.RUN_DIAGNOSTIC],
"severity": "medium",
"affected_users": 15
},
{
"id": "wifi_wrong_ssid",
"description": "Client connected to wrong SSID (guest vs corporate)",
"category": "network",
"correct_remediation": ActionType.RECONFIGURE_CLIENT,
"correct_remediation_alts": [],
"diagnostic_path": [ActionType.QUERY_DEVICE_STATUS, ActionType.INSPECT_NETWORK],
"severity": "low",
"affected_users": 1
},
]
# βββ Medium Task Root Causes ββββββββββββββββββββββββββββββββββ
TASK_MEDIUM_ROOT_CAUSES = [
{
"id": "expired_password",
"description": "User password expired, blocking VPN authentication",
"category": "auth",
"correct_remediation": ActionType.RESET_CREDENTIALS,
"correct_remediation_alts": [ActionType.ESCALATE_TICKET],
"diagnostic_path": [ActionType.CHECK_AUTHENTICATION, ActionType.INSPECT_LOGS],
"severity": "medium",
"affected_users": 1
},
{
"id": "vpn_version_mismatch",
"description": "VPN client version incompatible with gateway",
"category": "vpn",
"correct_remediation": ActionType.RECONFIGURE_CLIENT,
"correct_remediation_alts": [ActionType.ESCALATE_TICKET],
"diagnostic_path": [ActionType.QUERY_DEVICE_STATUS, ActionType.SEARCH_INTERNAL_KB],
"severity": "medium",
"affected_users": 1
},
{
"id": "dns_split_tunnel_conflict",
"description": "Split-tunnel DNS configuration conflict",
"category": "dns",
"correct_remediation": ActionType.FLUSH_DNS,
"correct_remediation_alts": [ActionType.RECONFIGURE_CLIENT],
"diagnostic_path": [ActionType.INSPECT_NETWORK, ActionType.RUN_DIAGNOSTIC],
"severity": "medium",
"affected_users": 1
},
{
"id": "mfa_token_desync",
"description": "MFA token out of sync with authentication server",
"category": "auth",
"correct_remediation": ActionType.RESET_CREDENTIALS,
"correct_remediation_alts": [ActionType.ESCALATE_TICKET],
"diagnostic_path": [ActionType.CHECK_AUTHENTICATION, ActionType.CONTACT_USER],
"severity": "medium",
"affected_users": 1
},
{
"id": "firewall_subnet_block",
"description": "Firewall blocking specific subnet for remote users",
"category": "network",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [ActionType.INSPECT_NETWORK, ActionType.RUN_DIAGNOSTIC],
"severity": "high",
"affected_users": 8
},
{
"id": "certificate_expiry",
"description": "VPN SSL certificate expired on gateway",
"category": "vpn",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [ActionType.INSPECT_LOGS, ActionType.SEARCH_INTERNAL_KB],
"severity": "high",
"affected_users": 12
},
]
# βββ Hard Task Root Causes ββββββββββββββββββββββββββββββββββββ
TASK_HARD_ROOT_CAUSES = [
{
"id": "sso_token_service_degradation",
"description": "SSO token service degraded in datacenter-east, affecting multiple applications",
"category": "sso",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [
ActionType.INSPECT_LOGS,
ActionType.CHECK_AUTHENTICATION,
ActionType.RUN_DIAGNOSTIC
],
"severity": "critical",
"affected_users": 150,
"multi_ticket": True
},
{
"id": "ldap_replication_lag",
"description": "LDAP replication lag causing inconsistent auth across regions",
"category": "auth",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [
ActionType.CHECK_AUTHENTICATION,
ActionType.INSPECT_LOGS,
ActionType.SEARCH_INTERNAL_KB
],
"severity": "critical",
"affected_users": 200,
"multi_ticket": True
},
{
"id": "dns_zone_transfer_failure",
"description": "DNS zone transfer failure causing resolution inconsistencies",
"category": "dns",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [
ActionType.INSPECT_NETWORK,
ActionType.INSPECT_LOGS,
ActionType.RUN_DIAGNOSTIC
],
"severity": "critical",
"affected_users": 300,
"multi_ticket": True
},
{
"id": "proxy_cascading_failure",
"description": "Web proxy cascading failure affecting multiple services",
"category": "network",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [
ActionType.INSPECT_NETWORK,
ActionType.INSPECT_LOGS,
ActionType.SEARCH_INTERNAL_KB
],
"severity": "critical",
"affected_users": 250,
"multi_ticket": True
},
{
"id": "certificate_chain_break",
"description": "Intermediate certificate chain break affecting SSL validation",
"category": "network",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [
ActionType.INSPECT_LOGS,
ActionType.RUN_DIAGNOSTIC,
ActionType.SEARCH_INTERNAL_KB
],
"severity": "critical",
"affected_users": 180,
"multi_ticket": True
},
{
"id": "storage_backend_degradation",
"description": "Shared storage backend degradation affecting file services",
"category": "hardware",
"correct_remediation": ActionType.ESCALATE_TICKET,
"correct_remediation_alts": [],
"diagnostic_path": [
ActionType.QUERY_DEVICE_STATUS,
ActionType.INSPECT_LOGS,
ActionType.RUN_DIAGNOSTIC
],
"severity": "critical",
"affected_users": 220,
"multi_ticket": True
},
]
class TicketGenerator:
"""
Generates realistic IT support tickets with configurable difficulty.
Supports adversarial sampling weights for adaptive difficulty.
"""
def __init__(self, seed: int | None = None):
self.rng = random.Random(seed)
self._sampling_weights: dict[str, float] = {}
def set_sampling_weights(self, weights: dict[str, float]) -> None:
"""Update sampling weights from adversary."""
self._sampling_weights = weights
def generate_ticket(
self,
task_level: TaskLevel,
seed: int | None = None
) -> dict[str, Any]:
"""
Generate a ticket scenario for the given difficulty level.
Returns:
Dictionary containing all ticket components:
- root_cause: The ground truth root cause info
- observation_template: Initial observation data
- misleading_log_index: Index of misleading log (if any)
"""
if seed is not None:
self.rng = random.Random(seed)
if task_level == TaskLevel.EASY:
return self._generate_easy_ticket()
elif task_level == TaskLevel.MEDIUM:
return self._generate_medium_ticket()
elif task_level == TaskLevel.HARD:
return self._generate_hard_ticket()
else:
raise ValueError(f"Invalid task level: {task_level}")
def _generate_easy_ticket(self) -> dict[str, Any]:
"""Generate easy difficulty ticket (Wi-Fi connectivity)."""
# Apply sampling weights if available
causes = TASK_EASY_ROOT_CAUSES.copy()
if self._sampling_weights:
weights = [self._sampling_weights.get(c["id"], 1.0) for c in causes]
root_cause = self.rng.choices(causes, weights=weights, k=1)[0]
else:
root_cause = self.rng.choice(causes)
# Generate user context
user_context = self._generate_user_context()
# Generate initial logs (no misleading entries for easy)
logs = self._generate_initial_logs_easy(root_cause)
# Create observation template
observation_template = {
"ticket_summary": "Hi, I can't connect to Wi-Fi and need help urgently.",
"user_context": user_context,
"network_status": NetworkStatus.UNKNOWN,
"vpn_status": VPNStatus.NA,
"auth_status": AuthStatus.OK,
"service_health": {
"dhcp": ServiceHealth.UNKNOWN,
"dns": ServiceHealth.UNKNOWN,
"wifi": ServiceHealth.UNKNOWN,
},
"system_logs": logs,
}
return {
"root_cause": root_cause,
"observation_template": observation_template,
"misleading_log_index": None,
}
def _generate_medium_ticket(self) -> dict[str, Any]:
"""Generate medium difficulty ticket (VPN access)."""
causes = TASK_MEDIUM_ROOT_CAUSES.copy()
if self._sampling_weights:
weights = [self._sampling_weights.get(c["id"], 1.0) for c in causes]
root_cause = self.rng.choices(causes, weights=weights, k=1)[0]
else:
root_cause = self.rng.choice(causes)
user_context = self._generate_user_context()
user_context.location = "remote"
# Generate logs with 1 misleading entry
logs, misleading_idx = self._generate_initial_logs_medium(root_cause)
observation_template = {
"ticket_summary": "I'm working from home and can't access any internal tools through VPN. It was working fine yesterday.",
"user_context": user_context,
"network_status": NetworkStatus.UNKNOWN,
"vpn_status": VPNStatus.NA,
"auth_status": AuthStatus.OK,
"service_health": {
"vpn_client": ServiceHealth.UNKNOWN,
"vpn_gateway": ServiceHealth.UNKNOWN,
"dns": ServiceHealth.UNKNOWN,
},
"system_logs": logs,
}
return {
"root_cause": root_cause,
"observation_template": observation_template,
"misleading_log_index": misleading_idx,
}
def _generate_hard_ticket(self) -> dict[str, Any]:
"""Generate hard difficulty ticket (multi-service failure)."""
causes = TASK_HARD_ROOT_CAUSES.copy()
if self._sampling_weights:
weights = [self._sampling_weights.get(c["id"], 1.0) for c in causes]
root_cause = self.rng.choices(causes, weights=weights, k=1)[0]
else:
root_cause = self.rng.choice(causes)
user_context = self._generate_user_context()
# Generate logs with multiple misleading entries
logs, misleading_idx = self._generate_initial_logs_hard(root_cause)
observation_template = {
"ticket_summary": "Multiple users reporting access issues across different systems. Email and collaboration tools are affected.",
"user_context": user_context,
"network_status": NetworkStatus.UNKNOWN,
"vpn_status": VPNStatus.NA,
"auth_status": AuthStatus.OK,
"service_health": {
"mail": ServiceHealth.UNKNOWN,
"sharepoint": ServiceHealth.UNKNOWN,
"teams": ServiceHealth.UNKNOWN,
"sso": ServiceHealth.UNKNOWN,
},
"system_logs": logs,
}
return {
"root_cause": root_cause,
"observation_template": observation_template,
"misleading_log_index": misleading_idx,
}
def _generate_user_context(self) -> UserContext:
"""Generate randomized user context."""
departments = ["Engineering", "Sales", "Finance", "HR", "Operations"]
roles = ["Manager", "Analyst", "Developer", "Coordinator", "Specialist"]
devices = ["Laptop", "Desktop", "Tablet"]
os_versions = ["Windows 11", "Windows 10", "macOS 14", "macOS 13"]
locations = ["onsite", "remote"]
return UserContext(
department=self.rng.choice(departments),
role=self.rng.choice(roles),
device_type=self.rng.choice(devices),
os_version=self.rng.choice(os_versions),
location=self.rng.choice(locations),
)
def _generate_initial_logs_easy(self, root_cause: dict) -> list[LogEntry]:
"""Generate initial logs for easy task (no misleading entries)."""
now = datetime.utcnow()
logs = []
# Add generic startup logs
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=5)).isoformat(),
level="INFO",
service="NetworkManager",
message="Network service initialized",
is_misleading=False
))
# Add category-relevant log
category = root_cause["category"]
if category == "dns":
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=3)).isoformat(),
level="WARN",
service="DNSResolver",
message="DNS resolution timeout for internal.company.com",
is_misleading=False
))
elif category == "auth":
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=2)).isoformat(),
level="ERROR",
service="WiFiAuth",
message="Authentication failed: Invalid credentials",
is_misleading=False
))
elif category == "hardware":
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=1)).isoformat(),
level="WARN",
service="DeviceManager",
message="Network adapter state changed",
is_misleading=False
))
logs.append(LogEntry(
timestamp=now.isoformat(),
level="ERROR",
service="NetworkManager",
message="Connection attempt failed",
is_misleading=False
))
return logs
def _generate_initial_logs_medium(
self, root_cause: dict
) -> tuple[list[LogEntry], int]:
"""Generate logs for medium task with 1 misleading entry."""
now = datetime.utcnow()
logs = []
# Add real logs
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=10)).isoformat(),
level="INFO",
service="VPNClient",
message="VPN client started",
is_misleading=False
))
category = root_cause["category"]
if category == "auth":
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=7)).isoformat(),
level="ERROR",
service="AuthService",
message=f"Authentication failed: {root_cause['description']}",
is_misleading=False
))
elif category == "vpn":
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=6)).isoformat(),
level="WARN",
service="VPNGateway",
message=f"VPN handshake failed: {root_cause['description']}",
is_misleading=False
))
# Add misleading log (at random position)
misleading_messages = [
"Network latency spike detected (250ms avg)",
"DNS query timeout for vpn.company.com",
"Firewall rule evaluation took longer than expected",
]
misleading_log = LogEntry(
timestamp=(now - timedelta(minutes=4)).isoformat(),
level="WARN",
service="NetworkMonitor",
message=self.rng.choice(misleading_messages),
is_misleading=True
)
# Insert misleading log at random position (not first or last)
insert_pos = self.rng.randint(1, len(logs))
logs.insert(insert_pos, misleading_log)
logs.append(LogEntry(
timestamp=now.isoformat(),
level="ERROR",
service="VPNClient",
message="Connection failed after 3 retries",
is_misleading=False
))
return logs, insert_pos
def _generate_initial_logs_hard(
self, root_cause: dict
) -> tuple[list[LogEntry], int | None]:
"""Generate logs for hard task with multiple misleading entries."""
now = datetime.utcnow()
logs = []
# Add system logs with contradictory evidence
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=15)).isoformat(),
level="INFO",
service="SystemMonitor",
message="All services nominal",
is_misleading=True # Contradicts the actual failures
))
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=12)).isoformat(),
level="WARN",
service="LoadBalancer",
message="Backend pool health check degraded",
is_misleading=False
))
# Add a misleading authentication success
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=10)).isoformat(),
level="INFO",
service="AuthService",
message="User authentication successful (cached token)",
is_misleading=True
))
category = root_cause["category"]
if category == "sso":
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=8)).isoformat(),
level="ERROR",
service="SSOTokenService",
message="Token validation latency exceeding threshold (3000ms)",
is_misleading=False
))
elif category == "dns":
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=7)).isoformat(),
level="ERROR",
service="DNSService",
message="Zone transfer failed from primary nameserver",
is_misleading=False
))
logs.append(LogEntry(
timestamp=(now - timedelta(minutes=5)).isoformat(),
level="WARN",
service="ServiceMesh",
message="Multiple service endpoints reporting degraded state",
is_misleading=False
))
logs.append(LogEntry(
timestamp=now.isoformat(),
level="ERROR",
service="IncidentManager",
message=f"Multiple concurrent failures detected: {root_cause['description']}",
is_misleading=False
))
# Return index of first misleading log
misleading_idx = 0 # First log is misleading
return logs, misleading_idx
|