Skip to content

feat(ai): add bounded graph traversal recall - #884

Open
apex-mochen wants to merge 1 commit into
apache:masterfrom
apex-mochen:codex/geaflow-861-traversal-recall
Open

apex-mochen wants to merge 1 commit into
apache:masterfrom
apex-mochen:codex/geaflow-861-traversal-recall

Conversation

@apex-mochen

Copy link
Copy Markdown

Related to #861.

This adds a read-only traversal recall operator over GraphAccessor, with weighted random walks with restart, breadth-first search and depth-limited depth-first search. It aggregates candidate visits across anchors, excludes anchors from results, and returns path provenance alongside explicit scan, traversal, vertex, depth and result limits.

Weighted sampling caches a scaled cumulative distribution and uses binary search for repeated draws. The DFS implementation re-expands vertices reached later at a shallower depth, so an earlier deep arrival does not hide reachable descendants.

The local accessor emits the same backing self-loop multiple times through its adjacency indexes. The operator accounts for that loop once when constructing transition weights while still charging every scanned record to the scan budget. Distinct parallel edges are preserved. Edge properties participate in deterministic transition ordering.

Semantics for review

Provenance is the shortest observed walk, not a guaranteed globally shortest path. If the graph has A→C and A→B→C but only the latter was sampled, the sampled path is retained. This differs from the issue's shortest-path wording and needs agreement.

Random-walk scores sum per-anchor visit frequencies; they are not exact stationary PageRank probabilities. BFS/DFS scores count supporting anchors. Results are truncated after ranking, while separate traversal budgets bound the work. Cancellation and deadlines are cooperative and cannot preempt blocking accessor I/O.

Validation

On base 3c24c8e, local commit c52ff03:

  • Full 12-module Maven reactor succeeds, including Checkstyle and RAT.
  • geaflow-ai: 502 reported tests, zero failures/errors, one existing opt-in stress test skipped.
  • The new class contributes 32 passing JUnit tests using the real LocalMemoryGraphAccessor, including seeded differential checks over 100 synthetic graphs, weighted/self-loop/parallel-edge cases, provenance and budget boundaries.
  • Across the reactor: 656 reported tests, 655 passed, one skipped.

Command: mvn -B -ntp -pl geaflow-ai -am -Djacoco.skip=true -DcoverageAgent= test

Environment: Windows 11, Maven 3.9.11, Java 21.0.5, upstream Java 11 compilation target. The default reactor also succeeds, but JaCoCo 0.8.8 emits Java21 instrumentation errors; the command above disables coverage collection, not tests. No coverage, benchmark or production result is claimed. The skipped existing stress test requires graphrag.answer.input.

Existing retrieval pipelines are unchanged. The proposed API keeps Limits, Hit, Result and Strategy nested under GraphTraversalRecall. Upstream CI was not run as part of the local validation above.

@apex-mochen

Copy link
Copy Markdown
Author

Hi @yaozhongq, could you please help approve the JDK 8 and JDK 11 workflow runs for this PR at c52ff03? Both show “awaiting approval from a maintainer,” and no jobs have started. Thank you!

@yaozhongq

Copy link
Copy Markdown
Contributor

Hi @yaozhongq, could you please help approve the JDK 8 and JDK 11 workflow runs for this PR at c52ff03? Both show “awaiting approval from a maintainer,” and no jobs have started. Thank you!

Started

This branch has not been deployed

No deployments
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.

2 participants