Skip to main content

strop_core/worker/
cache_record.rs

1//! The on-disk cache-lease vocabulary shared by the deploying client and
2//! the actual worker process. A deployment probe has its own short-lived
3//! session; only the worker can record the lease it really serves.
4
5use serde::{Deserialize, Serialize};
6
7pub const CACHE_DIR_NAME: &str = "strop-worker";
8pub const OBJECTS_DIR: &str = "objects";
9pub const LEASES_DIR: &str = "leases";
10pub const RECEIPTS_DIR: &str = "receipts";
11
12/// Persistent inode shared by native lease admission and cache GC.
13/// Never unlink it: file locks are scoped to the inode, not the name.
14pub const CACHE_LOCK_FILE: &str = "cache.lock";
15
16#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
17pub struct LeaseRecord {
18    pub lease: u64,
19    pub object_sha256: String,
20}
21
22/// Receipt schema version.
23pub const RECEIPT_SCHEMA: u32 = 1;
24
25/// Bound on one provenance or lease document, before deserialization.
26pub const MAX_RECORD_BYTES: u64 = 16 * 1024;
27
28/// Provenance/binding facts for one cached object. Digests and identity
29/// only — never source payloads or credentials.
30#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
31pub struct CacheReceipt {
32    pub schema: u32,
33    /// Endpoint context this deployment was authorized for.
34    pub context: String,
35    /// Principal the deployment runs as.
36    pub principal: String,
37    /// Exact release the object was deployed from (== the client's).
38    pub version: String,
39    /// Target triple the object was built for (== the endpoint's).
40    pub target: String,
41    /// Content address: sha256 of the object bytes.
42    pub object_sha256: String,
43    pub object_bytes: u64,
44    /// Provenance anchor: sha256 of the release-catalog tarball these
45    /// bytes were verified against.
46    pub tarball_sha256: String,
47}
48
49/// One bounded native cache-retirement pass. Digest names only; no
50/// object bytes, paths, source contents or credentials cross the wire.
51#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
52pub struct CacheGcReport {
53    pub removed_objects: Vec<String>,
54    pub removed_receipts: usize,
55    pub kept_objects: usize,
56}