From 6f087cb53c2af4b9958905a734266170cd3135ae Mon Sep 17 00:00:00 2001 From: hobbyistz <293619914+hobbyistz@users.noreply.github.com> Date: Tue, 22 Sep 2026 17:31:27 -0400 Subject: [PATCH] test: allow one unit of published precision when re-deriving weights The live weight check re-derives each published weight from the published scores and attendance factors and demanded exact equality at six decimals. Those inputs are themselves published rounded to nine decimals, while the producer rounded its own unrounded result, so a re-derived weight can land a hair across a six-decimal boundary. Tolerate one unit of the published precision; a formula or input error is orders of magnitude larger. Signed-off-by: hobbyistz <293619914+hobbyistz@users.noreply.github.com> --- tests/live/test_attendance_live.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/live/test_attendance_live.py b/tests/live/test_attendance_live.py index e0ca392..72e3a91 100644 --- a/tests/live/test_attendance_live.py +++ b/tests/live/test_attendance_live.py @@ -133,7 +133,11 @@ def test_published_weights_re_derive_from_the_published_inputs(sku, live_days): """The port's acceptance check: softmax(gamma*Q + eta*ln A) with attendance-scaled ceilings and collapsing floors, run over the published Q and A under the published liveness params, must - reproduce every published weight EXACTLY at the published 6dp. + reproduce every published weight to within one unit of the published + 6dp. The inputs are themselves published rounded (Q and A at 9dp) + while the producer rounded its own unrounded result, so a re-derived + weight can land a hair across a 6dp boundary; a formula or input + error shows up orders of magnitude larger than that. The domain is the producer's CURRENT allocation set: ordinary rows plus provider-side no-price carries. A collection-failure carry @@ -175,7 +179,7 @@ def test_published_weights_re_derive_from_the_published_inputs(sku, live_days): attendance_eta=float(liveness["attendance_eta"]), ) for sid, receipt in domain.items(): - assert round(weights[sid], 6) == receipt["weight"], ( + assert abs(weights[sid] - receipt["weight"]) <= 1e-6 + 1e-9, ( f"{sku} {observation['observed_at']} {sid}: published weight " f"{receipt['weight']} but re-derived {round(weights[sid], 6)} " f"from Q={scores[sid]} A={factors[sid]} under "