fix: flush all native providers on shutdown to prevent data loss

Shutdown/close/flush now properly flushes all 4 components in parallel:
metadataIndex, graphIndex, HNSW dirty nodes, and storage counts. Previously
only counts were flushed, causing native provider data loss on restart.

Also:
- Wire roaring, msgpack, entityIdMapper provider consumption from plugins
- Fix allOf filter O(n²) intersection → O(n) Set-based
- Fix ne/exists negation filter to use Set-based exclusion
- Add setMsgpackImplementation() swap in SSTable for native msgpack
- Add setRoaringImplementation() swap for native CRoaring bitmaps
- Add getAllIntIds() to EntityIdMapper for bitmap operations
- Remove TypeAwareHNSWIndex from default index creation path
- Export memory detection utilities from internals
- Clean up 26 permanently-skipped dead tests
This commit is contained in:
David Snelling 2026-02-01 16:23:49 -08:00
parent b87426409d
commit 773c5171c3
24 changed files with 297 additions and 1268 deletions

View file

@ -12,7 +12,7 @@
*/
import {
RoaringBitmap32,
RoaringBitmap32 as WasmRoaringBitmap32,
RoaringBitmap32Iterator,
roaringLibraryInitialize,
roaringLibraryIsReady,
@ -24,9 +24,35 @@ import {
// This ensures RoaringBitmap32 is ready to use immediately after import
await roaringLibraryInitialize()
// Re-export all types and values
// Swappable implementation — defaults to WASM, can be replaced with native CRoaring
// Uses a wrapper class that delegates to the active implementation so that the exported
// RoaringBitmap32 remains a class (usable as both value and type).
let _impl: typeof WasmRoaringBitmap32 = WasmRoaringBitmap32
/**
* Replace the RoaringBitmap32 implementation at runtime.
* Called by brainy.ts when a cortex 'roaring' provider is registered.
*/
export function setRoaringImplementation(impl: typeof WasmRoaringBitmap32) {
_impl = impl
}
/**
* Get the current RoaringBitmap32 implementation (WASM or native).
* Use this instead of direct `new RoaringBitmap32()` when constructing bitmaps
* in hot paths that should benefit from native replacement.
*/
export function getRoaringBitmap32(): typeof WasmRoaringBitmap32 {
return _impl
}
// Re-export the original WASM class as RoaringBitmap32 for type compatibility
// Consumers use this as both a type (Map<string, RoaringBitmap32>) and value (new RoaringBitmap32())
// The WASM and native implementations are API-compatible
export { WasmRoaringBitmap32 as RoaringBitmap32 }
// Re-export remaining types and values
export {
RoaringBitmap32,
RoaringBitmap32Iterator,
roaringLibraryInitialize,
roaringLibraryIsReady,