## AIVA: Expand Notification Channels

This PRD focuses on expanding the notification channels available for AIVA alerts, building upon the existing email notification system.

### GPM-069: PagerDuty Integration - Setup
**Goal:** Configure AIVA to send alerts to PagerDuty.
**Acceptance Criteria:**
- A new configuration section exists in the AIVA configuration file for PagerDuty settings (API key, service ID).
- The configuration section allows enabling/disabling PagerDuty integration.
- Default PagerDuty settings are documented.
**Files:** `config/aiva.yaml`, `docs/configuration.md`
**Spawns:** Implement the actual sending of alerts to PagerDuty.

### GPM-070: PagerDuty Integration - Alert Sending
**Goal:** Send alert notifications to PagerDuty when alert thresholds are breached.
**Acceptance Criteria:**
- When a throttling alert is triggered and PagerDuty integration is enabled, an incident is created in PagerDuty.
- The PagerDuty incident includes relevant alert details (timestamp, metric name, threshold breached, current value).
- Error handling is in place to catch and log any issues when sending alerts to PagerDuty.
**Files:** `aiva/notifier.py`, `aiva/alert_handler.py`
**Spawns:** Implement the ability to resolve PagerDuty incidents when the alert condition is no longer met.

### GPM-071: SMS Integration - Setup
**Goal:** Configure AIVA to send alerts via SMS.
**Acceptance Criteria:**
- A new configuration section exists in the AIVA configuration file for SMS settings (Twilio account SID, auth token, phone number).
- The configuration section allows enabling/disabling SMS integration.
- Default SMS settings are documented.
**Files:** `config/aiva.yaml`, `docs/configuration.md`
**Spawns:** Implement the actual sending of alerts via SMS.

### GPM-072: SMS Integration - Alert Sending
**Goal:** Send alert notifications via SMS when alert thresholds are breached.
**Acceptance Criteria:**
- When a throttling alert is triggered and SMS integration is enabled, an SMS message is sent.
- The SMS message includes relevant alert details (metric name, threshold breached, current value).
- SMS message length is limited to stay within SMS character limits.
- Error handling is in place to catch and log any issues when sending alerts via SMS.
**Files:** `aiva/notifier.py`, `aiva/alert_handler.py`
**Spawns:** Explore the possibility of using short URLs for links within SMS messages to reduce character count.

### GPM-073: Notification Channel Prioritization
**Goal:** Allow users to prioritize notification channels based on severity or alert type.
**Acceptance Criteria:**
- The AIVA configuration allows defining a priority order for notification channels (e.g., PagerDuty > SMS > Email).
- Different alert types can be configured to use different notification channel priorities.
- If sending to a higher-priority channel fails, the system attempts to send to the next available channel in the priority list.
**Files:** `config/aiva.yaml`, `aiva/notifier.py`
**Spawns:** Implement a mechanism for reporting notification failures and retrying failed notifications.

### GPM-074: PagerDuty Incident Resolution
**Goal:** Automatically resolve PagerDuty incidents when the alert condition is resolved.
**Acceptance Criteria:**
- When a throttling alert condition is no longer met, the corresponding PagerDuty incident is resolved.
- The PagerDuty incident resolution includes details about the resolution (timestamp, metric name).
- Error handling is in place to catch and log any issues when resolving incidents in PagerDuty.
**Files:** `aiva/notifier.py`, `aiva/alert_handler.py`
**Spawns:** Investigate using PagerDuty change events to track deployments and their impact on metrics.

### GPM-075: Notification Channel Testing
**Goal:** Implement a test function to verify that notification channels are configured correctly.
**Acceptance Criteria:**
- A CLI command or API endpoint is available to test the configuration of each notification channel.
- The test function sends a test notification to the configured channel and verifies that it is received.
- The test function reports any errors encountered during the test.
**Files:** `aiva/cli.py`, `aiva/api.py`, `aiva/notifier.py`
**Spawns:** Create a user interface for configuring and testing notification channels.
