euv-core 0.48.3

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
use super::*;

/// Visual quality invariants that every adaptive render candidate MUST satisfy to participate in switching.
#[derive(Clone, Copy, Data, Debug, Eq, Hash, PartialEq)]
pub struct VisualEquivalenceContract {
    /// Font shaping, metrics, and glyph rasterization match the baseline.
    #[get(type(copy))]
    pub(crate) fonts_identical: bool,
    /// Layout geometry and subpixel snapping match the baseline.
    #[get(type(copy))]
    pub(crate) layout_identical: bool,
    /// Color gamut, sRGB/linear blending, and premultiplied alpha match the baseline.
    #[get(type(copy))]
    pub(crate) color_identical: bool,
    /// Analytical SDF / MSAA / SSAA anti-aliasing coverage matches the baseline.
    #[get(type(copy))]
    pub(crate) antialiasing_identical: bool,
    /// Soft drop-shadow spread, offset, and blur match the baseline.
    #[get(type(copy))]
    pub(crate) shadows_identical: bool,
    /// Backdrop-blur kernel and rounded clip mask match the baseline.
    #[get(type(copy))]
    pub(crate) blur_identical: bool,
    /// Visible tile coverage and clipping bounds match the baseline.
    #[get(type(copy))]
    pub(crate) visible_tiles_identical: bool,
    /// Decoded media, image, and sprite sampling quality matches the baseline.
    #[get(type(copy))]
    pub(crate) media_quality_identical: bool,
}

/// Capability and visual-equivalence declaration for one host rendering candidate.
#[derive(Clone, Copy, Data, Debug, Eq, Hash, PartialEq)]
pub struct CandidateCapabilities {
    /// Rendering path candidate represented by this capability record.
    #[get(type(copy))]
    pub(crate) candidate: RenderBackendCandidate,
    /// True when the host actually supports this candidate channel.
    #[get(type(copy))]
    pub(crate) supported: bool,
    /// Visual-equivalence invariants guaranteed by this candidate.
    #[get(type(copy))]
    pub(crate) visual_contract: VisualEquivalenceContract,
    /// True when platform rules require warmup/resource creation steps on the UI/render thread.
    #[get(type(copy))]
    pub(crate) requires_ui_thread_warmup: bool,
    /// True when this capability entry originates from a simulated/emulated profile rather than a real device.
    #[get(type(copy))]
    pub(crate) is_simulated_profile: bool,
    /// True when direct GPU presentation has been verified on a real target device.
    #[get(type(copy))]
    pub(crate) direct_gpu_verified_on_device: bool,
    /// Concrete low-level graphics backend bound to this candidate.
    #[get(type(copy))]
    pub(crate) graphics_backend: GraphicsBackend,
}

/// Complete capability and channel declaration for a target host platform.
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct HostCapabilityProfile {
    /// Target execution platform kind.
    #[get(type(copy))]
    pub(crate) platform: PlatformKind,
    /// Ordered host-declared rendering candidates.
    pub(crate) candidates: Vec<CandidateCapabilities>,
    /// True when the host exposes only one valid rendering channel and MUST NEVER probe others.
    #[get(type(copy))]
    pub(crate) single_channel_only: bool,
    /// Baseline visual-equivalence contract required of every eligible candidate.
    #[get(type(copy))]
    pub(crate) baseline_contract: VisualEquivalenceContract,
}

/// Composite cache key scoping a verified startup winner to exact hardware, driver, display mode, build, and scene profile.
#[derive(Clone, Data, Debug, Deserialize, Eq, Hash, New, PartialEq, Serialize)]
pub struct WinnerCacheKey {
    /// Device or GPU adapter identifier.
    pub(crate) device_id: String,
    /// Graphics driver version string.
    pub(crate) driver_version: String,
    /// Display refresh mode in millihertz (`144.0 Hz` = `144_000`) for exact hashing.
    #[get(type(copy))]
    pub(crate) display_mode_hz_millihz: u32,
    /// Application/engine build identifier or commit SHA.
    pub(crate) build_id: String,
    /// Scene workload profile key.
    #[get(type(copy))]
    pub(crate) scene_profile: SceneProfile,
}

