koprogo_api/application/ports/contractor_evaluation_repository.rs
1//! Port for persisting [`ContractorEvaluation`] entities (Story 3.9 — FR34
2//! FR35 INV-21 INV-24).
3//!
4//! Distinct from [`ContractEvaluationRepository`](super::contract_evaluation_repository::ContractEvaluationRepository),
5//! the legacy marketplace-rating port (Issue #276). Story 3.9 introduces the
6//! audit-grade flow gated by an approved TechnicalSpec.
7//!
8//! All methods return `Result<_, AppError>` natively — no legacy `String`
9//! error debt to migrate later (CRITICAL.md #4 / #555).
10//!
11//! Evaluations are append-only — the repository exposes only `save` and
12//! read methods; mutation guards are enforced at the DB trigger level (cf.
13//! migration `20260605070000_create_contractor_evaluations.sql`).
14
15use crate::application::error::AppError;
16use crate::domain::entities::ContractorEvaluation;
17use async_trait::async_trait;
18use uuid::Uuid;
19
20#[async_trait]
21pub trait ContractorEvaluationRepository: Send + Sync {
22 /// Persist a freshly minted evaluation (append-only).
23 async fn save(&self, evaluation: &ContractorEvaluation) -> Result<(), AppError>;
24
25 async fn find_by_id(&self, id: Uuid) -> Result<Option<ContractorEvaluation>, AppError>;
26
27 /// List every evaluation collected against a given contractor user,
28 /// newest first. Used by the contractor's "reputation" view.
29 async fn list_for_contractor(
30 &self,
31 contractor_user_id: Uuid,
32 ) -> Result<Vec<ContractorEvaluation>, AppError>;
33}