fix(render-core): harden template deserialization for floats and isolate scene inheritance #53
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 320 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.345
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #53"
general
weight: 0.35
walkersutton
## Summary
Hardens template deserialization for coordinates and dimensions across all element types so floating-point numbers parse cleanly (rounded to the nearest integer) with range and finiteness checks, adds load-time migration for legacy box elements omitting explicit width and height, and isolates scene inheritance to styling attributes.
Note on TODOS.md P0: The pre-existing test
render::frame::tests::layer_order_honors_explicit_ids_then_array_orderwas verified passing on main. This PR addresses the broader schema vulnerability by ensuring that floating-point numbers produced by hand-editing or AI prompt generators do not cause serde deserialization failures.Key Changes
1. Visitor-based flexible numeric deserialization: Replaced untagged enum deserialization with zero-buffering
Visitorimplementations (FlexibleI32VisitorandFlexibleU32Visitor) and typed newtype wrappers (FlexibleI32,FlexibleU32). Out-of-range floats and invalid types produce clean, precise deserialization errors.2. Backward-compatible dimension migration: Added load-time migration
migrate_legacy_element_dimensionsinTemplate::from_value_scaled. Any legacy box element (rect, plot, meter, gauge, image) lacking explicitwidthorheightinherits them from the scene canvas, ensuring older saved and AI-generated templates (like full-canvas background rects) load without error.3. Targeted scene inheritance: Restricted
merge_scene_into_itemto inheritable styling attributes (font,color,opacity,font_size,decimal_rounding). Prevents leaking scene-only metadata (start,end,layers,groups,vars,fps,lap_gate) into element configs.4. Comprehensive test coverage:
-
template_parses_with_float_dimensions_and_coordinates: Expanded to assert on all element types (label, value, plot, meter, rect, gauge, image).-
scene_inheritance_does_not_leak_scene_metadata: Hardened to assert directly on raw JSON values, proving that scene metadata does not leak into child elements.-
legacy_element_without_dimensions_migrates_scene_dimensions: Verifies that box elements without explicit dimensions inherit scene canvas dimensions.-
lap_gate_flexible_total_laps_deserializes: Verifies flexible float parsing forLapGateConfig.total_laps.-
out_of_range_float_fails_deserialization: Verifies that out-of-range floats fail deserialization with descriptive errors.Verification