fix: extraction, multi-hop traversal, and aggregate result shape (BR-ADV-FEATURES-BUN)

Three advanced-API correctness fixes, all reproducible on Node (not Bun-specific):

- Entity/concept extraction returned []. SmartExtractor combined agreeing signals
  with a weighted sum compared against an absolute 0.60 gate, so a confident
  low-weight signal lost selection to a mediocre high-weight one that then failed
  the gate, dropping the whole result. Select and gate on a normalized weighted
  average instead. The public `confidence` option now controls the threshold (was
  a dead hardcoded 0.60), and the embedding-signal timeout is raised 100ms -> 2000ms
  so the neural signal is not silently dropped on slower runtimes.

- Multi-hop find({ connected }) returned only the 1-hop neighbour. executeGraphSearch
  ignored depth/via; it now delegates to the depth-aware neighbors() BFS.

- find({ aggregate }) hid groupKey/metrics/count under .metadata, so callers
  expecting AggregateResult saw empty rows. Expose those fields at the top level.

Adds real-embedding regression tests in tests/integration/advanced-apis-regression.test.ts.
This commit is contained in:
David Snelling 2026-05-26 11:32:46 -07:00
parent 07754d135a
commit 0a9d1d9a17
8 changed files with 297 additions and 74 deletions

View file

@ -43,7 +43,10 @@ export interface EmbeddingSignalOptions {
minConfidence?: number // Minimum confidence threshold (default: 0.60)
checkGraph?: boolean // Check against graph entities (default: true)
checkHistory?: boolean // Check against historical data (default: true)
timeout?: number // Max time in ms (default: 100)
timeout?: number // Max time in ms (default: 2000). A real transformer embed of a single
// candidate is commonly 50200ms (cold/under load higher); the previous
// 100ms default silently timed out, dropping the neural signal entirely —
// which alone left concept extraction (no regex fallback) returning nothing.
cacheSize?: number // LRU cache size (default: 1000)
}
@ -110,7 +113,7 @@ export class EmbeddingSignal {
minConfidence: options?.minConfidence ?? 0.60,
checkGraph: options?.checkGraph ?? true,
checkHistory: options?.checkHistory ?? true,
timeout: options?.timeout ?? 100,
timeout: options?.timeout ?? 2000,
cacheSize: options?.cacheSize ?? 1000
}
}