Repository navigation
feat(json): emit Decimals as exact number literals (frontend-decimal epic, step A) - #215
Merged
Merged
Conversation
…epic, step A) The JSON provider serialized every Decimal via float() (core/charts.py), so monetary values crossed the wire as lossy float64 — visible to raw API consumers, exports, and high-precision values, and it leaked custom/budget amounts as float (R8). Switch dumps to simplejson with use_decimal=True: Decimals now emit as exact number literals (100.00, 88.571428571428571428571428571, ...). This is: - exact on the wire — a decimal-aware consumer recovers the exact value; - R8 fixed — custom amount values are exact, matching Balance/Price; - transparent to the frontend — the literals are valid JSON numbers, so JSON.parse still reads them (as float64 for display); no frontend change and no snapshot churn (the snapshot fixture re-parses to float before comparing). loads stays stdlib json (request parsing unaffected). The residual float64 narrowing on a plain-JSON.parse read is the frontend-decimal step (step B), tracked separately. Adds simplejson as a core dep + types-simplejson stub. test_number_precision_boundary rewritten: every value now crosses the wire exactly (the old high-precision xfail flips), with a test documenting the remaining float-parse narrowing on the read side.
This was referenced Jul 1, 2026
robcohen
added a commit
that referenced
this pull request
Jul 4, 2026
#239) * fix(desktop): install real project deps; smoke test the frozen sidecar Fixes #233. The sidecar build pip-installed a hand-maintained package list that drifted from pyproject.toml twice: simplejson (core since #215, imported at charts.py:16 in the startup chain) and wasmtime (core since the component engine became the only backend; the list's comment still called it an optional extra). Result: the v1.31.0 desktop sidecar crashed on startup on every platform, and nothing in the pipeline ever executed the binary to notice. - Install `pyinstaller .` so the frozen build gets exactly pyproject's dependencies; the drift class is gone. - Add a functional smoke step to the matrix: run the frozen sidecar against a mini ledger and require an HTTP response. Catches the #233 failure class (missing bundled module, startup crash) on all four platforms before release, including the Rosetta x64 binary. * fix(desktop): build wheel with uv, install with arch-pinned pip All four runners reproduced the pip BackendUnavailable against the custom build backend (same as local). uv drives the backend fine, so: uv builds the pure-Python wheel natively (arch-independent), then the arch-pinned pip installs the wheel, keeping dependency resolution under the target arch for the Rosetta x64 build. * fix(desktop): bundle wasmtime's platform dynlib; smoke the engine path Round 2's smoke caught the next layer on all four platforms: the sidecar started but every engine call 500'd because PyInstaller never bundled wasmtime's _libwasmtime native library (leading-underscore name in a platform subdir defeats collect_dynamic_libs' default lib*.so pattern; explicit patterns fix it — verified present in the local build TOC). The smoke step now also requires an engine-backed API endpoint, so a Flask shell that starts without a working engine can never pass again. * fix(desktop): discover ledger slug from redirect in engine smoke Round 3 proved the dynlib fix (sidecar starts and serves everywhere); the engine probe 404'd only because the hardcoded slug guess was wrong. Derive the API URL from the / redirect instead, and log it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step A of the frontend-decimal epic — closes the wire half of C2 and fixes R8, and it landed far smaller than the original "regenerate 53 snapshots" estimate.
What
The JSON provider serialized every
Decimalviafloat()(core/charts.py), so monetary values crossed the wire as lossy float64. Switchdumpstosimplejsonwithuse_decimal=True→ Decimals emit as exact number literals (88.571428571428571428571428571instead of88.57142857142857).float()intermediate is gone.JSON.parsestill reads them (float64 for display, same as today). No frontend change, no snapshot churn (the snapshot fixture re-parses to float before comparing).Scope & verification
Diff is 3 files (
charts.py,pyproject.toml,uv.lock) + the boundary test. Full py suite 100% coverage, 544 passed; JS 86 pass;just mypyclean.test_number_precision_boundaryrewritten: every value now crosses the wire exactly (the old high-precisionxfailflips to passing), with one test documenting the residual — a plainJSON.parse/json.loadsread still narrows to float64.To weigh
simplejson(+types-simplejsonstub). It's the clean way to emit exact Decimal literals (stdlibjsoncan't — its C encoder ignores a float subclass's__repr__).loadsstays stdlibjson, so request parsing is unaffected.🤖 Generated with Claude Code