Egonex Knowledge Graph Schema: 26 Edge Types and Node Structure in Understand Anything

The Understand Anything knowledge graph schema defines 26 canonical edge types and 13 node types in schema.ts, with edges strictly validated by a Zod enumeration to ensure graph integrity.

The Egonex-AI/Understand-Anything repository implements a strict knowledge graph schema for code understanding. While schema.ts defines both node and edge taxonomies—including 13 distinct node types for entities like files, functions, and services—the EdgeTypeSchema enumeration provides the authoritative list of 26 relationship types that govern how these entities connect within the graph.

The 26 Canonical Edge Types

The EdgeTypeSchema in understand-anything-plugin/packages/core/src/schema.ts (lines 4‑14) defines a fixed enumeration of 26 strings. These represent the only valid relationship types accepted by the graph validator:

  1. imports – A file/module imports another
  2. exports – A file/module exports symbols
  3. contains – One artifact contains another (e.g., a class contains a method)
  4. inherits – Classical inheritance relationship
  5. implements – Interface implementation
  6. calls – A function/method calls another
  7. subscribes – Event‑based subscription
  8. publishes – Event‑based publication
  9. middleware – Middleware chaining relationship
  10. reads_from – Reads data from a source (e.g., DB, file)
  11. writes_to – Writes data to a target
  12. transforms – Data transformation pipeline step
  13. validates – Validation of input/output
  14. depends_on – General dependency
  15. tested_by – Test case covering a unit
  16. configures – Configuration relationship
  17. related – Loose semantic relation
  18. similar_to – Similarity relation
  19. deploys – Deployment of a service/component
  20. serves – Service serving an endpoint
  21. migrates – Migration operation (e.g., DB migration)
  22. documents – Documentation linking
  23. provisions – Resource provisioning
  24. routes – Routing relationship (e.g., API route to handler)
  25. defines_schema – Schema definition relationship
  26. triggers – Event/cron trigger relationship

These types are central to the graph’s semantics and are enforced by Zod validation (z.enum([...])) in the schema. Any unknown value is treated as invalid and the edge is dropped during validation (see the validation logic in validateGraph).

Edge Type Categories

The 26 edge types span six semantic categories that cover code structure, runtime behavior, and infrastructure:

  • Structural – imports, exports, contains, inherits, implements describe code‑level composition.
  • Behavioral – calls, subscribes, publishes, middleware capture runtime interactions.
  • Data‑flow – reads_from, writes_to, transforms, validates model how data moves and is validated.
  • Dependency – depends_on, tested_by, configures express auxiliary relationships.
  • Semantic – related, similar_to provide higher‑level knowledge‑graph connections.
  • Infrastructure – deploys, serves, migrates, documents, provisions, routes, defines_schema, triggers map deployment‑time artifacts and operational concerns.

Validation and Aliases

The schema provides strict validation and alias normalization through EdgeTypeSchema and EDGE_TYPE_ALIASES.

Validating Edge Types

When constructing a graph edge programmatically, Zod enforces the enum:

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

// Build an edge object – Zod will enforce the enum
const edge = {
  source: "node-123",
  target: "node-456",
  type: "calls" as const,
  direction: "forward" as const,
  weight: 0.9,
};

// Validate with Zod (throws if type is not one of the 26)
EdgeTypeSchema.parse(edge.type); // ✅ passes

Full Graph Validation

The validateGraph function drops invalid edges during processing:

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);
}

Alias Normalization

When language models output non‑canonical types like extends, the library maps them to canonical types:

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

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

Key Files

The following files form the single source of truth for edge semantics:

Summary

  • The Egonex Understand Anything knowledge graph uses exactly 26 edge types defined in schema.ts.
  • The EdgeTypeSchema Zod enum strictly validates all edges; invalid types are rejected during validateGraph execution.
  • Edges fall into six categories: Structural, Behavioral, Data‑flow, Dependency, Semantic, and Infrastructure.
  • The EDGE_TYPE_ALIASES map normalizes variant terms (like extends → inherits) to canonical values.
  • Source files in packages/core/src/ provide the complete type definitions and validation logic.

Frequently Asked Questions

What file contains the 26 edge type definitions?

The authoritative definitions reside in understand-anything-plugin/packages/core/src/schema.ts at lines 4‑14. This file exports EdgeTypeSchema, a Zod enumeration that strictly limits valid edge types to the 26 canonical strings.

How does the schema handle invalid edge types?

The validateGraph function parses edge types through EdgeTypeSchema. Any value not in the enumeration of 26 types is flagged as invalid and dropped during validation, preventing malformed relationships from entering the knowledge graph.

Can I use synonyms like "extends" instead of "inherits"?

Yes. The EDGE_TYPE_ALIASES map in schema.ts converts common synonyms to canonical types. For example, extends automatically maps to inherits before validation, ensuring consistency while accepting natural language variations from LLM outputs.

Are the 26 edge types extensible?

No. The schema uses a fixed Zod enum (z.enum([...])) that accepts only the 26 predefined strings. This strict typing ensures graph consistency across the Understand Anything ecosystem. To add new relationship types, the enumeration in schema.ts must be modified directly.

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 →