- Add Project model with slug, description, autonomy level, and settings - Add AgentType model for agent templates with model config and failover - Add AgentInstance model for running agents with status and memory - Add Issue model with external tracker sync (Gitea/GitHub/GitLab) - Add Sprint model with velocity tracking and lifecycle management - Add comprehensive Pydantic schemas with validation - Add full CRUD operations for all models with filtering/sorting - Add 280+ tests for models, schemas, and CRUD operations Implements #23, #24, #25, #26, #27 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
89 lines
2.5 KiB
Python
89 lines
2.5 KiB
Python
# app/models/syndarix/project.py
|
|
"""
|
|
Project model for Syndarix AI consulting platform.
|
|
|
|
A Project represents a client engagement where AI agents collaborate
|
|
to deliver software solutions.
|
|
"""
|
|
|
|
from sqlalchemy import Column, Enum, ForeignKey, Index, String, Text
|
|
from sqlalchemy.dialects.postgresql import (
|
|
JSONB,
|
|
UUID as PGUUID,
|
|
)
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.models.base import Base, TimestampMixin, UUIDMixin
|
|
|
|
from .enums import AutonomyLevel, ProjectStatus
|
|
|
|
|
|
class Project(Base, UUIDMixin, TimestampMixin):
|
|
"""
|
|
Project model representing a client engagement.
|
|
|
|
A project contains:
|
|
- Configuration for how autonomous agents should operate
|
|
- Settings for MCP server integrations
|
|
- Relationship to assigned agents, issues, and sprints
|
|
"""
|
|
|
|
__tablename__ = "projects"
|
|
|
|
name = Column(String(255), nullable=False, index=True)
|
|
slug = Column(String(255), unique=True, nullable=False, index=True)
|
|
description = Column(Text, nullable=True)
|
|
|
|
autonomy_level: Column[AutonomyLevel] = Column(
|
|
Enum(AutonomyLevel),
|
|
default=AutonomyLevel.MILESTONE,
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
|
|
status: Column[ProjectStatus] = Column(
|
|
Enum(ProjectStatus),
|
|
default=ProjectStatus.ACTIVE,
|
|
nullable=False,
|
|
index=True,
|
|
)
|
|
|
|
# JSON field for flexible project configuration
|
|
# Can include: mcp_servers, webhook_urls, notification_settings, etc.
|
|
settings = Column(JSONB, default=dict, nullable=False)
|
|
|
|
# Foreign key to the User who owns this project
|
|
owner_id = Column(
|
|
PGUUID(as_uuid=True),
|
|
ForeignKey("users.id", ondelete="SET NULL"),
|
|
nullable=True,
|
|
index=True,
|
|
)
|
|
|
|
# Relationships
|
|
owner = relationship("User", foreign_keys=[owner_id])
|
|
agent_instances = relationship(
|
|
"AgentInstance",
|
|
back_populates="project",
|
|
cascade="all, delete-orphan",
|
|
)
|
|
issues = relationship(
|
|
"Issue",
|
|
back_populates="project",
|
|
cascade="all, delete-orphan",
|
|
)
|
|
sprints = relationship(
|
|
"Sprint",
|
|
back_populates="project",
|
|
cascade="all, delete-orphan",
|
|
)
|
|
|
|
__table_args__ = (
|
|
Index("ix_projects_slug_status", "slug", "status"),
|
|
Index("ix_projects_owner_status", "owner_id", "status"),
|
|
Index("ix_projects_autonomy_status", "autonomy_level", "status"),
|
|
)
|
|
|
|
def __repr__(self) -> str:
|
|
return f"<Project {self.name} ({self.slug}) status={self.status.value}>"
|