Skip to main content

crev_data/proof/review/
mod.rs

1use crate::level::Level;
2pub use code::*;
3use derive_builder::Builder;
4pub use package::Draft;
5pub use package::*;
6use serde::{Deserialize, Serialize};
7use std::default::Default;
8
9pub mod code;
10pub mod package;
11
12#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialOrd, Ord, PartialEq, Eq, Default)]
13#[serde(rename_all = "lowercase")]
14pub enum Rating {
15    #[serde(alias = "dangerous")] // for backward compat with some previous versions
16    Negative,
17    #[default]
18    Neutral,
19    Positive,
20    Strong,
21}
22
23/// Information about review result
24#[derive(Clone, Debug, Serialize, Deserialize, Builder, PartialEq, Eq)]
25pub struct Review {
26    #[builder(default = "Default::default()")]
27    pub thoroughness: Level,
28    #[builder(default = "Default::default()")]
29    pub understanding: Level,
30    #[builder(default = "Default::default()")]
31    pub rating: Rating,
32}
33
34impl Default for Review {
35    fn default() -> Self {
36        Review::new_none()
37    }
38}
39
40/// Information about an LLM agent that performed the review.
41///
42/// Presence of this field in a review proof (code or package)
43/// indicates that the review was conducted by (or with assistance of)
44/// an LLM agent.
45#[derive(Clone, Debug, Serialize, Deserialize)]
46pub struct LlmAgentInfo {
47    /// Model identifier (e.g. "claude-opus-4-6", "gpt-4o")
48    pub model: String,
49    /// Model version string, if available (e.g. "2026-04-01")
50    #[serde(
51        skip_serializing_if = "Option::is_none",
52        default,
53        rename = "model-version"
54    )]
55    pub model_version: Option<String>,
56    /// Whether a human guided the agent during the review (interactive
57    /// session), as opposed to a fully autonomous review.
58    #[serde(rename = "human-guided", default)]
59    pub human_guided: bool,
60}
61
62impl Review {
63    #[must_use]
64    pub fn new_positive() -> Self {
65        Review {
66            thoroughness: Level::Low,
67            understanding: Level::Medium,
68            rating: Rating::Positive,
69        }
70    }
71
72    #[must_use]
73    pub fn new_negative() -> Self {
74        Review {
75            thoroughness: Level::Low,
76            understanding: Level::Medium,
77            rating: Rating::Negative,
78        }
79    }
80    #[must_use]
81    pub fn new_none() -> Self {
82        Review {
83            thoroughness: Level::None,
84            understanding: Level::None,
85            rating: Rating::Neutral,
86        }
87    }
88
89    #[must_use]
90    pub fn is_none(&self) -> bool {
91        *self == Self::new_none()
92    }
93}