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:
2026-05-28 12:27:07 -04:00
parent 8bad2fe945
commit c576c6609e
2 changed files with 71 additions and 1 deletions

View File

@@ -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)