Skip to main content

render_node_with_adjacency

Function render_node_with_adjacency 

Source
pub fn render_node_with_adjacency(
    node: &Node,
    repo: &ReadonlyRepo,
    per_direction_cap: usize,
) -> String
Expand description

Like render_node but augments the output with two graph adjacency blocks derived from repo’s current commit:

ntype: Doc
id: ...
summary: ...
Outgoing:
  tagged -> <topic_id>
Incoming:
  authored <- <alice_id>

Each block is capped at per_direction_cap entries; if the bucket had more, a trailing ... (+N more) line is emitted so the reader knows the display was clipped. Blocks with no edges are omitted entirely. Entry order is the adjacency bucket’s stored order (SPEC §4.9 (label, src|dst, edge_cid) sort), so the rendered string is byte-stable.

Use this from CLI / MCP / agent-facing paths that benefit from showing surrounding graph context. The hot Retriever::execute render path keeps calling the cheaper render_node because adjacency-aware rendering there would add a per-item O(log n) bucket fetch for every ranked candidate, and callers that do not need the blocks should not pay the cost.