feat(8.0): no-freeze auto-upgrade hooks — isMigrating() deference + stampBrainFormat() + brain-format export

Three hooks so a native provider can run a non-blocking, online, background
build-new→verify→swap index migration on a large-brain upgrade while brainy stays
out of the way — no minutes-long blocking rebuild-on-open/first-query.

- isMigrating?(): boolean — OPTIONAL on MetadataIndexProvider / GraphIndexProvider /
  VectorIndexProvider (mirrors isReady?()/init?(), feature-detected). While a
  provider reports migrating, brainy SKIPS its rebuild for that index — per-index,
  so a non-migrating sibling still rebuilds; skipped even under epoch-drift or
  size()===0 — in both rebuildIndexesIfNeeded and the lazy first-query force path.
  The provider serves correct reads from canonical until it verifies-and-swaps.
- brain.stampBrainFormat() — public; the provider calls it once its background swap
  verifies, so brainy authors dataFormat (the provider never does). brainy withholds
  its own marker stamp while any provider is migrating, so the shared epoch is never
  advanced ahead of a deferred index.
- ./brain-format export — the marker module's EXPECTED_INDEX_EPOCH / CURRENT_DATA_FORMAT
  are importable so a native provider shares the constant (no duplicate = no
  lockstep-drift). 8-case test; unit 1743 green.
This commit is contained in:
David Snelling 2026-06-30 13:37:23 -07:00
parent bd6faf7499
commit b6b919890c
4 changed files with 378 additions and 18 deletions

View file

@ -56,6 +56,10 @@
"import": "./dist/internals.js",
"types": "./dist/internals.d.ts"
},
"./brain-format": {
"import": "./dist/storage/brainFormat.js",
"types": "./dist/storage/brainFormat.d.ts"
},
"./embeddings/wasm": {
"import": "./dist/embeddings/wasm/index.js",
"types": "./dist/embeddings/wasm/index.d.ts"