From 6c097bff1084d6172f7226e61406b25743e290d3 Mon Sep 17 00:00:00 2001 From: volt Date: Mon, 26 Oct 2026 20:05:45 +0000 Subject: [PATCH] volt: beam: Q82 -- json_canonical.py says it is not JCS and names the three measured divergences - the docstring said "RFC 8785-ish"; it now says NOT RFC 8785 (JCS) in those words, because the hedge only holds if the three readings are written down. - measured at this file (scratch/q82/floats.py, output in the closure record): -0.0 -> "-0.0" where RFC 8785 Table 1 gives "0"; 1e-06 -> "1e-06" where the table gives "0.000001"; 9007199254740993 -> "9007199254740993" where JCS's double-based maximum positive integer is 9007199254740992. - the docstring also states that sort_keys sorts by code point, not by UTF-16 code unit, so key order diverges from JCS above U+FFFF. - no behaviour change: the seven cells still pass and `bash wizard-work/beam/CHECK` is rc 0, Ran 198, the same number as the previous commit. CHECK: bash wizard-work/beam/CHECK | grep -q '^Ran 198 tests' && python3 -m unittest discover -s wizard-work/beam -p test_json_canonical.py --- wizard-work/beam/json_canonical.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wizard-work/beam/json_canonical.py b/wizard-work/beam/json_canonical.py index 5998392..4699aa6 100644 --- a/wizard-work/beam/json_canonical.py +++ b/wizard-work/beam/json_canonical.py @@ -1,5 +1,17 @@ -"""Canonical JSON serialization (RFC 8785-ish): sorted keys, compact separators, -no NaN/Infinity, deterministic float repr, UTF-8, ensure_ascii=False.""" +"""Canonical JSON serialization: sorted keys, compact separators, no NaN/Infinity, +deterministic float repr, UTF-8, ensure_ascii=False. + +NOT RFC 8785 (JCS), and not claimed to be. JCS is IEEE-754 double-based with its +own number grammar; this module emits Python's `repr` for floats and passes int +through unchanged. Three measured divergences from RFC 8785 Table 1: + + -0.0 -> "-0.0" (JCS: "0") + 1e-06 -> "1e-06" (JCS: "0.000001") + 2**53+1 -> "9007199254740993" (JCS max positive integer: 9007199254740992) + +Key order is `sort_keys=True`, i.e. by Unicode code point; JCS sorts by UTF-16 +code unit, so the two diverge above U+FFFF. +""" from __future__ import annotations import json import math