/// Cached verified performance winner persisted for fast startup reuse.
#[derive(Clone, Copy, Data, Debug, Deserialize, New, PartialEq, Serialize)]
pub struct WinnerCacheEntry {
    /// Verified winning backend candidate.
    #[get(type(copy))]
    pub(crate) winner: RenderBackendCandidate,
    /// Monotonic timestamp in milliseconds when this winner was verified.
    #[get(type(copy))]
    pub(crate) verified_at_ms: u64,
    /// Observed p95 frame time in milliseconds at verification.
    #[get(type(copy))]
    pub(crate) p95_ms: f64,
    /// Observed p99 frame time in milliseconds at verification.
    #[get(type(copy))]
    pub(crate) p99_ms: f64,
    /// Observed missed-frame ratio in `[0.0, 1.0]` at verification.
    #[get(type(copy))]
    pub(crate) missed_frame_rate: f64,
    /// Observed input-to-present latency in milliseconds at verification.
    #[get(type(copy))]
    pub(crate) input_to_present_ms: f64,
}

/// Bounded startup winner cache invalidating automatically when driver, display mode, or build changes.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct WinnerCache {
    /// Verified winner entries keyed by `(device_id, driver_version, display_mode_hz, build_id, scene_profile)`.
    pub(crate) entries: HashMap<WinnerCacheKey, WinnerCacheEntry>,
    /// Maximum number of retained entries before evicting the oldest record.
    #[get(type(copy))]
    pub(crate) max_entries: usize,
}

/// Fixed-size zero-allocation hot-path telemetry record pushed into `BoundedTelemetryQueue`.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct TelemetrySample {
    /// Monotonic rendered frame index.
    #[get(type(copy))]
    pub(crate) frame_index: u64,
    /// Reused existing monotonic callback or present timestamp in nanoseconds.
    #[get(type(copy))]
    pub(crate) timestamp_ns: u64,
    /// Observed frame-callback interval in milliseconds.
    #[get(type(copy))]
    pub(crate) callback_interval_ms: f64,
    /// Observed presentation interval in milliseconds (compositor or proxy).
    #[get(type(copy))]
    pub(crate) present_interval_ms: f64,
    /// Provenance of `present_interval_ms`.
    #[get(type(copy))]
    pub(crate) present_timing_source: PresentTimingSource,
    /// Outcome of this frame presentation attempt.
    #[get(type(copy))]
    pub(crate) present_outcome: SurfacePresentOutcome,
    /// True when this presented frame missed the active display deadline.
    #[get(type(copy))]
    pub(crate) missed_deadline: bool,
    /// End-to-end input-to-present latency in milliseconds (valid only when `input_latency_measured` is true).
    #[get(type(copy))]
    pub(crate) input_to_present_ms: f64,
    /// True when `input_to_present_ms` carries a real observation.
    #[get(type(copy))]
    pub(crate) input_latency_measured: bool,
    /// Observed CPU raster time in milliseconds (valid when `cpu_raster_measured` is true).
    #[get(type(copy))]
    pub(crate) cpu_raster_ms: f64,
    /// True when `cpu_raster_ms` was directly measured.
    #[get(type(copy))]
    pub(crate) cpu_raster_measured: bool,
    /// Bytes uploaded to GPU/surface on this frame.
    #[get(type(copy))]
    pub(crate) upload_bytes: u64,
    /// Scene profile active during this frame.
    #[get(type(copy))]
    pub(crate) scene_profile: SceneProfile,
    /// Active display mode refresh rate in Hertz.
    #[get(type(copy))]
    pub(crate) display_mode_hz: f64,
    /// Rendering backend candidate that produced this sample.
    #[get(type(copy))]
    pub(crate) candidate: RenderBackendCandidate,
}

/// Fixed-capacity non-blocking drop-oldest telemetry ring queue with zero heap allocation on hot-path `push`.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct BoundedTelemetryQueue {
    /// Pre-allocated fixed-capacity sample ring storage.
    pub(crate) slots: Vec<TelemetrySample>,
    /// Index of the oldest unread sample.
    #[get(type(copy))]
    pub(crate) head: usize,
    /// Number of valid unread samples currently stored.
    #[get(type(copy))]
    pub(crate) len: usize,
    /// Fixed slot capacity of the ring buffer.
    #[get(type(copy))]
    pub(crate) capacity: usize,
    /// Total oldest samples overwritten due to queue saturation.
    #[get(type(copy))]
    pub(crate) dropped_oldest_count: u64,
}

