Skip to main content

kernel/artifacts/
artifact.rs

1//! The stored `Artifact` record and the `ArtifactDraft` a writer submits.
2
3use serde::{Deserialize, Serialize};
4
5use crate::records::{Capability, JsonValue};
6
7/// A stored generated output: where its bytes live, a content hash, provenance
8/// (model/runtime/capability/params), timing, and ownership (job, session).
9#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
10pub struct Artifact {
11    pub id: String,
12    /// The output file path, relative to the store root.
13    pub path: String,
14    /// SHA-256 (hex) of the output bytes.
15    pub content_hash: String,
16    #[serde(skip_serializing_if = "Option::is_none", default)]
17    pub preview_path: Option<String>,
18    /// The model's display name.
19    pub model: String,
20    /// The model's registry id.
21    pub model_id: String,
22    pub runtime: String,
23    pub capability: Capability,
24    pub params: JsonValue,
25    /// Creation time, epoch milliseconds.
26    pub created_at: i64,
27    pub duration_ms: i64,
28    pub job_id: String,
29    #[serde(skip_serializing_if = "Option::is_none", default)]
30    pub session_id: Option<String>,
31}
32
33/// Everything needed to store one output. The store fills in the id, path,
34/// content hash, preview path, and creation time.
35#[derive(Debug, Clone)]
36pub struct ArtifactDraft {
37    pub data: Vec<u8>,
38    pub file_extension: String,
39    pub preview: Option<Vec<u8>>,
40    pub model: String,
41    pub model_id: String,
42    pub runtime: String,
43    pub capability: Capability,
44    pub params: JsonValue,
45    pub job_id: String,
46    pub duration_ms: i64,
47    pub session_id: Option<String>,
48}