"""影子模式对比记录模型 — 比较数字分身建议与人类实际决策""" import uuid from datetime import datetime from sqlalchemy import Column, String, Text, DateTime, JSON, Float, Integer, Boolean from app.core.database import Base class ShadowComparison(Base): """影子模式对比记录""" __tablename__ = "shadow_comparisons" id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4())) user_id = Column(String(36), nullable=False, index=True) category = Column(String(30), nullable=False, comment="场景: code_review/email/document/decision") # 影子建议 shadow_suggestion = Column(JSON, nullable=True, comment="数字分身生成的建议") shadow_confidence = Column(Float, default=0.5, comment="影子置信度") # 用户实际决策 user_decision = Column(JSON, nullable=True, comment="用户实际操作") user_action = Column(String(50), nullable=True, comment="action: accept/modify/reject/ignore") # 对比结果 match_score = Column(Float, nullable=True, comment="匹配分数(0-1)") match_detail = Column(JSON, nullable=True, comment="匹配详情: {matched_points, diverged_points}") # 上下文 context = Column(JSON, nullable=True, comment="触发场景上下文") source_execution_id = Column(String(36), nullable=True, comment="关联执行日志ID") created_at = Column(DateTime, default=datetime.now) def __repr__(self): return f""