/// Low-frequency aggregated telemetry window derived from `BoundedTelemetryQueue`.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct AggregatedTelemetryWindow {
    /// Total samples aggregated in this window.
    #[get(type(copy))]
    pub(crate) sample_count: u64,
    /// Number of frames with `SurfacePresentOutcome::Submitted`.
    #[get(type(copy))]
    pub(crate) presented_frames: u64,
    /// Number of frames with `SurfacePresentOutcome::SkippedUnchanged`.
    #[get(type(copy))]
    pub(crate) skipped_unchanged_frames: u64,
    /// Number of frames with `SurfacePresentOutcome::Failed`.
    #[get(type(copy))]
    pub(crate) failed_frames: u64,
    /// Number of submitted frames that missed the display deadline.
    #[get(type(copy))]
    pub(crate) missed_deadline_frames: u64,
    /// 50th percentile present interval in milliseconds.
    #[get(type(copy))]
    pub(crate) present_p50_ms: f64,
    /// 95th percentile present interval in milliseconds.
    #[get(type(copy))]
    pub(crate) present_p95_ms: f64,
    /// 99th percentile present interval in milliseconds.
    #[get(type(copy))]
    pub(crate) present_p99_ms: f64,
    /// 95th percentile input-to-present latency in milliseconds (valid only when `has_input_latency` is true).
    #[get(type(copy))]
    pub(crate) input_to_present_p95_ms: f64,
    /// True when at least one real input-to-present latency sample was present.
    #[get(type(copy))]
    pub(crate) has_input_latency: bool,
    /// True when presentation intervals came from `PresentTimingSource::CompositorMeasured`.
    #[get(type(copy))]
    pub(crate) has_compositor_timing: bool,
    /// Scene profile of this window.
    #[get(type(copy))]
    pub(crate) scene_profile: SceneProfile,
    /// Display mode refresh rate in Hertz for this window.
    #[get(type(copy))]
    pub(crate) display_mode_hz: f64,
    /// Candidate backend represented by this window.
    #[get(type(copy))]
    pub(crate) candidate: RenderBackendCandidate,
}

/// Comparable real-presentation performance summary for one candidate under a specific `(scene_profile, display_mode_hz)`.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub struct CandidateScore {
    /// Candidate backend being scored.
    #[get(type(copy))]
    pub(crate) candidate: RenderBackendCandidate,
    /// Scene profile during measurement (must match opponent).
    #[get(type(copy))]
    pub(crate) scene_profile: SceneProfile,
    /// Display refresh mode in millihertz during measurement (must match opponent).
    #[get(type(copy))]
    pub(crate) display_mode_hz_millihz: u32,
    /// Fraction of real presented frames that missed the active deadline in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) missed_frame_ratio: f64,
    /// Tail p95 actual present interval in milliseconds.
    #[get(type(copy))]
    pub(crate) p95_frame_ms: f64,
    /// Tail p99 actual present interval in milliseconds.
    #[get(type(copy))]
    pub(crate) p99_frame_ms: f64,
    /// Input-to-present latency in milliseconds.
    #[get(type(copy))]
    pub(crate) input_to_present_ms: f64,
    /// Net positive gain in milliseconds for `Hybrid` over both pure GPU and pure CPU (`<= 0.0` disqualifies `Hybrid`).
    #[get(type(copy))]
    pub(crate) hybrid_net_gain_ms: f64,
    /// Number of real presented frames backing this score.
    #[get(type(copy))]
    pub(crate) sample_count: u64,
}

/// Interactive runtime state invariants that normal performance-driven backend switches MUST NEVER reset or downgrade.
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct RuntimeStateSnapshot {
    /// Active horizontal scroll offset in logical pixels.
    #[get(type(copy))]
    pub(crate) scroll_offset_x: f32,
    /// Active vertical scroll offset in logical pixels.
    #[get(type(copy))]
    pub(crate) scroll_offset_y: f32,
    /// Active gesture recognizer token (`0` when idle).
    #[get(type(copy))]
    pub(crate) active_gesture_id: u64,
    /// Focused interactive node identifier (`0` when unfocused).
    #[get(type(copy))]
    pub(crate) focused_node_id: u64,
    /// Monotonic page/route state revision counter.
    #[get(type(copy))]
    pub(crate) page_state_revision: u64,
    /// Continuous animation timeline position in nanoseconds.
    #[get(type(copy))]
    pub(crate) animation_timeline_ns: u64,
    /// Target presentation refresh rate in Hertz (normal perf switches MUST NOT lower this).
    #[get(type(copy))]
    pub(crate) target_refresh_hz: f64,
}

