Files

2.6 KiB

Core Standalone UUID, Checked Bits, and Portable Hash

Task IDs: M-CORE-02, M-CORE-03 Phase: P1 Status: APPROVED Contracts: C-01, C-02, C-05

1. Context and baseline

include/Void/Core/Uuid.hpp currently includes <Void/Math/Random.hpp> (an undeclared dependency leak violating C-01), allocates temporary std::string objects in parse() and v5_lite(), and marks v4() unconditionally noexcept. include/Void/Core/Bits.hpp lacks checked boundary variants, and include/Void/Core/Hash.hpp uses __builtin_memcpy in murmur3_32.

2. Deliverables

  • Portable incremental/constexpr extensions in include/Void/Core/Hash.hpp.
  • Zero-Math, zero-allocation Uuid APIs in include/Void/Core/Uuid.hpp.
  • include/Void/Core/CheckedBits.hpp (checked_extract, checked_deposit, checked_align_up, checked_align_down).
  • Expanded unit tests in tests/standalone/Core/{Uuid,Bits,Hash}.cpp and isolated installed consumer tests/package/CoreOnly.

3. Exact files and interfaces

  • include/Void/Core/Hash.hpp: fnv1a64_offset_basis, fnv1a64_update, crc32_initial, crc32_update, crc32_finalize; endian-portable constexpr murmur3_32.
  • include/Void/Core/Uuid.hpp: remove <Void/Math/Random.hpp> and <format>; add GenerateError, v4(G&), try_v4() noexcept, throwing v4(), constexpr format_chars, constexpr zero-alloc parse, zero-alloc byte-identical v5_lite.
  • include/Void/Core/CheckedBits.hpp: BitError { invalid_range, invalid_alignment, overflow }, checked_extract, checked_deposit, checked_align_up, checked_align_down.
  • tests/package/CoreOnly/{CMakeLists.txt,main.cpp}, tests/package/InstalledComponents.cmake.

4. Edge cases

  • checked_extract/checked_deposit: offset = width, count = 0, count = width, offset + count integer overflow.
  • checked_align_up: alignment = 0, non-power-of-two, value = MAX overflow.
  • Uuid::v5_lite: golden byte-for-byte equivalence with 1.x ns.bytes + name hash output.
  • Throwing custom URBG propagates out of v4(G&); try_v4() converts random_device failure without returning nil.

5. Acceptance criteria

  • -DVOID_ENABLED_MODULES=Core -DVOID_ENABLE_TESTING=OFF installs and runs CoreOnly with all external packages disabled and no Math dependency.
  • Core tests pass with -DVOID_WARNINGS_AS_ERRORS=ON and ASan/UBSan.

6. Verification commands

dev cpp-gcc -c cmake -S . -B /tmp/void-p1-core -G Ninja -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Debug -DVOID_ENABLED_MODULES="Core;Testing" -DVOID_WARNINGS_AS_ERRORS=ON
dev cpp-gcc -c cmake --build /tmp/void-p1-core --parallel 4
dev cpp-gcc -c /tmp/void-p1-core/tests/VoidTests --filter "Uuid*|Bits*|Hash*"