2.7 KiB
2.7 KiB
Data Exact 64-Bit Signed/Unsigned JSON Numbers and Checked Conversion
Task ID: M-DATA-02 Phase: P1 Status: APPROVED Contracts: C-01, C-05, C-07
1. Context and baseline
include/Void/Data/Json.hpp currently stores all numbers as double, silently rounding integers above 2^53 through parse, DOM construction, equality, serialization, SAX events, and Reflect.hpp. StrictJson (Void::Json::Strict::Value) is already signed int64_t and must remain completely unchanged (C-07).
2. Deliverables
src/Data/module.cmakeupdated toINTERNAL_DEPS Core Math Time.- Extended
include/Void/Data/Json.hpp:NumberKind,ConversionError,int64_t/uint64_t/doublevariant alternatives, unambiguous integral/float constructors,is_int/is_uint/is_double/is_integer/number_kind/as_uint/get_int/get_uint,number_as<T>delegating toVoid::Numeric::checked_cast, exact cross-typeoperator==, strict RFC 8259 numeric grammar parsing (256-byte limit,-0-> integer0,-0.0preserved as negative double), optionalSaxHandler::{on_int,on_uint}retainingon_numbercompatibility, exactstd::to_charsserialization +try_serialize. - Updated
include/Void/Data/Reflect.hpp(exact integerleaf_to_json,number_as<T>inleaf_from_jsonand versioned envelopes) andinclude/Void/Configuration/Config.hpp(exact integer stringification). - Expanded tests in
tests/standalone/Data/{Json,Reflect}.cpp;StrictJson.hppandtests/standalone/Data/StrictJson.cppuntouched.
3. Exact files and interfaces
src/Data/module.cmakeinclude/Void/Data/Json.hppinclude/Void/Data/Reflect.hppinclude/Void/Configuration/Config.hpptests/standalone/Data/{Json,Reflect}.cpp
4. Edge cases
INT64_MIN,INT64_MAX,UINT64_MAX, and2^53 ± 1survive parse, serialize, equality, and reflection round trips without silent rounding; integers< INT64_MINor> UINT64_MAXfail parsing.Value{UINT64_MAX} != Value{static_cast<double>(UINT64_MAX)}andValue{(std::uint64_t{1} << 53) + 1} != Value{static_cast<double>(1ULL << 53)}.number_as<double>rejects2^53 + 1withRounding::exact, succeeds with explicitRounding::nearest_even;try_serializerejectsNaN/InfwithError::NonFinite.
5. Acceptance criteria
Data;Update;Configuration;Testingsuites (Json*|StrictJson*|Reflect*|Update*|Config*) pass under-DVOID_WARNINGS_AS_ERRORS=ONwithout modifyingStrictJson.
6. Verification commands
dev cpp-gcc -p openssl -c bash -lc 'cmake -S . -B /tmp/void-p1-data -G Ninja -DVOID_ENABLED_MODULES="Data;Update;Configuration;Testing" -DVOID_WARNINGS_AS_ERRORS=ON && cmake --build /tmp/void-p1-data && /tmp/void-p1-data/tests/VoidTests --filter "Json*|StrictJson*|Reflect*|Update*|Config*"'