rayhpeng 793169529c refactor(feedback): align the slice with the hexagonal spec
- command-ify the write use cases (RateRun / RetractRunRating; queries
  keep plain parameters, commands stay dumb data)
- split the domain errors into exceptions.py, a peer of model.py
  (PEP 8 Error suffixes, AWS-style module name)
- unify the aggregate->row mapping as _apply(row, feedback) so one
  explicit field list serves both the insert and the update path
- drop the unused feedback.message_id column (migration 0011): feedback
  is bound to a run, nothing ever wrote or read the field
- pin remove_for_run's equality semantics for user_id=None in the
  contract suite and fix the port docstring that contradicted both
  implementations
2026-07-29 18:28:54 +08:00

28 lines
840 B
Python

"""The known errors of the feedback context.
One family under one base class, so the primary adapter can map the whole
family onto protocol codes in a single table. Class names keep the PEP 8
``Error`` suffix; the module is named ``exceptions`` after the AWS
hexagonal guidance's domain folder of the same name.
"""
class FeedbackError(Exception):
"""Base error for the feedback domain."""
class InvalidRatingError(FeedbackError):
"""Raised when a rating is not +1 or -1."""
class InvalidTagError(FeedbackError):
"""Raised when a feedback tag is not a known reason slug."""
class DuplicateFeedbackError(FeedbackError):
"""Raised when a concurrent upsert conflicts on the same run's feedback."""
class RunNotFoundError(FeedbackError):
"""Raised when the run does not exist or does not belong to the thread."""