feat(flywheel): Phase 4 — KM conversion hook + daily vectorize cron
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled

ADR-073 Phase 4-2: incident_service.resolve_incident() KM conversion hook
- resolve 時 fire-and-forget KMConversionService.convert(incident)
- 已解決的 Incident 自動轉換為結構化 KM 條目,完成飛輪「學習固化」節點
- KMConversionService (Phase 4-1) 已存在 (km_conversion_service.py, 336 lines)

ADR-073 Phase 4-3: 15-cronjob-km-vectorize.yaml
- 每日 03:00 台北時間呼叫 /api/v1/knowledge/embed-all
- 自動向量化當日新增 KM 條目,確保 RAG 查詢不遺漏新知識
- 加入 kustomization.yaml resources

Phase 4-4: handle_callback log_manual_fix 已存在 (telegram_gateway.py:2468)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-12 14:40:33 +08:00
parent dbc77c5e62
commit f2fc4712ad
3 changed files with 77 additions and 0 deletions

View File

@@ -836,6 +836,17 @@ class IncidentService:
except Exception:
logger.exception("kb_extract_task_create_failed", incident_id=incident_id)
# ADR-073 Phase 4-2: resolve 時觸發 KM conversion (2026-04-12 ogt)
# 將已解決的 Incident 轉換為結構化 KM 條目,驅動飛輪學習固化節點
try:
import asyncio
from src.services.km_conversion_service import get_km_conversion_service
asyncio.create_task(
get_km_conversion_service().convert(incident)
)
except Exception:
logger.exception("km_conversion_task_create_failed", incident_id=incident_id)
# 2026-04-07 Claude Code: Sprint 4 B4 — 手動處理推斷
# I1+S1 Fix: 委託 derive_key_from_incident() 統一推導
try:

View File

@@ -0,0 +1,65 @@
# =============================================================================
# KM Vectorize CronJob - ADR-073 Phase 4-3 飛輪學習固化
# =============================================================================
# 每日 03:00 台北 (19:00 UTC 前一天) 自動向量化新增 KM 條目
# 確保 RAG 查詢可存取最新知識,完成飛輪「學習固化」節點
#
# 2026-04-12 ogt (ADR-073 Phase 4-3)
# =============================================================================
apiVersion: batch/v1
kind: CronJob
metadata:
name: km-vectorize
namespace: awoooi-prod
labels:
app: awoooi
component: km-vectorize
phase: "4-3"
spec:
# 每日 19:00 UTC = 03:00 台北
schedule: "0 19 * * *"
timeZone: "Asia/Taipei"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 3
startingDeadlineSeconds: 300
jobTemplate:
spec:
backoffLimit: 2
activeDeadlineSeconds: 300
template:
metadata:
labels:
app: awoooi
component: km-vectorize
spec:
restartPolicy: OnFailure
containers:
- name: km-vectorize
image: 192.168.0.110:5000/awoooi-api:latest
imagePullPolicy: Always
command:
- python
- -c
- |
import asyncio, httpx, os
async def main():
api = os.environ.get("INTERNAL_API_URL", "http://awoooi-api:8000")
async with httpx.AsyncClient(timeout=120) as c:
r = await c.post(f"{api}/api/v1/knowledge/embed-all")
print("embed-all:", r.status_code, r.text[:200])
asyncio.run(main())
env:
- name: TZ
value: "Asia/Taipei"
- name: INTERNAL_API_URL
value: "http://awoooi-api.awoooi-prod.svc.cluster.local:8000"
resources:
requests:
cpu: "50m"
memory: "64Mi"
limits:
cpu: "200m"
memory: "128Mi"
serviceAccountName: awoooi-api

View File

@@ -30,6 +30,7 @@ resources:
- 09-pdb.yaml
- 13-cronjob-k3s-report.yaml
- 14-cronjob-weekly-report.yaml
- 15-cronjob-km-vectorize.yaml
# 映像配置 (Tag 由 CI 動態注入)
# Harbor 金庫: 110 主機 (192.168.0.110:5000)