Skip to content

Feature/new tiered int - #11

Merged
NikolayChirkov merged 56 commits into
mainfrom
feature/new-tiered-int
Aug 25, 2026
Merged

Feature/new tiered int#11
NikolayChirkov merged 56 commits into
mainfrom
feature/new-tiered-int

Conversation

@NikolayChirkov

Copy link
Copy Markdown
Collaborator

No description provided.

NikolayChirkov and others added 27 commits June 27, 2026 16:20
Switch to TieredInt<StartSize, tierMax...> with buffer and stream serialization, restore comparison operators and std traits, and update tests for the new encoding.

Co-authored-by: Cursor <cursoragent@cursor.com>
Partial deserialization is no longer needed now that DeserializeFrom reads the full encoded value in one pass.

Co-authored-by: Cursor <cursoragent@cursor.com>
Base cell width (1, 2, or 4 bytes) now drives minimum encoded size and tier multipliers, with compile-time validation and tests for StartSize 2 and 4.

Co-authored-by: Cursor <cursoragent@cursor.com>
Select runtime storage from kMaxEncodable, enforce compile-time assignment bounds with if consteval, and fix test includes for libc++ Clang 20.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use StartSize * 2^(NumTiers-1) instead of a global StartSize*8 cap, enforce
the 8-byte wire limit at compile time, and add size static_asserts for all
test TieredInt aliases.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover every tier boundary where serialized size increases, plus kUpper
at kMaxWireBytes for T1–T6 via buffer and stream round-trips.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use TieredInt<std::uint16_t, ...> / std::int16_t instead of int StartSize,
keep TieredIntFromStartSize aliases, and implement native signed LE encoding
with tier-1 direct values and sign-bit negative overflow.

Co-authored-by: Cursor <cursoragent@cursor.com>
Compare signed and unsigned inputs in separate branches using int64_t
and uint64_t respectively, and add a compile-time T6 kUpper assignment test.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign was incorrectly stored in the header MSB, colliding with large positive overflow headers; encode signed values via ZigZag and reuse the unsigned tier path.

Co-authored-by: Cursor <cursoragent@cursor.com>
Split check_value by signedness before casting, require buffer length in Deserialize, and add signed 3/4-tier tests including extremes above 2^31.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add saturated single-cell mode when the first wire tier fills the header, use safe mixed signed/unsigned compare, propagate cxx_std_23 on the numeric target, and return FixedPoint::Cast by value.

Co-authored-by: Cursor <cursoragent@cursor.com>
Provide a lazy input-iterator view for variable-length TieredInt wire data and throw on truncated deserialize instead of asserting at runtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
Drop the old Q-format API and AE_FIXED macros in favor of compile-time
range mapping, integer-only runtime arithmetic, and numeric_traits support.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add BoundRatio for compile-time bound conversion, cross-type Cast, multiply/divide,
and min/max/clamp helpers; default tests to MacPorts Clang 20.

Co-authored-by: Cursor <cursoragent@cursor.com>
Max is now a required logical bound with compile-time kScaleExp selection; add/sub, cast, and div_to use shift-based integer arithmetic only.

Co-authored-by: Cursor <cursoragent@cursor.com>
Exponential stores wire codes with compile-time magnitude tables; text_io adds to_chars/FromString for TieredInt, FixedPoint, and Exponential without runtime float.

Co-authored-by: Cursor <cursoragent@cursor.com>
wire_traits and Serialize/Deserialize cover built-in integers, TieredInt, FixedPoint, and Exponential with short-buffer rejection via std::out_of_range.

Co-authored-by: Cursor <cursoragent@cursor.com>
Introduce runtime_numeric_traits with opt-in float/double backend, default BoundaryCode to Wire kRawMax, split exponential wire IO from core headers, and extend wire/type-size tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Require extension header space and compile-time boundary checks, remove saturated single-cell mode and start-size aliases, and add stack-buffer ostream printing for TieredInt and FixedPoint.

Co-authored-by: Cursor <cursoragent@cursor.com>
Make ordinary numeric construction logical-valued and compile-time
checked for constants, preventing silent runtime clamping through the
normal constructor:

- FixedPoint: consteval integral/floating constructors with compile-time
  range checks; explicit runtime APIs FromRuntimeInteger/Saturating/
  TryFromRuntimeInteger for clamping or checked conversion.
- Exponential: logical-value consteval constructors (integer range
  checked, float consteval-only), explicit FromCode/Code raw-code
  construction, value() accessor, and runtime conversion APIs. Wire IO
  deserializes via FromCode.
