Skip to main content

euv_performance/observability/
struct.rs

1use super::*;
2
3/// Target host and rendering backend description inside `ObservabilityReportV1`.
4#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
5pub struct ObservabilityTarget {
6    /// Canonical target platform enum.
7    #[get(type(copy))]
8    pub(crate) platform: ObservabilityPlatform,
9    /// Host operating system name and version.
10    pub(crate) os: String,
11    /// Physical device, emulator, or headless host descriptor.
12    pub(crate) device: String,
13    /// Active graphics/rendering backend identifier.
14    pub(crate) backend: String,
15    /// Active runtime execution mode label.
16    pub(crate) mode: String,
17    /// Optional execution fidelity kind (`real_device`, `headless`, `pty`, etc.).
18    #[serde(default, skip_serializing_if = "Option::is_none")]
19    #[get(skip)]
20    pub(crate) execution_kind: Option<ObservabilityExecutionKind>,
21}
22
23/// Build identity metadata inside `ObservabilityReportV1`.
24#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
25pub struct ObservabilityBuild {
26    /// Git commit SHA or worktree label.
27    pub(crate) commit: String,
28    /// Cargo or platform build profile (`release`, `debug`, `profile`).
29    pub(crate) profile: String,
30    /// Optional crate or application semantic version.
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    #[get(skip)]
33    pub(crate) version: Option<String>,
34}
35
36/// Profiler or harness tool entry recorded inside `ObservabilityReportV1::tools`.
37#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
38pub struct ObservabilityTool {
39    /// Tool or crate name.
40    pub(crate) name: String,
41    /// Tool version string.
42    pub(crate) version: String,
43    /// Measurement scopes provided by this tool.
44    pub(crate) scope: String,
45}
46
47/// Executed workload fixture metadata inside `ObservabilityReportV1`.
48#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
49pub struct ObservabilityWorkload {
50    /// Canonical workload fixture identifier.
51    pub(crate) fixture: String,
52    /// Number of measured cycles or iterations executed.
53    #[get(type(copy))]
54    pub(crate) cycles: u64,
55    /// Checkpoint phase label (e.g. `"post_drain"`).
56    pub(crate) checkpoint: String,
57    /// Optional warmup cycles discarded before sampling.
58    #[serde(default, skip_serializing_if = "Option::is_none")]
59    #[get(skip)]
60    pub(crate) warmup_cycles: Option<u64>,
61    /// Optional drain grace period in milliseconds.
62    #[serde(default, skip_serializing_if = "Option::is_none")]
63    #[get(skip)]
64    pub(crate) grace_period_ms: Option<u64>,
65}
66
67/// Explicit scope coverage record inside `ObservabilityReportV1::coverage`.
68#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
69pub struct ObservabilityCoverage {
70    /// Scope name (e.g. `"frame_interaction"`, `"layout_render_cache"`, `"gpu_resources"`).
71    pub(crate) scope: String,
72    /// Whether this scope is required for a `pass` verdict.
73    #[get(type(copy))]
74    pub(crate) required: bool,
75    /// Coverage state (`measured`, `missing`, `unsupported`, `not_applicable`).
76    #[get(type(copy))]
77    pub(crate) status: ObservabilityCoverageStatus,
78    /// Optional diagnostic reason (serialized as `null` when absent).
79    #[get(skip)]
80    pub(crate) reason: Option<String>,
81}
82
83/// Budget threshold definition attached to an `ObservabilityMetric`.
84#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
85pub struct ObservabilityThreshold {
86    /// Evaluation rule (`max`, `min`, `max_slope_per_cycle`, etc.).
87    #[get(type(copy))]
88    pub(crate) rule: ObservabilityThresholdRule,
89    /// Threshold numeric limit (or `None` when informational).
90    #[get(skip)]
91    pub(crate) value: Option<f64>,
92    /// Unit string matching the parent metric's unit.
93    pub(crate) unit: String,
94    /// Version tag identifying the active performance budget contract.
95    pub(crate) budget_version: String,
96}
97
98/// Single unified metric entry conforming to `schemas/report-v1.schema.json` and `metrics/catalog-v1.json`.
99#[derive(Clone, Debug, Deserialize, Getter, PartialEq, Serialize)]
100pub struct ObservabilityMetric {
101    /// Canonical catalog metric identifier (e.g. `"frame.interval_ms"`).
102    pub(crate) id: String,
103    /// Owning coverage scope name.
104    pub(crate) scope: String,
105    /// Canonical unit enum.
106    #[get(type(copy))]
107    pub(crate) unit: ObservabilityUnit,
108    /// Measurement availability state (`measured`, `unmeasured`, etc.).
109    #[get(type(copy))]
110    pub(crate) status: ObservabilityMetricStatus,
111    /// Sampling window description.
112    pub(crate) window: String,
113    /// Summary statistic tag (`p95`, `total`, `live_count`, etc.).
114    #[get(type(copy))]
115    pub(crate) statistic: ObservabilityStatistic,
116    /// Scalar measurement value for common metrics (`None` when unmeasured or leak-only).
117    #[serde(default, skip_serializing_if = "Option::is_none")]
118    #[get(skip)]
119    pub(crate) value: Option<f64>,
120    /// Post-warmup baseline value for leak/lifecycle metrics.
121    #[serde(default, skip_serializing_if = "Option::is_none")]
122    #[get(skip)]
123    pub(crate) baseline: Option<f64>,
124    /// Post-drain value for leak/lifecycle metrics.
125    #[serde(default, skip_serializing_if = "Option::is_none")]
126    #[get(skip)]
127    pub(crate) after_drain: Option<f64>,
128    /// Linear slope per cycle for leak/lifecycle metrics.
129    #[serde(default, skip_serializing_if = "Option::is_none")]
130    #[get(skip)]
131    pub(crate) slope_per_cycle: Option<f64>,
132    /// Optional sample count collected during the window.
133    #[serde(default, skip_serializing_if = "Option::is_none")]
134    #[get(skip)]
135    pub(crate) samples: Option<u64>,
136    /// Optional metric producer source identifier.
137    #[serde(default, skip_serializing_if = "Option::is_none")]
138    #[get(skip)]
139    pub(crate) source: Option<String>,
140    /// Optional clock source label.
141    #[serde(default, skip_serializing_if = "Option::is_none")]
142    #[get(skip)]
143    pub(crate) clock: Option<String>,
144    /// Optional sampling frequency in Hertz.
145    #[serde(default, skip_serializing_if = "Option::is_none")]
146    #[get(skip)]
147    pub(crate) sample_rate_hz: Option<f64>,
148    /// Optional unavailability diagnostic reason.
149    #[serde(default, skip_serializing_if = "Option::is_none")]
150    #[get(skip)]
151    pub(crate) reason: Option<String>,
152    /// Evidence identifiers linking into `ObservabilityReportV1::evidence`.
153    pub(crate) evidence_refs: Vec<String>,
154    /// Optional budget threshold (always serialized, `null` when informational).
155    #[get(skip)]
156    pub(crate) threshold: Option<ObservabilityThreshold>,
157}
158
159/// Attributed leak or budget violation finding inside `ObservabilityReportV1::findings`.
160#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
161pub struct ObservabilityFinding {
162    /// Classification (`expected_retained`, `unexpected_leak`, `budget_violation`, `unattributed_growth`).
163    #[get(type(copy))]
164    pub(crate) classification: ObservabilityFindingClass,
165    /// Responsible subsystem or owner path (serialized as `null` when unattributed).
166    #[get(skip)]
167    pub(crate) owner: Option<String>,
168    /// Optional human-readable finding summary.
169    #[serde(default, skip_serializing_if = "Option::is_none")]
170    #[get(skip)]
171    pub(crate) summary: Option<String>,
172    /// Evidence identifiers backing this finding.
173    pub(crate) evidence_refs: Vec<String>,
174}
175
176/// Artifact evidence entry referenced by metrics and findings.
177#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
178pub struct ObservabilityEvidence {
179    /// Stable evidence identifier referenced by `evidence_refs`.
180    pub(crate) id: String,
181    /// Relative path or URI of the evidence artifact.
182    pub(crate) artifact: String,
183    /// Optional SHA-256 hex digest of the artifact.
184    #[serde(default, skip_serializing_if = "Option::is_none")]
185    #[get(skip)]
186    pub(crate) sha256: Option<String>,
187    /// Whether sensitive tokens/credentials were redacted from the artifact.
188    #[get(type(copy))]
189    pub(crate) redacted: bool,
190    /// Optional human-readable artifact description.
191    #[serde(default, skip_serializing_if = "Option::is_none")]
192    #[get(skip)]
193    pub(crate) description: Option<String>,
194}
195
196/// Complete schema-v1 cross-platform performance and leak observability report.
197#[derive(Clone, Debug, Deserialize, Getter, PartialEq, Serialize)]
198pub struct ObservabilityReportV1 {
199    /// Fixed schema version (`"1.0"`).
200    pub(crate) schema_version: String,
201    /// Target platform, OS, device, backend, and execution mode.
202    pub(crate) target: ObservabilityTarget,
203    /// Build commit, profile, and version metadata.
204    pub(crate) build: ObservabilityBuild,
205    /// Active measurement tools and scopes.
206    pub(crate) tools: Vec<ObservabilityTool>,
207    /// Executed workload fixture metadata.
208    pub(crate) workload: ObservabilityWorkload,
209    /// Overall four-state verdict (`pass`, `fail`, `inconclusive`, `unsupported`).
210    #[get(type(copy))]
211    pub(crate) status: ObservabilityStatus,
212    /// Per-scope coverage matrix.
213    pub(crate) coverage: Vec<ObservabilityCoverage>,
214    /// Collected common and leak metrics.
215    pub(crate) metrics: Vec<ObservabilityMetric>,
216    /// Attributed findings (retained caches, confirmed leaks, or budget breaches).
217    pub(crate) findings: Vec<ObservabilityFinding>,
218    /// Referenced artifact evidence descriptors.
219    pub(crate) evidence: Vec<ObservabilityEvidence>,
220}