/// First-frame verification descriptor submitted by a warmed candidate at a frame boundary.
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct HandoffFrameDescriptor {
    /// Physical surface width produced by the candidate first frame.
    #[get(type(copy))]
    pub(crate) width: u32,
    /// Physical surface height produced by the candidate first frame.
    #[get(type(copy))]
    pub(crate) height: u32,
    /// Exact DPI scale factor used by the candidate first frame.
    #[get(type(copy))]
    pub(crate) scale_factor: f32,
    /// Exact `scene_version` rendered into the candidate first frame.
    #[get(type(copy))]
    pub(crate) scene_version: u64,
    /// Measured candidate first-frame render + submit duration in milliseconds.
    #[get(type(copy))]
    pub(crate) frame_time_ms: f64,
    /// Active frame deadline in milliseconds that the first frame must satisfy.
    #[get(type(copy))]
    pub(crate) deadline_ms: f64,
    /// True when the candidate first frame rendered without error.
    #[get(type(copy))]
    pub(crate) first_frame_ok: bool,
}

/// Budget slicing and deferred resource reclamation settings for `HandoffCoordinator`.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct HandoffBudgetConfig {
    /// Number of budget-sliced warmup steps required before candidate first-frame boundary check.
    #[get(type(copy))]
    pub(crate) warmup_steps_required: u32,
    /// Maximum per-frame UI/render-thread warmup work slice in milliseconds.
    #[get(type(copy))]
    pub(crate) per_frame_budget_ms: f64,
    /// Maximum elapsed warmup wall time in milliseconds before aborting.
    #[get(type(copy))]
    pub(crate) max_warmup_timeout_ms: u64,
    /// Minimum post-handoff fence frames confirmed before releasing old backend resources.
    #[get(type(copy))]
    pub(crate) post_commit_fence_frames: u32,
}

/// Frame-boundary backend handoff state machine ensuring uninterrupted presentation, exact version matching, and deferred resource release.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct HandoffCoordinator {
    /// Active handoff lifecycle stage.
    #[get(type(copy))]
    pub(crate) stage: HandoffStage,
    /// Previous backend continuing to present until frame-boundary takeover.
    #[get(type(copy))]
    pub(crate) old_candidate: RenderBackendCandidate,
    /// Candidate backend warming up for takeover.
    #[get(type(copy))]
    pub(crate) target_candidate: RenderBackendCandidate,
    /// Target physical width captured when handoff started.
    #[get(type(copy))]
    pub(crate) target_width: u32,
    /// Target physical height captured when handoff started.
    #[get(type(copy))]
    pub(crate) target_height: u32,
    /// Target DPI scale factor captured when handoff started.
    #[get(type(copy))]
    pub(crate) target_scale_factor: f32,
    /// Target `scene_version` the candidate warms up on.
    #[get(type(copy))]
    pub(crate) target_scene_version: u64,
    /// Monotonic timestamp in milliseconds when warmup began.
    #[get(type(copy))]
    pub(crate) started_at_ms: u64,
    /// Number of per-frame budget-sliced warmup steps completed.
    #[get(type(copy))]
    pub(crate) warmup_steps_completed: u32,
    /// Active warmup budget and deferred release configuration.
    #[get(type(copy))]
    pub(crate) budget_config: HandoffBudgetConfig,
    /// True while old backend resources remain alive and MUST NOT be released yet.
    #[get(type(copy))]
    pub(crate) old_resources_retained: bool,
    /// Sync fence identifier assigned at frame-boundary takeover.
    #[get(type(copy))]
    pub(crate) commit_fence_id: u64,
    /// Latest completed sync fence identifier confirmed after handoff.
    #[get(type(copy))]
    pub(crate) completed_fence_id: u64,
    /// True once at least one post-handoff present has been confirmed on the new backend.
    #[get(type(copy))]
    pub(crate) post_handoff_present_confirmed: bool,
    /// Diagnostic abort reason from the most recent aborted handoff.
    #[get(skip)]
    pub(crate) last_abort_reason: Option<HandoffAbortReason>,
    /// Cumulative verified seamless handoff commits (explicitly excluding fault failovers).
    #[get(type(copy))]
    pub(crate) seamless_success_count: u64,
    /// Cumulative cleanly aborted handoffs where the old backend kept presenting.
    #[get(type(copy))]
    pub(crate) abort_count: u64,
    /// Runtime state snapshot captured at handoff start to assert zero state/timeline reset.
    #[get(type(copy))]
    pub(crate) preserved_state: RuntimeStateSnapshot,
}