- Add compile-fail tests verifying out-of-range constants and runtime
  float construction are rejected at compile time.

Co-authored-by: Cursor <cursoragent@cursor.com>
PackedRing<T, StorageBytes> is a byte ring that stores serialized T
values back to back, with no per-record length headers. It relies on T
being self-delimiting on the wire: the bytes_read reported by
Deserialize is enough to skip from one record to the next.

- Index types (head/tail/used/count) use SmallestUIntForSize<StorageBytes>
  rather than std::size_t.
- push evicts the oldest records until a value fits, or fails if the
  value alone exceeds capacity. Records may straddle the physical buffer
  end; reads reassemble them through a stack buffer before decoding.
- Iterator yields decoded T values by value, never by reference.
- FixedPoint serializes/skips its raw value and Exponential its code(),
  reusing the existing wire_traits, so the ring needs no per-type code.
- Add wire_io SerializedSizeAt<T> to report a record's byte length.
- Tests cover TieredInt/FixedPoint/Exponential payloads, eviction,
  wraparound, and the index type selection.

Co-authored-by: Cursor <cursoragent@cursor.com>
Verify FixedPoint<TieredInt>, Exponential variants, and PackedRing
composition through wire round-trips, ring behavior, and trait checks.
Split Exponential-heavy tests into separate files to keep compile times
practical; FutureCode Exponential tests use an explicit BoundaryCode
because the default kRawMax would build an enormous magnitude table.

Co-authored-by: Cursor <cursoragent@cursor.com>
Add fixed_math primitives and rewrite encode/decode to use arithmetic mapping
with safe DefaultBoundaryCode, avoiding compile-time tables proportional to
BoundaryCode. Update Exponential and composed tests for two-byte wire ranges.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace hardcoded log/exp iteration counts and work types with ExponentialMathPolicy, fix encode rounding, and add policy and boundary tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
Clamp raw values in int64 space before rep cast, divide wide multiply products in the intermediate type, and strengthen policy boundary tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
- make integral FixedPoint operator+ consteval
- remove GCC -Wtype-limits test warnings
- verify GCC, Clang and MSVC builds
Comment thread CMakeLists.txt Outdated
Comment thread numeric/tiered_int.h Outdated
NikolayChirkov and others added 8 commits June 30, 2026 11:36
Co-authored-by: Cursor <cursoragent@cursor.com>
Use windows-latest, Visual Studio 18 2026 with -A x64, unified configure/build/test steps, and the same MSVC/MinGW environment setup as aether-client-cpp.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Merge remote README rewrite and document kMaxBoundaryCode default.

Co-authored-by: Cursor <cursoragent@cursor.com>
@NikolayChirkov

Copy link
Copy Markdown
Collaborator Author

Anton, please re-review when you have a chance.

I addressed the previous review comments and did an additional pass across the changed code, not only on the exact commented lines:

  • kept the project at C++20;
  • removed C++23-only usage;
  • kept numeric core exception-free: no throw / stdexcept in numeric core;
  • fixed constexpr validation so it works on GCC/MinGW without diagnostic pragma tricks;
  • kept -fno-exceptions compatibility;
  • restored required CI check names;
  • kept MSVC on Visual Studio generator;
  • removed duplicated workflow build/test steps where possible;
  • applied kCamelCase for ordinary static constexpr members, while keeping STL-like value/type in traits;
  • changed byte counts to std::size_t;
  • replaced SFINAE-style stream checks with requires/concepts;
  • added noexcept where safe;
  • applied CamelCase function naming and east const in touched numeric code;
  • updated assertions/preconditions where invalid use is a contract violation.

CI is green now.

I also rewrote the README manually after the API/documentation changes:

  • clarified TieredInt serialization tiers and chunk sizes;
  • fixed the wrong “first template parameter is the wire cell type” explanation;
  • documented FixedPoint scale placement, including cases where the binary point is far outside the raw storage type;
  • removed old local compiler paths from build docs;
  • moved Exponential-over-TieredInt examples into Combined Types;
  • added practical packed-size examples for payload sizes, latency exponential codes, and linear ping FixedPoint over TieredInt.

Please take another look.

