feat(l1): extend FlowProposal with source/linked_ticket/validated_by_outcome
Adds source (NOT NULL, backfilled to 'manual_draft'), linked_ticket_id, linked_ticket_kind, validated_by_outcome columns. CHECK constraints on source values and linked_ticket_kind values. walked_path lives on the new l1_walk_sessions table (Task 6) — NOT on FlowProposal. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ import uuid
|
||||
from datetime import datetime, timezone
|
||||
from typing import Optional, Any, TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import String, Text, DateTime, ForeignKey, Integer, Float, CheckConstraint
|
||||
from sqlalchemy import String, Text, DateTime, ForeignKey, Integer, Float, Boolean, CheckConstraint, text as sa_text
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy.dialects.postgresql import UUID, JSONB
|
||||
|
||||
@@ -48,6 +48,14 @@ class FlowProposal(Base):
|
||||
"status IN ('pending', 'approved', 'modified', 'rejected', 'dismissed', 'auto_reinforced')",
|
||||
name="ck_flow_proposals_status",
|
||||
),
|
||||
CheckConstraint(
|
||||
"source IN ('ai_realtime_l1', 'kb_accelerator', 'manual_draft', 'ai_promoted')",
|
||||
name="ck_flow_proposals_source",
|
||||
),
|
||||
CheckConstraint(
|
||||
"linked_ticket_kind IS NULL OR linked_ticket_kind IN ('psa', 'internal')",
|
||||
name="ck_flow_proposals_linked_ticket_kind",
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(
|
||||
@@ -135,6 +143,16 @@ class FlowProposal(Base):
|
||||
comment="The flow that was created/updated when this proposal was approved",
|
||||
)
|
||||
|
||||
# ── L1 workspace ──
|
||||
source: Mapped[str] = mapped_column(
|
||||
String(30), nullable=False, server_default=sa_text("'manual_draft'"),
|
||||
)
|
||||
linked_ticket_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
linked_ticket_kind: Mapped[Optional[str]] = mapped_column(String(10), nullable=True)
|
||||
validated_by_outcome: Mapped[bool] = mapped_column(
|
||||
Boolean(), nullable=False, server_default=sa_text('false'),
|
||||
)
|
||||
|
||||
# ── Timestamps ──
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
||||
|
||||
Reference in New Issue
Block a user