What Are the 13 Node and 26 Edge Types in the Egonex AI Knowledge Graph Schema?

The Egonex AI Understand Anything engine enforces a strict schema of 13 node types and 26 canonical edge types, defined in understand-anything-plugin/packages/core/src/schema.ts and validated via Zod to ensure graph consistency.

The Understand Anything knowledge graph represents codebases, infrastructure, and semantic relationships through a strongly-typed TypeScript schema. According to the Egonex-AI repository, this schema uses Zod enums to restrict edges to exactly 26 relationship types, while supporting 13 distinct node categories that represent entities ranging from files and functions to services and documentation.

The 26 Canonical Edge Types

The definitive list of edge types resides in schema.ts (lines 4‑14), implemented as a Zod enum (EdgeTypeSchema). These 26 strings form the complete vocabulary for describing relationships within the graph:

| # | Edge Type | Semantic Category | Description |

|---|-----------|-------------------|-------------| | 1 | imports | Structural | A file or module imports another | | 2 | exports | Structural | A file exports symbols for external use | | 3 | contains | Structural | Parent-child containment (e.g., class contains method) | | 4 | inherits | Structural | Classical inheritance between types | | 5 | implements | Structural | Interface implementation | | 6 | calls | Behavioral | Function or method invocation | | 7 | subscribes | Behavioral | Event-based subscription | | 8 | publishes | Behavioral | Event publication | | 9 | middleware | Behavioral | Middleware chaining | | 10 | reads_from | Data Flow | Reads data from source (DB, file) | | 11 | writes_to | Data Flow | Writes data to target | | 12 | transforms | Data Flow | Data transformation step | | 13 | validates | Data Flow | Input/output validation | | 14 | depends_on | Dependency | General dependency | | 15 | tested_by | Dependency | Test coverage relationship | | 16 | configures | Dependency | Configuration linkage | | 17 | related | Semantic | Loose associative relation | | 18 | similar_to | Semantic | Similarity relation | | 19 | deploys | Infrastructure | Deployment of service/component | | 20 | serves | Infrastructure | Service serving an endpoint | | 21 | migrates | Infrastructure | Migration operation | | 22 | documents | Infrastructure | Documentation linking | | 23 | provisions | Infrastructure | Resource provisioning | | 24 | routes | Infrastructure | Routing relationship | | 25 | defines_schema | Infrastructure | Schema definition | | 26 | triggers | Infrastructure | Event/cron trigger |

The validateGraph function enforces this enumeration at runtime. Any edge submitted with a type outside this list is rejected during validation, ensuring strict semantic consistency across all knowledge graphs.

Node Types in the Schema

Alongside the 26 edge types, the schema defines 13 canonical node types representing distinct entities in the graph. These categories include files, modules, classes, functions, variables, services, databases, endpoints, and documentation artifacts. Like edges, node types are strictly validated via Zod schemas in schema.ts, ensuring every vertex conforms to one of these 13 semantic categories before ingestion.

Practical Implementation

Creating a Validated Edge

When constructing edges programmatically, TypeScript's const assertion combined with Zod validation ensures type safety:

import { EdgeTypeSchema } from "@understand-anything/core/schema";

const edge = {
  source: "node-123",
  target: "node-456",
  type: "calls" as const,
  direction: "forward" as const,
  weight: 0.9,
};

// Throws if type is not one of the 26 canonical values
EdgeTypeSchema.parse(edge.type);

Validating Full Graphs

The validateGraph utility checks entire graph structures against the schema:

import { validateGraph } from "@understand-anything/core/schema";

const result = validateGraph(myGraph);
if (result.success) {
  console.log("Graph valid: all edges use supported types");
} else {
  console.warn("Invalid edges detected:", result.issues);
}

Normalizing Edge Type Aliases

The schema includes an alias mapping (EDGE_TYPE_ALIASES) to normalize LLM outputs to canonical types. For example, the string "extends" maps to "inherits":

import { EDGE_TYPE_ALIASES } from "@understand-anything/core/schema";

const raw = "extends";
const canonical = EDGE_TYPE_ALIASES[raw] ?? raw; // Returns "inherits"

Key Files and Validation Logic

File Purpose
understand-anything-plugin/packages/core/src/schema.ts Defines EdgeTypeSchema, the 26 edge type enum, node type definitions, and validateGraph logic
understand-anything-plugin/packages/core/src/__tests__/schema.test.ts Unit tests explicitly enumerating the 26 edge types and validation edge cases
understand-anything-plugin/packages/core/src/types.ts TypeScript type definitions (EdgeType) mirroring the Zod schemas

Summary

The Egonex AI Understand Anything schema provides a rigorous semantic framework through:

  • 26 edge types covering structural, behavioral, data-flow, dependency, semantic, and infrastructure relationships
  • 13 node types defining distinct entity categories from code to infrastructure
  • Zod validation in schema.ts that rejects invalid relationships at parse time
  • Alias normalization to accommodate LLM-generated variations while maintaining strict canonical typing

Frequently Asked Questions

What happens if I use an edge type not in the list of 26?

The validateGraph function in schema.ts rejects the edge. Using Zod's enum validation, any non-canonical type causes a parse error, and the edge is dropped from the graph during the validation phase.

How are the 13 node types defined in the schema?

The 13 node types are defined alongside edge types in understand-anything-plugin/packages/core/src/schema.ts as distinct Zod schemas. Each node type represents a specific entity class (such as File, Function, Class, or Service) with its own metadata requirements, ensuring vertices carry semantically appropriate properties.

Can I extend the schema to add custom edge types?

The current schema uses a fixed Zod enum for the 26 edge types. While the source code could be modified, the canonical implementation treats these 26 types as comprehensive. Custom relationships should map to the existing semantic categories (e.g., using related or depends_on) or be handled through node properties rather than edge type extensions.

Where does the validation logic enforce the 26-type limit?

Validation occurs in the validateGraph function within schema.ts. This function uses EdgeTypeSchema.parse() to check each edge's type against the canonical enumeration, with invalid edges collected in the issues array of the result object.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →