## 🛠️ 核心能力框架

### 1. AI 韌性參考架構（AI Resilience Reference Architecture）

```
Client → API Gateway → Rate Limiter → AuthZ
       → Inference Router (multi-model, weighted, health-aware)
       → Circuit Breaker Layer
       → LLM Provider Pool (primary + fallback models)
       → Response Validator (schema, safety, grounding check)
       → Cache Layer (semantic + exact match)
       → Async Queue (for non-latency-sensitive workloads)
       → Observability (traces, metrics, logs, LLM eval hooks)
```

### 2. SLI/SLO 設計模板（AI 服務）

| SLI | 定義 | 典型 SLO | Alert 條件 |
|-----|------|----------|------------|
| Availability | 非 5xx 且非 timeout 請求比例 | 99.9% / 30d | error rate > 0.1% 持續 5m |
| Latency | p99 end-to-end（含 TTFT） | < 3s | p99 > 4s 持續 10m |
| Quality | grounding score / eval pass rate | > 95% | 日環比下降 > 5% |
| Tool Success | agent tool-call 成功率 | > 99% | < 98% 持續 15m |
| Cost Efficiency | cost per successful request | budget 內 | 日超支 > 20% |

### 3. 故障模式百科（AI-Specific FMEA）

- **Cascade Failure**：上游 LLM 降速 → 重試風暴 → 下游 queue 飽和 → 全面 timeout
  - *緩解*：retry budget、exponential backoff with jitter、hedged requests（謹慎）、bulkhead per tenant
- **Silent Degradation**：模型 silently 降質（temperature drift、prompt cache stale）
  - *緩解*：continuous eval pipeline、synthetic canary queries、prompt version pinning
- **Context Avalanche**：長對話 + RAG 注入 → context overflow → truncation 導致錯誤 tool call
  - *緩解*：context budget manager、summarization checkpoint、priority-based truncation
- **Embedding Drift**：上游資料變更但 index 未重建 → retrieval 品質下降
  - *緩解*：index freshness SLI、incremental reindex、shadow retrieval eval

### 4. 混沌工程實驗目錄

| 實驗 | 注入方式 | 預期行為 | 通過標準 |
|------|----------|----------|----------|
| LLM Timeout | 延遲 primary 5s | fallback 啟動 < 2s | 使用者收到降級回應，無 5xx |
| Rate Limit Storm | 模擬 429 | client 退避，queue 不溢出 | p99 < 2x baseline |
| GPU OOM | 限制 VRAM | 請求 reroute 至備用 pool | 可用性 > 99% |
| Vector DB Partition | 阻斷 replica | 讀取 fallback 至 stale cache | RAG 延遲 < 2x，有 stale 標記 |
| Agent Loop | 注入 fault tool | max iteration guard 觸發 | 優雅終止 + 使用者通知 |

### 5. Observability Stack 清單

- **Tracing**：OpenTelemetry → Jaeger/Tempo；span 必須含 `model.name`, `token.input`, `token.output`, `latency.ttft`
- **Metrics**：Prometheus + Grafana；RED method + LLM-specific dashboards
- **Logging**：structured JSON；禁止 log raw prompt 含 PII
- **LLM Eval**：Langfuse / Arize / 自建 golden set regression
- **Synthetic**：每 1-5 分鐘執行 canary query，alert on quality/latency drift

### 6. Disaster Recovery Playbook 骨架

1. **RPO/RTO 對齊**：與業務確認可接受資料遺失與恢復時間
2. **備援拓撲**：active-active（多區）vs active-passive（冷備）
3. **資料層**：向量索引 snapshot、embedding model version lock、checkpoint 頻率
4. **通訊計畫**：incident commander、status page、customer comms template
5. **演練節奏**：季度 DR drill、月度 game day、每 sprint reliability review

### 7. 工具與技術棧熟悉度

Kubernetes, Istio/Linkerd, Envoy, Redis, Kafka, PostgreSQL/pgvector, Pinecone/Weaviate/Milvus, vLLM/TGI, LangChain/LangGraph, Temporal, ArgoCD, Terraform, Pulumi, Datadog/Grafana, PagerDuty/Opsgenie, Gremlin/LitmusChaos, k6/Locust。