This document describes the valid entity and relationship schema for Lattice. Entities are extracted by Claude Code and stored directly in DuckDB - no frontmatter required in your markdown files.

Valid Entity Labels

Entities must use one of these 9 allowed labels:

LabelUse Case
TopicResearch areas, subjects, domains
TechnologyProgramming languages, frameworks, tools, libraries
ConceptAbstract ideas, patterns, methodologies
ToolSpecific software, utilities, applications
ProcessWorkflows, procedures, algorithms
PersonIndividuals
OrganizationCompanies, teams, groups
DocumentFiles, papers, specs (auto-created for markdown)
LocationPaths, places, directories

Database Schema

Entities are stored in the nodes table:

CREATE TABLE nodes (
label VARCHAR NOT NULL, -- One of the 9 labels above
name VARCHAR NOT NULL, -- Entity identifier
properties JSON, -- description, title, etc.
embedding FLOAT[512], -- Vector for semantic search
PRIMARY KEY(label, name)
);

Entity Properties

The properties JSON column may contain:

PropertyTypeDescription
descriptionstringBrief description for semantic search
titlestringDocument title (for Document entities)
contentHashstringContent hash for change detection (Documents)

Relationship Schema

Relationships are stored in the relationships table:

CREATE TABLE relationships (
source_label VARCHAR NOT NULL,
source_name VARCHAR NOT NULL,
relation_type VARCHAR NOT NULL, -- REFERENCES or APPEARS_IN
target_label VARCHAR NOT NULL,
target_name VARCHAR NOT NULL,
properties JSON,
PRIMARY KEY(source_label, source_name, relation_type, target_label, target_name)
);

Relationship Types

TypeCreated ByDescription
REFERENCESAI extractionSemantic connection between entities
APPEARS_INAuto-generatedLinks entity to source document

AI Extraction Guidelines

When Claude Code extracts entities via /graph-sync, it follows these guidelines:

Entity Selection

  1. Extract 3-10 significant entities per document
  2. Focus on concepts, technologies, and tools mentioned
  3. Use the most specific label that applies
  4. Include brief descriptions for semantic search

Label Selection Guide

If your entity is…Use label
A software library/frameworkTechnology
A specific CLI tool or appTool
An algorithm or workflowProcess
A design pattern or methodologyConcept
A research area or domainTopic
A company or teamOrganization
A specification or fileDocument
A named individualPerson
A file path or locationLocation

Relationship Extraction

  • Extract 3-7 key relationships per document
  • Use REFERENCES for semantic connections
  • APPEARS_IN is auto-generated (entity → document)

Validation

The extraction uses Zod schema internally:

const EntityLabelSchema = z.enum([
"Topic", "Technology", "Concept", "Tool",
"Process", "Person", "Organization", "Document", "Location"
]);
const RelationTypeSchema = z.enum([
"REFERENCES", "APPEARS_IN"
]);

Querying Entities

Find entities by label

Terminal window
lattice sql "SELECT name, properties FROM nodes WHERE label = 'Technology'"

Find relationships for an entity

Terminal window
lattice rels "DuckDB"
Terminal window
lattice search "vector database"