Knowledge Tree

Hierarchical organization of beliefs into a navigable tree structure.

The knowledge tree provides a hierarchical view of beliefs. While the knowledge graph connects beliefs by semantic relationships, the tree organizes them into a layered taxonomy of topics and sub-topics. A belief can appear in multiple locations in the tree.

Place a Belief

engine.tree_place_belief(belief_id) → list[str]
Places a belief in the knowledge tree hierarchy. Returns a list of node IDs where the belief was placed. A belief can appear in multiple nodes.
node_ids = engine.tree_place_belief("belief-id")
print(f"Belief placed in {len(node_ids)} tree nodes")
for nid in node_ids:
    print(f"  node: {nid}")

Get a Node

engine.tree_get_node(node_id) → dict
Returns the node details including its position in the tree.
node = engine.tree_get_node("node-id")
# Returns:
# {
#     "id": "node-id",
#     "name": "Defense Systems",
#     "description": "Beliefs about defensive structures and strategies",
#     "parent_ids": ["parent-node-id"],
#     "layer": 2,
#     "belief_count": 15,
# }

Node Fields

FieldTypeDescription
idstrUnique node identifier
namestrHuman-readable node name
descriptionstrWhat this category covers
parent_idslist[str]Parent node IDs (can have multiple)
layerintDepth in the tree (0 = root)
belief_countintNumber of beliefs in this node

Get Children

engine.tree_get_children(node_id) → list[dict]
Returns all child nodes of the given node.
children = engine.tree_get_children("node-id")
for child in children:
    print(f"  {child['name']}: {child['belief_count']} beliefs")

Get Paths

engine.tree_get_path(belief_id) → list[list[str]]
Returns all paths from root to the nodes where this belief is placed. Each path is a list of node IDs from root to leaf.
paths = engine.tree_get_path("belief-id")
for path in paths:
    names = [engine.tree_get_node(nid)["name"] for nid in path]
    print(" → ".join(names))
    # e.g. "Root → Military → Defense Systems → Fortifications"

Tree vs. Graph

The knowledge tree and knowledge graph serve different purposes:

FeatureKnowledge GraphKnowledge Tree
StructureArbitrary connectionsHierarchical taxonomy
EdgesSemantic similarity, dream synthesisCategory membership
TraversalBFS from any nodeRoot-to-leaf paths
Use caseFinding related beliefsBrowsing by topic
Multiple parentsN/A (it is a graph)Yes, beliefs can appear in multiple categories