feat(p3.2+adr-100): Model Version Tracker + SLO 自治 + KB rot cleaner
Some checks failed
run-migration / migrate (push) Failing after 12s
CD Pipeline / build-and-deploy (push) Has been cancelled

Wave 8 P3.2 模型版本追蹤 + ADR-100 SLO 自我治理 + 配套:

P3.2 — Model Version Tracking:
- model_version_probe.py (268 行) — 探測 Ollama / OpenRouter 等 provider 的 model version
- model_version_tracker.py (101 行) — 對齊 PG provider_version_history 表
- migrations/p3_2_provider_version_history.sql + rollback — 25 行 schema
- db/models.py +32 行 — ProviderVersionHistory ORM

ADR-100 — AI 自主化 SLO:
- docs/adr/ADR-100-ai-autonomous-slo.md (167 行) — 飛輪 SLO 設計與閾值
- ops/monitoring/slo-rules.yml (254 行) — Prometheus SLO recording rules + alerts
- ops/monitoring/tests/test_slo_rules.yaml (242 行) — promtool unit tests

整合修改:
- main.py +72 行 — Lifespan 啟動 model_version_probe + KB rot cleaner schedule
- gitea_webhook.py +45 行 — webhook 接收 model 版本變化通知
- ci_auto_repair.py / evidence_snapshot.py / pre_decision_investigator.py — 配合接線

新測試:
- test_kb_rot_cleaner_schedule.py (120 行) — 9 tests pass
- test_slo_rules.yaml — promtool 驗收

Tests: 9 passed (test_kb_rot_cleaner_schedule)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Multiple Engineers (P3.2 + ADR-100) <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-04-27 14:54:19 +08:00
parent 9908fdf50d
commit 025a493f06
14 changed files with 1370 additions and 36 deletions

View File

@@ -17,6 +17,7 @@ from uuid import uuid4
from sqlalchemy import (
JSON,
BigInteger,
Boolean,
CheckConstraint,
DateTime,
Float,
@@ -1297,3 +1298,34 @@ class TrustRecordDB(Base):
Index("ix_trust_records_score", "score"),
Index("ix_trust_records_updated", "updated_at"),
)
# =============================================================================
# AIProviderVersionHistory - AI Provider 版本歷史
# 2026-04-27 P3.2.2 by Claude
# =============================================================================
class AIProviderVersionHistory(Base):
"""AI Provider 版本探測歷史記錄
每次 ModelVersionTracker.run_probe_cycle() 寫入一筆。
changed=True 表示本次探測到版本或 digest 與上一筆不同。
Migration: apps/api/migrations/p3_2_provider_version_history.sql
"""
__tablename__ = "ai_provider_version_history"
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
provider: Mapped[str] = mapped_column(String(40), nullable=False, index=True)
model: Mapped[str] = mapped_column(String(100), nullable=False)
version: Mapped[str | None] = mapped_column(String(200), nullable=True)
digest: Mapped[str | None] = mapped_column(String(80), nullable=True)
captured_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), nullable=False, default=taipei_now,
)
prev_version: Mapped[str | None] = mapped_column(String(200), nullable=True)
changed: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
__table_args__ = (
Index("ix_provider_version_captured", "provider", "captured_at"),
)