Brain Docs

Reference

Rust SDKInstallationHTTP clientWire client
create_relationget_relationlist_relationstraverse_relationssupersede_relationtombstone_relation
ErrorsRetriesPagination
Brain/Docs
✦ ASKBrain on GitHubDashboard
Rust SDKRelationstraverse_relations

traverse_relations

Walk the relation graph outward from an entity and get paths back — with a truncation flag you must check.

PURPOSE

Walk the relation graph outward from one entity. Returns paths, not nodes — so you can see how two entities are connected, not just that they are.

POST/v1/entities/:id/traverseBearer API keystable
async fn traverse_relations(&self, entity_id: &str, input: &TraverseInput) -> Result<TraverseResult, BrainHttpError>
Handshake credentialstable
async fn traverse_relations(&self, request: &RelationTraverseRequest) -> Result<Vec<TraversalPathWire>>
async fn traverse_relations_frames(&self, request: &RelationTraverseRequest) -> Result<Vec<RelationTraverseResponseFrame>>

Parameters

ParameterTypeRequired
entity_idstringrequired

Where to start. Positional on the HTTP tier; the wire field is startEntity.

directionstringoptional

Which way to walk. An integer on the wire.

relation_typesstring[]optional

Only follow these types. The single most effective way to keep a traversal cheap.

max_depthintegeroptional

Hop limit.

max_nodesintegeroptional

Node budget.

include_supersededbooleanoptional

Walk through non-head versions too.

Returns

FieldTypePresence
pathsTraversalPath[]always

Each a list of steps — relationId, from, to, relationType, depth, and resolved fromName / toName when available.

total_pathsintegeralways

How many were found.

truncatedbooleanalways

true means a budget stopped the walk and the result is partial.

Example

let t = brain
    .traverse_relations(&priya_id, &TraverseInput {
        relation_types: Some(vec!["works_at".into(), "reports_to".into()]),
        max_depth: Some(3),
        max_nodes: Some(200),
        ..Default::default()
    })
    .await?;

if t.truncated {
    eprintln!("partial neighbourhood — raise max_nodes");
}
truncated means the answer is incomplete

Reporting a truncated traversal as the complete neighbourhood is the mistake this flag exists to prevent. Either raise the budget or tell the reader the view is partial — do not quietly present it as the whole graph.

The wire request adds timeAtUnixNanos: traverse the graph as it stood at a moment, rather than as it stands now. It also has a frame-level form, traverse_relations_frames.

On the wire

Entity ids are UUID bytes, properties is a propertiesBlob, and evidence is a single reference rather than an array. Every request carries a requestId plus an optional actAs.

See also
list_relationsThe typed graph

Was this page helpful?

list_relations

List an entity's relations in either direction — one HTTP verb, two wire verbs.

supersede_relation

Replace a relation with a new version, keeping the chain readable.

On this page

ParametersReturnsExampleOn the wire
Suggest an editOpen in Playground