@soulcraft/cor 3.0.5 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -217,12 +217,21 @@ export declare class GraphAdjacencyIndex implements GraphIndexProvider {
217
217
  isHealthy(): boolean;
218
218
  /**
219
219
  * Whether the graph's edges are loaded and queryable WITHOUT a rebuild —
220
- * brainy 8.0's rebuild gate (#36). Delegates straight to the native
221
- * edges-ready latch (set on SSTable cold-load, a non-empty manifest, or a
222
- * memtable flush) ORed with a live non-empty memtable. Synchronous (no
223
- * await) and **never gated on the verb-id membership walk**, so the
224
- * deferred O(N) membership fast-follow can never depress readiness for a
225
- * graph whose edges are already mapped in.
220
+ * brainy 8.0's rebuild gate (#36). Synchronous (no await) and **never gated
221
+ * on the verb-id membership walk**, so the deferred O(N) membership fast-follow
222
+ * can never depress readiness for a graph whose edges are already mapped in.
223
+ *
224
+ * The native `is_ready()` latch fires only when EDGES load (SSTable cold-load,
225
+ * a non-empty manifest, or a memtable flush). That latch is never set for an
226
+ * **edgeless** brain (entities but no relationships — a very common shape:
227
+ * per-user brains, catalogs, CMS content), so a naive delegate reported
228
+ * `false` and made brainy spuriously rebuild the graph on every boot — which
229
+ * cascades into an id-mapper hydration + a full metadata rebuild (the observed
230
+ * multi-minute boot / 502 window). An edgeless graph is trivially ready: a
231
+ * rebuild would reconstruct zero edges. So once cold-load has run
232
+ * ({@link initialized}) we also report ready when the durable graph stores are
233
+ * genuinely EMPTY — distinguished from "edges exist on disk but didn't load"
234
+ * (which must still rebuild) via the persisted SSTable + memtable counts.
226
235
  */
227
236
  isReady(): boolean;
228
237
  /**
@@ -497,15 +497,38 @@ export class GraphAdjacencyIndex {
497
497
  }
498
498
  /**
499
499
  * Whether the graph's edges are loaded and queryable WITHOUT a rebuild —
500
- * brainy 8.0's rebuild gate (#36). Delegates straight to the native
501
- * edges-ready latch (set on SSTable cold-load, a non-empty manifest, or a
502
- * memtable flush) ORed with a live non-empty memtable. Synchronous (no
503
- * await) and **never gated on the verb-id membership walk**, so the
504
- * deferred O(N) membership fast-follow can never depress readiness for a
505
- * graph whose edges are already mapped in.
500
+ * brainy 8.0's rebuild gate (#36). Synchronous (no await) and **never gated
501
+ * on the verb-id membership walk**, so the deferred O(N) membership fast-follow
502
+ * can never depress readiness for a graph whose edges are already mapped in.
503
+ *
504
+ * The native `is_ready()` latch fires only when EDGES load (SSTable cold-load,
505
+ * a non-empty manifest, or a memtable flush). That latch is never set for an
506
+ * **edgeless** brain (entities but no relationships — a very common shape:
507
+ * per-user brains, catalogs, CMS content), so a naive delegate reported
508
+ * `false` and made brainy spuriously rebuild the graph on every boot — which
509
+ * cascades into an id-mapper hydration + a full metadata rebuild (the observed
510
+ * multi-minute boot / 502 window). An edgeless graph is trivially ready: a
511
+ * rebuild would reconstruct zero edges. So once cold-load has run
512
+ * ({@link initialized}) we also report ready when the durable graph stores are
513
+ * genuinely EMPTY — distinguished from "edges exist on disk but didn't load"
514
+ * (which must still rebuild) via the persisted SSTable + memtable counts.
506
515
  */
507
516
  isReady() {
508
- return this.native.isReady();
517
+ if (this.native.isReady())
518
+ return true;
519
+ if (!this.initialized)
520
+ return false;
521
+ // Cold-load has run but the edges-ready latch is unset. Ready ⇔ there is
522
+ // nothing durable to load: no SSTables and empty memtables on either the
523
+ // source or target tree. If any durable edges exist but didn't load, this
524
+ // is false and brainy correctly rebuilds.
525
+ const raw = this.native.getStats();
526
+ const s = typeof raw === 'string' ? JSON.parse(raw) : raw;
527
+ const durableEmpty = Number(s?.sourceSstableCount ?? 0) === 0 &&
528
+ Number(s?.targetSstableCount ?? 0) === 0 &&
529
+ Number(s?.sourceMemTableSize ?? 0) === 0 &&
530
+ Number(s?.targetMemTableSize ?? 0) === 0;
531
+ return durableEmpty;
509
532
  }
510
533
  /**
511
534
  * @description **#18 migration lock — feature-detected by Brainy.** `true` while
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/cor",
3
- "version": "3.0.5",
3
+ "version": "3.0.6",
4
4
  "description": "Native Rust acceleration for Brainy \u2014 SIMD distance, vector quantization, zero-copy mmap, native embeddings. Free tier for storage, Pro license for compute acceleration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",