/// Policy thresholds and rollout controls for `AdaptiveRenderRouter`.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct AdaptiveRouterConfig {
    /// Rollout mode (`RecommendOnly` default shadow mode vs `AutoSwitch` live takeover).
    #[get(type(copy))]
    pub(crate) switch_mode: AdaptiveSwitchMode,
    /// Consecutive missed-deadline frames required before considering a candidate probe.
    #[get(type(copy))]
    pub(crate) sustained_miss_threshold: u32,
    /// Input-to-present latency ratio over target frame interval triggering a probe.
    #[get(type(copy))]
    pub(crate) input_latency_degrade_ratio: f64,
    /// Consecutive candidate wins required before recommending or triggering a switch.
    #[get(type(copy))]
    pub(crate) consecutive_wins_required: u32,
    /// Minimum net latency improvement in milliseconds required to overcome switch cost.
    #[get(type(copy))]
    pub(crate) switch_cost_ms: f64,
    /// Minimum dwell time in milliseconds between performance-driven switches.
    #[get(type(copy))]
    pub(crate) min_dwell_ms: u64,
    /// Cooldown duration in milliseconds after a switch or failover.
    #[get(type(copy))]
    pub(crate) cooldown_ms: u64,
    /// Minimum explicit frame headroom fraction required to run a probe when not idle.
    #[get(type(copy))]
    pub(crate) probe_min_headroom_ratio: f64,
    /// Fixed capacity of `BoundedTelemetryQueue`.
    #[get(type(copy))]
    pub(crate) telemetry_queue_capacity: usize,
}

/// Structured decision returned by `AdaptiveRenderRouter` stages.
#[derive(Clone, Copy, Data, Debug, Eq, Hash, PartialEq)]
pub struct AdaptiveDecision {
    /// Specific routing/handoff/fault action category.
    #[get(type(copy))]
    pub(crate) kind: AdaptiveDecisionKind,
    /// Backend candidate currently presenting frames.
    #[get(type(copy))]
    pub(crate) active_candidate: RenderBackendCandidate,
    /// Recommended optimal candidate (may differ from `active_candidate` in `RecommendOnly` mode).
    #[get(type(copy))]
    pub(crate) recommended_candidate: RenderBackendCandidate,
    /// True when the router actively applied a backend change or started handoff.
    #[get(type(copy))]
    pub(crate) applied: bool,
    /// Human-readable static rationale for observability and telemetry evidence.
    #[get(type(copy))]
    pub(crate) reason: &'static str,
    /// True when the last valid frame MUST be retained (never submitting a blank frame).
    #[get(type(copy))]
    pub(crate) preserve_last_valid_frame: bool,
    /// Explicit hardware/surface/driver/thermal fault tag when triggered by a fault.
    #[get(skip)]
    pub(crate) fault_tag: Option<FaultEventKind>,
}

/// Serializable compact telemetry snapshot of `AdaptiveRenderRouter` embedded in `AdaptiveFrameMetrics`.
#[derive(Clone, Copy, Data, Debug, Default, Deserialize, Eq, Hash, PartialEq, Serialize)]
pub struct AdaptiveRouterSnapshot {
    /// Currently active rendering backend candidate.
    #[get(type(copy))]
    pub(crate) active_candidate: RenderBackendCandidate,
    /// Most recently recommended rendering backend candidate.
    #[get(type(copy))]
    pub(crate) recommended_candidate: RenderBackendCandidate,
    /// Active rollout switch mode (`recommend_only` or `auto_switch`).
    #[get(type(copy))]
    pub(crate) switch_mode: AdaptiveSwitchMode,
    /// Current frame-boundary handoff lifecycle stage.
    #[get(type(copy))]
    pub(crate) handoff_stage: HandoffStage,
    /// Cumulative verified seamless handoff commits (excluding fault failovers).
    #[get(type(copy))]
    pub(crate) seamless_handoff_successes: u64,
    /// Cumulative cleanly aborted handoffs.
    #[get(type(copy))]
    pub(crate) handoff_aborts: u64,
    /// Cumulative fault-driven failovers (explicitly tracked apart from seamless handoffs).
    #[get(type(copy))]
    pub(crate) fault_failovers: u64,
    /// Total headroom-gated candidate probes authorized.
    #[get(type(copy))]
    pub(crate) probe_runs: u64,
    /// Total candidate probes skipped due to lack of idle time or explicit headroom.
    #[get(type(copy))]
    pub(crate) probe_skips_no_headroom: u64,
    /// Total startup cache hits reused from `WinnerCache`.
    #[get(type(copy))]
    pub(crate) cache_hits: u64,
    /// Total shadow-mode recommendations recorded in `RecommendOnly` mode.
    #[get(type(copy))]
    pub(crate) recommendations_logged: u64,
    /// True when a fault has been tagged during this session.
    #[get(type(copy))]
    pub(crate) has_tagged_fault: bool,
    /// Most recent tagged fault classification (valid when `has_tagged_fault` is true).
    #[get(type(copy))]
    pub(crate) last_fault_kind: FaultEventKind,
}

