"""PresentationReview — a system-tag the auto-apply sweep applied that ALSO looked like real content, flagged for operator review (milestone 141 + #1464). When a sweep applies a system tag but the image ALSO scores highly on a content head, it still applies the tag but records this row so a review strip can surface it ("⚠ also looks like "). Two modes (#1464): 'chrome' (banner — image is HIDDEN, review is keep-hidden / un-hide) and 'process' (wip / editor screenshot — image stays VISIBLE, review is confirm / remove-tag). Resolved rows are pruned by retention. """ from datetime import datetime from sqlalchemy import DateTime, Float, ForeignKey, String, func from sqlalchemy.orm import Mapped, mapped_column from .base import Base class PresentationReview(Base): __tablename__ = "presentation_review" image_record_id: Mapped[int] = mapped_column( ForeignKey("image_record.id", ondelete="CASCADE"), primary_key=True ) # The presentation tag that was auto-applied (banner / editor screenshot). tag_id: Mapped[int] = mapped_column( ForeignKey("tag.id", ondelete="CASCADE"), primary_key=True ) # The content tag the image ALSO scored high on — the "concerning" signal. # SET NULL (not CASCADE): losing the conflict tag shouldn't erase the flag. conflict_tag_id: Mapped[int | None] = mapped_column( ForeignKey("tag.id", ondelete="SET NULL"), nullable=True ) conflict_score: Mapped[float] = mapped_column(Float, nullable=False) # Which sweep flagged this (#1464): 'chrome' (banner, hidden) or 'process' # (wip / editor screenshot, shown). Drives which review strip surfaces it and # what "resolve" means (un-hide vs remove-tag). Existing rows backfill 'chrome'. mode: Mapped[str] = mapped_column( String(16), nullable=False, default="chrome", server_default="chrome" ) created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), nullable=False, server_default=func.now() ) # Set when the operator keeps-hidden or un-hides; retention prunes resolved. resolved_at: Mapped[datetime | None] = mapped_column( DateTime(timezone=True), nullable=True )