Comment thread numeric/exponential.h Outdated
Comment thread numeric/exponential.h Outdated
Comment thread numeric/exponential.h Outdated
Comment thread numeric/exponential.h Outdated
Comment thread ae-numeric/exponential.h
Comment thread numeric/fixed_point.h Outdated
Comment thread numeric/wire_io.h Outdated
Comment thread numeric/packed_ring.h Outdated
Comment thread numeric/packed_ring.h Outdated
Comment thread numeric/packed_ring.h Outdated
Comment thread numeric/packed_ring.h Outdated
@NikolayChirkov

Copy link
Copy Markdown
Collaborator Author

@BartolomeyKant, please re-review when you have a chance.

I addressed the latest comments and applied the same cleanup across analogous code:

  • renamed the CMake target and public include root from numeric to ae-numeric, so public includes are now #include <ae-numeric/...>;
  • updated install rules, README examples, tests, and the cpplint CI path accordingly;
  • replaced DeserializeResult::BytesRead with bytes_read;
  • rewrote the Exponential floating conversion through FloatingWorkCodec, FloatingToWork, and WorkToFloating, using fixed-width integer bit arithmetic;
  • replaced the FixedPoint PromoteRep specialization table with generic integral promotion, including mixed signedness handling, while preserving same-rep support for packed reps;
  • optimized PackedRing wrap copies with std::span plus memcpy and removed ordinal-only iterator comparison;
  • kept the code C++20 and exception-free.

Local checks passed with MacPorts Clang 20.1.8 and CMAKE_OSX_DEPLOYMENT_TARGET=13.3:

  • cmake --build build-mp-clang20-macos13.3-ae --config Debug --parallel;
  • ctest --test-dir build-mp-clang20-macos13.3-ae --output-on-failure - 5/5 passed;
  • cpplint --recursive ./ae-numeric.

GitHub Actions are green for fc29c6d: cpplint, Ubuntu GCC, macOS Apple-Clang, Windows MinGW, and Windows MSVC.

@BartolomeyKant BartolomeyKant left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reread previous comments. Do not rewrite code just to pretend something is changed.
@NikolayChirkov your AI start hallucinating, validate what you're pushing.

NikolayChirkov and others added 4 commits August 24, 2026 08:40
C++23 if consteval discarded the runtime branch; with is_constant_evaluated both branches are ODR-used, so provide a non-constexpr definition that still fails constant evaluation.

Co-authored-by: Cursor <cursoragent@cursor.com>
Share common uint64 helpers in integer_math.h and add direct boundary,
exhaustive, and coverage tests for the new arithmetic paths.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Prove TieredInt<uint8_t,250,1514,1049834> matches historical packet/API size encoding byte-for-byte across the legacy domain.

Co-authored-by: Cursor <cursoragent@cursor.com>

Copy link
Copy Markdown
Collaborator Author

@BartolomeyKant I re-validated every open review thread against the current HEAD b82a367 and replied to each one individually with the actual current state.

Verified now:

  • strict C++20; the former if consteval path is gone;
  • GCC, Clang, and MSVC no-exceptions builds pass;
  • current GitHub Actions run is green;
  • fixed-width types are used for bit manipulation;
  • FloatingWorkCodec<float> / FloatingWorkCodec<double> and generic conversion wrappers are present;
  • mixed-signedness FixedPoint promotion is handled by numeric digit range, not sizeof alone;
  • PackedRing uses std::span plus memcpy, and iterator equality uses pos_ rather than an ordinal;
  • legacy TieredInt wire compatibility is covered by golden, exhaustive, randomized, and cross-decode tests;
  • downstream aether-tele and aether-client-cpp migrations are green and preserve existing wire bytes.

I also called out the two remaining style nuances rather than claiming they were changed: the internal helper kWordPow is still misnamed as a function, and STL-style trait/type aliases intentionally remain lowercase. I have not resolved the review threads; please re-review the current diff when convenient.

Restructure DeserializeUnsignedMagnitude if-constexpr/else so MSVC /WX
no longer sees unreachable fallback code, and add minimal ValueType
addition with range checks for tele arithmetic call sites.

@BartolomeyKant BartolomeyKant left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issues in aether-tele should be fixed in this repository

Comment thread ae-numeric/fixed_math.h Outdated
Comment thread ae-numeric/text_io.h Outdated
Comment thread CMakeLists.txt Outdated
Comment thread tests/CMakeLists.txt Outdated
Co-authored-by: Cursor <cursoragent@cursor.com>
@NikolayChirkov
NikolayChirkov merged commit 2723cb0 into main Aug 25, 2026
5 checks passed
@NikolayChirkov
NikolayChirkov deleted the feature/new-tiered-int branch August 25, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants