-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Milestone
Description
Problem / Motivation
Raw deserialization of floating-point values can bypass runtime invariants if not carefully guarded. For example, a serialized -0.0 or non-canonical NaN could
be loaded directly into memory, violating the strict determinism guarantees required for Echo's simulation loop. We must ensure that no path exists to
instantiate an F32Scalar without passing through the canonicalization logic.
Proposal / Scope
- Guard Deserialization: Verify that the serde::Deserialize implementation for F32Scalar strictly routes all inputs through F32Scalar::new() to apply canonicalization (mapping -0.0 to +0.0, sanitizing NaNs).
- Forbid Zerocopy: Explicitly ensure/document that F32Scalar does not implement zerocopy::FromBytes or similar traits that allow reinterpret casts from raw bytes.
- Verify Guard: Enable and pass test_policy_serialization_guard in crates/rmg-core/tests/determinism_policy_tests.rs to prove that deserializing a "bad" payload (e.g., -0.0) results in a clean +0.0 instance in memory.
Related Docs/Issues/PRs
- docs/SPEC_DETERMINISTIC_MATH.md (Policy 2: Zerocopy & Serialization)
- task: Flush subnormals #118, task: Canonicalize
-0.0#117, feat: F32Scalar and Nan, -NaN #128
Metadata
Metadata
Assignees
Labels
Projects
Status
Open