brainy/tests/unit/storage
David Snelling 6721c52ad7 fix: getNouns cursor pagination re-scanned the first page forever (permanent CPU loop)
The shard-scan pagination adapter is offset-based and ignored the cursor, so
getNouns({ pagination: { cursor } }) re-returned the first page on every cursor
call. Harmless until 7.32.1 made totalCount the true dataset total — after which
hasMore correctly stays true until a caller has paged through everything. A
caller that paginates by cursor (cursor = page.nextCursor) — notably aggregate
backfill over an already-populated store — then looped forever, re-walking the
entire entity shard tree each iteration and pegging 1-2 CPU cores permanently on
the JS main thread, with zero queries or traffic. (Pre-7.32.1 the same loop
ended after one page, silently backfilling only the first 500 entities — an
incomplete aggregate.)

getNouns() now treats the cursor as an opaque, advancing offset token, so cursor
pagination advances and terminates exactly like offset pagination — and an
aggregate backfill streams the whole corpus exactly once (no longer truncated,
no longer looping). Hardened the backfill loop to pure offset pagination as
defense in depth.

Regression (reproduces the infinite loop, fails fast on any re-scan):
tests/unit/storage/getNouns-cursor-pagination.test.ts
2026-06-22 18:00:01 -07:00
..
cow feat: content-type-aware compression policy in COW BlobStorage (2.5.0 #32) 2026-05-28 11:55:10 -07:00
binaryBlob.test.ts feat(storage): add raw binary-blob primitive to every storage adapter 2026-05-27 11:50:04 -07:00
fileSystemStorage-rootDirectory.test.ts fix: query-cap memory misread (MemAvailable + floor) + rootDirectory getter for native mmap fast-path 2026-06-16 08:46:39 -07:00
getNouns-cursor-pagination.test.ts fix: getNouns cursor pagination re-scanned the first page forever (permanent CPU loop) 2026-06-22 18:00:01 -07:00
getNouns-totalCount.test.ts fix: getNouns().totalCount reports true total, not page size; quiet benign mmap-vector log 2026-06-17 14:01:33 -07:00
vfs-mkdir-bug.test.ts fix(vfs): resolve two critical VFS bugs causing directory listing corruption 2025-12-04 11:22:30 -08:00