1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//! Focused repair checks and complete validation.
//!
//! Explanations, baselines and comparisons are in [`crate::evidence`].
use serde::{Deserialize, Serialize};
use crate::project::ProjectResult;
/// Independent repair contract version.
pub const VERSION: u32 = 1;
/// Source-engine batch output; each phase retains its independent proof report.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct BatchResult {
/// Complete selected-function phase, absent if it did not produce evidence.
pub focus: Option<ProjectResult>,
/// Independent complete requested-target phase. A standalone repair
/// document (the repair worker's output, `sail repair-check --output json`)
/// carries it. A job result omits it: the job's `result` is this phase,
/// so readers receive the graph once.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub full: Option<ProjectResult>,
/// Hash of the validated optional engine build manifest.
pub manifest_sha256: String,
/// Number of Verus driver subprocesses actually started by this batch.
/// An engine batch can run ghost verification and final executable checks
/// inside one driver; this is not the number of internal Rust sessions.
pub compiler_invocations: u64,
/// True only for engine-supported focus/full batching within compiler calls.
pub batched: bool,
/// Exact focus selection was unavailable or ambiguous; full evidence is retained.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub selection_error: Option<crate::output::ErrorInfo>,
/// The engine faulted before any target could fall back individually
/// (ADR 0027). `full` is then an independent stock verification, retained
/// as evidence; it never accepts the repair.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub engine_fault: Option<crate::output::ErrorInfo>,
}
impl BatchResult {
/// Whether selection succeeded and full validation established current complete evidence.
/// Preliminary focus success cannot authorize a repair, and neither can a
/// stock fallback after an engine fault. Without a full phase, false.
#[must_use]
pub fn accepted(&self) -> bool {
self.full
.as_ref()
.is_some_and(|full| self.accepted_with(full))
}
/// [`Self::accepted`] with the full phase supplied separately, as in a job
/// result whose `result` holds it.
#[must_use]
pub fn accepted_with(&self, full: &ProjectResult) -> bool {
self.selection_error.is_none() && self.engine_fault.is_none() && accepted(full)
}
}
/// Whether an independently completed full report authorizes a repair.
///
/// Summary counts are derived evidence, not acceptance authority: the report
/// must be internally consistent and every function must be confirmed verified.
#[must_use]
pub fn accepted(full: &ProjectResult) -> bool {
crate::acceptance::complete_selection(full).is_some()
}
/// Explicit selected target/function; never guessed from semantic dependencies.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Selection {
/// Cargo package selection.
pub package: String,
/// Explicit binary name; library selection is unique within the package.
pub target: Option<String>,
/// `lib` or `bin`; target names alone are ambiguous.
pub kind: String,
/// Exact crate-qualified function identifier as reported by Verus.
pub function: String,
}
/// Repair submission uses the existing environment/revision request contract.
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct Submission {
/// Verification context, arguments and originating environment.
pub verification: crate::jobs::Submission,
/// Explicit target/function selection.
pub selection: Selection,
}
/// Finished repair response; accepted is derived rather than trusted from storage.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ResultDocument {
/// Independent contract version.
pub version: u32,
/// Complete phase evidence.
pub batch: BatchResult,
/// Derived from successful selection and the independently finalized full report.
pub accepted: bool,
}
impl From<BatchResult> for ResultDocument {
fn from(batch: BatchResult) -> Self {
Self {
version: VERSION,
accepted: batch.accepted(),
batch,
}
}
}