Skip to main content

rustferry_remote/
handoff.rs

1//! Public compile-to-sign handoff documents.
2//!
3//! These types contain only serializable evidence. Archive sealing, extraction, inspection, and
4//! worker policy remain implementation details of the macOS worker and provider clients.
5
6use schemars::JsonSchema;
7use serde::{Deserialize, Serialize};
8
9use crate::{
10    artifact::{UnsignedXcarchiveExpectation, UnsignedXcarchiveInspection},
11    protocol::IosDeviceBuildRequest,
12    source::{SourceArchive, SourceManifest},
13};
14
15/// Current sealed unsigned-archive descriptor schema.
16pub const SEALED_UNSIGNED_ARCHIVE_SCHEMA_VERSION: u32 = 1;
17/// Current compile-phase evidence schema.
18pub const COMPILE_PHASE_EVIDENCE_SCHEMA_VERSION: u32 = 1;
19/// Current complete compile-handoff envelope schema.
20pub const COMPILE_HANDOFF_SCHEMA_VERSION: u32 = 1;
21
22/// Public descriptor for one exact unsigned `.xcarchive` ZIP.
23#[derive(Clone, Debug, Eq, JsonSchema, PartialEq, Serialize, Deserialize)]
24#[serde(deny_unknown_fields)]
25pub struct SealedUnsignedArchive {
26    /// Sealed-handoff schema version.
27    pub schema_version: u32,
28    /// Exact deterministic ZIP size and SHA-256.
29    pub transport: SourceArchive,
30    /// Exact file paths, modes, sizes, and hashes inside the archive.
31    pub contents: SourceManifest,
32    /// Structural and physical-device invariants recomputed after extraction.
33    pub expectation: UnsignedXcarchiveExpectation,
34}
35
36/// Public Apple and Rust toolchain evidence selected by the compile phase.
37#[derive(Clone, Debug, Eq, JsonSchema, PartialEq, Serialize, Deserialize)]
38#[serde(deny_unknown_fields)]
39pub struct CompileToolchainEvidence {
40    /// Worker operating-system family and version.
41    pub worker_os: String,
42    /// Worker architecture.
43    pub worker_architecture: String,
44    /// Normalized Xcode version evidence.
45    pub xcode_version: String,
46    /// Selected iPhoneOS SDK version.
47    pub iphoneos_sdk_version: String,
48    /// Selected iPhoneOS SDK build version.
49    pub iphoneos_sdk_build_version: String,
50    /// SHA-256 of the canonical selected Xcode developer-directory string.
51    pub developer_directory_sha256: String,
52    /// Rust compiler version used by the selected installation.
53    pub rust_version: String,
54    /// Exact physical-iPhone Rust target.
55    pub rust_target: String,
56}
57
58/// Public evidence emitted by the credential-free compile phase.
59#[derive(Clone, Debug, Eq, JsonSchema, PartialEq, Serialize, Deserialize)]
60#[serde(deny_unknown_fields)]
61pub struct CompilePhaseEvidence {
62    /// Compile-evidence schema version.
63    pub schema_version: u32,
64    /// Provider job identifier.
65    pub job_id: String,
66    /// Provider implementation name.
67    pub provider: String,
68    /// Canonical SHA-256 of the complete submitted request.
69    pub request_sha256: String,
70    /// Exact verified source-manifest SHA-256.
71    pub source_sha256: String,
72    /// Exact `Cargo.lock` content SHA-256 from the source manifest.
73    pub cargo_lock_sha256: String,
74    /// Exact `ferry.toml` content SHA-256 from the source manifest.
75    pub config_sha256: String,
76    /// Client version copied from trusted provider metadata.
77    pub rustferry_version: String,
78    /// Worker crate version.
79    pub worker_version: String,
80    /// Selected toolchain evidence.
81    pub toolchain: CompileToolchainEvidence,
82    /// Deterministic sealed unsigned archive descriptor.
83    pub sealed_archive: SealedUnsignedArchive,
84    /// Independently inspected unsigned archive and Mach-O graph.
85    pub archive_inspection: UnsignedXcarchiveInspection,
86    /// Compile start time in Unix seconds.
87    pub started_at_unix_seconds: u64,
88    /// Compile completion time in Unix seconds.
89    pub finished_at_unix_seconds: u64,
90}
91
92/// Complete public handoff downloaded by a protected signer or independent client verifier.
93#[derive(Clone, Debug, JsonSchema, PartialEq, Serialize, Deserialize)]
94#[serde(deny_unknown_fields)]
95pub struct CompileHandoff {
96    /// Handoff-envelope schema version.
97    pub schema_version: u32,
98    /// Exact declarative request submitted by the client.
99    pub request: IosDeviceBuildRequest,
100    /// Credential-free compile evidence bound to the request.
101    pub compile: CompilePhaseEvidence,
102}