feat(8.0): eager graphIndex.init() before the isReady() rebuild gate

A native graph provider cold-loads its source->target adjacency lazily, so
isReady() would report false at the rebuild gate on a cold open and force a
spurious rebuild (failing the §7.1 rebuild()==0 acceptance). Add an OPTIONAL
GraphIndexProvider.init() (mirrors MetadataIndexProvider.init) and call it during
init, AFTER metadataIndex.init() (id-mapper hydrated first, so a native int
adjacency resolves endpoints through it) and BEFORE rebuildIndexesIfNeeded. The JS
graph index omits init() and self-loads on demand, so the JS path is unchanged.
This commit is contained in:
David Snelling 2026-06-30 09:55:19 -07:00
parent fc7f110479
commit 8f4787bb10
2 changed files with 25 additions and 0 deletions

View file

@ -264,6 +264,18 @@ export interface GraphIndexProvider {
*/
isReady?(): boolean
/**
* @description OPTIONAL eager cold-load. Called once during brain init AFTER
* the metadata provider's `init()` (so the id-mapper is hydrated; a native int
* adjacency resolves endpoints through it the id-mapper-before-adjacency
* order) and BEFORE the rebuild gate so a native provider loads its
* sourcetarget adjacency from storage and reports `isReady() === true` at the
* gate, with no spurious rebuild (the §7.1 `rebuild()==0` acceptance). Mirrors
* {@link MetadataIndexProvider.init}. The JS graph index omits it and
* self-loads its adjacency on demand.
*/
init?(): Promise<void>
/**
* @description Entity ints reachable from `id` (1 hop), deduped.
* @param id - The entity's interned int (from the shared idMapper).