brainy/tests/unit/utils
David Snelling e47fea0917 feat(8.0): EntityIdMapper U32 ceiling + EntityIdSpaceExceeded error
The JS fallback EntityIdMapper caps at u32::MAX to match the metadata
index's Roaring32 bitmap width. Before this guard, a brain past 4.29 B
entities would silently widen `nextId` into JS's safe-integer range,
truncating ints inside the bitmaps and zeroing query results — the
same silent under-count cortex 3.0's Piece 10 just closed on the
native path. Brainy 8.0 surfaces the overflow loudly instead.

When `nextId` would exceed `U32_ENTITY_ID_MAX`, `getOrAssign` throws
`EntityIdSpaceExceeded` with a message pointing at the cortex 3.0
binary mapper's `idSpace: 'u64'` mode as the migration path (mmap-
backed extendible-hash KV, persists the full u64 range losslessly).

The existing-UUID lookup path bypasses the guard — only fresh
allocations can overflow.

Surfaces via `@soulcraft/brainy/internals`:
- `EntityIdMapper` (already exported, behavior gated)
- `EntityIdSpaceExceeded` (new)
- `U32_ENTITY_ID_MAX` (new constant, = 0xFFFF_FFFF)

This is the lockstep half of cortex 3.0 / Piece 10 / Step 15. Cortex's
`NativeBinaryEntityIdMapperWrapper` ships the U64 binary mapper that
takes over above this ceiling; brainy ships the bright-line failure
that points consumers at it.

New test: tests/unit/utils/entity-id-mapper-u32-ceiling.test.ts (6
assertions covering the constant, the error shape, normal
allocations, the boundary case at exactly u32::MAX, the overflow
throw, and the existing-uuid lookup bypass).
2026-06-02 10:20:01 -07:00
..
collation.test.ts fix: deterministic code-point string collation for column store + aggregation 2026-05-26 17:35:18 -07:00
contentExtractor.test.ts feat: expand ContentCategory to universal 6-category set for highlight() 2026-01-27 13:44:58 -08:00
entity-id-mapper-stability.test.ts feat: mmap-vector backend wiring — HNSWIndex consumes vectorStore:mmap (2.4.0 #2) 2026-05-28 10:37:47 -07:00
entity-id-mapper-u32-ceiling.test.ts feat(8.0): EntityIdMapper U32 ceiling + EntityIdSpaceExceeded error 2026-06-02 10:20:01 -07:00
memoryLimits.test.ts feat: COW always-on architecture + cloud storage clear() fix (v5.11.0) 2025-11-18 13:44:02 -08:00
metadataIndex-text-indexing.test.ts feat: add structured content extraction and batch embedding optimization to highlight() 2026-01-27 10:27:22 -08:00
metadataIndex-type-aware.test.ts fix: eliminate flaky test timeouts and add storage adapters guide 2026-01-31 09:11:20 -08:00
mutex.test.ts feat: add distributed architecture with sharding and coordination 2025-09-22 15:45:35 -07:00
paramValidation.test.ts fix: resolve 10 test failures across clustering, metadata, and deletion 2025-10-09 16:33:08 -07:00
resultRanking.test.ts feat: hook native sort:topK provider into search result ranking 2026-05-27 13:13:47 -07:00
roaring-bitmap-integration.test.ts fix: migrate from roaring (native C++) to roaring-wasm for universal compatibility 2025-10-14 10:24:59 -07:00
unifiedCache-eviction.test.ts fix: correct cache eviction formula to prioritize high-value items 2025-10-13 11:21:19 -07:00
vectorQuantization-sq4.test.ts feat: SQ4 (4-bit) scalar quantization + native distance hook (2.5.0 #30) 2026-05-28 12:27:10 -07:00