hindsight icon indicating copy to clipboard operation
hindsight copied to clipboard

Observation graph expansion performs an avoidable second SQL round trip

Open jervaise opened this issue 3 months ago • 1 comments

Problem

Hindsight 0.9.1 parallel_retrieval takes about 17 seconds for a 49,206-unit memory bank with about 1.3 million links. Trace evidence identifies observation graph/link expansion as the dominant phase.

Current cause

_expand_observations performs entity/source traversal and semantic/causal expansion as two normal SQL executions. The intermediate UUID relation is materialized in the client and sent back to the database.

Proposed boundary

Fuse the existing observation entity/source relation into the semantic/causal query as a CTE while preserving predicates, score expressions, ordering, limits, time windows, duplicate handling, and PostgreSQL/Oracle behavior.

Verification

  • focused fixtures prove identical ordered IDs, scores, and counts for overlapping sources, duplicate entities, empty sources, multiple fact types, and active time windows
  • normal observation expansion performs one fetch instead of two
  • the fixed recall benchmark records before/after p50 and p95 plus result equivalence

Origin

Tracked by mutmutco/Jerv-Hub#652 after the JervLife Voyage migration estate audit.

jervaise avatar Aug 28 '26 09:08 jervaise

claimed by session 01a047a5-4336-7cde-94b1-6fbaab8496e7 for an upstream pull request tracked by mutmutco/Jerv-Hub#652

jervaise avatar Aug 28 '26 09:08 jervaise