Skip to main content

euv_core/app/runner/
struct.rs

1use super::*;
2
3/// Top-level cross-platform application configuration.
4#[derive(Clone, Data, Debug, PartialEq)]
5pub struct AppConfig {
6    /// Primary window creation settings.
7    pub(crate) window: WindowConfig,
8    /// Clear background color drawn beneath the root scene node.
9    #[get(type(copy))]
10    pub(crate) clear_color: Color,
11}
12
13/// Opt-in per-phase microsecond breakdown for a single `App::step_frame` execution.
14#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, PartialEq)]
15pub struct FramePhaseMetrics {
16    /// Window command flushing, event polling, and input dispatch duration in microseconds.
17    #[get(type(copy))]
18    pub(crate) input_us: u64,
19    /// Reactive effect flushing, animation/gesture/scroll ticking, and damage collection duration in microseconds.
20    #[get(type(copy))]
21    pub(crate) reactive_us: u64,
22    /// `LayoutEngine::compute` pass duration in microseconds.
23    #[get(type(copy))]
24    pub(crate) layout_us: u64,
25    /// Display-list compilation duration in microseconds when timed separately (`0` when combined into `raster_us`).
26    #[get(type(copy))]
27    pub(crate) paint_list_us: u64,
28    /// Unified render pass (`Renderer::render_frame`) duration in microseconds.
29    #[get(type(copy))]
30    pub(crate) raster_us: u64,
31    /// Native surface / framebuffer region presentation duration in microseconds.
32    #[get(type(copy))]
33    pub(crate) present_us: u64,
34}
35
36/// Unified per-frame diagnostic telemetry covering phase timings, damage ratio, redraw cause, and idle-aware FPS.
37#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
38pub struct FrameTelemetry {
39    /// Monotonic frame identifier matching `FrameStats::get_frame_index()`.
40    #[get(type(copy))]
41    pub(crate) frame_id: u64,
42    /// Microsecond breakdown across pipeline phases (zeroed when telemetry timing is disabled).
43    #[get(type(copy))]
44    pub(crate) phases: FramePhaseMetrics,
45    /// Fraction of physical viewport area rasterized (`0.0` when idle, `(0.0..=1.0]` when rendered).
46    #[get(type(copy))]
47    pub(crate) dirty_area_ratio: f32,
48    /// Diagnostic reason when the frame promoted to full-viewport redraw (`FullRedrawReason::None` for partial or idle).
49    #[get(type(copy))]
50    pub(crate) full_redraw_reason: FullRedrawReason,
51    /// Effective target cadence in Hertz (`min(fps_limit, display_refresh_rate_hz)` or `display_refresh_rate_hz`).
52    #[get(type(copy))]
53    pub(crate) target_hz: f32,
54    /// Active presented frames per second (`0.0` while idle, smoothed active present cadence while rendering).
55    #[get(type(copy))]
56    pub(crate) present_fps: f32,
57    /// Whether this frame skipped rendering because the scene was clean or rate-capped.
58    #[get(type(copy))]
59    pub(crate) is_idle: bool,
60    /// Number of scene nodes recomputed during layout.
61    #[get(type(copy))]
62    pub(crate) layout_nodes: usize,
63    /// Number of display-list draw commands executed.
64    #[get(type(copy))]
65    pub(crate) draw_commands: usize,
66    /// Number of physical pixels shaded.
67    #[get(type(copy))]
68    pub(crate) pixels_shaded: usize,
69    /// Native display target refresh mode in Hertz (distinct from callback and completed frame rates).
70    #[get(type(copy))]
71    pub(crate) target_refresh_mode_hz: f32,
72    /// Measured host frame-callback tick rate in Hertz when `has_callback_sample` is `true`.
73    #[get(type(copy))]
74    pub(crate) callback_rate_hz: f32,
75    /// True when `callback_rate_hz` reflects an active measured sample rather than idle no-sample.
76    #[get(type(copy))]
77    pub(crate) has_callback_sample: bool,
78    /// Measured completed & presented frame rate in Hertz when `has_completed_sample` is `true` (`0.0` / idle when skipped).
79    #[get(type(copy))]
80    pub(crate) completed_frame_rate_hz: f32,
81    /// True when `completed_frame_rate_hz` holds a live non-idle completed frame sample.
82    #[get(type(copy))]
83    pub(crate) has_completed_sample: bool,
84    /// Monotonic presentation timestamp in nanoseconds when `has_present_timestamp` is `true`.
85    #[get(type(copy))]
86    pub(crate) present_timestamp_ns: u64,
87    /// True when this frame completed submission with a valid monotonic presentation timestamp.
88    #[get(type(copy))]
89    pub(crate) has_present_timestamp: bool,
90    /// Explicit frame submission outcome separating idle skip, submitted, and retryable submit failure.
91    #[get(type(copy))]
92    pub(crate) submit_outcome: FrameSubmitOutcome,
93    /// True when this frame took the composite-only fast path without layout or full repaint.
94    #[get(type(copy))]
95    pub(crate) composite_only: bool,
96    /// Cumulative layout telemetry snapshot (`invalidations`, `passes`, `changed_passes`, `changed_nodes_total`).
97    #[get(type(copy))]
98    pub(crate) layout_telemetry: LayoutTelemetry,
99}
100
101/// Unified cross-platform application runtime orchestrating platform events, reactivity, layout, and rendering.
102#[derive(CustomDebug, Data)]
103pub struct App {
104    /// Application configuration.
105    pub(crate) config: AppConfig,
106    /// Active direct OS or headless platform backend.
107    #[debug(skip)]
108    #[get(skip)]
109    pub(crate) platform: Box<dyn PlatformBackend>,
110    /// Primary window live state.
111    #[get(type(copy))]
112    pub(crate) window_state: WindowState,
113    /// Shared scene tree handle.
114    pub(crate) scene: SceneHandle,
115    /// Framework context carrying reactive breakpoint, theme, gesture, and safe-area signals.
116    pub(crate) context: Context,
117    /// Deterministic cross-platform layout engine.
118    pub(crate) layout_engine: LayoutEngine,
119    /// Multi-mode rendering pipeline (`Auto`, `Software`, `Hardware`, `Hybrid`).
120    pub(crate) renderer: Renderer,
121    /// Queued imperative window commands awaiting dispatch.
122    pub(crate) command_queue: WindowCommandQueue,
123    /// Local key-value storage service.
124    pub(crate) storage: StorageStore,
125    /// Flag indicating whether the application loop should keep running.
126    #[get(type(copy))]
127    pub(crate) running: bool,
128    /// Pending damage region for the next rendered frame.
129    #[get(type(copy))]
130    pub(crate) pending_damage: DamageRegion,
131    /// Real-time polled keyboard, pointer, and scroll state for game loops and interactive viewports.
132    pub(crate) input_state: InputState,
133    /// Fixed-timestep accumulator and FPS telemetry clock for real-time game rendering.
134    #[get(type(copy))]
135    pub(crate) frame_clock: FrameClock,
136    /// Platform-native services hub (permissions, protocol registration, Dynamic Island, haptics, tray, A11y).
137    pub(crate) services: PlatformServiceHub,
138    /// Reactive signal carrying the most recently received custom-scheme or universal deep link.
139    #[get(type(copy))]
140    pub(crate) deep_link: Signal<Option<DeepLinkEvent>>,
141    /// Shared dynamic update hub for live component-level and page-level OTA updates.
142    pub(crate) dynamic_hub: DynamicUpdateHub,
143    /// Last scene revision that was rasterized and presented, enabling zero-cost idle frame skipping.
144    #[get(type(copy))]
145    pub(crate) last_rendered_revision: u64,
146    /// Most recently submitted OS/Web cursor icon to avoid redundant platform cursor calls.
147    #[get(type(copy))]
148    pub(crate) last_cursor: CursorIcon,
149    /// Attached real-time game engine hosts receiving automatic OS input forwarding.
150    #[debug(skip)]
151    pub(crate) game_hosts: Vec<GameEngineHost>,
152    /// Active touch pointer identifier currently driving single-finger pan scrolling.
153    #[get(skip)]
154    pub(crate) touch_drag_pointer_id: Option<u64>,
155    /// Starting touch coordinate for mobile pan-to-scroll detection.
156    #[get(skip)]
157    pub(crate) touch_drag_origin: Option<Point>,
158    /// Previous touch coordinate for incremental mobile scroll deltas.
159    #[get(skip)]
160    pub(crate) touch_drag_last: Option<Point>,
161    /// Whether the active touch gesture has crossed tap slop into pan-scrolling.
162    #[get(type(copy))]
163    pub(crate) touch_dragging: bool,
164    /// Cumulative post-slop drag displacement in logical pixels for the active touch scroll gesture.
165    #[get(type(copy))]
166    pub(crate) touch_drag_travel: f32,
167    /// Locked scroll axis for the active touch drag (`0` = unlocked, `1` = vertical, `2` = horizontal, `3` = free).
168    #[get(type(copy))]
169    pub(crate) touch_scroll_axis: u8,
170    /// Touch pan displacement accumulated during the current frame for jitter-free velocity estimation.
171    #[get(type(copy))]
172    pub(crate) touch_vel_accum_delta: Point,
173    /// Fixed 8-entry stack ring buffer of `(dt_secs, dx, dy)` frame samples preventing thumb-lift backward fling reversals.
174    #[get(skip)]
175    #[get_mut(skip)]
176    #[set(skip)]
177    pub(crate) touch_vel_ring: [(f32, f32, f32); 8],
178    /// Ring buffer index of the oldest live velocity sample in `0..8`.
179    #[get(type(copy))]
180    pub(crate) touch_vel_head: usize,
181    /// Number of live samples currently stored in `touch_vel_ring` (`0..=8`).
182    #[get(type(copy))]
183    pub(crate) touch_vel_len: usize,
184    /// Elapsed idle seconds since the last touch pan movement while a finger remains held down.
185    #[get(type(copy))]
186    pub(crate) touch_vel_idle_secs: f32,
187    /// Whether the active pointer press grabbed a scrollbar track for thumb dragging.
188    #[get(type(copy))]
189    pub(crate) scrollbar_dragging: bool,
190    /// Active scrollbar thumb drag axis (`0` = none, `1` = vertical, `2` = horizontal).
191    #[get(type(copy))]
192    pub(crate) scrollbar_drag_axis: u8,
193    /// Active selectable `NodeKind::Text` node currently undergoing pointer drag selection.
194    #[get(skip)]
195    pub(crate) text_selecting_node: Option<NodeId>,
196    /// Starting character index anchored at pointer-down for drag text selection.
197    #[get(type(copy))]
198    pub(crate) text_select_anchor_char: usize,
199    /// Consecutive click count on the same selectable text node (`1` = caret, `2` = word, `3` = full node).
200    #[get(type(copy))]
201    pub(crate) text_click_count: u8,
202    /// Most recently clicked selectable text node for multi-click detection.
203    #[get(skip)]
204    pub(crate) text_last_click_node: Option<NodeId>,
205    /// Coordinates of the most recent click on a selectable text node.
206    #[get(skip)]
207    pub(crate) text_last_click_pos: Option<Point>,
208    /// Elapsed seconds since the most recent click on a selectable text node.
209    #[get(type(copy))]
210    pub(crate) text_last_click_age_secs: f32,
211    /// Active multi-touch / pointer contact map keyed by `pointer_id` for pinch & swipe recognition.
212    pub(crate) active_pointers: HashMap<u64, Point>,
213    /// Device kind recorded per active `pointer_id` for deterministic touch vs mouse separation.
214    pub(crate) active_pointer_devices: HashMap<u64, PointerDevice>,
215    /// Initial contact point of the active single-pointer gesture stroke.
216    #[get(skip)]
217    pub(crate) gesture_origin: Option<Point>,
218    /// Baseline two-finger distance recorded when a pinch gesture starts.
219    #[get(type(copy))]
220    pub(crate) pinch_base_dist: f32,
221    /// Accumulated hold duration in seconds for long-press gesture detection.
222    #[get(type(copy))]
223    pub(crate) gesture_hold_secs: f32,
224    /// Whether `GestureEventKind::LongPress` has already fired for the current press.
225    #[get(type(copy))]
226    pub(crate) long_press_fired: bool,
227    /// Coordinates of the most recent completed clean tap for double-tap detection.
228    #[get(skip)]
229    pub(crate) last_tap_pos: Option<Point>,
230    /// Elapsed seconds since the most recent completed clean tap.
231    #[get(type(copy))]
232    pub(crate) last_tap_age_secs: f32,
233    /// Monotonic gesture event sequence counter.
234    #[get(type(copy))]
235    pub(crate) gesture_seq: u64,
236    /// Inertial touch-scroll fling velocity in logical pixels per second.
237    #[get(type(copy))]
238    pub(crate) scroll_velocity: Point,
239    /// Pointer coordinates where inertial touch-scroll fling originated for hit-target resolution.
240    #[get(type(copy))]
241    pub(crate) scroll_fling_pos: Point,
242    /// Locked innermost scrollable node captured at touch-down to prevent nested scroll penetration.
243    #[get(skip)]
244    pub(crate) touch_scroll_target: Option<NodeId>,
245    /// Remaining smooth-scroll interpolation delta for discrete mouse-wheel notches.
246    #[get(type(copy))]
247    pub(crate) smooth_scroll_pending: Point,
248    /// Pointer coordinates captured when smooth wheel scrolling started.
249    #[get(type(copy))]
250    pub(crate) smooth_scroll_pos: Point,
251    /// Locked scroll container target for active smooth wheel interpolation.
252    #[get(skip)]
253    pub(crate) smooth_scroll_target: Option<NodeId>,
254    /// Re-entrancy guard preventing nested `step_frame` execution during macOS live-resize callbacks.
255    #[get(type(copy))]
256    pub(crate) in_step_frame: bool,
257    /// Accumulated blink phase timer in seconds for the focused `NodeKind::Input` caret.
258    #[get(type(copy))]
259    pub(crate) caret_blink_secs: f32,
260    /// When `true`, global swipe gestures are suppressed because the active stroke started in a canvas, slider, or isolated region.
261    #[get(type(copy))]
262    pub(crate) gesture_suppressed: bool,
263    /// Elapsed seconds accumulated for smoothed live FPS telemetry publication.
264    #[get(type(copy))]
265    pub(crate) fps_accum_secs: f32,
266    /// Rendered frame count accumulated inside the current FPS sampling window.
267    #[get(type(copy))]
268    pub(crate) fps_accum_frames: u32,
269    /// Accumulated frame time in seconds used to pace frames when an explicit FPS cap is configured.
270    #[get(type(copy))]
271    pub(crate) fps_budget_accum: f32,
272    /// Whether an editable `NodeKind::Input` currently holds focus and requests the system IME keyboard.
273    #[get(type(copy))]
274    pub(crate) last_ime_active: bool,
275    /// Handle of the `NodeKind::Input` that most recently activated the system IME keyboard.
276    #[get(skip)]
277    pub(crate) last_ime_node: Option<NodeId>,
278    /// Damage region rasterized during the most recent rendered frame for partial native surface presentation.
279    #[get(type(copy))]
280    pub(crate) last_frame_damage: DamageRegion,
281    /// Detected native hardware display refresh rate in Hertz (`60.0` fallback, `120.0`/`144.0`/`180.0`+ on high-refresh screens).
282    #[get(type(copy))]
283    pub(crate) display_refresh_rate_hz: f32,
284    /// Whether motion animations, smooth scrolling, inertia, or active games were running on the previous frame.
285    #[get(type(copy))]
286    pub(crate) was_animating: bool,
287    /// Cross-platform lifecycle and system event normalizer deduplicating OS notifications.
288    pub(crate) system_event_normalizer: SystemEventNormalizer,
289    /// Opt-in flag enabling per-phase microsecond timing instrumentation inside `step_frame` (zero syscall overhead when `false`).
290    #[get(type(copy))]
291    #[set(skip)]
292    pub(crate) telemetry_enabled: bool,
293    /// Most recently recorded `FrameTelemetry` snapshot.
294    #[get(type(copy))]
295    pub(crate) last_frame_telemetry: FrameTelemetry,
296    /// Pending diagnostic reason associated with `pending_damage` when full-viewport damage was queued before `step_frame`.
297    #[get(type(copy))]
298    pub(crate) pending_full_redraw_reason: FullRedrawReason,
299    /// Logical viewport size rasterized during the most recent rendered frame.
300    #[get(type(copy))]
301    pub(crate) last_rendered_viewport: Size,
302    /// Display DPI scale factor rasterized during the most recent rendered frame.
303    #[get(type(copy))]
304    pub(crate) last_rendered_scale: f32,
305    /// Active presented frames-per-second rate (`0.0` once idle beyond the sampling window).
306    #[get(type(copy))]
307    pub(crate) active_present_fps: f32,
308    /// Continuous idle seconds elapsed since the most recent rendered frame.
309    #[get(type(copy))]
310    pub(crate) idle_secs_since_present: f32,
311    /// Whether the most recent `step_frame` call skipped rendering due to a clean idle scene.
312    #[get(type(copy))]
313    pub(crate) is_idle_frame: bool,
314    /// Toggle enabling surgical pre/post-layout conservative bounds diffing instead of full-screen layout fallback (default `true`).
315    #[get(type(copy))]
316    #[set(skip)]
317    pub(crate) partial_layout_damage: bool,
318    /// Root reactive scope created by `App::mount` so root effects freeze cleanly in background.
319    #[get(skip)]
320    #[get_mut(skip)]
321    #[set(skip)]
322    pub(crate) mount_scope: Option<Scope>,
323    /// True while the application is frozen in background (zero CPU ticks, zero layout/paint/GPU work).
324    #[get(pub(crate), type(copy))]
325    #[set(pub(crate))]
326    pub(crate) background_frozen: bool,
327    /// True on the first frame after returning from background so elapsed sleep time clamps to `dt = 0.0`.
328    #[get(pub(crate), type(copy))]
329    #[set(pub(crate))]
330    pub(crate) resume_zero_dt_pending: bool,
331    /// Reactive scope handles frozen exclusively by background entry (leaving pre-frozen router pages untouched).
332    #[get(pub(crate))]
333    #[get_mut(pub(crate))]
334    #[set(pub(crate))]
335    pub(crate) background_frozen_scopes: Vec<ScopeId>,
336    /// Deterministic gesture arbitration arena enforcing priority tiers and touch-slop disambiguation.
337    #[get(pub(crate))]
338    #[get_mut(pub(crate))]
339    #[set(pub(crate))]
340    pub(crate) gesture_arena: GestureArena,
341    /// Last immersive fullscreen state synchronized with the platform backend.
342    #[get(pub(crate), type(copy))]
343    #[set(pub(crate))]
344    pub(crate) last_immersive_fullscreen: bool,
345    /// Surface presentation generation and automatic same-generation submit-failure retry tracker.
346    pub(crate) surface_present: SurfacePresentState,
347    /// Bounded, cancellable, context-validated route pre-warming pipeline.
348    pub(crate) route_prewarmer: RoutePrewarmer,
349    /// Unified deterministic page lifecycle controller (`Freeze`, `Resume`, `Evict`, `Destroy`, generation guards).
350    pub(crate) page_lifecycle: PageLifecycleController,
351    /// Low-overhead single-owner framework resource ownership and leak accountant.
352    pub(crate) resource_accountant: ResourceAccountant,
353    /// Accumulated elapsed seconds inside the current callback-rate measurement window.
354    #[get(pub(crate), type(copy))]
355    #[set(pub(crate))]
356    pub(crate) callback_accum_secs: f32,
357    /// Callback invocations counted inside the current callback-rate measurement window.
358    #[get(pub(crate), type(copy))]
359    #[set(pub(crate))]
360    pub(crate) callback_accum_ticks: u32,
361    /// Most recently measured host callback cadence in Hertz.
362    #[get(pub(crate), type(copy))]
363    #[set(pub(crate))]
364    pub(crate) last_callback_rate_hz: f32,
365    /// Whether `last_callback_rate_hz` holds a fresh measured callback rate sample.
366    #[get(pub(crate), type(copy))]
367    #[set(pub(crate))]
368    pub(crate) has_callback_rate_sample: bool,
369    /// Monotonic application clock in nanoseconds used for deterministic present timestamps and accounting grace periods.
370    #[get(pub(crate), type(copy))]
371    #[set(pub(crate))]
372    pub(crate) monotonic_clock_ns: u64,
373    /// Persistent per-frame scratch buffers reused across `step_frame` and input dispatch for zero steady-state heap allocations.
374    #[debug(skip)]
375    #[get(skip)]
376    #[get_mut(skip)]
377    #[set(skip)]
378    pub(crate) frame_arena: AppFrameArena,
379    /// Fixed 4-sample monotonic input timestamp ring `(ts_ns, x, y)` for phase-aligned resampling toward `target_present_time_ns`.
380    #[get(skip)]
381    #[get_mut(skip)]
382    #[set(skip)]
383    pub(crate) input_resample_ring: [(u64, f32, f32); 4],
384    /// Next write index into `input_resample_ring` in `0..4`.
385    #[get(pub(crate), type(copy))]
386    #[set(pub(crate))]
387    pub(crate) input_resample_head: usize,
388    /// Number of valid monotonic samples currently stored in `input_resample_ring` (`0..=4`).
389    #[get(pub(crate), type(copy))]
390    #[set(pub(crate))]
391    pub(crate) input_resample_len: usize,
392    /// Monotonic timestamp in nanoseconds of the previous scroll event for precision-trackpad vs discrete-wheel classification.
393    #[get(pub(crate), type(copy))]
394    #[set(pub(crate))]
395    pub(crate) last_scroll_ts_ns: u64,
396}
397
398/// Persistent reusable scratch vectors owned by `App` so steady-state frames allocate zero heap buffers.
399#[derive(CustomDebug, Default)]
400pub(crate) struct AppFrameArena {
401    /// Reusable visible portal `(is_dirty, screen_bounds)` scratch list.
402    pub(crate) visible_portals: Vec<(bool, Rect)>,
403    /// Reusable active game viewport dirty rect scratch list.
404    pub(crate) game_damage_rects: Vec<Rect>,
405    /// Reusable active `GameEngineHost` index scratch list.
406    pub(crate) active_host_indices: Vec<usize>,
407    /// Reusable clipped scroll container `(node_id, old_bounds)` list whose `DIRTY_SUBTREE_LAYOUT` bit is temporarily stashed during paint-damage collection.
408    pub(crate) stashed_scroll_nodes: Vec<(NodeId, Rect)>,
409    /// Reusable UI event callback queue avoiding per-pointer-move and per-scroll `Vec` allocations.
410    #[debug(skip)]
411    pub(crate) callbacks: Vec<(UiEventHandler, UiEvent)>,
412}
413
414/// Per-node scroll-chain evaluation step separating standard scroll, virtual scroll, parent traversal, and chaining blocks.
415#[derive(Clone, Copy, Debug, Default)]
416pub(crate) struct ScrollStepOutcome {
417    /// Standard scroll update `(next_offset, consumed_x, consumed_y)`.
418    pub(crate) std_update: Option<(Point, f32, f32)>,
419    /// Virtual scroll update `(next_virtual_y, total_virtual_h, consumed_y)`.
420    pub(crate) virtual_update: Option<(f32, f32, f32)>,
421    /// True when `next_parent_id` holds a valid ancestor along the scroll chain.
422    pub(crate) has_next_parent: bool,
423    /// Next ancestor node handle along the scroll chain when `has_next_parent` is `true`.
424    pub(crate) next_parent_id: NodeId,
425    /// True when this node blocks scroll chaining to outer ancestors.
426    pub(crate) blocks_scroll: bool,
427}
428
429/// Fused single-borrow pre-tick snapshot collected at the start of `App::step_frame`.
430#[derive(Clone, Copy, Debug, Default)]
431pub(crate) struct FramePreTick {
432    /// Whether a live `NodeKind::Input` currently holds keyboard focus.
433    pub(crate) has_focused_input: bool,
434    /// Whether `ime_node_id` holds a visible non-disabled input node requesting OS IME presentation.
435    pub(crate) has_ime_node: bool,
436    /// Focused input node handle requesting OS IME presentation when `has_ime_node` is `true`.
437    pub(crate) ime_node_id: NodeId,
438    /// Screen-space logical bounds of `ime_node_id`.
439    pub(crate) ime_rect: Rect,
440    /// Resolved frame animation timestep in seconds.
441    pub(crate) step_dt: f32,
442    /// Whether one or more `NodeTransition`s ticked inside the fused borrow.
443    pub(crate) anim_ticked: bool,
444    /// Whether active transitions were deferred until after `GameEngineHost::step`.
445    pub(crate) pending_game_transitions: bool,
446}
447
448/// Stack-first ancestor chain buffer avoiding heap allocations up to 32 tree levels deep.
449#[derive(Debug)]
450pub(crate) struct AncestorChain {
451    /// Inline stack buffer holding the first 32 ancestors (leaf first).
452    pub(crate) inline: [NodeId; 32],
453    /// Number of valid entries in `inline` when `spill` is empty.
454    pub(crate) len: usize,
455    /// Heap overflow buffer used only when ancestor depth exceeds 32.
456    pub(crate) spill: Vec<NodeId>,
457}