The 26 Edge Types in the Egonex-AI Understand Anything Knowledge Graph Schema
The Egonex-AI Understand Anything knowledge graph schema defines exactly 26 canonical edge types—ranging from structural dependencies like imports and inherits to operational relationships like deploys and triggers—that are enforced by a Zod validator in schema.ts.
The Understand Anything repository by Egonex-AI provides a strict knowledge graph schema for modeling codebases and infrastructure. At its core, the EdgeTypeSchema located in understand-anything-plugin/packages/core/src/schema.ts accepts only a fixed enumeration of 26 string values, ensuring consistent semantic relationships across all generated graphs.
Complete List of the 26 Edge Types
The canonical edge types are defined at lines 4‑14 of schema.ts and grouped into six semantic categories. These types cover everything from code-level composition to deployment-time operations.
Structural Relationships
These edge types describe static code composition and inheritance hierarchies:
imports— A file or module imports anotherexports— A file or module exports symbolscontains— One artifact contains another, such as a class containing a methodinherits— Classical inheritance relationship between entitiesimplements— Interface implementation relationship
Behavioral Relationships
These capture runtime interactions and event-driven communication:
calls— A function or method calls anothersubscribes— Event-based subscription relationshippublishes— Event-based publication relationshipmiddleware— Middleware chaining relationship
Data-Flow Relationships
These model how data moves through the system and undergoes validation:
reads_from— Reads data from a source such as a database or filewrites_to— Writes data to a target destinationtransforms— Data transformation pipeline stepvalidates— Validation of input or output data
Dependency and Configuration
These express auxiliary relationships and testing coverage:
depends_on— General dependency between componentstested_by— Test case covering a specific unitconfigures— Configuration relationship
Semantic Relationships
These provide higher-level knowledge graph connections:
related— Loose semantic relation between entitiessimilar_to— Similarity relation indicating conceptual proximity
Infrastructure and Operations
These map deployment artifacts and operational concerns:
deploys— Deployment of a service or componentserves— Service serving a specific endpointmigrates— Migration operation such as a database migrationdocuments— Documentation linking relationshipprovisions— Resource provisioning relationshiproutes— Routing relationship such as an API route to handlerdefines_schema— Schema definition relationshiptriggers— Event or cron trigger relationship
Schema Validation and Enforcement
The 26 edge types are immutable and enforced at runtime by the Zod validator. In understand-anything-plugin/packages/core/src/schema.ts, the EdgeTypeSchema is defined as z.enum([...]) containing all 26 strings exactly as listed above.
When the validateGraph function processes a graph, any edge containing a type not present in this enumeration is treated as invalid and dropped during validation. This strict validation guarantees that downstream graph algorithms and visualizations operate on a predictable, type-safe set of relationships.
The TypeScript type EdgeType defined in understand-anything-plugin/packages/core/src/types.ts mirrors this Zod enum, providing compile-time type safety throughout the codebase.
Working with Edge Types Programmatically
Validating a Single Edge Type
Use the EdgeTypeSchema to validate that a string belongs to the allowed set:
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
EdgeTypeSchema.parse(edge.type);
Validating an Entire Knowledge Graph
The validateGraph function checks all edges in a graph structure:
import { validateGraph } from "@understand-anything/core/schema";
const result = validateGraph(myGraph);
if (result.success) {
console.log("Graph is valid, edges use only the 26 supported types");
} else {
console.warn("Invalid edges:", result.issues);
}
Normalizing Edge Type Aliases
The schema includes an EDGE_TYPE_ALIASES map to handle common synonyms. For example, when a language model outputs extends, the library maps it to the canonical inherits:
import { EDGE_TYPE_ALIASES } from "@understand-anything/core/schema";
const raw = "extends";
const canonical = EDGE_TYPE_ALIASES[raw] ?? raw; // "inherits"
This normalization happens before Zod validation, ensuring that semantic equivalents are accepted without breaking the strict 26-type constraint.
Summary
- The Egonex-AI Understand Anything knowledge graph schema defines exactly 26 canonical edge types in
understand-anything-plugin/packages/core/src/schema.ts. - These types cover structural, behavioral, data-flow, dependency, semantic, and infrastructure relationships.
- The
EdgeTypeSchemaZod enum at lines 4‑14 enforces this set strictly, dropping any edges with unknown types duringvalidateGraphexecution. - Edge type aliases like
extends→inheritsare resolved before validation to accommodate flexible input while maintaining a fixed schema. - Unit tests in
understand-anything-plugin/packages/core/src/__tests__/schema.test.tsexplicitly enumerate and verify all 26 types.
Frequently Asked Questions
What happens if I use an edge type not in the list of 26?
The Zod validator in validateGraph rejects any edge type not present in the EdgeTypeSchema enumeration. According to the validation logic in schema.ts, these invalid edges are dropped during the parsing process, ensuring only compliant relationships persist in the knowledge graph.
How does the schema handle synonyms like "extends" for inheritance?
The EDGE_TYPE_ALIASES map defined in schema.ts normalizes common synonyms to canonical types before validation occurs. For instance, extends is automatically mapped to inherits, allowing language models and other input sources to use familiar terminology while the graph stores only the 26 standardized edge types.
Where are the 26 edge types tested in the codebase?
The complete enumeration is tested in understand-anything-plugin/packages/core/src/__tests__/schema.test.ts. The test suite explicitly iterates through all 26 edge types to verify that EdgeTypeSchema accepts each one and rejects invalid strings, serving as the single source of truth for schema compliance.
Can I extend the schema to add custom edge types?
The schema is designed as a fixed vocabulary of 26 types enforced by the Zod enum and the TypeScript EdgeType definition. Adding custom types requires modifying the source array in schema.ts (lines 4‑14), updating the EdgeType type in types.ts, and adjusting the corresponding test file to maintain validation integrity.
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:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →