generated from coulomb/repo-seed
Replace the ad-hoc coordination-domain spine with the Repo Classification Standard: 14 market domains, classification columns on managed_repos, and workplans anchored by repo_id (topic_id optional). - Add Alembic migration d8e9f0a1b2c3 with data backfill and workstream→workplan rename - Add api/classification.py validation and register-from-classification tooling - Expose workplan-first REST/MCP surface with legacy workstream aliases - Add C-24 consistency rule and legacy domain frontmatter mapping - Update dashboard repos page with category/capability/stake filters - Update orientation docs; mark STATE-WP-0065 finished
64 lines
2.5 KiB
Python
64 lines
2.5 KiB
Python
import enum
|
|
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import CheckConstraint, DateTime, Enum, ForeignKey, String, Text
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from api.models.base import Base, TimestampMixin, new_uuid
|
|
|
|
|
|
class DecisionType(str, enum.Enum):
|
|
made = "made"
|
|
pending = "pending"
|
|
|
|
|
|
class DecisionStatus(str, enum.Enum):
|
|
open = "open"
|
|
resolved = "resolved"
|
|
escalated = "escalated"
|
|
superseded = "superseded"
|
|
|
|
|
|
class Decision(Base, TimestampMixin):
|
|
__tablename__ = "decisions"
|
|
__table_args__ = (
|
|
CheckConstraint(
|
|
"topic_id IS NOT NULL OR workplan_id IS NOT NULL",
|
|
name="ck_decisions_topic_or_workplan",
|
|
),
|
|
)
|
|
|
|
id: Mapped[uuid.UUID] = mapped_column(
|
|
UUID(as_uuid=True), primary_key=True, default=new_uuid
|
|
)
|
|
topic_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("topics.id", ondelete="RESTRICT"), nullable=True, index=True
|
|
)
|
|
workplan_id: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("workplans.id", ondelete="RESTRICT"), nullable=True, index=True
|
|
)
|
|
title: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
description: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
decision_type: Mapped[DecisionType] = mapped_column(
|
|
Enum(DecisionType), nullable=False, default=DecisionType.pending
|
|
)
|
|
status: Mapped[DecisionStatus] = mapped_column(
|
|
Enum(DecisionStatus), nullable=False, default=DecisionStatus.open
|
|
)
|
|
rationale: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
decided_by: Mapped[str | None] = mapped_column(String(100), nullable=True)
|
|
decided_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
deadline: Mapped[datetime | None] = mapped_column(DateTime(timezone=True), nullable=True)
|
|
escalation_note: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
superseded_by: Mapped[uuid.UUID | None] = mapped_column(
|
|
UUID(as_uuid=True), ForeignKey("decisions.id", ondelete="SET NULL"), nullable=True
|
|
)
|
|
|
|
topic: Mapped["Topic | None"] = relationship("Topic", back_populates="decisions") # noqa: F821
|
|
workplan: Mapped["Workplan | None"] = relationship("Workplan", back_populates="decisions") # noqa: F821
|
|
progress_events: Mapped[list["ProgressEvent"]] = relationship( # noqa: F821
|
|
"ProgressEvent", back_populates="decision", lazy="selectin"
|
|
)
|