mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 15:29:36 +00:00
SQLAlchemy 2.0 reserves 'metadata' as a class-level attribute on DeclarativeBase classes. Using metadata_ Python attribute with column name 'metadata' caused issues during table creation in init_db(), which prevented pytest from collecting tests (exit code 4). Renamed to pack_metadata to avoid all reserved-name conflicts. https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""Evidence Pack — assembled proof for audit, board review, and compliance."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import enum
|
|
|
|
from sqlalchemy import Column, DateTime, Enum, ForeignKey, String, Text
|
|
from sqlalchemy.dialects.postgresql import JSONB, UUID
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.models.base import TenantModel
|
|
|
|
|
|
class EvidencePackType(str, enum.Enum):
|
|
DEAL_CLOSURE = "deal_closure"
|
|
COMPLIANCE_AUDIT = "compliance_audit"
|
|
QUARTERLY_REVIEW = "quarterly_review"
|
|
INCIDENT_RESPONSE = "incident_response"
|
|
BOARD_REPORT = "board_report"
|
|
|
|
|
|
class EvidencePackStatus(str, enum.Enum):
|
|
ASSEMBLING = "assembling"
|
|
READY = "ready"
|
|
REVIEWED = "reviewed"
|
|
ARCHIVED = "archived"
|
|
|
|
|
|
class EvidencePack(TenantModel):
|
|
__tablename__ = "evidence_packs"
|
|
|
|
title = Column(String(255), nullable=False)
|
|
title_ar = Column(String(255), nullable=True)
|
|
pack_type = Column(Enum(EvidencePackType), nullable=False)
|
|
entity_type = Column(String(80), nullable=True) # deal, lead, tenant, etc.
|
|
entity_id = Column(UUID(as_uuid=True), nullable=True)
|
|
assembled_by_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True)
|
|
status = Column(Enum(EvidencePackStatus), nullable=False, default=EvidencePackStatus.ASSEMBLING)
|
|
contents = Column(JSONB, default=list) # list of evidence items
|
|
pack_metadata = Column(JSONB, default=dict)
|
|
reviewed_by_id = Column(UUID(as_uuid=True), ForeignKey("users.id"), nullable=True)
|
|
reviewed_at = Column(DateTime(timezone=True), nullable=True)
|
|
hash_signature = Column(String(64), nullable=True) # SHA256 of contents
|
|
|
|
assembled_by = relationship("User", foreign_keys=[assembled_by_id])
|
|
reviewed_by = relationship("User", foreign_keys=[reviewed_by_id])
|