SynapsesOS
Reference

Graph Model

Overview

Synapses builds a relational graph from your codebase. The graph consists of nodes (code entities) connected by edges (relationships). This graph powers context carving, impact analysis, and all code intelligence features.

Node Types

Code Entities

TypeDescriptionExample
functionFunctions and proceduresValidateToken()
methodStruct/class methods(s *Server) Start()
structStruct definitionstype Config struct
interfaceInterface definitionstype Handler interface
variableVariables and constantsconst MaxRetries = 3
fileSource files (root containers)auth.go
packageLanguage packages/modulesinternal/auth

Synthetic Nodes

TypeDescriptionSource
routeHTTP/RPC routesInjected by route heuristic pass

Documentation Nodes

TypeDescription
sectionMarkdown heading (ATX # through ######)

Knowledge Nodes

TypeDescription
conceptAbstract ideas (e.g., “token bucket”, “eventual consistency”)
entityReal-world entities (people, organizations, products)
artifactDocuments, specs, standards (RFC 7519, GDPR Article 17)
decisionArchitectural/design decisions (from ADRs)

Node Properties

Node {
ID string // Stable UUID v4
Type string // One of the types above
Name string // Entity name
Package string // Language package
File string // Absolute file path
Line int // Source line number
Exported bool // Public/exported?
StableID string // UUID preserved across renames
Provenance string // "user-authored" | "generated" | "vendored" | "external"
Domain string // "code" | "infra" | "api" | "docs" | "issues" | "knowledge"
Metadata map // Flexible attributes (churn, coverage, cpu_pct, confidence)
}

Edge Types

Code Edges

TypeWeightDescription
CALLS1.0Function calls another function
DATA_FLOWS0.95Data dependency chain (source → sink)
IMPLEMENTS0.9Type implements an interface
HANDLES0.9Route → handler function (synthetic)
EMBEDS0.85Struct embeds another struct
DEPENDS_ON0.8Package dependency
IMPORTS0.7Module/package import
EXPORTS0.5Exported symbol
DEFINES0.15File → entity containment

Documentation Edges

TypeWeightDescription
CONTAINS0.15Document → section containment
EXPLAINS0.7Documentation section → code entity
DOCUMENTED_BY0.6Code entity → documentation section
LINKS_TO0.3Cross-document markdown links

Cross-Domain Edges

TypeWeightDescription
DEPLOYS0.75Code → infrastructure resource
CONSUMES0.75Code → API endpoint/service
CONFIGURED_BY0.65Code → config resource
DOCUMENTS0.65Docs → code (broader than EXPLAINS)
MENTIONS0.55Synthetic name-match edges (0.0-1.0 confidence)
MANUAL0.5User-defined via link_entities

Knowledge Edges

TypeWeightDescription
CONTRADICTS0.6Conflicting information
CAUSED_BY0.5Effect → cause relationship
INSTANCE_OF0.4Specific → general type
RELATES_TO0.3Generic fallback relationship

Storage

The graph is stored in SQLite with these key tables:

  • nodes: All graph nodes with properties
  • edges: All relationships (from_id, to_id, type)
  • manual_edges: User-created edges via link_entities
  • edge_learned_weights: Weight adjustments from agent feedback
  • call_sites: Unresolved call sites for deferred resolution
  • node_embeddings: Vector embeddings for semantic search
  • nodes_fts: FTS5 full-text search index

The graph is also kept in memory for fast traversal, with an optional FlatGraph (SoA layout) for cache-friendly PPR computation.