Spaces:
Runtime error
Runtime error
Update event.py
Browse files
event.py
CHANGED
|
@@ -4,7 +4,7 @@ Includes ReliabilityEvent, HealingAction, PolicyCondition, etc.
|
|
| 4 |
"""
|
| 5 |
|
| 6 |
from pydantic import BaseModel, Field, field_validator, computed_field, ConfigDict
|
| 7 |
-
from typing import Optional, List, Literal
|
| 8 |
from enum import Enum
|
| 9 |
from datetime import datetime, timezone
|
| 10 |
import hashlib
|
|
@@ -17,6 +17,16 @@ from agentic_reliability_framework.core.config.constants import (
|
|
| 17 |
MEMORY_WARNING, MEMORY_CRITICAL
|
| 18 |
)
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
class EventSeverity(str, Enum):
|
| 22 |
LOW = "low"
|
|
|
|
| 4 |
"""
|
| 5 |
|
| 6 |
from pydantic import BaseModel, Field, field_validator, computed_field, ConfigDict
|
| 7 |
+
from typing import Optional, List, Literal, Tuple
|
| 8 |
from enum import Enum
|
| 9 |
from datetime import datetime, timezone
|
| 10 |
import hashlib
|
|
|
|
| 17 |
MEMORY_WARNING, MEMORY_CRITICAL
|
| 18 |
)
|
| 19 |
|
| 20 |
+
def validate_component_id(component: str) -> Tuple[bool, str]:
|
| 21 |
+
"""Validate component ID format (alphanumeric and hyphens only)."""
|
| 22 |
+
if not isinstance(component, str):
|
| 23 |
+
return False, "Component ID must be a string"
|
| 24 |
+
if not (1 <= len(component) <= 255):
|
| 25 |
+
return False, "Component ID must be 1-255 characters"
|
| 26 |
+
if not re.match(r"^[a-z0-9-]+$", component):
|
| 27 |
+
return False, "Component ID must contain only lowercase letters, numbers, and hyphens"
|
| 28 |
+
return True, ""
|
| 29 |
+
|
| 30 |
|
| 31 |
class EventSeverity(str, Enum):
|
| 32 |
LOW = "low"
|