fix(phase25): 首席架構師 Review C1/C2/I1/I3 修正
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 57s

C1: NemotronProvider.privacy_level cloud→local
    NIM 部署在 192.168.0.188 內網,非官方雲端 API
    可納入 DIAGNOSE _local_fallback_chain 隱私邊界

C2: adopt() 端點暫停,返回 501
    API Pod 執行 git add -A 有安全風險
    ADR-057 起草後改用 Gitea PR API 實作

I1: timeout log 修正,記錄實際套用的 timeout 值
    原本永遠記錄 NEMOTRON_TIMEOUT_SECONDS=45
    現在記錄依 task_type 選擇的正確值

I3: route_sync() 補 DIAGNOSE 隱私邊界
    async route() 已有 _local_fallback_chain
    sync 版本遺漏,此次補齊

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-04 18:00:05 +08:00
parent c4eafd2a5b
commit a562db4048
3 changed files with 20 additions and 15 deletions

View File

@@ -116,19 +116,17 @@ async def rollback_drift(report_id: str) -> dict:
@router.post("/reports/{report_id}/adopt", summary="承認變更並更新 Git")
async def adopt_drift(report_id: str) -> dict:
async def adopt_drift(_report_id: str) -> dict:
"""
承認 K8s 漂移,更新 Git 使其與實際狀態一致
人工確認後才執行git commit + push gitea main
⚠️ 2026-04-04 ogt: C2 首席架構師裁示 — 暫時停用ADR-057 起草後再啟用)
API Pod 內執行 git add -A 有安全風險,改用 Gitea PR API 實作後才開放。
"""
report = _recent_reports.get(report_id)
if not report:
raise HTTPException(status_code=404, detail=f"Report {report_id} not found")
remediator = get_drift_remediator()
result = await remediator.adopt(report)
return result
raise HTTPException(
status_code=501,
detail="adopt() 端點暫停開放。ADR-057 起草後將改由 Gitea PR API 實作。",
)
# =============================================================================

View File

@@ -111,8 +111,10 @@ class NemotronProvider:
@property
def privacy_level(self) -> str:
# NIM 是雲端 GPU首席架構師 Q2 裁示: cloud 等級
return "cloud"
# 2026-04-04 ogt: Phase 25 首席架構師裁示 — NIM 部署在 192.168.0.188(內網 GPU
# 非 NVIDIA 官方雲端 API屬 local infra可納入 DIAGNOSE 隱私邊界
# 原標注 cloud 錯誤Q2 裁示前的預設),此次更正
return "local"
async def analyze(
self,
@@ -227,11 +229,12 @@ class NemotronProvider:
except asyncio.TimeoutError:
latency_ms = (time.perf_counter() - start) * 1000
timeout_secs = getattr(settings, "NEMOTRON_TIMEOUT_SECONDS", 30)
# 2026-04-04 ogt: I1 修正 — 使用實際套用的 timeout依 task_type 選擇)
logger.warning(
"nemotron_provider_timeout",
incident_id=incident_id,
timeout_seconds=timeout_secs,
timeout_seconds=timeout,
task_type=task_type,
latency_ms=round(latency_ms, 1),
)
return AIResult(
@@ -239,7 +242,7 @@ class NemotronProvider:
success=False,
provider=self.name,
latency_ms=latency_ms,
error=f"Tool calling timeout after {timeout_secs}s",
error=f"Tool calling timeout after {timeout}s",
)
except Exception as e:

View File

@@ -536,7 +536,11 @@ class AIRouter:
)
# 建立 Fallback 鏈
fallback_chain = self._build_fallback_chain(provider)
# 2026-04-04 ogt: I3 修正 — route_sync 也須尊重 DIAGNOSE 隱私邊界
if intent == IntentType.DIAGNOSE:
fallback_chain = [fc for fc in self._local_fallback_chain if fc[0] != provider]
else:
fallback_chain = self._build_fallback_chain(provider)
# 延遲預算
latency_budget = PROVIDER_LATENCY_BUDGET.get(provider, 30000)