codenib.ops.expand
¶
Classes:
| Name | Description |
|---|---|
ExpandContext |
Shared resources for graph expansion operators. |
Functions:
| Name | Description |
|---|---|
nodeinfo_to_queried |
Convert NodeInfo list to QueriedNode list, assigning rank-based scores. |
hydrate_candidate_contents |
Fill missing candidate content from persisted source spans. |
expand_graph_neighbors |
Return graph neighbors for retrieval candidates. |
expand_graph_region |
Expand ranked seeds through a bounded graph region. |
expand_retrieval_candidates |
Apply a bounded graph expansion plan to ranked retrieval seeds. |
ExpandContext
dataclass
¶
ExpandContext(
code_graph: CodeGraph | None = None,
lsp_provider: Any | None = None,
default_top_k: int = 50,
default_hops: int = 2,
default_direction: str = "both",
default_method: str = "bfs",
default_damping: float = 0.85,
filter_tests: bool = True,
)
Shared resources for graph expansion operators.
nodeinfo_to_queried
¶
nodeinfo_to_queried(nodes: list[NodeInfo]) -> list[QueriedNode]
Convert NodeInfo list to QueriedNode list, assigning rank-based scores.
Source code in codenib/ops/expand.py
hydrate_candidate_contents
¶
hydrate_candidate_contents(
candidates: Sequence[QueriedNode],
*,
repo_path: str | None,
git_commit: str | None = None
) -> list[QueriedNode]
Fill missing candidate content from persisted source spans.
Source code in codenib/ops/expand.py
expand_graph_neighbors
¶
expand_graph_neighbors(
context: ExpandContext,
seeds: Sequence[QueriedNode],
*,
per_seed: int = 5,
direction: str = "both",
repo_path: str | None = None,
include_content: bool = False,
symbol_only: bool = True,
require_span: bool = True,
score_scale: float = 0.5,
edge_types: Sequence[str] | None = (EDGE_TYPE_REFERENCE,)
) -> list[QueriedNode]
Return graph neighbors for retrieval candidates.
This is the retrieval-pipeline counterpart to the agent-facing graph navigation helpers: keep dense candidates as seeds, append compact graph neighbors, and leave ranking to the downstream reranker. Only one-hop predecessor/successor expansion is performed; no BFS/PPR is hidden here. Expansion follows reference edges by default so containment does not consume the dependency-neighbor budget.
Source code in codenib/ops/expand.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
expand_graph_region
¶
expand_graph_region(
context: ExpandContext,
seeds: Sequence[QueriedNode],
*,
top_k: int = 50,
hops: int = 2,
direction: str = "both",
use_ppr: bool = False,
repo_path: str | None = None,
include_content: bool = False
) -> list[QueriedNode]
Expand ranked seeds through a bounded graph region.
Multi-hop and PPR expansion share this operator so manifest-backed runtimes and the standalone retrieval pipeline execute the same graph semantics. If no region can be resolved, the function falls back to the one-hop neighbor operator.
Source code in codenib/ops/expand.py
expand_retrieval_candidates
¶
expand_retrieval_candidates(
context: ExpandContext,
seeds: Sequence[QueriedNode],
*,
seed_top_k: int | None,
expand_top_k: int,
hops: int,
direction: str,
use_ppr: bool,
repo_path: str | None,
include_content: bool = True
) -> list[QueriedNode]
Apply a bounded graph expansion plan to ranked retrieval seeds.