diff --git a/backend/app/models/artifact.py b/backend/app/models/artifact.py new file mode 100644 index 0000000..9597362 --- /dev/null +++ b/backend/app/models/artifact.py @@ -0,0 +1,34 @@ +"""Artifact model - task deliverables with versioning.""" +from sqlalchemy import Column, String, Integer, Text, ForeignKey +from app.models.base import Base, TimestampMixin, TenantMixin + + +class Artifact(Base, TimestampMixin, TenantMixin): + """An artifact is a deliverable produced by a task. + + Supports versioning: each task can have multiple artifact versions. + Type: text, code, document, data, image, mixed + """ + __tablename__ = "artifacts" + + id = Column(Integer, primary_key=True, autoincrement=True) + task_id = Column(Integer, ForeignKey("tasks.id"), nullable=False, index=True) + project_id = Column(Integer, ForeignKey("projects.id"), nullable=False) + + title = Column(String(500), nullable=False) + content = Column(Text, default="") + artifact_type = Column(String(50), default="text") + + # Versioning + version = Column(Integer, default=1) + is_latest = Column(String(10), default="true") + + # Source attribution + created_by_user_id = Column(Integer, ForeignKey("users.id"), nullable=True) + created_by_worker_id = Column(Integer, ForeignKey("ai_workers.id"), nullable=True) + + # Source references (for traceability - JSON array of source citations) + sources = Column(Text, default="[]") + + def __repr__(self): + return f""