Knowledge Graph

The knowledge graph stores structured relationships between entities in your project. Unlike flat memories, it captures how things connect — which services depend on what, who owns which components, and how architecture decisions evolve.

Core concepts

Facts (triples)

Every relationship is a subject → predicate → object triple. For example: auth-service uses JWT.

Confidence

Each fact has a confidence score (0–1). High-confidence facts are established truths; lower scores indicate assumptions or early decisions that may change.

Temporal validity

Facts can be invalidated without deletion. The timeline preserves history — you can see what was true when, not just what's true now.

Example usage

Adding facts

# Record architecture decisions as facts

kg_add

subject: "backend"

predicate: "uses"

object: "PostgreSQL"

confidence: 0.95

# Track ownership

kg_add

subject: "auth-module"

predicate: "owned-by"

object: "backend-team"

Querying relationships

# What does the backend use?

kg_query

entity: "backend"

direction: "outgoing"

> backend uses PostgreSQL (0.95)

> backend uses Express (0.90)

> backend deployed-on Docker (0.95)

Viewing timeline

# See how decisions evolved

kg_timeline

entity: "database"

> 2026-03-01 database considered MongoDB

> 2026-03-05 database decided PostgreSQL

> 2026-03-01 MongoDB consideration invalidated

Use cases

Architecture mapping

Track which services use which technologies, how components connect, and what depends on what.

Decision history

Record why choices were made and how they evolved. Never re-debate a settled decision.

Team ownership

Map who owns which modules, services, and domains. Useful for large codebases.

Dependency tracking

Understand impact before making changes. Query what depends on a component before modifying it.

API endpoints

The knowledge graph has 5 dedicated tools and corresponding REST endpoints. See the full API reference for request/response details.

  • kg_add — Add a fact (subject → predicate → object)
  • kg_query — Query entity relationships
  • kg_invalidate — Mark a fact as no longer true
  • kg_timeline — View fact history for an entity
  • kg_stats — Graph statistics (entity count, fact count)