Repository navigation
dbc: accept json.Number through shar 8000 ed scalar conversions - #86
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4dfbed8f4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6fc39f2 to
1d6ef67
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Values decoded with json.Decoder.UseNumber() currently reach DBC encoding as string labels. Recognise json.Number in the existing scalar helpers so Encode, EncodePayload and Patch accept numeric JSON inputs; the shared CDD codec gains the same support for numeric fields and arrays.
Unscaled integer conversions preserve the full signed/unsigned 64-bit range and accept equivalent decimal and exponent forms. Plain integers use Int64/strconv.ParseUint. Decimal/exponent forms use math/big.Rat after a cheap float magnitude check rejects overflow and nonzero magnitudes below one; zero mantissas bypass rational parsing. The approximate magnitude never supplies the integer result, so fractional and out-of-range values still fail exact checks, including around rounded 64-bit boundaries.
Scaled and floating-point conversions validate JSON syntax and use Number.Float64(), accepting normal rounding and underflow to zero while rejecting overflow. Huge-exponent zero literals and negative zero are supported. Existing range and quantisation rules remain in place. Ordinary strings retain label/text semantics; json.Number is always numeric, including in CDD ASCII-field validation. No dependencies or public API signatures added.
Validation: full go test -race ./..., go vet ./..., formatting and diff checks passed. Windows amd64, arm64 and 386 compilation passed; Windows binaries were not executed. Focused scalar and DBC/CDD lifecycle tests cover UseNumber input, fixed payload bytes, integer boundaries, decimal/exponent forms, malformed literals, huge-exponent zero, float underflow/rounding, and unchanged frames after rejected patches.
Temporary microbenchmarks on Apple M4 / Go 1.26.6, two 100 ms samples per case, compared the initial PR with this revision:
The exact exponent fallback pays a small cost for the magnitude check; ordinary integers and floating-point inputs avoid rational parsing.