made_core/ports/validator.rs
1//! [`ValidatorPort`] — domain-agnostic validation of a proposal.
2//!
3//! A validator knows how to produce one [`ValidatorReport`] for a given
4//! proposal. Adapters compose the reports (lint, policy, fact-check,
5//! clinical-safety, …) into a single [`ValidationOutcome`] in the
6//! application layer.
7
8use async_trait::async_trait;
9
10use crate::entities::{TaskConstraints, ValidatorReport};
11use crate::error::DomainError;
12
13#[async_trait]
14pub trait ValidatorPort: Send + Sync {
15 /// Stable identifier of what this validator checks (e.g.
16 /// `"lint"`, `"policy"`, `"clinical-safety"`). Used to tag the
17 /// emitted report.
18 fn kind(&self) -> &str;
19
20 /// Validate proposal content. The returned report's `kind` must
21 /// match [`Self::kind`].
22 async fn validate(
23 &self,
24 proposal_content: &str,
25 constraints: &TaskConstraints,
26 ) -> Result<ValidatorReport, DomainError>;
27}