import uuid from datetime import datetime, timezone from sqlalchemy import Boolean, DateTime, Float, Integer, String from sqlalchemy.orm import Mapped, mapped_column from app.db import Base class User(Base): __tablename__ = "users" id: Mapped[uuid.UUID] = mapped_column(primary_key=True, default=uuid.uuid4) username: Mapped[str] = mapped_column(String(32), unique=True, index=True) password_hash: Mapped[str] = mapped_column(String(255)) email: Mapped[str | None] = mapped_column(String(255), nullable=True) # --- hunter profile --------------------------------------------------- # All nullable so every pre-existing row — including the guest # `wanderer-` accounts minted by the open door — stays valid without a # backfill. Absent values are treated as "not set" and fall back at the # serialization layer, never here. # # The avatar is procedural: a GhostForm plus a hue, rendered by the same # GhostGlyph component that draws entities. No uploads means no # moderation surface, no EXIF stripping and no blob storage — and if a # real image is ever wanted, an `avatar_url` slots in beside these # without changing anything else. display_name: Mapped[str | None] = mapped_column(String(48), nullable=True) bio: Mapped[str | None] = mapped_column(String(280), nullable=True) gender: Mapped[str | None] = mapped_column(String(16), nullable=True) avatar_form: Mapped[str | None] = mapped_column(String(16), nullable=True) avatar_hue: Mapped[int | None] = mapped_column(Integer, nullable=True) # Hides the profile from /api/hunters and 404s the public page. It does # NOT stop messages arriving — privacy here is about being browsed, not # about being unreachable. profile_public: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False) essence: Mapped[int] = mapped_column(Integer, default=0) # Workstream B (character-depth-ghost-log spec): hidden per-user score, # nudged by judgment correctness, clamped to [-1.0, 1.0] everywhere it's # written (see app.judgment.clamp_favor). Read back as a small bias on # new entities' trait rolls at mint time (app.judgment.apply_favor_bias). favor: Mapped[float] = mapped_column(Float, default=0.0) created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(timezone.utc) )