/// Unified 5-stage cross-platform adaptive render router (Startup, Runtime, Selection, Handoff, Fault).
#[derive(Clone, Data, Debug, PartialEq)]
pub struct AdaptiveRenderRouter {
    /// Tunable adaptive routing thresholds and rollout mode.
    #[get(type(copy))]
    pub(crate) config: AdaptiveRouterConfig,
    /// Host capability profile and visual-equivalence baseline.
    pub(crate) host_profile: HostCapabilityProfile,
    /// Verified startup winner cache keyed by device, driver, display mode, build, and scene profile.
    pub(crate) winner_cache: WinnerCache,
    /// Fixed-capacity non-blocking drop-oldest hot-path telemetry queue.
    pub(crate) telemetry_queue: BoundedTelemetryQueue,
    /// Frame-boundary handoff coordinator managing warmup, commit, abort, and deferred release.
    #[get(type(copy))]
    pub(crate) handoff: HandoffCoordinator,
    /// Active backend candidate currently presenting frames.
    #[get(type(copy))]
    pub(crate) active_candidate: RenderBackendCandidate,
    /// Latest recommended backend candidate.
    #[get(type(copy))]
    pub(crate) recommended_candidate: RenderBackendCandidate,
    /// Active workload scene profile.
    #[get(type(copy))]
    pub(crate) active_scene_profile: SceneProfile,
    /// Active display mode refresh rate in Hertz.
    #[get(type(copy))]
    pub(crate) display_mode_hz: f64,
    /// Active device/adapter identifier for `WinnerCacheKey`.
    pub(crate) device_id: String,
    /// Active graphics driver version for `WinnerCacheKey`.
    pub(crate) driver_version: String,
    /// Active application/engine build identifier for `WinnerCacheKey`.
    pub(crate) build_id: String,
    /// Monotonic timestamp in milliseconds of the last committed backend switch.
    #[get(type(copy))]
    pub(crate) last_switch_ms: u64,
    /// True once at least one switch has occurred (gating `min_dwell_ms`).
    #[get(type(copy))]
    pub(crate) has_switched_once: bool,
    /// Monotonic timestamp in milliseconds until which probing and re-switching are suppressed.
    #[get(type(copy))]
    pub(crate) cooldown_until_ms: u64,
    /// Consecutive missed-deadline frame counter.
    #[get(type(copy))]
    pub(crate) sustained_miss_streak: u32,
    /// True when input-to-present latency degradation was detected in the active window.
    #[get(type(copy))]
    pub(crate) input_latency_degraded: bool,
    /// Candidate currently accumulating consecutive selection wins.
    #[get(skip)]
    pub(crate) streak_candidate: Option<RenderBackendCandidate>,
    /// Number of consecutive wins accumulated by `streak_candidate`.
    #[get(type(copy))]
    pub(crate) streak_wins: u32,
    /// True when the last valid frame is currently retained on screen across a fault or transition.
    #[get(type(copy))]
    pub(crate) last_valid_frame_retained: bool,
    /// Cumulative count of fault-driven failovers (never counted as seamless handoff successes).
    #[get(type(copy))]
    pub(crate) fault_failover_count: u64,
    /// Chronological log of explicitly tagged `(timestamp_ms, FaultEventKind)` events.
    pub(crate) tagged_fault_events: Vec<(u64, FaultEventKind)>,
    /// Total headroom-gated short probes authorized.
    #[get(type(copy))]
    pub(crate) probe_runs: u64,
    /// Total candidate probes skipped due to lack of idle time or explicit frame headroom.
    #[get(type(copy))]
    pub(crate) probe_skips_no_headroom: u64,
    /// Total startup winner cache hits.
    #[get(type(copy))]
    pub(crate) cache_hits: u64,
    /// Total shadow-mode recommendations logged in `RecommendOnly` mode.
    #[get(type(copy))]
    pub(crate) recommendations_logged: u64,
    /// Static reason string from the most recent router decision.
    #[get(type(copy))]
    pub(crate) last_decision_reason: &'static str,
}