feat(enh-005): directional GraphRAG expansion (in/out/any)#122
Merged
Conversation
First implementation on the 0.4 graph train. Adds a `direction` knob to GraphRAG expansion so it follows asymmetric edges the right way — `in` (callers / who-cites-X / dependents), `out` (callees / what-X-cites / dependencies), `any` (default = today's undirected `traverse`). - `direction: Literal["out","in","any"] = "any"` on `GraphExpansion` (agentforge_core.values.retrieval) + `GraphExpansionConfig` (agentforge_core.config.schema); threaded by build_retriever_from_config. - `Retriever._expand_via_graph` branches: `any` keeps the native traverse() path verbatim (byte-for-byte backward compatible); `in`/`out` run a BFS over the already-locked `GraphStore.get_edges(direction=...)` primitive (`_reach_via_get_edges`) — collecting edge.dst (out) / edge.src (in), fetching neighbours via get_node. Merge/decay/dedup pipeline reused. - NO ABC change, no major bump, no new package. Improves feat-023. The reference `traverse()` is out-directed, so `direction=in` is what surfaces predecessors (callers) that the undirected path can't reach — the headline test asserts exactly that. Tests: out=successors, in=predecessors, in-surfaces-what-traverse-cannot, multi-hop caller chain, edge-type filtering, no-predecessor tolerance, value + config defaults / rejection; existing feat-023 suite unchanged (backward-compat). Directional logic at 100% coverage; fully offline. Refs enh-005 · docs/enhancements/enh-005-directional-graph-expansion.md Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First implementation on the 0.4 graph train. Adds a
directionknob to GraphRAG expansion so it follows asymmetric edges the right way:in— callers / who-cites-X / dependentsout— callees / what-X-cites / dependenciesany(default) — today's undirectedtraversebehaviour, byte-for-byte unchangedHow
direction: Literal["out","in","any"] = "any"onGraphExpansion(agentforge_core.values.retrieval) +GraphExpansionConfig(agentforge_core.config.schema); threaded bybuild_retriever_from_config.Retriever._expand_via_graphbranches:anykeeps the nativetraverse()path verbatim;in/outrun a BFS over the already-lockedGraphStore.get_edges(direction=...)primitive (_reach_via_get_edges) — collectingedge.dst(out) /edge.src(in), fetching each neighbour viaget_node. The merge/decay/dedup pipeline is reused unchanged.The reference
traverse()is out-directed, sodirection=inis what surfaces the predecessors (callers) the undirected path can't reach —test_direction_in_surfaces_what_traverse_cannotasserts exactly that.Tests
out=successors ·in=predecessors · in-surfaces-what-traverse-cannot · multi-hop caller chain · edge-type filtering · no-predecessor tolerance · value + config defaults / bad-value rejection. The existing feat-023 suite is unchanged (backward-compat forany). Directional logic at 100% coverage, fully offline. Pre-commit green (mypy--strict, coverage, drift hook).Spec:
docs/enhancements/enh-005-directional-graph-expansion.md(status → in-progress; implementation section filled in).🤖 Generated with Claude Code