Skip to main content

greentic_deploy_spec/
pack_list_lock.rs

1//! `greentic.pack-list-lock.v1`.
2//!
3//! Pinned, per-revision list of the `.gtpack` artifacts a revision resolves to.
4//! Written under `<env_dir>/<pack_list_lock_ref>` at stage time — the lockfile
5//! that [`Revision::pack_list_lock_ref`](crate::Revision) points at — and read
6//! by `greentic-start` at boot to build the runner load set.
7//!
8//! Each [`LockedPack`] carries the env-relative path to an extracted `.gtpack`
9//! plus its `sha256:<hex>` content digest, so the boot loader can verify the
10//! artifact on disk still matches what was staged before loading it (closing
11//! the stage→boot TOCTOU window).
12
13use crate::ids::{PackId, RevisionId};
14use crate::version::SchemaVersion;
15use serde::{Deserialize, Serialize};
16use std::path::PathBuf;
17
18/// One pinned `.gtpack` within a revision's resolved pack list.
19#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
20pub struct LockedPack {
21    /// Pack identity, derived from the `.gtpack` file stem at stage time.
22    pub pack_id: PackId,
23    /// Env-relative path to the extracted `.gtpack` artifact on disk.
24    pub path: PathBuf,
25    /// Content digest of the artifact at `path`, `sha256:<hex>` (lowercase hex).
26    pub digest: String,
27}
28
29/// The `pack-list.lock` document for a single revision.
30#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
31pub struct PackListLock {
32    pub schema: SchemaVersion,
33    /// The revision this lock pins — binds the file to its owner so a misplaced
34    /// or cross-revision lock is detectable by the reader.
35    pub revision_id: RevisionId,
36    pub packs: Vec<LockedPack>,
37}
38
39impl PackListLock {
40    pub fn schema_str() -> &'static str {
41        SchemaVersion::PACK_LIST_LOCK_V1
42    }
43}