Nous.Decisions.Edge (nous v0.16.3)

View Source

A directed edge connecting two nodes in the decision graph.

Edges encode the relationships between decision nodes: which options were chosen, what actions lead to which outcomes, and how decisions supersede or depend on one another.

Architecture

Edges are plain structs stored alongside nodes in a Nous.Decisions.Store backend. Each edge has a typed relationship (edge_type) and connects a source node (from_id) to a destination node (to_id).

Quick Start

edge = Nous.Decisions.Edge.new(%{
  from_id: goal_node.id,
  to_id: decision_node.id,
  edge_type: :leads_to
})

Fields

FieldTypeDescription
idString.t()Unique identifier (auto-generated)
from_idString.t()Source node ID
to_idString.t()Destination node ID
edge_typeedge_type()Relationship type
metadatamap()Arbitrary key-value data
created_atDateTime.t()When the edge was created

Summary

Functions

Create a new edge with auto-generated ID and timestamp.

Types

edge_type()

@type edge_type() ::
  :leads_to | :chosen | :rejected | :requires | :blocks | :enables | :supersedes

t()

@type t() :: %Nous.Decisions.Edge{
  created_at: DateTime.t(),
  edge_type: edge_type(),
  from_id: String.t(),
  id: String.t(),
  metadata: map(),
  to_id: String.t()
}

Functions

new(attrs)

@spec new(map()) :: t()

Create a new edge with auto-generated ID and timestamp.

Required: :from_id, :to_id, and :edge_type.

Examples

iex> edge = Nous.Decisions.Edge.new(%{from_id: "a", to_id: "b", edge_type: :leads_to})
iex> edge.edge_type
:leads_to
iex> is_binary(edge.id)
true