fix: Restore all files lost during destructive rebase
A previous `git pull --rebase origin main` dropped 177 local commits,
losing 3400+ files across admin-v2, backend, studio-v2, website,
klausur-service, and many other services. The partial restore attempt
(660295e2) only recovered some files.
This commit restores all missing files from pre-rebase ref 98933f5e
while preserving post-rebase additions (night-scheduler, night-mode UI,
NightModeWidget dashboard integration).
Restored features include:
- AI Module Sidebar (FAB), OCR Labeling, OCR Compare
- GPU Dashboard, RAG Pipeline, Magic Help
- Klausur-Korrektur (8 files), Abitur-Archiv (5+ files)
- Companion, Zeugnisse-Crawler, Screen Flow
- Full backend, studio-v2, website, klausur-service
- All compliance SDKs, agent-core, voice-service
- CI/CD configs, documentation, scripts
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
123
backend/alerts_agent/actions/base.py
Normal file
123
backend/alerts_agent/actions/base.py
Normal file
@@ -0,0 +1,123 @@
|
||||
"""
|
||||
Base Classes für Alert Actions.
|
||||
|
||||
Definiert das Interface für alle Action-Handler.
|
||||
"""
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from datetime import datetime
|
||||
from typing import Dict, Any, Optional, List
|
||||
from enum import Enum
|
||||
|
||||
|
||||
class ActionType(str, Enum):
|
||||
"""Verfügbare Aktionstypen."""
|
||||
EMAIL = "email"
|
||||
WEBHOOK = "webhook"
|
||||
SLACK = "slack"
|
||||
TEAMS = "teams"
|
||||
TAG = "tag"
|
||||
ARCHIVE = "archive"
|
||||
|
||||
|
||||
@dataclass
|
||||
class ActionResult:
|
||||
"""Ergebnis einer ausgeführten Aktion."""
|
||||
success: bool
|
||||
action_type: ActionType
|
||||
message: str
|
||||
timestamp: datetime = field(default_factory=datetime.utcnow)
|
||||
details: Dict[str, Any] = field(default_factory=dict)
|
||||
error: Optional[str] = None
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Konvertiert zu Dict für Logging/Speicherung."""
|
||||
return {
|
||||
"success": self.success,
|
||||
"action_type": self.action_type.value,
|
||||
"message": self.message,
|
||||
"timestamp": self.timestamp.isoformat(),
|
||||
"details": self.details,
|
||||
"error": self.error,
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class AlertContext:
|
||||
"""Kontext für eine Aktion mit Alert-Informationen."""
|
||||
alert_id: str
|
||||
title: str
|
||||
url: str
|
||||
snippet: str
|
||||
topic_name: str
|
||||
relevance_score: Optional[float] = None
|
||||
relevance_decision: Optional[str] = None
|
||||
matched_rule: Optional[str] = None
|
||||
tags: List[str] = field(default_factory=list)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Konvertiert zu Dict für Templates."""
|
||||
return {
|
||||
"alert_id": self.alert_id,
|
||||
"title": self.title,
|
||||
"url": self.url,
|
||||
"snippet": self.snippet,
|
||||
"topic_name": self.topic_name,
|
||||
"relevance_score": self.relevance_score,
|
||||
"relevance_decision": self.relevance_decision,
|
||||
"matched_rule": self.matched_rule,
|
||||
"tags": self.tags,
|
||||
}
|
||||
|
||||
|
||||
class ActionHandler(ABC):
|
||||
"""
|
||||
Abstrakte Basisklasse für Action-Handler.
|
||||
|
||||
Jede Aktion (Email, Webhook, Slack) implementiert diese Schnittstelle.
|
||||
"""
|
||||
|
||||
@property
|
||||
@abstractmethod
|
||||
def action_type(self) -> ActionType:
|
||||
"""Gibt den Aktionstyp zurück."""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
async def execute(
|
||||
self,
|
||||
context: AlertContext,
|
||||
config: Dict[str, Any],
|
||||
) -> ActionResult:
|
||||
"""
|
||||
Führt die Aktion aus.
|
||||
|
||||
Args:
|
||||
context: Alert-Kontext mit allen relevanten Informationen
|
||||
config: Aktionsspezifische Konfiguration
|
||||
|
||||
Returns:
|
||||
ActionResult mit Erfolgsstatus und Details
|
||||
"""
|
||||
pass
|
||||
|
||||
def validate_config(self, config: Dict[str, Any]) -> bool:
|
||||
"""
|
||||
Validiert die Aktions-Konfiguration.
|
||||
|
||||
Args:
|
||||
config: Zu validierende Konfiguration
|
||||
|
||||
Returns:
|
||||
True wenn gültig
|
||||
"""
|
||||
return True
|
||||
|
||||
def get_required_config_fields(self) -> List[str]:
|
||||
"""
|
||||
Gibt erforderliche Konfigurationsfelder zurück.
|
||||
|
||||
Returns:
|
||||
Liste von Feldnamen
|
||||
"""
|
||||
return []
|
||||
Reference in New Issue
Block a user