brainy/tests/unit/brainy
David Snelling 945d92d29e fix: one field-resolution law across aggregation hooks, source.where, removeMany, and find() spellings
Four fixes from a consumer conformance report, one root disease — two
field-resolution regimes where there must be one:

- The delete/update aggregation hooks fed the engine a partial entity
  view (type/service/data/metadata only), so a reserved-field groupBy
  (subtype, visibility, ...) resolved to a nonexistent group on the way
  down: counts drifted upward forever after deletes, and updates moving
  an entity between reserved-field groups double-counted. The hooks now
  pass the full-fidelity view via entityForAggFromRawRecord (every
  reserved field top-level, mirroring the add path); the update sites
  pass the full get() view instead of a hand-rolled subset.
- Aggregation source.where resolved fields only against the custom
  metadata bag, so where on a reserved field silently matched nothing.
  The matcher now resolves each filtered field through
  resolveEntityField — the same single source of truth groupBy uses.
- removeMany() with no usable selector (bare array passed positionally,
  empty params, ids: []) resolved successfully having deleted nothing.
  All three now throw; the two legacy tests that pinned the silent
  no-op as 'graceful' now pin the refusal.
- find() where keys accept both spellings: a metadata.-prefixed key
  falls back to its flattened spelling when the prefixed one is not
  indexed (metadata is flattened at index time). A literal nested custom
  key named metadata still wins when indexed as spelled.

Five regression pins in aggregate-reserved-fields.test.ts (4 of 5 vary
red on the unfixed code).
2026-07-19 10:54:36 -07:00
..
add.test.ts fix: flush all native providers on shutdown to prevent data loss 2026-02-01 16:23:49 -08:00
batch-operations.test.ts fix: one field-resolution law across aggregation hooks, source.where, removeMany, and find() spellings 2026-07-19 10:54:36 -07:00
brain-format-handshake.test.ts feat(8.0): version-handshake marker (formatInfo + indexEpoch) for whole-brain auto-upgrade 2026-06-30 09:53:10 -07:00
counts-by-type-fix.test.ts fix: recalibrate find({ limit }) cap + two-tier enforcement + caller location 2026-06-08 12:49:43 -07:00
degraded-reads-surfaced.test.ts fix: surface a degraded derived index on reads instead of serving it silently 2026-07-13 09:49:38 -07:00
fill-subtypes.test.ts chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase 2026-06-11 14:51:00 -07:00
find-agg-edge-cases.test.ts fix(8.0): distinctCount aggregates distinct values of any type + edge-case regression tests 2026-06-17 12:03:06 -07:00
find-complement-operators.test.ts perf(8.0): negation/absence where-operators via roaring-bitmap difference 2026-06-29 11:19:18 -07:00
find-include-vectors.test.ts feat(8.0): upsert + FindParams.includeVectors + removeMany adaptive chunking 2026-06-20 16:34:20 -07:00
find-index-integrity-guard.test.ts fix(8.0): re-validate find() results against the predicate (index-integrity guard) 2026-06-24 16:25:12 -07:00
find-orderby-pagek.test.ts perf(8.0): bound find({ where, orderBy }) sort to the page (CTX-BR-FIND-ORDERBY) 2026-06-23 15:01:49 -07:00
find.test.ts feat(8.0)!: flip requireSubtype default to true (BRAINY-8.0-SUBTYPE-CONTRACT § C-1) 2026-06-09 14:58:25 -07:00
get.test.ts test(8.0): get() resolves null for absent custom ids instead of throwing 2026-06-16 10:47:10 -07:00
graph-analytics.test.ts feat(8.0): graph analytics — brain.graph.rank / communities / path 2026-06-23 12:32:03 -07:00
graph-export.test.ts feat(8.0): brain.graph.export() + noun-walk cursor + noun visibility hydration 2026-06-21 10:22:12 -07:00
graph-native-routing.test.ts fix(8.0): gate native graph analytics on the provider readiness flag 2026-06-24 15:18:50 -07:00
graph-subgraph.test.ts feat(8.0): brain.graph.subgraph(query) query→expand fusion (#61) 2026-06-23 13:30:30 -07:00
hybrid-search.test.ts feat(8.0)!: flip requireSubtype default to true (BRAINY-8.0-SUBTYPE-CONTRACT § C-1) 2026-06-09 14:58:25 -07:00
metadata-provider-contract.test.ts feat(8.0): wire the two cor-confirmed metadata-provider contract additions 2026-06-29 12:11:00 -07:00
migration-deference.test.ts fix: cold-open no longer re-derives durable indexes — complete the readiness contract for all three providers 2026-07-07 10:39:00 -07:00
migration-gate-family-scoped.test.ts fix: full-removal canonical deletes + family-scoped migration gate 2026-07-14 10:11:53 -07:00
relate-duplicate-optimization.test.ts chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase 2026-06-11 14:51:00 -07:00
relate.test.ts chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase 2026-06-11 14:51:00 -07:00
related-node-bidirectional.test.ts feat(8.0): related({ node }) — one-call both-direction incident edges 2026-06-21 08:43:55 -07:00
related-visibility-fast-path.test.ts perf(8.0): visibility-aware fast adjacency — related() stays O(degree) under default visibility 2026-06-20 16:34:32 -07:00
reserved-field-policy.test.ts feat(8.0): reserved-field enforcement — reservedFieldPolicy defaults to throw 2026-06-20 15:37:21 -07:00
similar-threshold.test.ts feat(8.0): API simplification — remove neural()/Db.search, one storage path key, integration→0 2026-06-20 13:31:11 -07:00
update-reserved-metadata-remap.test.ts feat(8.0): reserved-field enforcement — reservedFieldPolicy defaults to throw 2026-06-20 15:37:21 -07:00
update.test.ts feat(8.0): full query surface at historical generations via ephemeral index materialization 2026-06-11 08:12:11 -07:00
upsert.test.ts feat(8.0): upsert + FindParams.includeVectors + removeMany adaptive chunking 2026-06-20 16:34:20 -07:00
visibility.test.ts feat(8.0): reserved-field enforcement — reservedFieldPolicy defaults to throw 2026-06-20 15:37:21 -07:00