ferrify_domain/report.rs
1//! Final-report and verification-receipt types.
2//!
3//! These types are what make Ferrify's reporting contract concrete. A final
4//! status is paired with individual [`ValidationReceipt`] values and preserved
5//! risks so the runtime can say exactly what it observed instead of implying
6//! more certainty than the evidence supports.
7
8use serde::{Deserialize, Serialize};
9
10use crate::{RepoPath, RiskItem, VerificationKind};
11
12/// The result of an individual verification step.
13#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
14pub enum VerificationStatus {
15 /// The verification step succeeded.
16 Succeeded,
17 /// The verification step failed.
18 Failed,
19 /// The verification step did not run.
20 Skipped,
21}
22
23/// A reference to evidence captured during a verification step.
24#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
25pub struct ArtifactRef {
26 /// A short label for the artifact.
27 pub label: String,
28 /// Where the artifact can be found.
29 pub location: String,
30}
31
32/// A receipt proving which verification command ran and how it ended.
33#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
34pub struct ValidationReceipt {
35 /// The verification step that produced this receipt.
36 pub step: VerificationKind,
37 /// The command that was executed.
38 pub command: String,
39 /// The observed result.
40 pub status: VerificationStatus,
41 /// Artifacts captured during execution.
42 pub artifacts: Vec<ArtifactRef>,
43}
44
45/// The overall status for the final report.
46#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
47pub enum ChangeStatus {
48 /// The run produced a plan but no verification evidence.
49 Planned,
50 /// The run produced mixed or incomplete verification evidence.
51 PartiallyVerified,
52 /// The run produced the expected verification evidence.
53 Verified,
54 /// The run failed to produce acceptable evidence.
55 Failed,
56}
57
58/// The high-level change outcome shown to the operator.
59#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
60pub struct ChangeSummary {
61 /// The status of the run.
62 pub status: ChangeStatus,
63 /// A short human-readable summary.
64 pub headline: String,
65}
66
67/// A touched area that should appear in the final report.
68#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
69pub struct TouchedArea {
70 /// The repository-relative path for the touched area.
71 pub path: RepoPath,
72 /// Why the area was touched.
73 pub reason: String,
74}
75
76/// An assumption that influenced the run.
77#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
78pub struct Assumption {
79 /// The assumption preserved for the operator.
80 pub summary: String,
81}
82
83/// The evidence-backed final report.
84#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
85pub struct FinalChangeReport {
86 /// The overall outcome summary.
87 pub outcome: ChangeSummary,
88 /// The design rationale used for planning.
89 pub design_reason: String,
90 /// Areas the plan or patch selected.
91 pub touched_areas: Vec<TouchedArea>,
92 /// Verification receipts collected by the runtime.
93 pub validations: Vec<ValidationReceipt>,
94 /// Assumptions that still matter for review.
95 pub assumptions: Vec<Assumption>,
96 /// Risks that remain after the run.
97 pub residual_risks: Vec<RiskItem>,
98}