feat(8.0): GraphAccelerationProvider contract — the native graph-engine seam
Defines the optional native graph-acceleration provider (cor 3.0) that
brainy feature-detects and routes brain.graph.* / related({node}) /
find({connected}) to, falling back to pure-TS adjacency when absent. This is
the published seam cor wires its native build against (mirrors the existing
VersionedIndexProvider pattern: defined in plugin.ts, exported from index.ts,
implemented externally, feature-detected at runtime).
Contract (locked cross-team in the design thread):
- GraphAccelerationProvider: traverse, edgesForNode, graphCursorOpen/Next/Close,
pageRank, connectedComponents, shortestPath, neighborhoodSample, topByDegree.
Every read op is generation-aware (optional trailing generation?: bigint) so
db.asOf(g).graph.* resolves historically; omitted = now.
- Subgraph: columnar wire format (BigInt64Array node/edge columns, Uint16Array
edgeTypes, optional Uint8Array nodeDepth, truncated flag) — parallel typed
arrays, never array-of-objects; brainy maps u64<->UUID lazily for rendered rows.
- OpaqueIdSet: a find() universe forwarded opaquely into traverse/search for the
zero-crossing query->expand fusion (brainy never inspects it; the provider
version-tags + validates the envelope).
- VectorIndexProvider.search gains allowedIds?: OpaqueIdSet | ReadonlySet<string>
(predicate pushdown — recovers filtered recall lost to post-filtering).
- EntityIdMapperProvider gains entityIntsToUuids(BigInt64Array) — the bigint batch
reverse resolver for Subgraph.nodes; implemented on the JS mapper (TS fallback).
All new public types exported from index.ts. Test: entityIntsToUuids round-trip
+ order-preservation + empty-int sentinel.
This commit is contained in:
parent
682e786cc3
commit
a3d6fdb8b3
4 changed files with 391 additions and 1 deletions
|
|
@ -96,3 +96,31 @@ describe('EntityIdMapper U32 IdSpace ceiling (Brainy 8.0)', () => {
|
|||
expect(m.getOrAssign('uuid-existing')).toBe(assigned)
|
||||
})
|
||||
})
|
||||
|
||||
describe('EntityIdMapper.entityIntsToUuids (bigint batch resolver — graph engine)', () => {
|
||||
it('reverse-resolves a BigInt64Array of assigned ints to UUIDs, in order', async () => {
|
||||
const m = makeMapper()
|
||||
await m.init()
|
||||
const a = m.getOrAssign('uuid-a')
|
||||
const b = m.getOrAssign('uuid-b')
|
||||
const c = m.getOrAssign('uuid-c')
|
||||
// Out-of-assignment order, to prove it's positional (not sorted).
|
||||
const ints = BigInt64Array.from([BigInt(c), BigInt(a), BigInt(b)])
|
||||
expect(m.entityIntsToUuids(ints)).toEqual(['uuid-c', 'uuid-a', 'uuid-b'])
|
||||
})
|
||||
|
||||
it('yields "" for a never-assigned int (order-preserving, no drop)', async () => {
|
||||
const m = makeMapper()
|
||||
await m.init()
|
||||
const a = m.getOrAssign('uuid-a')
|
||||
const ints = BigInt64Array.from([BigInt(a), 999999n])
|
||||
// Position is preserved — the unknown int does not collapse the array.
|
||||
expect(m.entityIntsToUuids(ints)).toEqual(['uuid-a', ''])
|
||||
})
|
||||
|
||||
it('returns an empty array for empty input', async () => {
|
||||
const m = makeMapper()
|
||||
await m.init()
|
||||
expect(m.entityIntsToUuids(new BigInt64Array(0))).toEqual([])
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue