feat(playbook): version generated playbooks
All checks were successful
CD Pipeline / tests (push) Successful in 1m34s
Code Review / ai-code-review (push) Successful in 28s
Type Sync Check / check-type-sync (push) Successful in 1m10s
CD Pipeline / build-and-deploy (push) Successful in 10m19s
CD Pipeline / post-deploy-checks (push) Successful in 3m1s

This commit is contained in:
Your Name
2026-04-30 23:59:39 +08:00
parent 474b913ac9
commit f154ac022e
13 changed files with 426 additions and 5 deletions

View File

@@ -1005,6 +1005,10 @@ class PlaybookRecord(Base):
# Source tracing
source_incident_ids: Mapped[list[str]] = mapped_column(JSON, default=list, nullable=False)
version: Mapped[int] = mapped_column(Integer, default=1, nullable=False)
parent_playbook_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
supersedes_playbook_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
version_reason: Mapped[str | None] = mapped_column(Text, nullable=True)
ai_confidence: Mapped[float] = mapped_column(default=0.0, nullable=False)
# Stats — MUST be in PG (AI learning artifacts, cannot expire)
@@ -1048,6 +1052,7 @@ class PlaybookRecord(Base):
Index("ix_playbook_status", "status"),
Index("ix_playbook_trust_score", "trust_score"),
Index("ix_playbook_created_at", "created_at"),
Index("ix_playbook_lineage", "parent_playbook_id", "version"),
# W2 PR-L1: 快速查詢需要人工 review 的 Playbook預期數量少partial index 最省空間)
Index(
"ix_playbook_review_required",