Files
logos-cpp-sdk/cpp-generator
Dario LipicarandClaude Opus 5 ff8c3003a4 fix(cdylib): typed scalars go through the codec, and the emitted codec checks signedness (#115)
* fix(cdylib): typed scalars go through the codec, and the codec checks signedness

The cdylib dispatch decoded composites with the generated codec but scalars with
a bare nlohmann accessor. Two silent conversions lived in that gap:

    echoUint(-1)   -> 18446744073709551615   (.get<uint64_t>() wraps)
    echoInt(3.7)   -> 3                      (.get<int64_t>() truncates)

The Rust provider rejects both. So a contract both providers share answered
differently depending on which one a consumer resolved to, and one of the two
answers was a sign flip on a nominal value.

The reason this was left in place was circular, and it was written in the source:
the leniency "is pinned by the conformance matrix (`hostile/int/fractional`
expects 3 from 3.7 on this provider)". Those cells exist to DOCUMENT the
divergence — their own `why` text says the strict behaviour is correct. The
expectations moved with this change.

TWO sites, because fixing one relocates the bug rather than closing it:

  * jsonArgToStd no longer special-cases int/uint/float64/bool/tstr — everything
    typed goes through Codec<T>. `any` still passes through, since it declares
    nothing to check against; bstr keeps its tagged-bytes decoder.

  * the EMITTED codec (this generator writes its own copy into <name>_types.h,
    separate from logos_codec.h) gated integers on `is_number()`, which admits
    floats AND negatives. Routing scalars into it without fixing it would have
    changed nothing. The integer specializations are now spelled out rather than
    driven from the scalar table, because a category check is not enough for them.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* chore: bump logos-protocol to the signedness + sentinel fixes

logos-protocol c0df466 (#31):
  * Codec<T> checks integer signedness and range, so a negative can no longer
    wrap into an unsigned and a wide value can no longer truncate.
  * the pending-call sentinel is matched by shape rather than key presence, so
    a user map merely carrying that key no longer hangs the call.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-07-29 12:13:30 -03:00
..