Files
state-hub/api/models/workplan_launch_request.py
tegwick 0949d4c0d8 feat(classification-spine): implement STATE-WP-0065 repo-anchored model
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
2026-06-22 13:52:13 +02:00

40 lines
1.9 KiB
Python

import uuid
from sqlalchemy import Boolean, ForeignKey, String, Text
from sqlalchemy.dialects.postgresql import JSONB, UUID
from sqlalchemy.orm import Mapped, mapped_column, relationship
from api.models.base import Base, TimestampMixin, new_uuid
class WorkplanLaunchRequest(Base, TimestampMixin):
__tablename__ = "workplan_launch_requests"
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True), primary_key=True, default=new_uuid
)
workplan_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("workplans.id", ondelete="CASCADE"),
nullable=False,
index=True,
)
requested_by: Mapped[str] = mapped_column(String(100), nullable=False, default="dashboard")
requested_actor: Mapped[str | None] = mapped_column(String(100), nullable=True)
launch_mode: Mapped[str] = mapped_column(String(20), nullable=False, default="queued", index=True)
concurrency_mode: Mapped[str] = mapped_column(String(20), nullable=False, default="sequential", index=True)
priority: Mapped[str | None] = mapped_column(String(20), nullable=True, index=True)
repo_id: Mapped[uuid.UUID | None] = mapped_column(
UUID(as_uuid=True),
ForeignKey("managed_repos.id", ondelete="SET NULL"),
nullable=True,
index=True,
)
branch_preference: Mapped[str | None] = mapped_column(Text, nullable=True)
immediate_pickup: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default="false")
status: Mapped[str] = mapped_column(String(20), nullable=False, default="requested", server_default="requested", index=True)
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
request_metadata: Mapped[dict] = mapped_column(JSONB, nullable=False, default=dict, server_default="{}")
workplan: Mapped["Workplan"] = relationship("Workplan", back_populates="launch_requests") # noqa: F821