Skip to content

feat(retrieval): DIFFUSE random walk and EXPAND FROM evidence trees - #119

Merged
venkat1701 merged 5 commits into
mainfrom
feature/hypergraph-diffusion
Nov 23, 2026
Merged

venkat1701 merged 5 commits into
mainfrom
feature/hypergraph-diffusion

Conversation

@venkat1701

Copy link
Copy Markdown
Collaborator

Stacked on #115; it reads membership validity from the reverse-index postings that #115 adds. Merge #115 first, then retarget this to main.

This adds two association operators. Both run over the actual incidence structure: atom → containing hyperedge → member, never a pairwise expansion.

DIFFUSE: personalized PageRank from seed atoms (hora/Diffusion.java, Hora.diffuse). PROPAGATE keeps its old semantics.

  • Transitions: which hyperedge the walk takes is weighted by type weight and the role factor of the atom leaving. Which member comes next is weighted by membership weight and the role factor of the member entering.
  • Filters: VALID AT and an evidence POLICY filter memberships. A step with nothing admitted sends its mass back to the seeds.
  • Estimate: local push with a deterministic order. The residual bounds the total error of the atom scores exactly, every row carries a guaranteed upper bound, and the work is at most (2 - α)/(α·ε) incidence reads.

EXPAND FROM: a best-first evidence tree around the seeds (hora/Expansion.java).

  • Ranking: hyperedges come out in exact order of their best chain's value. Each step multiplies role and type factors, hub and size damping, and, with TOWARDS (RANK …), a relevance gate.
  • Reads: postings are read 64 at a time, only when the frontier reaches them.
  • Rows: they form a tree rooted at the seeds, and the message bounds everything not returned, including after a budget cut or frontier truncation.

The syntax is open for renaming before merge:

diffuse     = "DIFFUSE" "FROM" ref [ "WEIGHT" number ] { "," ref [ "WEIGHT" number ] }
              [ "THROUGH" identifier [ "WEIGHT" number ] { "," … } ] [ "EXIT" factors ] [ "ENTER" factors ]
              [ "VALID" "AT" additive ] [ "POLICY" policy ] [ "ALPHA" number ] [ "EPSILON" number ] "TOP" integer [ "EDGES" integer ] ;
expand_from = "EXPAND" "FROM" ref [ "WEIGHT" number ] { "," … } [ "THROUGH" identifier [ "FACTOR" number ] { "," … } ]
              [ "EXIT" factors ] [ "ENTER" factors ] [ "VALID" "AT" additive ] [ "TOWARDS" "(" rank ")" [ "GATE" number ] ]
              [ "DAMPING" number number ] [ "MIN" number ] "TOP" integer ;
factors     = "(" identifier number { "," identifier number } ")" ;

Testing

  • Full build: engine 269, database 196, server 41, all passing.
  • DIFFUSE: checked against an independent power iteration over the same chain, for 60 random models with role factors, type filters, validity and hyperedge seeds. Per atom, p ≤ π ≤ p + residual, and the total error equals the residual exactly. Runs are deterministic, and a run cut short by the budget keeps its certificate.
  • EXPAND FROM: checked against a fixpoint over max-product chain values for 80 random queries, including a hub with more than 64 postings. The checks cover exact values in order, a tree rooted at the seeds, a bound that holds, and budget and truncation cases.
  • Mutation checks:
    • DIFFUSE: ignoring exit factors, ignoring validity, dropping dangling mass.
    • EXPAND FROM: no hub damping, no gate, no pending bound.
  • Security: a tenant test for each operator.

Independent reviews. Both operators were reviewed.

  • DIFFUSE: one critical issue (cost lookups unmetered outside the default tenant) and two important ones (walks from filtered-out hyperedge seeds never ending, hub seeds never pushed), all fixed with tests.
  • EXPAND FROM: five important issues, all fixed with tests: whole posting lists read at once, an uncharged hub degree scan, silent truncation, a relevance scorer throwing on budget, and other tenants' counts leaking into DIFFUSE thresholds.

Not done here

  • EXPAND FROM still uses raw cardinality and weight maxima, which include other tenants' hidden members in old stores. The design accepts this.
  • Ties at the k cut are not ordered by id across entry kinds.
  • THROUGH takes FACTOR here but WEIGHT in DIFFUSE.

…tart

DIFFUSE ranks atoms and hyperedges by personalized PageRank from seed
atoms on the incidence structure: atom to containing hyperedge to member,
never a pairwise expansion. Hyperedge choice is weighted by type weight
and the leaving atom's role factor, member choice by membership weight
and the entering member's role factor. VALID AT and an evidence POLICY
filter memberships, and a step with nothing admitted returns its mass to
the seeds, so the walk stays a distribution.

The estimate comes from local push with a deterministic order. Its
residual bounds the total error of the atom scores exactly, every row
carries a guaranteed upper bound, and the work is bounded by
(2 - alpha) / (alpha * epsilon) incidence reads. PROPAGATE is unchanged;
Hora.diffuse is the Java entry point.

No issue tracks this work.
Each node's push cost is now read once, from its raw posting count, so the
work bound holds outside the default tenant; evidence lookups are counted.
Every seed is pushed at least once, so a seed with many memberships still
spreads its mass, and when every seed is a hyperedge whose members are
all filtered out the walk is refused instead of running until the budget
is gone. Seed weights that overflow, a repeated THROUGH type and a
repeated role factor are refused.

No issue tracks this work.
EXPAND FROM returns the hyperedges best connected to seed atoms, in exact
order of the value of their best chain: each step multiplies a factor in
[0, 1] built from role factors, type factors, hub and size damping and,
with TOWARDS (RANK ...), the hyperedge's relevance through a gate, so a
weakly relevant hyperedge can still connect two relevant ones. Incident
hyperedges are read 64 postings at a time and only when the frontier
reaches them. Each row names the atom it was entered through and the
hyperedge that atom came from, so rows form a tree rooted at the seeds,
and the message bounds the value of everything not returned, also when
the budget ends the run.

No issue tracks this work.
Incident postings are now read 64 at a time in key order instead of the
whole list at the first chunk, and an atom's hub factor is worked out once
when it is settled. When the frontier passes its cap it drops its lower
half, the run reports FRONTIER_TRUNCATED and the message says below which
value rows may be missing. A relevance query that runs out of budget ends
the run with a budget stop and a valid bound. A seed that is a hyperedge
is returned and expanded, the last accepted hyperedge's members are not
read, and repeated seeds, types and roles and an out-of-range MIN are
refused. DIFFUSE thresholds now use the reader's own degree.

No issue tracks this work.
@venkat1701
venkat1701 changed the base branch from feature/temporal-retrieval to main November 23, 2026 10:53
…ffusion

# Conflicts:
#	database/src/main/java/io/hstore/db/Reader.java
#	database/src/main/java/io/hstore/db/query/Ast.java
#	database/src/main/java/io/hstore/db/query/Executor.java
#	database/src/main/java/io/hstore/db/query/Parser.java
#	database/src/test/java/io/hstore/db/SecurityTest.java
#	docs/database/hora.md
#	docs/database/hql.md
#	server/src/main/java/io/hstore/server/StatementLogger.java
@venkat1701
venkat1701 merged commit ade9dc6 into main Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant