fix(api): Phase 16 R4 測試修復 - ParsedOperation 向後兼容
問題: - test_action_parsing.py 導入路徑未更新 (舊: approvals.py) - ParsedOperation dataclass 不支援 tuple 解包 修復: - 更新測試導入至 src.services.operation_parser - 新增 ParsedOperation.__iter__() 支援 tuple 解包 測試: 24/24 passed (100%) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,12 +29,20 @@ class ParsedOperation:
|
||||
operation_type: K8s 操作類型 (RESTART_DEPLOYMENT, DELETE_POD, etc.)
|
||||
resource_name: 目標資源名稱
|
||||
namespace: K8s Namespace (預設 "default")
|
||||
|
||||
Note:
|
||||
支援 tuple 解包以向後兼容:
|
||||
op, resource, ns = parse_operation_from_action(action)
|
||||
"""
|
||||
|
||||
operation_type: OperationType | None
|
||||
resource_name: str | None
|
||||
namespace: str
|
||||
|
||||
def __iter__(self):
|
||||
"""支援 tuple 解包: op, resource, ns = parsed"""
|
||||
return iter((self.operation_type, self.resource_name, self.namespace))
|
||||
|
||||
|
||||
def parse_operation_from_action(action: str) -> ParsedOperation:
|
||||
"""
|
||||
|
||||
@@ -9,7 +9,7 @@ Phase 12.1: Tool Calling 優化 - 行動解析測試
|
||||
|
||||
import pytest
|
||||
|
||||
from src.api.v1.approvals import parse_operation_from_action
|
||||
from src.services.operation_parser import parse_operation_from_action
|
||||
from src.services.executor import OperationType
|
||||
|
||||
# =============================================================================
|
||||
|
||||
@@ -5,17 +5,44 @@
|
||||
|
||||
---
|
||||
|
||||
## 📍 當前狀態 (2026-03-25 21:55 台北)
|
||||
## 📍 當前狀態 (2026-03-25 22:40 台北)
|
||||
|
||||
| 項目 | 狀態 |
|
||||
|------|------|
|
||||
| **當前 Phase** | **Phase 16 R4 瘦身 Router 進行中** |
|
||||
| **當前 Phase** | **Phase 16 R4 ✅ 完成** |
|
||||
| **Day** | Day 8 |
|
||||
| **驗證結束** | 2026-03-27 16:04 (48小時後) |
|
||||
| **重大決策** | ✅ **USE_NEW_ENGINE=true 已啟用** |
|
||||
| **CI/CD** | 🔄 Runner diag log 衝突修復中 |
|
||||
| **CI/CD** | ✅ **已修復** (移除自毀指令 + .gitignore 強化) |
|
||||
| **新規** | ✅ **絞殺者模式** + **封存策略** + **積木化強制執行** |
|
||||
|
||||
### ✅ 2026-03-25 Phase 16 R4.2 ApprovalExecutionService 完成 (Day 8 晚間 22:36)
|
||||
|
||||
**完成項目**:
|
||||
|
||||
| 模組 | Commit | 說明 |
|
||||
|------|--------|------|
|
||||
| approval_execution.py | 新建 | 從 approvals.py 抽取執行編排邏輯 (271 行) |
|
||||
| approvals.py | 4b3d98c | 移除內嵌 execute_approved_action (-310 行) |
|
||||
| ci.yaml / cd.yaml | 修復 | 移除 Runner 自毀指令 (rm -rf _work) |
|
||||
| .gitignore | 強化 | 防止 .claude/worktrees 干擾 CI/CD |
|
||||
|
||||
**瘦身總成果**: approvals.py 1097 → 787 行 (**-310 行, -28%**)
|
||||
|
||||
**新增模組**:
|
||||
- `src/services/operation_parser.py` (173 行) - 操作解析
|
||||
- `src/services/approval_execution.py` (271 行) - 執行編排
|
||||
|
||||
**CI/CD 穩定性修復**:
|
||||
- ❌ 移除 `rm -rf ~/actions-runner-*/_diag/` (防止 Runner 自殺)
|
||||
- ❌ 移除 `rm -rf _work` 相關指令
|
||||
- ✅ worktree 清理改在 checkout 後執行
|
||||
- ✅ .gitignore 防止 worktree 被 commit
|
||||
|
||||
**部署成功**: 4b3d98c @ 2026-03-25 22:36
|
||||
|
||||
---
|
||||
|
||||
### ✅ 2026-03-25 Phase 16 R4.1 OperationParser 抽取 (Day 8 晚間 21:55)
|
||||
|
||||
**完成項目**:
|
||||
|
||||
Reference in New Issue
Block a user