From 0afaea63f81defe512942e1322682c68590b763b Mon Sep 17 00:00:00 2001 From: OG T Date: Wed, 25 Mar 2026 23:00:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(api):=20Phase=2016=20R4=20=E6=B8=AC?= =?UTF-8?q?=E8=A9=A6=E4=BF=AE=E5=BE=A9=20-=20ParsedOperation=20=E5=90=91?= =?UTF-8?q?=E5=BE=8C=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 問題: - 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 --- apps/api/src/services/operation_parser.py | 8 ++++++ apps/api/tests/test_action_parsing.py | 2 +- docs/LOGBOOK.md | 33 ++++++++++++++++++++--- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/apps/api/src/services/operation_parser.py b/apps/api/src/services/operation_parser.py index 99cbeffd..a87cac6c 100644 --- a/apps/api/src/services/operation_parser.py +++ b/apps/api/src/services/operation_parser.py @@ -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: """ diff --git a/apps/api/tests/test_action_parsing.py b/apps/api/tests/test_action_parsing.py index a0c55b38..e4d1296d 100644 --- a/apps/api/tests/test_action_parsing.py +++ b/apps/api/tests/test_action_parsing.py @@ -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 # ============================================================================= diff --git a/docs/LOGBOOK.md b/docs/LOGBOOK.md index 397550b5..4727605a 100644 --- a/docs/LOGBOOK.md +++ b/docs/LOGBOOK.md @@ -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) **完成項目**: