Skip to main content

sail_api/
preparation.rs

1//! Optional daemon-owned preparation. These requests never authorize a proof.
2
3use serde::{Deserialize, Serialize};
4use std::path::PathBuf;
5
6/// Preparation protocol version, negotiated independently of ordinary jobs.
7pub const VERSION: u32 = 2;
8
9/// The successful invocation whose next-call recording is being prepared.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(deny_unknown_fields)]
12pub struct Origin {
13    /// Exact unchanged-call key, including output and environment settings.
14    pub key: String,
15    /// Original verification context.
16    pub context: String,
17    /// Complete closing input revision of the successful origin, including
18    /// generated inputs discovered by that run. Published proof revisions and
19    /// establishing provenance are independent and remain unchanged.
20    pub revision: String,
21    /// Canonical workspace of the origin's Current read-back record.
22    pub workspace: PathBuf,
23    /// Public establishing revision identified by that read-back record.
24    /// This can differ from the closing revision after generated-input discovery.
25    pub readback_revision: String,
26}
27
28/// One best-effort preparation request, owned by the receiving service.
29#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
30#[serde(deny_unknown_fields)]
31pub struct Submission {
32    /// Explicit protocol version; unknown versions are refused.
33    pub version: u32,
34    /// Ordinary verification inputs and originating environment.
35    pub verification: crate::jobs::Submission,
36    /// Successful origin, or `None` for initial new-project preparation.
37    pub origin: Option<Origin>,
38    /// Whether the originating caller requested JSON output.
39    pub json: bool,
40    /// Resolved Cargo colour decision, already bound by the replay key.
41    pub colour: bool,
42}
43
44/// Observable preparation state; none of these counters establishes proof.
45#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
46pub struct Status {
47    /// Supported protocol version.
48    pub version: u32,
49    /// Number of queued preparations.
50    pub queued: usize,
51    /// Workspace currently being prepared, if any.
52    pub running: Option<PathBuf>,
53    /// Completed actual unchanged-call recordings.
54    pub ready: u64,
55    /// Replaced or foreground-preempted preparations.
56    pub superseded: u64,
57    /// Failed, declined or interrupted preparations.
58    pub failed: u64,
59}
60
61/// Private worker outcome. The service uses this for scheduling, never admission.
62#[derive(Debug, Serialize, Deserialize)]
63#[serde(deny_unknown_fields)]
64pub struct Outcome {
65    /// Whether the worker committed an actual unchanged-call recording.
66    pub ready: bool,
67    /// New-project verification may schedule one later unchanged capture.
68    pub origin: Option<Origin>,
69}